include \masm32\include\masm32rt.inc
.data
myvar dw 65
.code
start:
invoke StdOut, addr myvar
inkey "Press a key to continue ..."
invoke ExitProcess, 0
end start
The above code prints the letter A instead of 65
I believe StdOut takes a pointer to a string argument .. So how do I print the number instead of its corresponding ascii value ?
Regards.
you're right - it want's a null terminated ascii string
what you want to do is convert the binary 65 into the string "65",0
Hutch has a couple routines to do this - dwtoa, i think is one of the names
the easy way is to use one of the macros
if 65 represents a signed value, use "str$"
if it's unsigned, use "ustr$"
in either case, it needs a dword
movzx eax,word ptr myvar ;zero-extend the WORD into a DWORD
print str$(eax),13,10
the "print" macro expands into StdOut
There are many ways to do it simplest is change the line to
myvar db "65", 10, 0
you could also define it as a dword
myvar dd 65
and print directly
print str$(myvar),13,10
Hi AssemblyBeginner,
Here is another example for you :
include \masm32\include\masm32rt.inc
.data
format db 'MyString = %s',13,10
db 'MyVar = %d',0
MyString db '65',0
MyVar dd 65
.code
start:
invoke crt_printf,ADDR format,ADDR MyString,MyVar
invoke ExitProcess,0
END start
Excelelent .. Thank you all :icon_cool: