Misc/Computer parts/CPUs/Intel x86/8086

From Digital Media Wiki 3 - Selfhost
Revision as of 20:31, 3 January 2026 by Bluecomb (talk | contribs) (Porting the Intel 8086 page from the GSites)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Registers[1][2]

  • AX - Primary accumulator - 16-bit, made up of 2 8-bit registers AH and AL (which will update with AX and vice versa), arithmetic and logical instructions
  • BX - Base register - 16-bit, made up of BH and BL (same details as AX),  stores offsets for memory addressing
  • CX - Loop counter - 16-bit, made up of CH and CL (same details as AX),  
  • DX - Data register - 16-bit, made up of DH and DL (same details as AX), I/O and extended arithmetic
  • SI - Source Index - 16-bit
  • DI - Destination Index - 16-bit
  • BP - Base Pointer - 16-bit
  • SP - Stack Pointer - 16-bit
  • IP - Instruction Pointer - 16-bit
  • CS - Code Segment - 16-bit
  • DS - Data Segment - 16-bit
  • ES - Extra Segment - 16-bit
  • SS - Stack Segment - 16-bit
  • Flags register (left to right):
    • N/A
    • N/A
    • N/A
    • N/A
    • Overflow Flag
    • Direction Flag
    • Interrupt flag
    • Trap Flag
    • Sign flag
    • Zero flag
    • N/A
    • Auxiliary carry flag
    • N/A
    • Parity flag
    • N/A
    • Carry flag

Opcodes[3]

For bytes that use the "addressing mode, register to update, register to get position from" (or, as called in source [3], "mod reg r/m") format:

Addressing mode codes:

  • 00 - no displacement
  • 01 - signed 8-bit displacement
  • 10 - unsigned 16-bit displacement
  • 11 - register to register (not allowed for LES)

Register to update codes:

  • 000 - AX
  • 001 - CX
  • 010 - DX
  • 011 - BX
  • 100 - SP
  • 101 - BP
  • 110 - SI
  • 111 - DI

Register access codes:

  • 000 - BX + SI
  • 001 - BX + DI
  • 010 - BP + SI
  • 011 - BP + DI
  • 100 - SI
  • 101 - DI
  • 110 - BP (unless mode is 00, then the only operand is the 16-bit address given after this byte)
  • 111 - BX
Byte code Assembly command Description Flags modified
B0 xx MOV AL, xx Moves 8-bit data to the AL register. AX will update accordingly. None
B1 xx MOV CL, xx Moves 8-bit data to the CL register. CX will update accordingly. None
B2 xx MOV DL, xx Moves 8-bit data to the DL register. DX will update accordingly. None
B3 xx MOV BL, xx Moves 8-bit data to the BL register. BX will update accordingly. None
B4 xx MOV AH, xx Moves 8-bit data to the AH register. AX will update accordingly. None
B5 xx MOV CH, xx Moves 8-bit data to the CH register. CX will update accordingly. None
B6 xx MOV DH, xx Moves 8-bit data to the DH register. DX will update accordingly. None
B7 xx MOV BH, xx Moves 8-bit data to the BH register. BX will update accordingly. None
B8 xx yy MOV AX, yyxx Moves 16-bit data to the AX register. AH and AL will update accordingly. None
B9 xx yy MOV CX, yyxx Moves 16-bit data to the CX register. CH and CL will update accordingly. None
BA xx yy MOV DX, yyxx Moves 16-bit data to the DX register. DH and DL will update accordingly. None
BB xx yy MOV BX, yyxx Moves 16-bit data to the BX register. BH and BL will update accordingly. None
BC xx yy MOV SP, yyxx Moves 16-bit data to the SP register. None
BD xx yy MOV BP, yyxx Moves 16-bit data to the BP register. None
BE xx yy MOV SI, yyxx Moves 16-bit data to the SI register. None
BF xx yy MOV DI, yyxx Moves 16-bit data to the DI register. None
C2 xx yy RETN yyxx Removes the return address (IP register) from the stack, and then removes yyxx more bytes from the stack. Returns within the same code segment. None
C3 RETN Removes the return address (IP register) from the stack. Returns within the same code segment. None
C4 xx yy zz LES register, [zzyy] Loads the offset of a 32-bit pointer (segment:offset) into a given register and the segment into the ES register. The xx byte is in the "mod reg r/m" format. None
C5 xx yy zz LDS register, [zzyy] Loads the offset of a 32-bit pointer (segment:offset) into a given register and the segment into the DS register. The xx byte is in the "mod reg r/m" format. None
CA xx yy RETF yyxx Removes the return address (IP register) and code segment (CS register) from the stack, and then removes yyxx more bytes from the stack. Returns in other code segments. None
CB RETF Removes the return address (IP register) and code segment (CS register) from the stack. Returns within the same code segment. None
CC INT 03 I'll write this in later None