News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Question on mov

Started by boogara, June 19, 2007, 05:03:39 PM

Previous topic - Next topic

boogara

According to this tutorial-ish page, http://furix.net/introduction-masm32

You are using eax for most of your assembly when it comes to things like mov, pop, push, etc...  But, how do you know which register to really use?

Why I'm asking is because I'm trying to get text from an edit control, and...well, it's not working out as I planned.


; above omitted
; +++++++++++++++++++

.data
ip_box db "Your IP address is...", 13, 10

.data?
address dd ?

.code
; working code omitted
.if eax == IDB_EXIT
invoke GetDlgItem,hWin, IDC_IPADDRESS
mov address, eax

invoke MessageBox, hWin, addr address, addr ip_box, MB_OK

; more omitted working code


I'm pretty sure the "mov address, eax" code is wrong...but, I'm not sure.

Sorry for the possibly silly question...but, I know once I'm aware of how to do this lil' bit, everything else will be much more easier for me.

Thank you for any help.

(And, yes...I have been reading tutorials :)  But, some of the tutorials I've read give you the code, yet...no guidance.)

Vortex

boogara,

The values returned by API function calls are stored in eax, so the code sequence below is correct :

invoke GetDlgItem,hWin, IDC_IPADDRESS
mov address, eax

boogara

Quote from: Vortex on June 19, 2007, 05:10:52 PM
boogara,

The values returned by API function calls are stored in eax, so the code sequence below is correct :

invoke GetDlgItem,hWin, IDC_IPADDRESS
mov address, eax

Hmmm....okay, so I'm not going insane XD

But, then why is it that when I try to display the data in the message box, it just comes up with weird data (as if the text in the box entered was unicode-encoded)?

EDIT

Okay, scratch that question...I got it to work, semi.  It doesn't show weird characters anymore, but it also won't show anything period...

Here's what I have now for the message box:


invoke MessageBox, hWin, address, addr ip_box, MB_OK


It'll display, but just not anything inside of the edit box.

ragdog

hi

.data?

hAddress db 256 dup (?)  ;256 lengt of buffer


invoke GetDlgItemText,hWnd,IDC_IPADDRESS,addr hAddress,sizeof hAddress

greets
ragdog

boogara

Quote from: ragdog on June 19, 2007, 05:26:16 PM
hi

.data?

hAddress db 256 dup (?)  ;256 lengt of buffer


invoke GetDlgItemText,hWnd,IDC_IPADDRESS,addr hAddress,sizeof hAddress

greets
ragdog

Thanks :)  Doesn't work *exactly* how I want it to, but I'll be able to work the bugs out now.

Quick question though...the "256 dup (?)" means to fill 256 bytes with "?" (or with nothing), right?  Basically a way to fill the variable with nothing.

Vortex

boogara,

Have a look at the Masm32 library reference coming with Hutch's Masm32 package, you will find the correct functions to convert numbers to ASCII and vice versa.

boogara

Quote from: Vortex on June 19, 2007, 05:39:10 PM
boogara,

Have a look at the Masm32 library reference coming with Hutch's Masm32 package, you will find the correct functions to convert numbers to ASCII and vice versa.
Shall do, thanks very much. ^_^

And thanks both Vortex and ragdog for your help with this!