Intel assembly syntax OFFSET
Asked Answered
G

1

6

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?

Goff answered 2/11, 2012 at 9:14 Comment(2)
Yes, in NASM. No, in MASM. And this is MASM syntax, as evidenced by the OFFSET keyword, but you tagged it NASM, so which do want to know?Goatish
Hello @harold i'm programming in nasm thats why i tagged nasm. I wanted to know how to do this masm code in nasm and what offset flat:base mean.Goff
A
8

Yes, mov dword [ebp - 16], base is correct NASM syntax to store the label address to 4 bytes of memory at EBP-16.

I haven't seen offset flat: for a while - I think it's obsolete, but it's what GAS's idea of .intel_syntax noprefix used to demand (I had to look at Gas's source code to find that out). gcc -masm=intel uses it when using symbol addresses as immediates, but offset base works, too, in GAS.

It means the same as offset to MASM, or the unadorned variable name in NASM.

Abercrombie answered 2/11, 2012 at 12:8 Comment(2)
I love Stack Overflow, just made my life a lot easier. Again. <3Stavanger
GNU assembler (GAS) .intel_syntax noprefix is not AT&T syntax at all. The GNU assembler's default .att_syntax is compatible with the syntax AT&T used for their x86 Unix assembler, but .intel_syntax noprefix was a more recent addition to GAS that doesn't derive from anything AT&T designed.Pyles

© 2022 - 2024 — McMap. All rights reserved.