“This article explains some of the more important syntactic and semantic differences between two of the most popular assemblers for Linux, GNU Assembler and Netwide Assembler, including differences in basic syntax, variables and memory access, macro handling, functions and external routines, stack handling, and techniques for easily repeating blocks of code.”
Looking at nasm examples made me go back 19 years, when I used to do a lot of coding in masm. Nice!
Heh, same here. I worked mainly in 8086 Assembler from around 1985 until 1992. I did pick up C around 1989, but the majority of the stuff I did was in Assembler (MASM).
The final “straw” for me was when I started using Windows 3.1, in 1992. That is what finally got me on the C band wagon, and away from Assembler.
Don’t get me wrong, ~10% of my code is still in asm, but all of it is inline in C projects. (under both GCC and VC)
As for AT&T vs. Intel, even though I’ve mostly gotten used to writing AT&T-style asm code, I still find it awkward.
– Gilboa
He got some things about Nasm wrong – namely it supports more than he says it does – e.g. 0x80 vs. 80h, it supports both.
Some of his text also seems to miss what is actually in his example (e.g %beginmacro vs. %macro).
Overall, good review.
AT&T assembler always becomes an unreadable mess. For maintainable code, Intel syntax is a big plus.
But what to do when you want to create assembly code not only for x86, but also MIPS, ARM, SPARC, PPC etc.? Then there should be NASM-like implementations for those platforms too, otherwise you get differing syntax between the various architectures.
P.S. Keep up with the development of FPC and I’m a student in the city you live in too .
Using Nasm on i386 has little impact on both portability and uniformity.
GAS isn’t the same on each platform. For example on ARM an immedeate operand is prefixed by # and uses “dest,source” operand order while on i386 it is $ for immedeate and “source,dest” operand order. For each platform you simply have a different syntax.
i still can not get used to the “swapped” operator syntax of gasm, maybe it is just because i learned it first or i’m drunk now.
is there anyone actually prefering the gasm notation over the intel one?
gasm is kinda turning me on… It’s called “AT&T syntax” 😉
Maybe it’s just because I practically learned assembler with GCC and GAS, but I find the operand order of Intel syntax really awkward.
movl $2, %eax == move 2 to eax
mov eax, 2 == move to eax 2… weird.
The prefixes can get annoying, though.
– Simon
I agree – due to the actual word move itself – the semantic meaning (at least for me) changes completely if you use the (also popular) word load instead:
load eax,2 ; semantically natural (similar to Z80 for instance).
move 2,eax ; quite ok (68000 and many others), even if I’d preferred the word copy in this context.
Yes, # or $ prefixes on constans are somewhat ugly. On the other hand, appended size specifier letters on instruction mnemonics is perhaps more elegant than byte pointer etc (how did MS justify the ptr part semantically?).