CPU

This post describes the CPU.

The CPU consists of Register and ALU (Arithmetic and Logic UNIT), Decoder UNIT, and Fetch UNIT.

Registers consist of the General Register, Stack Register, Flag Register, Instruction Register, Program Counter, Base Register, and Index Register.

  • General Register is a register that can be used for general purposes.
  • Stack Register is a register that stores the top address of the stack pointer.
  • Flag Register is a register that stores whether the result of an operation performed by the ALU is a positive or negative value, or whether an overflow or underflow has occurred.
  • Instruction Register is a register that stores instruction codes when instruction codes are fetched.
  • Program Counter is a register that stores the address value where the instruction code to be executed next is stored.
  • Base Register is a register that stores the top address of the storage area to be accessed.
  • Index Register is a register that stores the address relative to the address of the storage area to be accessed with respect to the base register.

The ALU consists of arithmetic circuits such as adders and logic operators, and performs the basic four arithmetic operations: addition, subtraction, multiplication, and division, as well as logical operations such as OR (logical OR), AND (logical AND), and NOR (exclusive OR).

The Decoder UNIT decodes instruction codes read from memory and controls registers, ALUs, and memory.

The Fetch UNIT recalls instruction codes from addresses stored in the Program Counter and stores (fetches) them in the Instruction Register.

The CPU execution cycle repeats Fetch, Decode, and Execute.

Fetch reads an instruction code from the memory address of the instruction code stored in the Program counter and stores the read instruction code in the Instruction Register. The Program counter increments to the next instruction code address.

Decoding decodes the instruction code stored in the Instruction Register, calculates the execution address of the data targeted by the instruction code, and stores the data from the execution address in the General Register.

Executing an instruction executes the instruction code. For example, if the instruction code is a calculation, the value of General Register saved by decoding is operated on by the ALU, and the result is saved in the General Register.

OSS-ECAL English
error: Content is protected !!