Reverse-engineering the Intel 8086 processor's HALT circuits
righto.com
righto.com
String instructions would be cool, I suspect microcode to have a few features only used by them in collaboration with the decode ROMs. For example REP is probably little more than one of the conditions that the microcode can test.
Indeed it is, and the same internal flag set by the REP prefix is also used by the multiplication and division subroutines to keep track of the sign bit. With the prefix, (I)MUL and (I)DIV will return a negated result on the 8086.
The 80186 only does this for IDIV. Mul/div on that processor is already mostly handled by dedicated logic, so the microcode is a lot shorter (and no longer uses any subroutines).
However, MUL and IMUL jump to a common exit point that can put the result into either DX:AX or an arbitrary register (for the three-operand form of IMUL), and again they used the REP flag to keep that extra bit of state. If it is set, the register is selected by the middle ModRM field. The usefulness of that undocumented "feature" is somewhat limited, since that is also part of the opcode, so the only choices for register are AH, CH, SP and BP.
Also, BOUND uses the flag as a 1-bit "loop counter" and will fail to check the upper bound when prefixed with REP.
The 80286 and everything newer either ignore the prefix or handle it similar to 0Fh: each prefixed opcode is now a separate instruction with its own microcode.
Username checks out.
And thank you for the interesting comments on these historical implementations!
Then no special logic would be needed, no extra states, etc.
Sure - there would be no power savings, and the memory bus wouldn't be idle, but we're either of those a requirement in 1970?
Or, as I understand other processors of the time might not even bother to include such an instruction, was it sort of optional or rarely used?
00 would be "increment A", 01 "decrement A". I would guess these weren't supported because of how that register is connected to the ALU?
FF = "load memory from memory", same as the HLT on the 8080.
On microprocessors of the time, they're indeed a little useless. None of the logic was going to disable the internal clock, this was decades before the introduction of gateable power wells, etc...
But on the bigger hardware where DMA was common, a halted CPU could be relied on not to be issuing needless requests to the memory bus and other clients like I/O devices (SMP was in its infancy in the 70's too) would have lower contention and higher throughput. I'm sure that was part of the thinking. The IBM PC itself tended not to contend on its bus much (CGA and MDA had their own framebuffers and floppy DMA was mostly a joke), but maybe there were other 8086 implementations that cared.
- 8x NEG
- 8x RETI/RETN (named differently but same behaviour)
- 4x IM0, 2x IM1 and 2x IM2
- and a whopping 178 opcodes in the ED block decode to a NOP (no operation)