MASM

MASM/NASM Differences

那年仲夏 提交于 2019-12-17 15:46:37
问题 What are the syntax differences between the NASM and MASM assemblers? 回答1: Section 2.2 of the NASM documentation is titled Quick Start for MASM Users which lists the important differences between NASM and MASM. 来源: https://stackoverflow.com/questions/2035747/masm-nasm-differences

DOS:基本汇编语言开发环境配置及其增强

本秂侑毒 提交于 2019-12-17 03:41:47
DOS:基本汇编语言调试环境配置及其增强 前言(可跳过) 具体需求 基本要求的实现 1.安装并配置DOSBox 2.MASM 2.0的安装 开发环境的增强 1.Windows 3.2的安装 2.MASM 6.11的安装 图形界面下的运行 在Windows 3.2中安装MASM 6.11 安装Turbo C 2.0 总结与反思(可跳过) 前言(可跳过) DOS,磁盘操作系统的缩写,一类古老的操作系统,如今的人们甚至可能都未曾听闻。但是,在三十年前,计算机上还没有普及图形界面的操作系统,人们依靠命令行来完成对文件的操作。 无数程序员们戴着眼镜,在茶色窗户的大楼内,坐在显像管显示器前,依靠着简单的调试程序,打出一行行黑白的代码,这些代码共同构成了今天展现在我们眼前的五彩斑斓的图形界面的基础。 在那些缺乏便捷工具的日子里,人们依靠勤劳的双手,创造出了更加便捷的工具,这些工具更进一步帮助人们完成了更为复杂而高效的工具。通过这些更加高效的工具,程序员们最终打造出了如今精彩纷呈的计算机世界。 那是一段枯燥的日子,终日只有黑白字符相伴,但那也是一段精彩的日子,如今多彩的世界就是建立在那些日子的基础之上。 当如今我们用着极为便捷的编程工具时,是否有意识到,在那些缺乏高效工具的日子里,老一辈程序员是如何依靠简陋的工具以及命令行界面来打造出如今呈现在我们眼前的如此复杂而高效的集成开发环境的。那一代程序员

Call C standard library function from asm in Visual Studio

安稳与你 提交于 2019-12-17 02:38:16
问题 I have a problem with calling C function from asm project created in visual studio (Win10 x64, Visual Studio 2015). Project consist of one asm file: .586 .model flat, stdcall option casemap:none includelib msvcrt.lib ExitProcess PROTO return:DWORD extern printf:near .data text BYTE "Text", 0 .code main PROC push offset text call printf add esp,4 invoke ExitProcess,0 main ENDP end main When I build project, linker outputs the error: Error LNK2019 unresolved external symbol _printf referenced

How to call printf from a C function that I call in the MASM assembler?

醉酒当歌 提交于 2019-12-16 18:06:32
问题 I have a C file called C.c and for now in that file I have one function that compares two numbers and saves the greater number to the register eax. I need help with creating the second function that will call printf inside and print some text. How to add support for printf in C that I can call from MASM assembler? My masm file: TITLE MASM Template (main.asm) .386 .model FLAT .stack 4096 WriteString PROTO stdcall ReadChar PROTO stdcall Crlf PROTO stdcall ExitProcess PROTO stdcall:DWORD greater

Want to save value from a variable into register

妖精的绣舞 提交于 2019-12-14 04:14:17
问题 I m using MASM compilor and DOSBOX. I want to Want to save value from a variable into register. i want to save num1 value into cx register. How can i do that? .MODEL SMALL .STACK 50H .DATA num1 db '5' NL DB 0DH, 0AH, '$' msg db ?,0AH,0DH,"Enter an odd number between 0 to 10:$" nxtline db 0Ah,0DH,"$" .CODE MAIN PROC MOV AX, @DATA MOV DS, AX LEA DX,msg mov ah,9 int 21H LEA DX,nxtline mov ah,9 int 21H MOV AH,1 INT 21H LEA DX,nxtline mov ah,9 int 21H mov bl,al ;save the value from input mov num1

Using masm to displays the letter that counting in an input string

梦想的初衷 提交于 2019-12-14 03:32:54
问题 Using masm(Visual Studio 2010), write a program that inputs an entire line of text, up to 132 characters, into a buffer. Then have my program determine how many times each letter of the alphabet occurs. You are to count all letter a-z, A-Z, and 0-9 only. The screen should be out put a - 4 times, b - 2 times, c- 9 times. 回答1: I made your program with compiler EMU8086 Intel syntax (just copy-paste-run). It's big but fully commented to help you understand, this is what it does: display a message

Writing out a single register in Assembly

强颜欢笑 提交于 2019-12-13 21:07:42
问题 Fairly simple question this time. How do I write to screen the contents of a single register in Assembly? I'm getting a bit tired of calling DumpRegs just to see the value of one register. I'm using x86 architecture, and MASM in Visual Studio, and Irvine32.lib. 回答1: Irvines's DumpReg uses repeatedly a macro of Macros.inc : mShowRegister . It can be used directly. Example: INCLUDE Irvine32.inc INCLUDE Macros.inc .code main PROC mov esi, 0DeadBeefh mShowRegister ESI, ESI exit main ENDP END main

Multiply two unsigned 16 bit values, without using multiply or divide instructions [8086 Assembly]

独自空忆成欢 提交于 2019-12-13 14:23:15
问题 I'm currently working on an assignment, where I write a subroutine where 2 unsigned numbers get multiplied and yield a result in the DX:AX pair. But i cannot use the instructions mul, imul, div, and idiv. When i run my code, the bottom half (the AX register) is always correct, but the DX register is not. Can anyone point me in the right direction as to what I am doing wrong? ;----------------------------------------------------------- ; ; Program: MULTIPLY ; ; Function: Multiplies two 16 bit

Objdump swapping fsubrp to fsubp on compiled assembly?

二次信任 提交于 2019-12-13 13:41:43
问题 I am porting Quake 2's inline Win32 assembly to GAS. I started out by taking the inline assembly and then placing it into it's own ASM file. Fixed any issues, then started porting to GAS. I do know that the src/dst is reversed in AT&T vs Intel syntax (including floating point registers for some math operations) and a few other small gotchas, but when I got this compiling fine I noticed that the code was not working as intended. I looked over it carefully for hours with a compare utility and

c++ gcc inline assembly does not seem to work

旧城冷巷雨未停 提交于 2019-12-13 11:10:13
问题 I am trying to figure out gcc inline assembly on c++. The following code works on visual c++ without % and other operands but i could not make it work with gcc void function(const char* text) { DWORD addr = (DWORD)text; DWORD fncAddr = 0x004169E0; asm( "push %0" "\n" "call %1" "\n" "add esp, 04" "\n" : "=r" (addr) : "d" (fncAddr) ); } I am injecting a dll to a process on runtime and fncAddr is an address of a function. It never changes. As I said it works with Visual C++ VC++ equivalent of