Earlier quoted context omitted.
I haven't. It's probably not fun.
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…
Learning to Read X86 Assembly Language
131–140 of 238 posts
Re: Learning to Read X86 Assembly Language
#132To understand assembly it really helps to know at least something about how computers work on a low level. When I first tried learning it (long time ago, in a high school) I had no idea how computers really work on such a low level, how CPU's addressing registers and that kind of stuff, and while I managed to learn the syntax, even write some asm code, it was all really confusing to me. And only few years later on Un…
It's helpful to realize x86 assembly is not what's executed by the machine; machine code is. One assembly instruction, e.g. ADDL, is translated to several different machine code instructions depending on the destination, source, and addressing mode.
Re: Learning to Read X86 Assembly Language
#133Earlier quoted context omitted.
>It also didn't have memory segmentation The Z80 only has a 16-bit address space. My favorite CISC architecture is the 68000 series.
Yes. But you could install an MMU. The 68k (and it's 8-bit semi-cousin, the 6809) were very nice. However, unlike the Z80, the 6502, and x86, they're no longer being made, and are increasingly rare.
Re: Learning to Read X86 Assembly Language
#134Earlier quoted context omitted.
Unfortunately not, but I'd love to hear from those who do.
I wouldn't be surprised if the reason was that people at Bell labs were mimicking some older syntax.
Re: Learning to Read X86 Assembly Language
#135Earlier quoted context omitted.
Unfortunately not, but I'd love to hear from those who do.
I wouldn't be surprised if the reason was that people at Bell labs were mimicking some older syntax.
(please don't upvote if you agree, i'm at 69 points :)
Re: Learning to Read X86 Assembly Language
#136Re: Learning to Read X86 Assembly Language
#137What 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…
And Golang uses a separate syntax from Intel syntax and AT&T syntax, so now there are three incompatible syntaxes in common use. What a mess. :( In Go's case it's because they wanted to have the syntax reflect the MachineInstr-like abstraction they have in place. I wouldn't be surprised if something similar was responsible for the AT&T syntax as well. (In case it isn't clear, my preference is to do what LLVM does and…
To quote "The details vary with architecture, and we apologize for the imprecision; the situation is not well-defined." [0]
Re: Learning to Read X86 Assembly Language
#138Also Matt Godbolt's gcc explorer is the the bee's knees for understanding assembly https://godbolt.org/ I think that playing around with it for 2 hours will teach you more than most classes on the topic. It really drives home why interactivity is such a bit deal in education. You should also try writing a script for counting instructions in binaries. It's pretty illuminating. Here are some sample statistics https://w…
One great example to try: add -O3 to the compiler options, then write a function returning its argument multiplied by 2, 3, 4, ... You'll see the various ways the compiler avoids emitting an actual multiplication instruction. The smallest multiplier I found that actually produced an imul: 46.
Re: Learning to Read X86 Assembly Language
#139Earlier quoted context omitted.
Suppose you're right and the registers are arbitrary. Then how would foreign function calls work? If you're compiling Rust code that calls into a C library, how does it know what registers to use? So the choice of registers cannot be arbitrary, unless the compiler knows the function is only used within an object file. The registers are predetermined by a convention unless you use the 'static' keyword to signal that t…
Then how would foreign function calls work? If you're compiling Rust code that calls into a C library, how does it know what registers to use? By using information kept with the function, or perhaps even encoded into the function name itself (as already happens when distinguishing between different calling conventions, or in the case of C++ name mangling)? Coming from an Asm background, where there basically is no on…
Re: Learning to Read X86 Assembly Language
#140Earlier quoted context omitted.
One great example to try: add -O3 to the compiler options, then write a function returning its argument multiplied by 2, 3, 4, ... You'll see the various ways the compiler avoids emitting an actual multiplication instruction. The smallest multiplier I found that actually produced an imul: 46.
Interesting example, I came up with clang 3.9 producing an imul with 11 though.
GCC produces an lea that multiplies by 5 into %rax for the return value, then another lea that multiplies that by 2 and adds the original.