【发布时间】:2015-10-11 22:20:11
【问题描述】:
我正在编写一个简单的汇编程序,它必须减去 3 个整数,只使用 16 位寄存器。然后我必须调用 DumpRegs 来显示输出。
我正在使用 Microsoft Visual Studio 2013。
我的代码:
INCLUDE Irvine32.inc
.386
.model flat, stdcall
.stack 4096
ExitProcess PROTO, dwExitCode:DWORD
.data
integerOne WORD 10 ; 16 bit WORD integerOne with the value 10
integerTwo WORD 3 ; 16 bit WORD integerTwo with the value 3
integerThree WORD 5 ; 16 bit WORD integerThree with the value 5
finalAnswer WORD ? ; 16 bit WORD finalAnswer with a unknown value
; to store the subtraction answer
.code ; Start of the code section
main PROC ; Main Procedure Start
mov EAX, 0 ; Moves 0 into the EAX register
mov AX, integerOne ; Loads the AX register with integerOne (10)
sub AX, integerTwo ; Subtracts integerTwo (3) from the AX register
sub AX, integerThree ; Subtracts integerThree (5) from the AX register
mov finalAnswer, AX ; Moves the contents of the AX register into finalAnswer
call DumpRegs ; Outputs the registers
INVOKE ExitProcess,0
main ENDP
END main
我在没有调试的情况下启动时遇到的错误如下:
Error 2 error MSB3721: The command "ml.exe /c /nologo /Zi /Fo"Debug\Subtracting Three Integers.obj" /W3 /errorReport:prompt /Ta"Subtracting Three Integers.asm"" exited with code 1. C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\BuildCustomizations\masm.targets 50 5 CSE 210 Assignment 2
我也收到警告:
Warning 1 warning A4011: multiple .MODEL directives found : .MODEL i C:\Users\Tapan\Desktop\Desktop Files\VS\CSE 210 Assignment 2\Subtracting Three Integers.asm 14 1 CSE 210 Assignment 2
这个程序昨天运行良好,这是输出窗口截图:
【问题讨论】:
-
如果您包含
INCLUDE Irvine32.inc,我相信它会自动为您设置.386、.stack 4096和.model flat, stdcall。我认为你的部分问题是你正在重新定义这些东西。尝试删除所有这三行,但保留INCLUDE Irvine32.inc -
@MichaelPetch 我评论了 .386、.stack 4096 和 .model flat、stdcall,并且成功了!非常感谢!
-
*我把它们注释掉了
标签: assembly visual-studio-2013 masm irvine32