【问题标题】:Error MSB3721 when trying to assemble a simple subtraction program in assembly尝试在汇编中汇编一个简单的减法程序时出现错误 MSB3721
【发布时间】: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


【解决方案1】:

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

INCLUDE Irvine32.inc

你在幕后隐含地这样做:

.386                    
.model flat, stdcall    
.stack 4096   

通过执行include irvine32.inc 并执行上述 3 行,您将定义这些选项两次。 Microsoft 汇编程序将此视为错误。这是在这条有点神秘的错误消息中提出的,它抱怨定义了多个 .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 

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-02-25
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-03-08
    • 1970-01-01
    相关资源
    最近更新 更多