ASM is easier than believed
Like I've stated several times, I find AT&T easier to read as well, as it's very regular. A nice bonus is that you can identify registers from the % even if you didn't know such a register exists (say, you're reading code for an architecture you don't know very well).
The real problem with goto is not with the control transfer, but with environments. Properly tail-recursive closures get both right.
- Combuster
- Member
- Posts: 9301
- Joined: Wed Oct 18, 2006 3:45 am
- Libera.chat IRC: [com]buster
- Location: On the balcony, where I can actually keep 1½m distance
- Contact:
while register use is more obvious in at&t syntax, IMHO memory addressing is more obvious in intel syntax as it is more explicit:
compare
foo(%eax,%ebx,0x4)
to
[foo + eax + 4*ebx]
if you know neither syntax, you can sensibly know in the second case what is being computed while you can't in AT&T syntax without looking it up.
Also, a memory access is hard to distinguish from a register access, while in intel syntax, you'll see [...] for every explicit memory operand, while in at&t "mov foo, %eax" is a memory access that reads pretty much like an immediate access.
now SIB addressing in AT&T isn't that hard to learn, but once you've seen some other dialects neither ATT nor Intel looks bad... Consider the following 68k assembly:I'll leave it as an excercise for the reader to try and figure what that does without getting the manual.
compare
foo(%eax,%ebx,0x4)
to
[foo + eax + 4*ebx]
if you know neither syntax, you can sensibly know in the second case what is being computed while you can't in AT&T syntax without looking it up.
Also, a memory access is hard to distinguish from a register access, while in intel syntax, you'll see [...] for every explicit memory operand, while in at&t "mov foo, %eax" is a memory access that reads pretty much like an immediate access.
now SIB addressing in AT&T isn't that hard to learn, but once you've seen some other dialects neither ATT nor Intel looks bad... Consider the following 68k assembly:
Code: Select all
mov.w ([foo,A3],D5.w*2,bar), -(A5)
- Brynet-Inc
- Member
- Posts: 2426
- Joined: Tue Oct 17, 2006 9:29 pm
- Libera.chat IRC: brynet
- Location: Canada
- Contact:
I've posted this about a billion times, You CAN use intel syntax in C (inline)..pcmattman wrote:Registers on the PDP-11 are annoying - r0, r1... sp...
Is there a version of GAS that takes Intel syntax? Can you use Intel syntax with GCC?
Either way, assembly is much easier than most say, once you take the time to learn it.
This is how you do it in C...
(Note that after you use Intel syntax you much switch back..)
Code: Select all
asm(".intel_syntax noprefix");
asm("mov eax, edx");
asm(.att_syntax");
Code: Select all
.intel_syntax noprefix
mov eax, edx
.att_syntax
IMHO assembly has it's place. but only if you use it in the right manner. For example, someone could write a whole system (by system, I mean a program that is database driven) in assembly, but wouldn't be maintainable (i.e if the code need to be ported to another achecture).
If you know that the archecture unlikly to change. then Assembly is the best laguage in the world (in moderation, is even better C).
If you know that the archecture unlikly to change. then Assembly is the best laguage in the world (in moderation, is even better C).
Microsoft: "let everyone run after us. We'll just INNOV~1"
No offense but that is a terrible reason to choose a syntax... If you don't know the ISA then you probably shouldn't be programming it. Intel Syntax is so much cleaner looking, and it actually matches the ISA instead of making up its own (movl etc)mystran wrote:Like I've stated several times, I find AT&T easier to read as well, as it's very regular. A nice bonus is that you can identify registers from the % even if you didn't know such a register exists (say, you're reading code for an architecture you don't know very well).
- mathematician
- Member
- Posts: 437
- Joined: Fri Dec 15, 2006 5:26 pm
- Location: Church Stretton Uk
- Colonel Kernel
- Member
- Posts: 1437
- Joined: Tue Oct 17, 2006 6:06 pm
- Location: Vancouver, BC, Canada
- Contact:
Uhhh... Macs these days are x86-compatible too. Where have you been?mathematician wrote:There may have been a time when portability was an issue with assembly language, but nowadays about 97% of desk top computers are IBM compatible PC's (much to the disgust of Mac users)
Also, there are still a lot of high-end servers out there running various *nix flavours on different architectures. For example, the project I'm working on now involves porting code between x86, Sparc, PowerPC, Itanium, and PA-RISC. This is a big commercial project for a big customer with big $$$... portability still matters IMNSHO.
Top three reasons why my OS project died:
- Too much overtime at work
- Got married
- My brain got stuck in an infinite loop while trying to design the memory manager
Actually I was referring to this article and the fact that most CPUs today are 8bit...
Every good solution is obvious once you've found it.