The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: lonewolff on March 08, 2009, 01:47:25 AM

Title: How do you store an address in a register? [Solved]
Post by: lonewolff on March 08, 2009, 01:47:25 AM
Hi there,

I am wondering how I can load a register with a pointer to some text. I want to display certain text given certain conditions.
Here is what I have. I think I am close, but it wont compile.


.data
TextCondition1 db "Condition 1",0
MsgBoxCaption db "Information",0

.code
start:

mov [ebx],TextCondition1

invoke MessageBox,NULL,ebx,addr MsgBoxCaption,MB_ICONINFORMATION
invoke ExitProcess,NULL

end start


The problem is at the mov [ebx],TextCondition1 line.

Any guidance would be much appreciated.  :bg
Title: Re: How do you store an address in a register?
Post by: sinsi on March 08, 2009, 02:44:57 AM
  mov ebx,OFFSET TextCondition1
Less common:
  lea ebx,[TextCondition1]
Title: Re: How do you store an address in a register?
Post by: lonewolff on March 08, 2009, 03:34:02 AM
Excellent. That is exactly what I was after.  :8)

I'll have to look up my opcodes to see what LEA does.

Thanks for your help.