Microprocessor fundamentals

CPU

The CPU controls and performs instructions. The CPU has a fetch-decode-execute cycle which continuously performs instructions.

The CPU consists of many components and registers.

  • Arithmetic logic unit - Performs mathematical and logical operations.

  • Control unit - Decodes instructions and handles execution.

  • Instruction register - Holds the most recent instruction

  • Memory address register - Holds the address of memory for reading or writing.

  • Memory data register - Holds the data retrieved from or to be written to memory.

Fetch-decode-execute cycle

  1. Fetch - Copy address of next instruction from PC to MAR. The PC is incremented. Get the data at the location in the MAR and copy it into the MDR, then copy that to the IR.

  2. Decode - The instruction in the IR is split into it's opcode and operand by the CU.

  3. Execute - The CU sends the necessary signals to execute the instruction.

The instruction is then decoded into the opcode and operand, after which the CU sends the necessary signals to execute it.

Register transfer language

Register transfer language (RTL) is used to describe register operations. For example [IR] $\leftarrow$ [MDR] means the contents of the MDR are copied to the IR. [MS(...)] refers to the contents of main store at the address specified.

The fetch-decode execute cycle can be represented using RTL.

  1. $[\text{MAR}] \leftarrow [\text{PC}]$

  2. $[\text{PC}] \leftarrow [\text{PC}] + 1$

  3. $[\text{MDR}] \leftarrow [\text{MS}([\text{MAR}])]$

  4. $[\text{IR}] \leftarrow [\text{MDR}]$

  5. $\text{CU} \leftarrow [\text{IR}]$

Assembly language

Assembly language is one level above machine code. It uses mnemonics which map closely to machine code instructions. Assembly code is converted into machine code by an assembler.

Assembly language has a variety of instructions including those for moving data, arithmetic, logic, branching and subroutines.

Addressing modes

Addressing modes are different ways of telling the processor where to find data. Addresses can be absolute, indirect or relative or may be a literal value.