3. Special purpose registers (1)

We have discussed general purpose registers as being discrete memory locations within the CPU used to hold temporary data and instructions. However there are also special purpose registers.

A special purpose register is one that has a specific control or data handling task to carry out. There are a number of special purpose registers within the CPU.CPU contains a set of registers

The diagram above shows that the CPU contains a number of registers in order to process data and to follow program instructions.

Some specialist ones include

Accumulator

This is one of the general purpose registers but it is specifically used to 'accumulate' the result of the currently running instructions.

For example, a small piece of code needs to fetch a value from main memory and then add 3 to it and finally store the result back into memory. The accumulator will be used

LDA 3001 This instruction will load the data at address 3001 into the accumulator
ADC #3 This instruction adds 3 to the content of the accumulator
STA 3001 This instruction stores the content of the accumulator into main memory at location 3001

As shown above the role of the accumulator is to store intermediate results of the current data processing being undertaken. The final results are then either stored in another general purpose register or memory location.

Program Counter

This holds the memory address of the next instruction.

For example if the program counter has the address 305 then the next instruction will be at location 305 in main memory (RAM). When a program is running, the program counter will often just be incrementing as it addresses one instruction after the other, e.g. 305, 306, 307.

However, the instructions will often modify the next address, for example, 305 becomes 39. What has happened is called a 'jump instruction'.

A jump instruction is one that causes the sequential flow of the program to jump to another part of the program. Jumps can be conditional (e.g. Jump if zero) or unconditional (e.g. JMP).

This is how the software programmer will cause different parts of his code to run depending on some condition e.g. a conditional IF statement. It is also how an interrupt routine is serviced. The program counter will be loaded with the starting address of the interrupt routine.

 

Challenge see if you can find out one extra fact on this topic that we haven't already told you

Click on this link: Program Counter

 

Instruction Register

This holds the current instruction to be executed, having been fetched from memory.

Challenge see if you can find out one extra fact on this topic that we haven't already told you

Click on this link: CPU instruction register

 

Copyright © www.teach-ict.com