Live data from Hacker News

Learning to Read X86 Assembly Language

patshaughnessy.net

151–160 of 238 posts

Re: Learning to Read X86 Assembly Language

#151

Earlier quoted context omitted.

They're not as common reasons. But yes, if you want to program your TRS-80 (but only the original: later ones were 6502), or your ZX* (How many of you lot know the ZX line? Spectrum? No?), or your Game Gear, or your Master System, or any of the various CP/M machines, you have to learn Z80.

How many of you lot know the ZX line? Spectrum? No? The ZX Spectrum and its clones were very popular in the UK, Eastern Europe, and the former USSR.

They also ruled in Portugal and Spain. Almost no C64 in sight beyond a few computer magazines.

Re: Learning to Read X86 Assembly Language

#152

Earlier quoted context omitted.

It wasn't easy. Very asymmetric, not many registers, and tiny stack. The only things that were written directly in it were the operating system, and the virtual machines for higher level languages such as COBOL and MPL, because it was too hard to compile to. I worked on the virtual machines. After programming in it, I can assure you that programming in other assembly languages (including x86) is a breeze. I should pu…

Isn't the high level Burroughs assembly a compertly insane almost high level language? I looked into implementing it into my assembler and just ran in the other direction when I saw how much unnecessary co plexity there was in the language.

On the other hand it allowed for ESPOL and NEWP, two memory safe systems programming languages, with unsafe memory access having to be marked as such.

Re: Learning to Read X86 Assembly Language

#153
post #135

Earlier quoted context omitted.

I wouldn't be surprised if the reason was that people at Bell labs were mimicking some older syntax.

I remember reading a long time ago about the syntaxes and the author said that it is because AT&T assembled faster. Makes sense considering that the intel syntax requires some backtracking (or more of temporary data). (please don't upvote if you agree, i'm at 69 points :)

> Makes sense considering that the intel syntax requires some backtracking (or more of temporary data).

That would imply that the Intel syntax is not LL(1) or LR(1). Are you sure?

Re: Learning to Read X86 Assembly Language

#154
And, of course, modern compilers will usually produce faster, more optimized code than you ever could, without making any mistakes.

This assertion comes up over and over again in the last 30 years. Every time I've had it asserted to me, it always came from non-assembler programmers, who always wrote in a high level language. I have yet to see evidence of optimizing compilers generating code even remotely close in efficiency to what we would code directly in assembler.

A coder would never write all those extra frame pointer setup code, nor would they waste encoding and tact cycles shuffling values from one register to another. For example, a human might write the code from the article thus:

  Add42: addb $42, %al
         ret
and that's it. No frame pointer or stack setup, that's all unnecessary overhead because compiler algorithms can't reliably make such contextual decisions.

Re: Learning to Read X86 Assembly Language

#155

What a train wreck! It’s hard to imagine a more confusing state of affairs. I'd say that's more attributed to someone many many years ago deciding they would not follow the official Intel syntax (for what reason I do not know), and somehow convincing the rest of the community to follow them. That's actually one of the things that could make for a very interesting article: how one processor family got two different an…

This. The AT&T syntax for x86 thing is a huge mistake. All the official docs are Intel syntax. Intel syntax is easier to read and write. Half the gotchas in this article are problems that don't exist in Intel syntax, like the instruction suffixes. The instruction suffixes get even weirder when you get to the sign extending instructions. I wrote an article about this here: http://blog.reverberate.org/2009/07/giving-up…

The AT&T syntax for x86 thing is a huge mistake.

For someone who grew up on normal processors (MC68000 and UltraSPARC) AT&T syntax is the best thing since sliced bread: it's perfectly logical to move something to somewhere, instead of "move to somewhere something".

Re: Learning to Read X86 Assembly Language

#156

Earlier quoted context omitted.

They're not as common reasons. But yes, if you want to program your TRS-80 (but only the original: later ones were 6502), or your ZX* (How many of you lot know the ZX line? Spectrum? No?), or your Game Gear, or your Master System, or any of the various CP/M machines, you have to learn Z80.

