Email or username:

Password:

Forgot your password?
Top-level
Ken Shirriff

Now microcode takes over, running the internal steps for the instruction. Each micro-instruction is 21 bits long, with 5 different types of micro-instruction. Each moves an internal source register to a destination. It also does a particular task such as an ALU or memory op.

8 comments
Ken Shirriff

Suppose you want to add the AX register to the BX register: "ADD BX,AX". The microcode moves the register specified by N (i.e. BX) to the ALU's temporary A register. BX, specified by N, moves to tmpB. The sum Σ is moved to BX (N). The ALU op (XI) comes from the instruction.

Ken Shirriff

Thus, a simple add takes 3 micro-instructions (and 3 clock cycles). The microcode is very generic: it doesn't know the particular registers, the ALU operation, or the operand size. It just specifies the steps and the hardware figures out the details. This keeps microcode small.

Ken Shirriff

Adding to memory "ADD [SI],AX" uses the same microcode. A microcode subroutine gets the SI address and reads (R) from memory. Now M represents the memory value. The microcode adds, then falls through to write (W) the result to memory due to the writeback (WB) condition.

Ken Shirriff

Each of the 8 addressing formulas has a short microcode subroutine to compute the effective address. The 8086's Translation ROM determines the appropriate 13-bit microcode address based on the ModR/M byte.

Ken Shirriff

For an addressing mode with a displacement "ADD AX,[SI+1234]", a few more lines of microcode fetch the displacement bytes (e.g. 1234) from the instruction prefetch queue (Q), put them in tmpB, and add them to the SI value.

Ken Shirriff

The 8086 chip squeezed a lot of functionality into just 512 words of microcode, making hardware take care of details. The die photo shows these functional blocks on the die. Microcode takes a large area but even registers (like M and N) use a substantial area of the silicon.

Ken Shirriff

Microcode is very low level and pretty tricky, but hopefully this brief Mastodon explanation makes some sense. For a more detailed look at microcode, see my blog post: righto.com/2023/02/8086-modrm-

Ken Shirriff replied to Ken
Go Up