I am writing a simple assembly program which has to subtract 3 integers, using only 16 bit registers. Then I have to call DumpRegs to show the output.
I am using Microsoft Visual Studio 2013.
My code:
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
The error I am getting when I am starting without Debugging is the following:
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
I also get a warning:
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
This program ran fine yesterday, here is the output window screenshot:
When using Kip's Irvine Win32 library and you do this:
INCLUDE Irvine32.inc
You are implicitly doing this under the hood:
.386
.model flat, stdcall
.stack 4096
By doing include irvine32.inc
AND doing the above 3 lines you are defining these options twice. The Microsoft Assembler sees this as an error. This was suggested in this somewhat cryptic error message where it complained about multiple .model
directives being defined:
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
I believe that to avoid this problem when using include irvine32.inc
you simply remove all three of the following lines and just include irvine32.inc:
.386
.model flat, stdcall
.stack 4096 ; If a bigger stack is needed(>4096) then define it to be larger