Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intel assembly syntax OFFSET

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?

like image 428
Weigel Gram Avatar asked Nov 02 '12 09:11

Weigel Gram


People also ask

What is offset in assembly code?

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.

What offset flat?

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.

What is Intel syntax?

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.

Does NASM use Intel syntax?

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.


1 Answers

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.

like image 125
Frank Kotler Avatar answered Sep 25 '22 19:09

Frank Kotler