Now that i know u can use gcc for Intel syntax instead of default at&t with
gcc -S -masm=intel test.c
There is this line
mov DWORD PTR [ebp-16], OFFSET FLAT:base
Is it the same as mov dword[ebp-16], base
?
Otherwise what must i do?
In assembly language In computer engineering and low-level programming (such as assembly language), an offset usually denotes the number of address locations added to a base address in order to get to a specific absolute address.
OFFSET would have translated to a segment selector (DS) and OFFSET, whereas OFFSET FLAT translates to an absolute address of the label LC0 relative to 0 (seeing as that's the base of the DS segment in flat mode), which the linker resolves after it is assembled.
In Intel syntax the first operand is the destination, and the second operand is the source whereas in AT&T syntax the first operand is the source and the second operand is the destination. The advantage of AT&T syntax in this situation is obvious.
One of the biggest differences between NASM and GAS is the syntax. GAS uses the AT&T syntax, a relatively archaic syntax that is specific to GAS and some older assemblers, whereas NASM uses the Intel syntax, supported by a majority of assemblers such as TASM and MASM.
Yes, mov dword [ebp - 16], base
should be fine. I haven't seen offset flat:
for a while - I think it's obsolete, but it's what AT&T's idea of .intel_syntax
used to demand (I had to look at Gas's source code to find that out). Means the same as offset
to Masm, or the unadorned variable name in Nasm.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With