Chapter 1: The Intel 8080 Instruction Set

An instruction in machine code performs a single operation from the computer’s instruction set architecture. Each instruction is built into the hardware of the computer using digital circuits.

We could spend a lot of time studying how these digital circuits work. We won’t. Deciding whether to do that or not presents a fork in the road in the journey to demystify computers between computer engineering and computer science. Our focus here will be on computer science. So to just give you a taste of how digital circuits work, we will take a look at just two of them, an adder circuit and an SRAM flip-flop

For any of you who want to dive deeper into the world of diginal circuits, using them to build a computer, we recommend taking a look at From Nand to Tetris.

Abstract View of Our Computer

As we stated last chapter in The Altair 8800, our computer is a comprised of a combination of a central processing unit a clock, memory, data and address buses, and input / output devices.

In 1974 Ed Roberts integrated the Intel 8080 CPU with what later became known as the S-100 bus, and a front panel consisting of switches and lights to produce the Altair. Here is a simple block diagram showing these components:

Altair 8800 diagram

Since we will begin programming this machine in machine code, we will controlling this hardware directly, so we need to understand how it works.

The four basic operations of all computers are in this diagram, with input by way of switches, and output by way of lights on the front panel, processing by way of the CPU, and two kinds of memory, the random-access memory available through memory boards, and the process registers that are part of the Intel 8080 CPU.

The RAM came in varying amounts through expansion boards ranging from the 256 bytes that came with the base kit up to the maximum of 64 KB addressible by the 16 bit address space.

Registers

A register is a storage location directly accessible to the computer’s processor. Registers are built-in to the CPU, and the computer’s instruction set architecture is designed around them. For this reason we will need to get to know the registers on the 8080 very well if we want to understand how its instructions operator.

8-Bit General Purpose Registers and Accumulator

The following eight registers (with one being a “pseudo-register” which we will discuss more shortly) are named with a 3-bit identifier.

B

000

General-purpose / Scratchpad register

C

001

General-purpose / Scratchpad register

D

010

General-purpose / Scratchpad register

E

011

General-purpose / Scratchpad register

H

100

High-order byte of HL address pair

L

101

Low-order byte of HL address pair

M

110

Pseudo-Register pointed to by the HL pair

A

111

Accumulator (primary register for arithmetic/logic)

16-Bit Register Pairs

BC

00

Register pair B (B holds high byte, C low byte)

DE

01

Register pair D (D holds high byte, E low byte)

HL

10

Memory pointer / accumulator pair (H high, L low)

SP

11

Stack pointer (PSW for PUSH/POP)

The program status word (PSW) is a 16-bit word that combines the 8-bit flag register with the 8-bit accumulator.

Special Purpose Registers

Program Counter (PC)

16-bit register holding the address of the next instruction to fetch.

Stack Pointer (SP)

16-bit register pointing to the active stack location in external memory.

Flag Register (PSW/F)

8-bit register containing condition flags

The flag register contains special bits (flags) for sign (S), zero (Z), auxiliary carry (A), parity (P), and carry (C).

The pseudo-register M is a memory byte (8-bits) whose address is contained in the HL register pair that can be used in place of a real register for many operations.

The Accumulator

The accumulator is the register that stores the output of arithmetic and logic computations performed by the ALU. When we want to use the 8080’s adder circuit for example, we need to put one of the addends in the accumulator, and the other in another register, and the use the instruction that adds these two registers and stores the result in the accumulator.

Glossary

instruction

The smallest single operation that the computer can be directed to execute.

Exercises