5. Current Instruction and PSW
Current Instruction Register (CIR)
This holds the current instruction to be executed, having been fetched from memory.
It is the 'Instruction Register' in the picture above. As was mentioned earlier, there is no standardised name for these registers and manufacturers have come up with their own. But no matter what they are called within a specific CPU, they share the same purpose.
Program Status Word (PSW)
A commonly used computing term is 'flag'. This denotes a single binary bit within a register. They are often used to indicate a true or false condition.
The PSW has a number of duties all rolled into one.
- It holds the status of the last calculation by the Arithmetic Logic Unit in terms of did it become zero? Was a carry bit generated? What is the sign of the result? and so on.
- It helps control the flow of the program. For example the code might be checking out an IF instruction on whether to run the next bit of code. The PSW will hold a flag to indicate if the IF statement is true or not.
- It stores error flags. For example a calculation such as an unintended divide by zero will cause an overflow flag to be set.
On the Intel Pentium chip this the 'EFLAGS' register and the picture below show part of it. Each bit within the register has a purpose and below are shown three of those flags.
When a calculation has just been carried out, the sign, zero and carry flags are suitably set by the CPU. The programmer can then write code to check on these flags.
Challenge see if you can find out one extra fact on this topic that we haven't already told you
Click on this link: writing good programming code
Copyright © www.teach-ict.com