3 ms·
The opcode encoding goes AX CX DX BX, not AX BX CX DX. This is a bit like the XKCD comic about bad kerning - you need to point it out and then people cant be un
by blueflow 6y ago
The opcode encoding goes AX CX DX BX, not AX BX CX DX. This is a bit like the XKCD comic about bad kerning - you need to point it out and then people cant be unbothered by it.
- userbinator 6y agoBX is special because in 16-bit mode it's the only one of the ABCD registers that can be used in addressing modes. ...and detecting 11 or 00 is easier than 01 or 10 in hardware, because it saves an inversion and thus a few transistors.
- blueflow 6y agoThis doesnt make sense - the 16-bit modr/m byte (required for indirect register access) doesn't use the 'regular' opcode numberings, and the 32-bit modr/m byte can use any GPR, so BX is not special anymore (as mentioned in the article).
- kiwidrew 6y agoThat's because Intel made the 8086 kind-of-sort-of backwards compatible with the 8080; it had six 8-bit registers (A Flags B C D E) plus a 16-bit register pair (H L), in that order. AL corresponds to the 8080's A register and AH to the flags (which is also why the LAHF and SAHF instructions exist). CX corresponds to B+C and DX corresponds to D+E. Finally, BX is the 8086 equivalent of the 8080's pointer register HL. (The 8086 didn't use the same opcodes as the 8080 but it was designed this way so that a simple translator could 'convert' existing 8080 code.)
- blueflow 6y agoWhy would the 8086 encoding be inspired from the 8080 when these two are generally not meant to be compatible in terms of their encoding? There is no gain from any of that. This is like a urban legend that i have never found the source for. I stopped believing it after learning that the 8080 encoding order is BCDEHLMA, with the accumulator being last at position 7.