Machine cycles
In the Intel 8085 microprocessor, a machine cycle is a sequence of events required to perform a basic operation such as a memory read, a memory write, an input/output read or an input/output write. The 8085 has several types of machine cycles, and each machine cycle consists of one or more clock cycles (T-states). The main machine cycles of the 8085 are described in detail below:
Opcode fetch cycle
Purpose: this is the first machine cycle of every instruction. Its main purpose is to fetch the opcode (the part of the instruction that determines the operation to be performed) from the memory location pointed to by the program counter (PC).
Steps and T-states:
T1 state:
The 16-bit address of the memory location (from the PC) is placed on the address bus.
The lower 8 bits of the address (A₀ - A₇) are multiplexed with the data bus on pins AD₀ - AD₇, while the upper 8 bits (A₈ - A₁₅) are available on pins A₈ - A₁₅.
The Address Latch Enable (ALE) signal goes high. This high ALE signal is used to latch the lower 8 bits of the address into an external latch (usually a 74LS373).
T2 state:
ALE goes low and the memory read control signal RD is activated.
This signals the memory to place the opcode on the data bus (AD₀ - AD₇).
T3 state:
The opcode is read from the data bus into the instruction register (IR) of the microprocessor.
T4 state:
The opcode is decoded by the microprocessor control unit to determine the instruction type and the operations to be performed.
Memory read cycle
Purpose: this machine cycle is used to read data from a memory location. It may be part of an instruction that requires data from memory, for example the LDA (Load Accumulator) instruction.
Steps and T-states:
T1 state:
The 16-bit memory address is placed on the address bus.
As in the opcode fetch, the lower 8 bits are multiplexed with the data bus, and ALE goes high to latch the lower 8 bits.
T2 state:
ALE goes low and the RD signal is activated.
This tells the memory to place the data at the specified address onto the data bus.
T3 state:
The data is read from the data bus into the appropriate register (for example, into the accumulator in the case of LDA).
Memory write machine cycle
Purpose: used to write data to a memory location. Instructions such as STA (Store Accumulator) use this machine cycle.
Steps and T-states:
T1 state:
The 16-bit memory address is placed on the address bus, and ALE goes high to latch the lower 8 bits.
T2 state:
ALE goes low and the data to be written (for example, the contents of the accumulator) is placed on the data bus.
The write control signal WR is activated, telling the memory to accept the data from the data bus and store it at the specified address.
T3 state:
The data is written to the memory location.
Input/output read machine cycle
Purpose: this machine cycle is used to read data from an input/output device. The IN instruction uses this cycle.
Steps and T-states:
T1 state:
The 8-bit I/O port address is placed on the lower 8 bits of the address bus (AD₀ - AD₇), and ALE goes high to latch it.
The IO/M (input/output memory select) signal goes high, indicating that an input/output operation is being performed.
T2 state:
The ALE signal goes low and the RD signal is activated.
This signals the input/output device to place the data on the data bus.
T3 state:
The data is read from the data bus into the accumulator.
Input/output write cycle
Purpose: used to write data to an input/output device. This cycle is used by the OUT instruction.
Steps and T-states:
T1 state:
The 8-bit I/O port address is placed on the lower 8 bits of the address bus (AD₀ - AD₇), and ALE goes high to latch it.
The IO/M signal goes high, indicating an input/output operation.
T2 state:
ALE goes low and the data to be written (usually from the accumulator) is placed on the data bus.
The WR signal is activated, telling the input/output device to accept the data.
T3 state:
The data is written to the input/output device.