Inside the CPU
The CPU contains an arithmetic-logic unit (ALU), where arithmetic functions are carried out, a control unit, which sends control signals to the memory and peripherals, the system clock, which keeps the various components in correct time with each other, and several registers, which are special memory locations that each have a specific purpose.
Registers
The registers inside a typical processor are:
- Accumulator, also called general purpose register: The accumulator is a temporary storage space for arithmetic operations. Without it, the result of every operation would have to be written to main memory, and then read back into the ALU, which is very slow. For example, to add up a list of numbers, they are loaded one by one from main memory and added into the accumulator. The final answer is then copied back to main memory.
- Current instruction register: The current instruction register stores the instruction that is currently being executed.
- Memory address register: The memory address register stores the address of data or instructions that are to be accessed from main memory.
- Memory data register: The memory data register stores data that have been read from, or is about to be written to, the main memory.
- Program counter, also called sequence control register: The program counter stores the address of the next instruction to be fetched from main memory.
- Status register: The status register contains flag bits that are set or cleared depending on the result of the last instruction. The overflow bit is an example of a status flag in the status register.
The Fetch-Execute Cycle
When the processor fetches and executes an instruction, it makes use of the registers. The steps that the CPU follows for the assembly language instruction LDA A3 (Load the number at address A3 into the accumulator) are:
- First, the program counter is read for the address of the next instruction to be executed.
- The contents of the program counter are copied to the memory address register.
- The required address in main memory is found, and the contents of that are copied to the memory data register.
- The program counter is incremented by one, since the old value has already been fetched.
- The contents of the memory data register are copied to the current instruction register.
- The instruction in the current instruction register is decoded. The instruction is "load the contents of memory location A3 into the accumulator".
- A3 is copied into the memory address register, and the correct memory location is found. The contents of A3 are copied to the memory data register, and then into the accumulator. The instruction has been executed.
- The program counter is read for the next instruction to be executed …
This process may seem very slow and cumbersome, but a modern computer can do this cycle millions of times per second.
Source: Machine Level Structure, retrieved 2013-08-08. Licensed under the Creative Commons Attribution/Share-Alike Licence.
touque.ca > Education Commons > IB > Topics > 2
[This page last updated 2020-12-23 at 13h10 Toronto local time.]
© 2007–2025 Hersch, Bear & Company Limited. All rights reserved. “Grammar Authority,” “grammarauthority.com,” “touque.ca,” and “Canada’s Thinking Cap” are trademarks of Hersch, Bear & Company Limited. All other trademarks and copyrights are the property of their respective owners.
Privacy Policy | Licence to Copy | How to cite | Contact us