We now examine in detail how the basic pipeline CPU execute instructions with constants as second operand.
Dest Reg OpCode I Src Reg1 Src Reg2
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
| 0 | 0 | 0 | 0 | 1 | 0 | 0 | 0 | 0 | 1 | 0 | 1 | 0 | 0 | 1 | 1 |
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+
= 8 83 (decimal value of each byte)
The ID stage also extracts the constant (=3) stored inside the instruction "add r1,r2,#3"
![]() |
Incidently, the B register is updated with R3 because the ID stage does not know which operand will be used.... You will see in the next step that there is no harm in fetching R3 into B.
And ofcourse, D register is updated with R1 (but R1 will not also be used in this instruction).
It uses the ALU opcode (00 = ADD) to select the addition operation of the input values (R2 + 3)
![]() |
Also, SMDR register will be updated with the value R1 (but this value will not be used by the instruction - see next step).
So you can see now that fetching R3 into the B register was harmless - the MUX will use the constant (=3) in IR1 to execute the instruction.
|
Executes the following instructions:
10 65 // mov r1, #65 R1 = 00000000 01000001 18 4 // mov r2, #4 R2 = 00000000 00000100 26 24 // mov r3, #24 R3 = 00000000 00011000 34 2 // mov r4, #2 R4 = 00000000 00000010 42 8 // mov r5, #8 R5 = 00000000 00001000 58 3 // mov r7, #3 R7 = 00000000 00000011 0 0 // nop 0 0 // nop 0 0 // nop 0 0 // nop 0 0 // nop 8 83 // add r1,r2,#3 (R1=R2+3) R1 := 00000000 00000111 |