3 ms·
This also explains how the otherwise undefined "LEA reg, reg" works --- I believe on 186+ it's a #UD, but on the 8086 it just puts the result of the last addres
by userbinator 4y ago
This also explains how the otherwise undefined "LEA reg, reg" works --- I believe on 186+ it's a #UD, but on the 8086 it just puts the result of the last address calculation into the destination, itself having not done any itself (whereas in the valid case, it always would.)
There was some discussion about that here in the past, not surprisingly on another one of Ken's 8086 RE articles: https://news.ycombinator.com/item?id=24248773 https://news.ycombinator.com/item?id=24248773
There are other notable undefined ModR/M combinations here, which the behaviour thereof can hopefully now be answered:
https://retrocomputing.stackexchange.com/questions/21747/undocumented-modr-m-byte-combinations https://retrocomputing.stackexchange.com/questions/21747/und...
- kens 4y agoI took a closer look. As you suggested, LEA reg1,reg2 will simply run the micro-instruction "IND→N RNI" without doing any effective address calculation first. Whatever address is in the IND (Indirect) register will be written to the register specified in the reg field. As for JMP FAR rm with a register, what I seen in the microdcode doesn't quite match the linked discussion. The microcode is IND → tmpC INC2 tmpC JMP FAR rm Σ → IND SUSP tmpB → PC R DS,P0 OPR → CS FLUSH RNI So it will add 2 to the hidden IND register, read the segment value from that address, and put that in the CS register. Meanwhile, the PC gets the value from the hidden ALU temporary B register. As for the mystery FF FF instruction, I think it jumps into "PUSH rm" and ends up pushing DI. SP → tmpA DEC2 tmpA PUSH rm Σ → IND Σ → SP M → OPR W SS,P0 RNI
- userbinator 4y agoAs for the mystery FF FF instruction, I think it jumps into "PUSH rm" and ends up pushing DI. In other words, it seems that FF/6 (the normal "PUSH rm") and FF/7 (officially undefined) are aliases? The other notable anomaly is that 8F/1-7 are also officially undefined, while "POP rm" is at 8F/0. Ignoring the 0F-prefixed ones (POP CS, everyone knows that one by now), there are some interesting gaps in the group table: https://www.sandpile.org/x86/opc_grp.htm https://www.sandpile.org/x86/opc_grp.htm Perhaps all those undefined opcodes could be worth writing another detailed article about, now that you've become familiar with how the instruction decoding works.