尝试在汇编中组装一个简单的减法程序时出错MSB3721

时间:2015-10-11 22:20:11

标签: assembly visual-studio-2013 masm irvine32

我正在编写一个简单的汇编程序,只需要使用16位寄存器就可以减去3个整数。然后我必须调用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

这个程序昨天运行正常,这是输出窗口截图:

Output Window

1 个答案:

答案 0 :(得分:1)

使用Kip的Irvine Win32库时,你会这样做:

INCLUDE Irvine32.inc

你隐含地这样做了:

.386                    
.model flat, stdcall    
.stack 4096   

通过执行include irvine32.inc并执行上述3行,您将两次定义这些选项。 Microsoft Assembler将此视为错误。在这个有点神秘的错误消息中提出了这一点,它抱怨定义了多个.model指令:

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时要避免此问题,您只需删除以下所有三行,只需添加 irvine32.inc

.386                    
.model flat, stdcall    
.stack 4096  ; If a bigger stack is needed(>4096) then define it to be larger