This was a nice read, but I was hoping for something one step above this. When I was writing an emulator, I spent so much time looking at 8080(ish) code that I began to see constructs for bigger concepts. Like, “oh you’re setting up and running a loop over some subroutine X times.” “You’re checking if a certain math expression equals a certain value before continuing.” Etc. I imagine an Assembly reader sees these thi…
The faker's guide to reading x86 assembly language
11–20 of 49 posts
Re: The faker's guide to reading x86 assembly language
#12This was a nice read, but I was hoping for something one step above this. When I was writing an emulator, I spent so much time looking at 8080(ish) code that I began to see constructs for bigger concepts. Like, “oh you’re setting up and running a loop over some subroutine X times.” “You’re checking if a certain math expression equals a certain value before continuing.” Etc. I imagine an Assembly reader sees these thi…
Re: The faker's guide to reading x86 assembly language
#13This was a nice read, but I was hoping for something one step above this. When I was writing an emulator, I spent so much time looking at 8080(ish) code that I began to see constructs for bigger concepts. Like, “oh you’re setting up and running a loop over some subroutine X times.” “You’re checking if a certain math expression equals a certain value before continuing.” Etc. I imagine an Assembly reader sees these thi…
An easy way to learn to see those patterns is through exploring compiler output: https://godbolt.org/ Other than that, I like "Assembly Language Step By Step" by Jeff Duntemann, which is currently in its third edition and is Linux-only, as opposed to previous editions which were MS-DOS and Linux. He has example assembly code (Intel syntax for NASM, another reason I like his book) for download on his website: http://w…
1. Data movements (mov)
2. Control flow (various jumps with corresponding tests, call and ret)
3. Calling convention. But you can often wing this and figure it out from context.
Re: The faker's guide to reading x86 assembly language
#14Re: The faker's guide to reading x86 assembly language
#15Yes, the simple opcodes are the most-used, and this was one of the ideas floating around that helped inspire RISC, but be careful how you figure out which opcodes are different. For example, mov in x86 is extremely polysemous: It can be move from register to register, load register with data from RAM, store register contents out to RAM, store a constant out to RAM, and even perform ALU operations and then use the res…
One thing worth pointing out is that, if you ignore the way the assembly is written and instead look at the binary encoding, then x86 is closer to a RISC idea. Essentially, the core of an x86 instruction is opcode + ModR/M byte, which encodes a register and register-or-memory operand. There's one opcode [1] that means "move from second operand to first operand" and a different opcode that means "move from first opera…
You could say the same thing about the VAX, which was even more CISC than the x86 is, because of how its opcode encoding worked: Bytes for the opcode, bytes for addressing modes, bytes for register specifications or constant values or memory addresses. Ditto the PDP-10. Which is to say that's not a helpful way of making the RISC/CISC divide because it ignores everything that makes those kinds of processors different.
Somewhat down in this page, written by processor designer John Mashey, is a list of features which RISC processors tend to have that CISC processors don't:
https://userpages.umbc.edu/~vijay/mashey.on.risc.html
Above that list are two points which get to the heart of the RISC project:
> The RISC characteristics:
> a) Are aimed at more performance from current compiler technology (i.e., enough registers).
> OR
> b) Are aimed at fast pipelining
> - in a virtual-memory environment
> - with the ability to still survive exceptions
> - without inextricably increasing the number of gate delays (notice that I say gate delays, NOT just how many gates).
The point b is where RISC chips really pulled away from CISC in terms of architectural design, especially chips like the MIPS, which Mashey worked on: The MIPS had a number of points where it exposed the tricks it used to pipeline more aggressively, even at the expense of making compilers somewhat harder to write and/or human assembly-language programmers think a bit harder. However, the lack of complicated addressing modes (post-increment, scale-and-offset, etc.) and the lack of register-memory opcodes with ALU operations, and total lack of memory-memory operations, is still a very common feature of RISC design.
I also want to take on this:
> Furthermore, the ability to put a memory operand on, say, an ADD instruction is close in effect to having a compressed instruction encoding that encodes "LD to a temporary, unnamed register followed by ADD that register to the destination register" in fewer bytes than having both (also avoids clobbering a register, useful given the thin 8 registers 32-bit x86 has).
The difference between having one opcode which does both memory operations and ALU operations and not having those kinds of opcodes is faulting: If the CPU has to take a fault, does it have to back out a lot of ALU state such that opcodes appear to be atomic? CISC chips do, and they pay for it, whereas RISC chips are designed not to have to. This, again, makes pipelining easier. (And the page I linked to goes into this as well.)
CISC/RISC is points on a scale, but that doesn't mean it's helpful to "reinterpret" things to try and make CISC seem equivalent to RISC.
Re: The faker's guide to reading x86 assembly language
#16does anyone know why at&t opcodes ever existed in the first place?
Re: The faker's guide to reading x86 assembly language
#17does anyone know why at&t opcodes ever existed in the first place?
Re: The faker's guide to reading x86 assembly language
#18does anyone know why at&t opcodes ever existed in the first place?
https://news.ycombinator.com/item?id=33586476
which cites this PDF:
Re: The faker's guide to reading x86 assembly language
#19does anyone know why at&t opcodes ever existed in the first place?
Here's one explanation: https://news.ycombinator.com/item?id=33586476 which cites this PDF: https://www.bell-labs.com/usr/dmr/www/otherports/newp.pdf
https://go.googlesource.com/go/+/refs/tags/go1.19.4/src/runt...
Re: The faker's guide to reading x86 assembly language
#20Earlier quoted context omitted.
An easy way to learn to see those patterns is through exploring compiler output: https://godbolt.org/ Other than that, I like "Assembly Language Step By Step" by Jeff Duntemann, which is currently in its third edition and is Linux-only, as opposed to previous editions which were MS-DOS and Linux. He has example assembly code (Intel syntax for NASM, another reason I like his book) for download on his website: http://w…
Regarding the book, What would be the difference between 32bit and 64bit? Is it still relevant to read today?
https://wiki.osdev.org/Calling_Conventions
Richard Blum [2] after Dunteman.
[1] At a reasonable level of approximation.
[2] https://www.wiley.com/en-us/Professional+Assembly+Language-p...