Since I'm an absolute beginner to Asm, I don't know, how to give out a simple number (for example the result of a calculation) in a MessageBox. :stupid:

I tried it that way:
mov eax, 03
invoke MessageBox, NULL, eax, addr , MB_OK

but the program crashes. Seems that you can't give out the value of a register that way. But how else?

Please help me!!!
Posted on 2002-06-20 07:12:07 by Overflow

You need to convert the numeric value to a ascii value.
Look into masm32.lib (and the masm32.hlp) file for
"dwtoa" (dword to ascii). A search on this board for "dwtoa"
will bring up some examples, too.

Posted on 2002-06-20 07:16:22 by bazik
Posted on 2002-06-20 07:20:07 by bazik
if you check out the doco here, you will see that the second parameter needs to be a pointer to a NULL terminated string, not a literal value in the eax register, which is why baZiK was telling you to convert it to an ASCII value ;)
Posted on 2002-06-20 07:52:54 by sluggy

The message box contains 3 [b]Ok[/b] buttons and no text.

Posted on 2002-06-20 08:01:17 by bazik
I use wsprintf, but I usually use it to convert more than just one number

Just thought that I would put my two cents in
Posted on 2002-06-20 08:26:08 by gorshing
OK, that works. Thank you very much!!!
I already guessed, that I have to convert the value to an ASCII-String, but I didn't know how, because usually, I write in VB and there, this is done automatically...
Posted on 2002-06-20 11:11:09 by Overflow
Using WSPRINTF to print text strings:

buff db 128 dup(?)
Caption db "Hello world this is the number: %d",0 ; <<< %d for int's

mov eax, 3
invoke wsprintf, addr buff, addr Caption, eax
invoke MessageBox, NULL, addr buff, NULL, MB_OK
invoke ExitProcess, NULL
end start

Using dwtoa to purely convert:

buff db 128 dup(?)
Caption db "Hello world this is the number:",0

mov eax, 3
invoke dwtoa, eax, addr buff
invoke MessageBox, NULL, addr buff, addr Caption, MB_OK
invoke ExitProcess, NULL
end start

Posted on 2002-06-20 14:37:12 by NaN

perhaps the tutorials on my website could help you..

Posted on 2002-06-21 11:01:46 by NOP-erator