Hi!

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
Hi!

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.

regards,
bAZiK
Posted on 2002-06-20 07:16:22 by bazik
Posted on 2002-06-20 07:20:07 by bazik
Overflow,
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


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


:stupid:
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
gorshing
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:


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

[b].code[/b]
start:
mov eax, 3
invoke wsprintf, addr buff, addr Caption, eax
invoke MessageBox, NULL, addr buff, NULL, MB_OK
invoke ExitProcess, NULL
end start
end



Using dwtoa to purely convert:


[b].data?[/b]
buff db 128 dup(?)
Caption db "Hello world this is the number:",0

[b].code[/b]
start:
mov eax, 3
invoke dwtoa, eax, addr buff
invoke MessageBox, NULL, addr buff, addr Caption, MB_OK
invoke ExitProcess, NULL
end start
end


Enjoy.
:NaN:
Posted on 2002-06-20 14:37:12 by NaN
hi,

perhaps the tutorials on my website could help you..
http://noperator.de.vu

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