How many of you lot know the ZX line? Spectrum? No? The ZX Spectrum and its clones were very popular in the UK, Eastern Europe, and the former USSR.

... and for a brief period of time in the late '80s, "popular" in India as well. (I quoted popular because they were bloody expensive. In 7th grade, a kid in my class had one. He was the only one in all of the school to have a computer.).

Re: Learning to Read X86 Assembly Language

#157

Earlier quoted context omitted.

This. The AT&T syntax for x86 thing is a huge mistake. All the official docs are Intel syntax. Intel syntax is easier to read and write. Half the gotchas in this article are problems that don't exist in Intel syntax, like the instruction suffixes. The instruction suffixes get even weirder when you get to the sign extending instructions. I wrote an article about this here: http://blog.reverberate.org/2009/07/giving-up…

The AT&T syntax for x86 thing is a huge mistake. For someone who grew up on normal processors (MC68000 and UltraSPARC) AT&T syntax is the best thing since sliced bread: it's perfectly logical to move something to somewhere, instead of "move to somewhere something".

I haven't done any 68K Asm and barely glanced at SPARC, but how does src, dst interact with noncommutative operations like subtraction and comparison? E.g. with x86 Intel syntax,

    cmp eax, 5     ; eax - 5
    jg morethan5   ; eax > 5 ? then jump.
    sub eax, ecx     ; eax = eax - ecx
This is one of the most confusing things about AT&T x86 --- the comparisons and subtractions have their operands reversed, and you have to identify and manually reverse them to understand the code correctly. With Intel syntax, the operands to a subtraction appear in the usual arithmetic order. Or do those processors' syntax keep the order but instead replace the subtrahend with the result??

    sub A, B    ; B = A - B ??

Re: Learning to Read X86 Assembly Language

#158

x86 is the worst ISA. If you want to play with assembler without feeling a desire to stab yourself and end it all, I recommend ARM. Or go learn Z80, x86's weird, 8-bit cousin (it had a 16-bit version, but it sold poorly), which had a greater emphasis on backwards compatability (you can run code from the original 8080 on a Z80, unchanged), and is nicer to work with (because it wasn't extended in unticipated directions…

x86 is the worst ISA. If you want to play with assembler without feeling a desire to stab yourself and end it all, I recommend ARM.

Yes, intel is really bad, especially for learning, and while ARM is certainly better, it's pretty esoteric, and also backwards (right to left) like intel.

If you want a nice, orthogonal ISA to learn assembler on, MC68000 family is a song. The instructions are human readable, the processor is big endian, and the moves are src, dst. It's almost like a high level programming language.

Re: Learning to Read X86 Assembly Language

#159
post #40

Earlier quoted context omitted.

> an absolutely ugly jumble of [...] religious backwards compatability, odd hacks, and various extensions Like POSIX, MS-Windows, X11, WinAPI, C++, HTML5, ... ;-)

Hey, I didn't say it was the only one. Although POSIX and HTML5 hold up a bit better than Win32 and C++, IMHO. Especially POSIX (it's not great, but it works pretty well). But I've heard X11 is absolutely miserable, so the windows folks don't have a monopoly on satanically evil APIs with religious backwards-compatability.

Everything you wrote is actually correct, so I'm really not sure why you're being voted down, but it's a behavioral pattern I've noticed on HN in general: write anything that's not high praise or in any way disagrees with what's popular and expect to be brutally censored. It really has me contemplating ditching HN altogether, if all we're ever going to do here is stroke eachothers' egos and pander to popular trends. And here I thought the point of HN was stimulating discussion.

Re: Learning to Read X86 Assembly Language

#160
post #61

Earlier quoted context omitted.

Hey, I didn't say it was the only one. Although POSIX and HTML5 hold up a bit better than Win32 and C++, IMHO. Especially POSIX (it's not great, but it works pretty well). But I've heard X11 is absolutely miserable, so the windows folks don't have a monopoly on satanically evil APIs with religious backwards-compatability.

It helps to have actual real life experience under your belt when making such claims. You seem to be parroting what countless rants have already repeated without much content.

How many times must common knowledge be supported by evidence? Every time? This has been beaten to death.
Post reply on HN