[[File:Siemens 8086-2 PDIP.jpg|thumb|right|Intel 8086 manufactured by Siemens for Amstrad PC1512]]
The Intel 8086 is a landmark 16‑bit microprocessor introduced by Intel in 1978. It was the first in the x86 family and established many architectural conventions that continue to influence modern personal computing.
With a hybrid internal design—featuring 16‑bit registers and a 16‑bit arithmetic logic unit (ALU) paired with a 20‑bit external address bus—the 8086 could directly address 1 megabyte of memory, a significant leap over its 8‑bit predecessors.
Although there were definitely other CPUs in use in the 1980s, the vast majority of microcomputers people had at home or at the office used either a [[MOS 6502]] (or one of its variants), a Zilog [[Z80]], an early member of the [[Intel 8086]] family, or a [[Motorola 68000]].
<br>
= History =
Developed in After the mid‑1970s as a response to release of the growing need for greater processing power and memory capacity, the 8086 was designed to bridge the gap between earlier 8‑bit processors (like the Intel [[Intel 8080]] CPU, Intel began working on the iAPX 432 project. It was an ambitious 32‑bit design—aimed at supporting advanced, high‑level programming features in hardware—which took several years and 8085) and a large team to develop, partly because it awaited further improvements in chip density per Moore’s Law. Meanwhile, to quickly counter the future competition, Intel rushed a simpler, lower‑risk design: the 8086. This chip, developed as an incremental evolution of 16‑bit computingthe 8080 and managed by a separate team, was ready for mass market in 1978.
The chip’s design was partly influenced by the need to maintain some backward compatibility with 8‑bit software while also providing a richer instruction set for high‑level languages such as Pascal and PL/M.
Although the [[PC|IBM PC ]] later used the nearly identical 8088 (which featured an 8‑bit external data bus for cost savings), the 8086 itself became the architectural blueprint for the x86 family, directly influencing later processors. As for the iAPX 432, it turned out to be a commercial failure, and was discontinued in 1986. Intel then tried to venture into RISC CPUs in the late 1980s with the i860 and i960. But it was ultimately unsuccessful.
<br>
= Architecture =
== Hybrid Internal Design ==Most sources claim that the 8086 has about 29,000 transistors. But actually, it has only 19,618 transistors. [https://www.righto.com/2023/01/counting-transistors-in-8086-processor.html Source]
InternallyTo put it into perspective, the 8086 features a 16‑bit execution unit (EU) that performs arithmetic64KB of DRAM contains 524, logic288 transistors, and control functions, while a separate bus interface unit (BIU) handles all data transfers and external communicationsas 1 bit of DRAM needs 1 transistor.
Fun fact: The BIU includes original IBM PC came with 16KB of memory. [https://devblogs.microsoft.com/oldnewthing/20090128-00/?p=19353 Source] == Microcode == Whereas the Z80 and the 6502 CPUs use a six‑byte prefetch queue that overlaps Decode ROM (PLA), the 8086 uses microcode instead. To execute a machine instruction fetching with execution, improving overall throughputthe computer internally executes several simpler micro-instructions, specified by the microcode. ExternallyIn other words, microcode forms another layer between the 20‑bit machine instructions and the hardware. The 8086's microcode ROM holds 512 micro-instructions, each 21 bits wide. The microcode engine is assisted by two smaller ROMs: the "Group Decode ROM" to categorize machine instructions, and the "Translation ROM" to branch to microcode subroutines for address bus—combined with calculation and other roles. See: [https://righto.com/8086/groupRom.html Group Decode ROM viewer] [https://www.righto.com/2022/11/how-8086-processors-microcode-engine.html How the 8086 processor's microcode engine works] [https://www.reenigne.org/blog/8086-microcode-disassembled/ 8086 microcode disassembled] Reverse-engineering the: [https://www.righto.com/2023/03/8086-multiplication-microcode.html multiplication algorithm] [https://www.righto.com/2023/04/reverse-engineering-8086-divide-microcode.html division microcode] [https://www.righto.com/2023/04/8086-microcode-string-operations.html string operations] [https://www.righto.com/2023/01/reverse-engineering-conditional-jump.html conditional jumps] [https://www.righto.com/2023/03/8086-register-codes.html register codes] [https://www.righto.com/2023/02/8086-modrm-addressing.html ModR/M addressing microcode] [https://www.righto.com/2023/02/how-8086-processor-determines-length-of.html instructions length] [https://www.righto.com/2023/02/silicon-reverse-engineering-intel-8086.html flags circuitry] [https://www.righto.com/2023/02/8086-interrupt.html interrupt circuitry] [https://www.righto.com/2023/01/reverse-engineering-intel-8086.html HALT circuitry] [https://www.righto.com/2020/08/reverse-engineering-8086s.html ALU circuitry] in the Intel 8086 processor == Block Diagrams == Internally, the 8086 features a 16‑bit Execution Unit (EU) that performs arithmetic, logic, and control functions, while simultaneously a separate Bus Interface Unit (BIU) handles all data bus—enables transfers and external communications. The BIU includes a 6‑byte prefetch queue (4-byte for 8088). The EU fetches instructions from the processor prefetch queue (not directly from memory). It has no direct connection to the external system bus, relying entirely on the BIU for data and instruction access up . Since EU and BIU are independent, whenever the EU starts decoding and executing fetched instructions, the BIU actively fetches additional instruction bytes to 1 megabyte keep the queue filled. Only the BIU differs between the 8088 and 8086. As the EU is the same for both, the programming instructions are exactly the same for each. Programs written for the 8086 can be run on the 8088 without any changes. See: [https://www.righto.com/2023/01/the-8086-processors-microcode-pipeline.html The 8086 processor's microcode pipeline from die analysis] [https://www.righto.com/2024/03/8088-prefetch-circuitry.html Intel 8088 processor's instruction prefetch circuitry] [https://www.righto.com/2024/04/intel-8088-bus-state-machine.html Inside the Intel 8088 processor's bus interface state machine] [[File:Block-diagram-of physical memory-8086.jpg]] <br> [[File:8086 die blocks.png|500px]]
== Memory Segmentation ==
To overcome the 16‑bit limitation of its registers while still addressing 1 MB of memory, the 8086 employs a segmented memory model.
In this scheme, the BIU forms memory addresses are formed by shifting a 16‑bit segment register four bits to the left and then adding a 16‑bit offset. This results in a 20‑bit physical address.
Although this model can be seen as complex, it allowed small programs (fitting within a 64‑KB 64KB segment) to be loaded at a fixed offset, simplifying relocation in many cases.
== Register Structure ==See: [https://www.righto.com/2023/07/8086-pins.html Reverse-engineering the 8086 processor's address and data pin circuits]
The 8086 provides 16‑bit general‑purpose registers divided into pairs that can be accessed as separate 8‑bit registers. Its register file includes:== Register File ==
*'''Data Registers{| class="wikitable" style="white-space:''' nowrap;"! Register !! Size !! Description !! Notes|-| AX (accumulatorAccumulator)|| 16-bit || Primary register for arithmetic, BXlogic, CX I/O. || Can be accessed as two 8-bit registers: AH (counterHigh)and AL (Low). Often an implied operand.|-| BX (Base) || 16-bit || General-purpose, often used as a base pointer for memory addressing. || Can be accessed as BH and DX—each accessible BL. Only GP register usable as high an offset in memory addressing (AHe.g., BH`[BX]`).|-| CX (Count) || 16-bit || General-purpose, CH, DHoften used as a loop counter (`LOOP` instruction) and low for string operations (AL`REP` prefixes). || Can be accessed as CH and CL.|-| DX (Data) || 16-bit || General-purpose, BLused for I/O port addressing (`IN`, CL`OUT`), and holds high word in 16x16 multiplication / 32/16 division. || Can be accessed as DH and DL) 8‑bit registers.*'''Pointer and Index Registers:''' |-| SP (Stack Pointer) || 16-bit || Points to the top of the current stack pointer(offset within SS). || Used implicitly by `PUSH`, `POP`, `CALL`, `RET`, interrupts.|-| BP (base pointerBase Pointer), || 16-bit || Points to data within the stack segment (offset within SS). || Often used to access function parameters and local variables on the stack.|-| SI (Source Index) || 16-bit || Used as a source indexpointer offset (usually within DS)for string operations. Can be used as a general-purpose index register. || Default segment is DS, and can be overridden.|-| DI (Destination Index) || 16-bit || Used as a destination indexpointer offset (usually within ES) for string operations. Can be used as a general-purpose index register. || Default segment is ES for addressing and data manipulationstring ops, can be overridden.|-| IP (Instruction Pointer) || 16-bit || Holds the offset address of the next instruction to be executed within the current Code Segment (CS). || Analogous to Program Counter (PC). Cannot be directly manipulated by most instructions (modified by jumps, calls, etc.). Physical address = (CS *16) + IP.|-| FLAGS || 16-bit || Contains status and control flags: <br/> '''Segment RegistersStatus Flags:''' CS <br/> * bit 0 - CF (codeCarry Flag), DS <br/> * bit 2 - PF (dataParity Flag), SS <br/> * bit 4 - AF (stackAuxiliary Carry Flag), and ES <br/> * bit 6 - ZF (extraZero Flag) which define the memory segments for program code, data, and the stack.<br/> *bit 7 - SF (Sign Flag) <br/> * bit 11 - OF (Overflow Flag) <br/> '''Instruction Pointer and Control Flags:''' A 16‑bit instruction pointer <br/> * bit 8 - TF (Trap Flag) <br/> * bit 9 - IF (Interrupt Enable Flag) <br/> * bit 10 - DF (Direction Flag) <br/> (Other bits are undefined/reserved in 8086) || AF used for BCD arithmetic. DF controls string op direction (inc/dec SI/DI). TF enables single-stepping. IF enables maskable interrupts.|-| CS (Code Segment) || 16-bit || Points to the base address of the current code segment. || Used with IPto find the next instruction.|-| DS (Data Segment) and a 16‑bit status register that includes flags || 16-bit || Points to the base address of the current data segment. || Default segment for most data access.|-| SS (such as zero, carry, sign, overflow, Stack Segment) || 16-bit || Points to the base address of the current stack segment. || Used with SP and auxiliary carryBP.|-| ES (Extra Segment) || 16-bit || Points to indicate the outcomes base address of an extra data segment. || Often used as the destination segment for string operations(with DI).|}
=<br> = Instruction Set ==
As a complex instruction set computer (CISC), the 8086 supports a rich array of operations, including multiple addressing modes such as register, immediate, and memory addressing.
The 8086's instruction set was designed with a new concept, the "ModR/M" byte, which usually follows the opcode byte. The ModR/M byte specifies the memory addressing mode and the register (or registers) to use, allowing that information to be moved out of the opcode.
Although most operations execute on 16‑bit operands, the chip allows manipulation of 8‑bit data as well—an important feature for compatibility with legacy 8‑bit software.
See: [https://yassinebridi.github.io/asm-docs/8086_instruction_set.html Complete 8086 instruction set] [https://www.righto.com/2023/08/datapoint-to-8086.html Tracing the roots of the 8086 instruction set to the Datapoint 2200 minicomputer]
{| class="wikitable" style="text-align: center;"
|+ 8086 Instruction Set Summary
! rowspan=2 | Mnemonic !! rowspan=2 | Description !! rowspan=2 | Operation !! colspan=6 | Flags Affected
|-
! OF !! SF !! ZF !! AF !! PF !! CF
|-
| AAA || ASCII Adjust After Addition || Adjust AL after BCD addition || U || U || U || * || U || *
|-
| AAD || ASCII Adjust Before Division || Adjust AX before BCD division || U || * || * || U || * || U
|-
| AAM || ASCII Adjust After Multiply || Adjust AX after BCD multiplication || U || * || * || U || * || U
|-
| AAS || ASCII Adjust After Subtraction || Adjust AL after BCD subtraction || U || U || U || * || U || *
|-
| ADC || Add with Carry || Destination + Source + CF → Destination || * || * || * || * || * || *
|-
| ADD || Add || Destination + Source → Destination || * || * || * || * || * || *
|-
| AND || Logical AND || Destination ∧ Source → Destination || 0 || * || * || U || * || 0
|-
| CALL || Call Procedure || Push IP (and CS); Target → IP (and CS) || – || – || – || – || – || –
|-
| CBW || Convert Byte to Word || Sign extend AL into AH || – || – || – || – || – || –
|-
| CLC || Clear Carry Flag || 0 → CF || – || – || – || – || – || 0
|-
| CLD || Clear Direction Flag || 0 → DF || – || – || – || – || – || –
|-
| CLI || Clear Interrupt Flag || 0 → IF || – || – || – || – || – || –
|-
| CMC || Complement Carry Flag || ¬CF → CF || – || – || – || – || – || *
|-
| CMP || Compare || Destination - Source (Flags set, result discarded) || * || * || * || * || * || *
|-
| CMPSB || Compare String Byte || Compare byte [DS:SI] with [ES:DI]; Update SI, DI || * || * || * || * || * || *
|-
| CMPSW || Compare String Word || Compare word [DS:SI] with [ES:DI]; Update SI, DI || * || * || * || * || * || *
|-
| CWD || Convert Word to Double Word || Sign extend AX into DX:AX || – || – || – || – || – || –
|-
| DAA || Decimal Adjust After Addition || Adjust AL after packed BCD addition || U || * || * || * || * || *
|-
| DAS || Decimal Adjust After Subtraction || Adjust AL after packed BCD subtraction || U || * || * || * || * || *
|-
| DEC || Decrement by 1 || Destination - 1 → Destination || * || * || * || * || * || –
|-
| DIV || Unsigned Divide || AX / Src(Byte) → AL (Q), AH (R) <br> DX:AX / Src(Word) → AX (Q), DX (R) || U || U || U || U || U || U
|-
| ESC || Escape (to coprocessor) || Used for floating-point/coprocessor instructions || – || – || – || – || – || –
|-
| HLT || Halt || Halt processor until interrupt or reset || – || – || – || – || – || –
|-
| IDIV || Signed Divide || AX / Src(Byte) → AL (Q), AH (R) <br> DX:AX / Src(Word) → AX (Q), DX (R) || U || U || U || U || U || U
|-
| IMUL || Signed Multiply || AL * Src(Byte) → AX <br> AX * Src(Word) → DX:AX || * || U || U || U || U || *
|-
| IN || Input from Port || Port → AL or AX || – || – || – || – || – || –
|-
| INC || Increment by 1 || Destination + 1 → Destination || * || * || * || * || * || –
|-
| INT || Interrupt || Push Flags, CS, IP; Vector → CS:IP || Clears TF, IF || – || – || – || – || –
|-
| INTO || Interrupt on Overflow || If OF=1 then INT 4 || Clears TF, IF if trap || – || – || – || – || –
|-
| IRET || Interrupt Return || Pop IP, CS, Flags || * || * || * || * || * || *
|-
| Jcc || Conditional Jump (e.g., JE, JNE, JG...) || If condition is met then IP + disp → IP || – || – || – || – || – || –
|-
| JMP || Unconditional Jump || Target → IP (and possibly CS) || – || – || – || – || – || –
|-
| LAHF || Load AH from Flags || Low byte of Flags → AH || – || – || – || – || – || –
|-
| LDS || Load Pointer using DS || mem → reg; mem+2 → DS || – || – || – || – || – || –
|-
| LEA || Load Effective Address || Effective Address of Source → Destination Register || – || – || – || – || – || –
|-
| LES || Load Pointer using ES || mem → reg; mem+2 → ES || – || – || – || – || – || –
|-
| LOCK || Lock Bus Prefix || Assert LOCK# signal during next instruction || – || – || – || – || – || –
|-
| LODSB || Load String Byte || [DS:SI] → AL; Update SI || – || – || – || – || – || –
|-
| LODSW || Load String Word || [DS:SI] → AX; Update SI || – || – || – || – || – || –
|-
| LOOP || Loop || CX - 1 → CX; If CX ≠ 0 then Jump || – || – || – || – || – || –
|-
| LOOPE / LOOPZ || Loop while Equal / Zero || CX - 1 → CX; If CX ≠ 0 and ZF=1 then Jump || – || – || – || – || – || –
|-
| LOOPNE / LOOPNZ || Loop while Not Equal / Not Zero || CX - 1 → CX; If CX ≠ 0 and ZF=0 then Jump || – || – || – || – || – || –
|-
| MOV || Move || Source → Destination || – || – || – || – || – || –
|-
| MOVSB || Move String Byte || Move byte [DS:SI] to [ES:DI]; Update SI, DI || – || – || – || – || – || –
|-
| MOVSW || Move String Word || Move word [DS:SI] to [ES:DI]; Update SI, DI || – || – || – || – || – || –
|-
| MUL || Unsigned Multiply || AL * Src(Byte) → AX <br> AX * Src(Word) → DX:AX || * || U || U || U || U || *
|-
| NEG || Negate (Two's Complement) || 0 - Destination → Destination || * || * || * || * || * || *
|-
| NOP || No Operation || No operation || – || – || – || – || – || –
|-
| NOT || Logical NOT (One's Complement) || ¬Destination → Destination || – || – || – || – || – || –
|-
| OR || Logical OR || Destination ∨ Source → Destination || 0 || * || * || U || * || 0
|-
| OUT || Output to Port || AL or AX → Port || – || – || – || – || – || –
|-
| POP || Pop Word from Stack || [SS:SP] → Destination; SP + 2 → SP || – || – || – || – || – || –
|-
| POPF || Pop Flags from Stack || [SS:SP] → Flags; SP + 2 → SP || * || * || * || * || * || *
|-
| PUSH || Push Word onto Stack || SP - 2 → SP; Source → [SS:SP] || – || – || – || – || – || –
|-
| PUSHF || Push Flags onto Stack || SP - 2 → SP; Flags → [SS:SP] || – || – || – || – || – || –
|-
| RCL || Rotate Left through Carry || Rotate Destination left, CF fills LSB, MSB fills CF || * || – || – || – || – || *
|-
| RCR || Rotate Right through Carry || Rotate Destination right, CF fills MSB, LSB fills CF || * || – || – || – || – || *
|-
| REP || String Repeat Prefix || Repeat following string op while CX ≠ 0 || – || – || – || – || – || –
|-
| REPE / REPZ || Repeat While Equal / Zero Prefix || Repeat following string op while CX ≠ 0 and ZF=1 || – || – || – || – || – || –
|-
| REPNE / REPNZ || Repeat While Not Equal / Not Zero Prefix || Repeat following string op while CX ≠ 0 and ZF=0 || – || – || – || – || – || –
|-
| RET || Return from Procedure || Pop IP (and CS) from stack || – || – || – || – || – || –
|-
| ROL || Rotate Left || Rotate Destination left, MSB fills LSB and CF || * || – || – || – || – || *
|-
| ROR || Rotate Right || Rotate Destination right, LSB fills MSB and CF || * || – || – || – || – || *
|-
| SAHF || Store AH into Flags || AH → Low byte of Flags || * || * || * || * || * || *
|-
| SAL / SHL || Shift Arithmetic/Logical Left || Shift Destination left, 0 fills LSB, MSB fills CF || * || * || * || U || * || *
|-
| SAR || Shift Arithmetic Right || Shift Destination right, MSB preserved, LSB fills CF || * || * || * || U || * || *
|-
| SBB || Subtract with Borrow || Destination - Source - CF → Destination || * || * || * || * || * || *
|-
| SCASB || Scan String Byte || Compare AL with byte [ES:DI]; Update DI || * || * || * || * || * || *
|-
| SCASW || Scan String Word || Compare AX with word [ES:DI]; Update DI || * || * || * || * || * || *
|-
| SHR || Shift Logical Right || Shift Destination right, 0 fills MSB, LSB fills CF || * || 0 || * || U || * || *
|-
| STC || Set Carry Flag || 1 → CF || – || – || – || – || – || 1
|-
| STD || Set Direction Flag || 1 → DF || – || – || – || – || – || –
|-
| STI || Set Interrupt Flag || 1 → IF || – || – || – || – || – || –
|-
| STOSB || Store String Byte || AL → [ES:DI]; Update DI || – || – || – || – || – || –
|-
| STOSW || Store String Word || AX → [ES:DI]; Update DI || – || – || – || – || – || –
|-
| SUB || Subtract || Destination - Source → Destination || * || * || * || * || * || *
|-
| TEST || Logical Compare (AND) || Destination ∧ Source (Flags set, result discarded) || 0 || * || * || U || * || 0
|-
| WAIT || Wait || Wait for TEST# pin active (for coprocessor sync) || – || – || – || – || – || –
|-
| XCHG || Exchange || Source ↔ Destination || – || – || – || – || – || –
|-
| XLAT / XLATB || Translate Byte || AL → [DS:BX + AL] || – || – || – || – || – || –
|-
| XOR || Logical Exclusive OR || Destination ⊕ Source → Destination || 0 || * || * || U || * || 0
|}
Note: Some instructions like LOOPE and LOOPZ are mnemonics for the same opcode. They are provided to match different programming contexts: LOOPE when thinking in terms of equality (e.g., a comparison was equal), LOOPZ when thinking in terms of zero (e.g., result was zero).
== Secret Instruction ==
The secret instruction is SALC (Set AL register to Carry). Its opcode is 0xD6. This instruction sets the AL register to 0 if the carry flag is 0, and sets the AL register to FF if the carry flag is 1.
Intel put this in all its x86 processors but didn't document it, using it as a trap. If a manufacturer cloned an Intel processor, the presence of the SALC instruction would prove that the clone stole Intel's microcode.
Intel sued NEC for making 8086 clones, claiming that NEC ripped off Intel's microcode. NEC claimed they wrote their own microcode. NEC's chip didn't have the secret SALC instruction and Intel lost the case.
See: [https://www.righto.com/2023/07/undocumented-8086-instructions.html Undocumented 8086 instructions, explained by the microcode]
<br>
= 8087 Floating Point Unit =
Intel introduced the 8087 chip in 1980 to improve floating-point performance on 8086/8088 computers.
Since early microprocessors were designed to operate on integers, arithmetic on floating point numbers was slow, and transcendental operations such as trig or logarithms were even worse. But the 8087 co-processor greatly improved floating point speed, up to 100 times faster.
The benefits of floating point hardware are so great that Intel started integrating the floating-point unit into the processor with the 80486DX in 1989.
See: [https://www.righto.com/2018/08/inside-die-of-intels-8087-coprocessor.html Inside the die] [https://www.righto.com/2018/09/two-bits-per-transistor-high-density.html High-density ROM] [https://www.righto.com/2020/05/extracting-rom-constants-from-8087-math.html Extracting ROM constants] [https://www.righto.com/2020/05/die-analysis-of-8087-math-coprocessors.html Fast bit shifter] 8087 FPU reverse engineered
<br>
==Links==
*{{EnWiki}}
*[https://www.computerhistory.org/collections/catalog/102702019 Intel 386 oral history panel]
*[https://www.chibialiens.com/8086/ Learn Assembly Programming with ChibiAliens] Multi-platform 8086 tutorial
*[https://userpages.umbc.edu/~squire/intel_book.pdf Intel Microprocessors Practical Reference]
*[https://archive.org/details/8086-pg 8086 Programmer's Pocket Reference Guide]
*[https://www.retroparla.com/wp-content/uploads/2024/03/8086.pdf Micro Chart 8086 CPU reference card]
*[https://wwwslideshare.reenigne.orgnet/blogslideshow/8086-microcode-disassembledpindiagramdetailsof8086microprocessor/ 266134566 Pin diagram of 8086 microcode disassembled]*[https://github.com/SingleStepTests Tom Harte's SingleStepTests]*[https://github.com/reenigne/reenigne/blob/master/8088/acid88/acid88.txt Acid88] A testsuite for cycle-exact 8088 PC/XT emulators
<br>