0
votes

I'm using intel syntax with GNU AS as I'm used to X86 assembler from back in the day and I make less mistakes than I would with the AT&T syntax. Back in the 16 bit days, an instruction like:

mov ax, [bx]

would move the byte pointer at bx into ax. Some assemblers had overrides on this asssumption, normally with a directive. Now that I'm using 32 bit assembly, almost every line is:

mov eax, dword ptr [bx]

Is there any way to make that the default or do I live with "dword ptr" all over the place? I do realise that I could go AT&T and have movl and movq etc...

1
Can't you use nasm instead? AFAIK it can produce object files that are compatible with gcc/ld.Michael
The assembler is smart enough to figure out the operation size when possible. mov eax, [ebx] will use dword ptr automatically.Jester
Not familiar with that assembler, but dword ptr in your example is redundant. The target register already defines the size. In MASM the size directive is only required when the size cannot be inferred, as in e.g. push dword ptr [].500 - Internal Server Error
This makes sense actually. I remember MASM would get this right and I remember using byte ptr to override a normal word move to ax. I'll try it both ways and get a hex dump...carveone
Having gas can be very unpleasant ;)500 - Internal Server Error

1 Answers

0
votes

This reply doesn't suit a comment style so I'll answer my own question. Thanks to Jester and "500 - Internal...". They are right. Using "as -a=111" and "as -a=222" and comparing:

***** 111
  11
  12 0003 8B4D08                mov     ecx, dword ptr [ebp + 8]
  13
***** 222
  11
  12 0003 8B4D08                mov     ecx, [ebp + 8]
  13
*****

That's beyond a doubt!