How do i add 2 numbers in assembly. i tried something like this
.386
.model flat,stdcall
option casemap:none
.data
db msg "Result is: ",0
.code
start :
mov eax,200
add eax,200
add eax,400
sub eax,100
invoke StdOut msg,0
end start
Still getting some errors, how do i go from there?
OK, you are not including any system files so you can do it a number of ways,
Add this line at the top.
include \masm32\include\masm32rt.inc
This means you can remove the following as the runtime INCLUDE file already has them but more importantly you can now use the Windows API functions and the MASM32 library with its macro support.
.386
.model flat,stdcall
option casemap:none
The following has added a bit to your code but your mnemonics were done correctly.
include \masm32\include\masm32rt.inc
.data
msg db "Result is: ",0
lf db 13,10,13,10,0
buffer db 64 dup (0) ; 64 byte bufffer
pbuf dd buffer ; pointer to buffer
.code
start:
mov eax,200
add eax,200
add eax,400
sub eax,100
mov pbuf, ustr$(eax) ; convert EAX result to string
invoke StdOut,OFFSET msg ; display your text mesage
invoke StdOut,pbuf ; display the result
invoke StdOut,OFFSET lf ; append the 2 line feeds so it displays OK
inkey
exit
end start
Hi irnix,
include \masm32\include\masm32rt.inc
.data
msg db 'Result is: %d',0
.code
start:
mov eax,200
add eax,200
add eax,400
sub eax,100
invoke crt_printf,ADDR msg,eax
invoke ExitProcess,0
END start