Programming model The Intel 8080 is the successor to the
8008. It uses the same basic
instruction set and
register model as the 8008, although it is neither
source code compatible nor
binary code compatible with its predecessor. Every instruction in the 8008 has an equivalent instruction in the 8080. The 8080 also adds 16-bit operations in its instruction set. Whereas the 8008 required the use of the HL register pair to indirectly access its 14-bit memory space, the 8080 has addressing modes to directly access its full 16-bit memory space. The internal 7-level push-down
call stack of the 8008 was replaced by a dedicated 16-bit stack-pointer (SP) register. The 8080's 40-pin
DIP packaging provides a 16-bit
address bus and an 8-bit
data bus that more efficiently access 64
KiB (216 bytes) of memory.
Registers The processor has seven 8-bit
registers (A, B, C, D, E, H, and L), where A is the primary 8-bit accumulator. The other six registers can be used as either individual 8-bit registers or in three 16-bit register pairs (BC, DE, and HL, referred to as B, D and H in Intel documents) depending on the particular instruction. Some instructions can also use the HL register pair as a (limited) 16-bit accumulator. A pseudo-register M, which refers to the dereferenced memory location pointed to by HL, can be used almost anywhere other registers can be used. The 8080 has a 16-bit
stack pointer to memory, replacing the 8008's internal
stack, and a 16-bit
program counter.
Flags The processor maintains internal
flag bits (a
status register), which indicate the results of arithmetic and logical instructions. Only certain instructions affect the flags. The flags are: •
Sign (S), set if the result is negative. •
Zero (Z), set if the result is zero. •
Parity (P), set if the number of 1 bits in the result is even. •
Carry (C), set if the last addition operation resulted in a carry or if the last subtraction operation required a borrow. •
Auxiliary carry (AC or H), used for
binary-coded decimal arithmetic (BCD). The carry bit can be set or complemented by specific instructions. Conditional-branch instructions test the various flag status bits. The accumulator and the flags together are called the PSW, or program status word. PSW can be pushed to or popped from the stack.
Commands, instructions As with many other 8-bit processors, all instructions are encoded in one byte (including register numbers, but excluding immediate data), for simplicity. Some can be followed by one or two bytes of data, which can be an immediate operand, a memory address, or a port number. Like more advanced processors, it has automatic CALL and RET instructions for multi-level procedure calls and returns (which can even be conditionally executed, like jumps) and instructions to save and restore any 16-bit register pair on the machine stack. Eight one-byte call instructions () for subroutines exist at the fixed addresses 00h, 08h, 10h, ..., 38h. These are intended to be supplied by external hardware in order to invoke a corresponding
interrupt service routine, but are also often employed as fast
system calls. The slowest instruction is , which exchanges the register pair HL with the last item pushed on the stack.
8-bit instructions All 8-bit ALU operations with two operands can only be performed on the 8-bit
accumulator (the A register). The other operand can be either an immediate value, another 8-bit register, or a memory byte addressed by the 16-bit register pair HL. Increments and decrements can be performed on any 8 bit register or an HL-addressed memory byte. Direct copying is supported between any two 8-bit registers and between any 8-bit register and an HL-addressed memory byte. Due to the regular encoding of the instruction (using a quarter of available opcode space), there are redundant codes to copy a register into itself (, for instance), which are of little use, except for delays. The systematic opcode for is instead used to encode the halt (HLT (x86 instruction)|) instruction, halting execution until an external reset or interrupt occurs.
16-bit operations Although the 8080 is generally an 8-bit processor, it has limited abilities to perform 16-bit operations. Any of the three 16-bit register pairs (BC, DE, or HL, referred to as B, D, H in Intel documents) or SP can be loaded with an immediate 16-bit value (using ), incremented or decremented (using and ), or added to HL (using ). By adding HL to itself, it is possible to achieve the same result as a 16-bit arithmetical left shift with one instruction. The only 16-bit instructions that affect any flag is , which sets the CY (carry) flag in order to allow for programmed 24-bit or 32-bit
arithmetic (or larger), needed to implement
floating-point arithmetic. BC, DE, HL, or PSW can be copied to and from the stack using and . A stack frame can be allocated using and . A branch to a computed pointer can be executed with . loads HL from directly addressed memory and stores HL likewise. The instruction exchanges the values of the HL and DE register pairs. exchanges last item pushed on stack with HL. None of these 16-bit operations were supported on the earlier Intel 8008.
Instruction set Input/output scheme Input output port space The 8080 supports 256
input/output (I/O) ports, accessed via dedicated I/O instructions taking port addresses as operands. Generating the control signals for selecting between RAM and I/O is usually aided by a support chip (8212 or 8228). This I/O mapping scheme is regarded as an advantage, as it frees up the processor's limited address space. Many CPU architectures instead use so-called
memory-mapped I/O (MMIO), in which a common address space is used for both RAM and peripheral chips. This removes the need for dedicated I/O instructions, although a drawback in such designs may be that special hardware must be used to insert wait states, as peripherals are often slower than memory. In some simple 8080 computers, however, I/O is indeed addressed as if they were memory cells, "memory-mapped", leaving the I/O commands unused. I/O addressing can also sometimes employ the fact that the processor outputs the same 8-bit port address to both the lower and the higher address byte (i.e., would put the address 0505h on the 16-bit address bus). Similar I/O-port schemes are used in the backward-compatible Zilog Z80 and Intel 8085, and the closely related x86 microprocessor families.
Separate stack space One of the bits in the processor state word (see below) indicates that the processor is accessing data from the stack. Using this signal, it is possible to implement a separate stack memory space. This feature is seldom used.
Status word For more advanced systems, during the beginning of each machine cycle, the processor places an eight bit status word on the data bus. This byte contains flags that determine whether the memory or I/O port is accessed and whether it is necessary to handle an interrupt. The interrupt system state (enabled or disabled) is also output on a separate pin. For simple systems, where the interrupts are not used, it is possible to find cases where this pin is used as an additional single-bit output port (the popular
Radio-86RK computer made in the
Soviet Union, for instance).
Interrupts Hardware
interrupts are initiated by asserting the interrupt request (INT) pin. At the next opcode fetch cycle (M1), the interrupt will be acknowledged with the INTA state code. At this time, an instruction is "jammed" (Intel's word) by external hardware on the data bus. This can be a one-byte RST instruction, or if using an
Intel 8259, a CALL instruction. Interrupts may be enabled and disabled with EI and DI instructions, respectively. Interrupts are disabled after an INTA; they must be re-enabled explicitly by the
interrupt service routine. The 8080 does not support
non-maskable interrupts.
Example code The following 8080/8085
assembler source code is for a subroutine named that copies a block of data bytes of a given size from one location to another. The data block is copied one byte at a time, and the data movement and looping logic utilizes 16-bit operations.
Pin use The address bus has its own 16 pins, and the data bus has 8 pins that are usable without any multiplexing. Using the two additional pins (read and write signals), it is possible to assemble simple microprocessor devices very easily. Only the separate IO space, interrupts, and DMA need added chips to decode the processor pin signals. Nonetheless, the pin load capacity is limited; even simple computers often require bus amplifiers. The processor needs three power sources (−5, +5, and +12 V) and two non-overlapping high-amplitude synchronizing signals. Nonetheless, at least the late Soviet version КР580ВМ80А was able to work with a single +5 V power source, the +12 V pin being connected to +5 V and the −5 V pin to ground. The pin-out table, from the chip's accompanying documentation, describes the pins as follows: == Support chips ==