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?

2
  • 1
    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?
    – harold
    Nov 2, 2012 at 10:40
  • 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. Nov 2, 2012 at 11:42

1 Answer 1

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.

2
  • I love Stack Overflow, just made my life a lot easier. Again. <3 Mar 15, 2014 at 9:47
  • 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. Jan 14 at 11:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.