News for hackers. Stuff that matters.
Re:“Hello World” in assembly language on Linux by 2bluesc on Wednesday April 22, 2015 @03:45PM (#9423048)
Went to see the printf or puts implementation rather then just calling a library function. Then saw Intel assembly and reminded myself why I've never wrestled with it.
Re:“Hello World” in assembly language on Linux by mitchi on Wednesday April 22, 2015 @04:02PM (#9423158)
This is the GNU assembler AT&T syntax though, which is known to be horrendous. Other assemblers have much nicer syntax.
Re:“Hello World” in assembly language on Linux by userbinator on Wednesday April 22, 2015 @04:47PM (#9423439)
Agreed; most programmers I know who write a lot of x86 Asm tend to stick with the Intel syntax. I've never found the "it's easier to parse" argument for AT&T syntax particularly convincing, especially as GAS is written in C while some of the Intel syntax assemblers existing at the time were themselves written in x86 Asm. Neither is the "it makes it more consistent with the other arch's assemblers" - just look at GAS' syntax for MIPS and ARM. It seems to me like someone was really obsessed with the SPARC syntax (which I find roughly as horrendous.)

http://x86asm.net/articles/what-i-dislike-about-gas/

Re:“Hello World” in assembly language on Linux by Narishma on Wednesday April 22, 2015 @06:22PM (#9423964)
I don't think either syntax is nicer than the other. It's just a matter personal preference and familiarity.
Re:“Hello World” in assembly language on Linux by cbd1984 on Wednesday April 22, 2015 @11:24PM (#9424855)
Intel syntax has more intuitive memory access syntax:

AT&T syntax:

    movl mem_location(%ebx,%ecx,4), %eax
Intel syntax:

    mov eax, [ebx + ecx*4 + mem_location]
The other differences are minor compared to that, IMHO.

https://en.wikipedia.org/wiki/X86_assembly_language#Syntax

Re:“Hello World” in assembly language on Linux by lokedhs on Thursday April 23, 2015 @12:30AM (#9425024)
I can agree with most of that, except for the fact that Intel arguments are backwards. That throws me off every time. I don't know of any other assembler syntax that uses that argument order.
Re:“Hello World” in assembly language on Linux by oso2k on Thursday April 23, 2015 @01:44AM (#9425171)
For me, I remember the notation by correlating it to its "high-level" equivalent.

   mov eax, [ ptr ]
is like

   eax = *ptr;  // or, eax = ptr[ 0 ];
The offset/multiplier memory addressing format for AT&T syntax was always more troubling for me. Coming from a TASM/MASM/NASM/PASCAL/x86 background first, it felt "icky" to put offsets outside of the "brackets" (or parenthesis, as it were) [0][1].

[0] https://github.com/lpsantil/rt0/blob/master/src/lib/00_start...

[1] https://github.com/lpsantil/rt0/blob/master/src/lib/00_start...

Re:“Hello World” in assembly language on Linux by userbinator on Thursday April 23, 2015 @06:26AM (#9425779)
Standard ARM, MIPS, PowerPC, x86, and Z80 Asm syntax all have the destination on the far left.

68k, Alpha, PDP-11, SPARC, and VAX have the destination on the far right.

The order is probably as contentious as the great endianness debate, but I think one of the most awkward parts of having src, dst order is that subtraction looks backwards. I prefer dst, src because it corresponds closely with the direction of assignment in higher-level languages:

    op a, b, c       ; a = b op c
    op a, b          ; a op= b