The microprocessor is typically referred to as the central processing unit (CPU). It is the part of the processor system which processes the data, fetching instructions from memory, decoding them and executing them. The internal structure (architecture) โ depends on the microprocessor concerned.
The figure below illustrates a general architecture of a microprocessor:
The following are the functions of the basic parts of a microprocessor:
Arithmetic and Logic Unit (ALU)
The arithmetic and logic unit is responsible for performing the data manipulation.
Control unit
The control unit establishes the timing and sequence of operations. It generates the timing signals used to fetch a program instruction from memory and execute it. A typical microprocessor uses a clock with a maximum frequency of 1 MHz, that is, a clock period of 1 ฮผs, and instructions require between two and twelve clock cycles. Operations involving the microprocessor are counted in terms of cycles they take.
Registers
The internal data that the CPU is currently using is temporarily held in a group of registers while instructions are being executed. These are memory locations within the microprocessor and are used to store information involved in program execution.
Generally, a microprocessor contains a group of registers, each type of register having a different function.
There are a number of types of registers, their number, size and types varying from one microprocessor to another. The common types of registers include:
Accumulator Register
The accumulator register (A) is where data for an input to the arithmetic and logic unit is temporarily stored. In order for the CPU to be able to access, that is, read instructions or data in the memory, the accumulator register has to supply the address of the required memory word using the address bus. When this is done, the required instructions or data can be read into the CPU using the data bus. As only one memory location can be addressed at once, temporary storage has to be used when, for instance, when numbers are combined. A good example, is the addition of two numbers, one of the numbers is fetched from one address and placed in the accumulator register, while the CPU fetches the other number from the other memory address. Then the two numbers can be processed by the ALU section of the CPU. The result is then transferred back into the accumulator register. Therefore, the accumulator is a temporary holding register for data to be operated on by the arithmetic and logic unit, and after the operation, the register for holding the results. Thus, it is involved in all data transfers associated with the execution of arithmetic and logic operations.
Program Counter Register (PC) or Instruction Pointer (IP)
This is the register used to allow the CPU to keep track of its position in a program. This register contains the address of the memory location that contains the next program instruction. As each instruction is executed, the program counter register is updated so that it contains the address of the memory location where the next instruction to be executed is stored. The program counter is incremented each time so that the CPU executes instructions sequentially unless an instruction, such as JUMP or BRANCH, changes the program counter out of that sequence.
Memory Address Register (MAR)
This register contains the address of data. For example in summing of two numbers, the memory address register is loaded with the address of the first number. The data at the address is then moved to the accumulator. The memory address of the second number is then loaded into the memory address register. The data at that address is then added to the data in the accumulator. The result is then stored in a memory location addressed by the memory address register.
Instruction Register (IR)
This register stores an instruction. After fetching an instruction from the memory via the data bus, the CPU stores it in the instruction register. After each such fetch, the microprocessor increments the program counter by 1 with the result that the program counter points to the next instruction waiting to be fetched. The instruction can then be decoded and used to execute an operation. This sequence is referred to as the fetch-execute cycle.
Status Register/Flag Register/Condition Code Register
This contains information about the result of the latest process carried out in the arithmetic and logic unit. It contains individual bits with each bit having special significance. The bits are referred to as flags. The status of the latest operation is indicated by each flag with each flag being set or reset to indicate a specific status. For instance, they can be used to indicate whether the last operation resulted in a negative result, a zero result, a carry output occurs (e.g. the sum of two binary numbers like 1010 and 1100 is (1)0010, which might be larger than the microprocessorโs word size and hence there is a carry of a 1), an overflow occurs or the program is to be allowed to be interrupted to allow an external event to occur.
Common flags used include:
Flag | Set, i.e. 1 | Reset, i.e. 0 |
Z | Result is zero | Result is not zero |
N | Result is negative | Result is not negative |
C | Carry is generated | Carry is not generated |
V | Overflow occurs | Overflow does not occur |
I | Interrupt is ignored | Interrupt is processed normally |
As an example, let us consider the state of Z, N, C and V flags for the operation of adding the hexadecimal numbers 02 and 06. The result is 08. Since it is not zero, then Z is 0. The result positive, therefore N is 0. There is no carry, so C is 0. The unsigned result is within the range -128 to +128 and so V is 0. On the other hand, consider the flags when the hexadecimal numbers added are F9 and 08. The result is (1)01. The result is not zero, so Z is 0. Since it is positive, the N is 0. The unsigned result has a carry and so C is 1. The unsigned result is within the range -128 to +128 and so V is 0.
Stack Pointer or Register (SP)
The contents of this register form an address which defines the top of the stack in RAM. The stack is a special area of the memory in which program counter values can be stored when a subroutine part of a program is being utilized.
General Purpose Registers
These may serve as temporary storage for data or addresses and can be used in operations involving transfers between other registers.
You may also read:
- CPU Registers
- Basic Features of a Microprocessor-Based System
- How Special Function Registers (SFRs) are Mapped into Memory Space
- How Microprocessors differs from Microcontrollers
Leave a Reply