Can someone please explain what AT&T versus Intel syntax even matter?
I personally can read AT&T faster, having read more of it. I personally can write AT&T and would have to relearn some stuff to be able to write intel syntax.
It used to be the opposite. Back in the days of DOS, if you'd given me AT&T assembler, I'd been lost, while I could easily read Intel syntax.
So it's really just a question of bothering to learn the few differences. For most purposes it's enough to know that:
Code: Select all
- prefix registers with %, prefix immediates with $, not too different from BASIC
- source operand first, destination second:
mov $0, %eax # move 0 to eax
- immediate without $-prefix is address:
mov globalvar,%eax # load memory at "globalvar" into %eax
- if your address is in register, put parens around it:
mov (%eax), %eax # load memory at "%eax" into %eax
- if you want both, put register after immediate:
mov -1(%eax), %eax # load memory at %eax-1 into %eax
- if you want two registers, use a comma
mov -1(%eax,%ebx), %eax # load memory at %eax+%ebx-1 into %eax
- and finally, you wanna scale the second register
mov -1(%eax,%ebx,4),%eax # load from %eax+4*%ebx-1 into %eax
The only other thing then, is that you put characters (most often b and l for byte and long) after opcode's name if data size isn't obvious without..
Code: Select all
movl $0, location # move long $0 into location
movb $0, byteloc # move byte $0 into byteloc
It takes about 3 days of reading and writing that systax before you stop thinging about it.
edit: oh and let me add that GAS actually has a pretty powerful macro language of it's own in addition to allowing you to use C-macros if you want... so it's not like GAS forces you to write like your compiler does.
The real problem with goto is not with the control transfer, but with environments. Properly tail-recursive closures get both right.