Alright, I've poked at this for a good 20 minutes in between watching the ballgame. What I have is something that looks like this:
.data
g_test_baseline dd ?
.code
mov eax, g_test_baseline
The problem here is MASM is taking my instruction to move the address of g_test_baseline to mean this:
mov eax, [g_test_baseline]
Which is not what I want ::). How do we tell masm to quit trying to be smart :bg.
normal masm syntax does not use brackets to access the data at a label
if you want the address...
mov eax,offset g_test_baseline
now, GoAsm works like you were expecting masm to :P
Quote from: dedndave on May 09, 2012, 01:16:47 AM
normal masm syntax does not use brackets to access the data at a label
if you want the address...
mov eax,offset g_test_baseline
now, GoAsm works like you were expecting masm to :P
Yey! As does NASM. Thanks :clap:.
I think from memory that you can also use,
lea eax, your_label
Quote from: hutch-- on May 09, 2012, 02:40:31 AM
I think from memory that you can also use,
lea eax, your_label
:8). It let me do that! Thanks :U
you certainly want to use LEA for local variables
i think, for globals, MOV ,offset works a little better
When I want the address of a variable, I tend to always use LEA regardless of whether it is local or global. My reasoning is that I never have to double-check if it is one or the other. Using OFFSET would not work for local variables, but LEA works for both.
the assembler will tell you if offset does not work :bg
Quote from: dedndave on May 10, 2012, 06:49:28 PM
the assembler will tell you if offset does not work :bg
I have went to doing it raymond's way since MASM tries to be too smart about memory addressing. I wish there was a way to tell it to treat
[]'s as correctly indicating programmer intent.
nix,
MASM only ever requires [] around registers to indicated that the register is a memory operand [esi] etc .... It will generally ignore [] around named variables so that [myvar] and myvar are the same. It is a notation difference between MASM and other assemblers like NASM that use the [] brackets to indicate that the contents are an address. With MASM you have either named memory operands (local or .data or .data?) or a register enclosed in [] brackets to indicate that it is a memory operand.