ScropTheOSAdventurer wrote:I should've figured. Thanks sortie! But then, how do I get the actual address of stack_top in intel syntax?
UPDATE:
@sortie: I looked at the nasm code for pointing to the stack_top label, and it is exactly the same code I used, so I am confused.
Not familiar with intel syntax, but since you're using GAS, have you tried prefixing your labels with '$' to get their address? eg.
Code: Select all
Label:
.asciz "this is a string"
mov $Label, %rsi
either way, without using the '$' prefix GAS treats what you put as an address, ie. it takes the value at the address. For your example,
would really be
, which is really not what you want.
Note that I could be completely wrong and that GAS actually does intel syntax properly. In that case take this as a small lesson on how AT&T syntax works (:
Also, I personally recommend using GAS syntax anyway, it's more intuitive and you should already have an assembler from your binutils toolchain.
EDIT: I didn't really answer your question right.
IIRC for intel syntax, the address of literals is simply the name of the literal, in your case 'stack_top', which is why I suspect GAS is doing something a little wrong.
EDIT EDIT:
By looking at your disassembly, I see 'dword ptr ds:', which unequivocally means 'the value at the address of'.
I don't really suggest using intel syntax with an assembler designed for AT&T syntax.
The simplest options here would be:
1. Learn AT&T syntax, then convert your code.
2. Use NASM to assemble your code.