The "R" registers
The "R" registers are a set of eight registers that are named R0, R1, etc. up to and including R7.
These registers are used as auxillary registers in many operations. To continue with the above example, perhaps there is need to add 10 and 20. The original number 10 may be stored in the Accumulator whereas the value 20 may be stored in, say, register R4. To process the addition there is necessity to execute the command: ADD A, R4
After executing this instruction the Accumulator will contain the value 30.
There is need to think of the "R" registers as very important auxillary, or "helper", registers. The Accumulator alone would not be very useful if it were not for these "R" registers. The "R" registers are also used to temporarily store values. For example, lets say there is need to add the values in R1 and R2 together and then subtract the values of R3 and R4. One way to do this would be:
MOV A, R3 ; Move the value of R3 into the accumulator
ADD A, R4 ; Add the value of R4
MOV R5, A ; Store the resulting value temporarily in R5
MOV A, R1 ; Move the value of R1 into the accumulator
ADD A, R2 ; Add the value of R2
SUBB A, R5 ; Subtract the value of R5 (which now contains R3 + R4)
Comments
Post a Comment