# | Instruction | Accumulator | Mem 5 |
# | Instruction | Accumulator | N | P |
GO INP
SUB VAL
JZR BYE
JMP GO
BYE STP
VAL DAT 21
Of course, the SSCPU instruction set does not have an operation for multiply. So you will need to rely on repeated use of the ADD instruction. This might be done with or without a loop.
You may assume the program is reloaded, reinitializing all of memory, every time it is run.
part 7) Many machinecodes do have a store immediate, but in this
CPU there would have to be a special operand format where the 12 bits for
the operand contains both the memory address and the immediate data.
Since 4 bits are needed for the memory address, that would leave only 8
bits for immediate data. The effect of immediate storing can be obtained
from a sequence of two instructions, one loading the immediate value, and
the second storing in to the desired memory address.
# | Instruction | Accumulator | Mem 5 |
0 | LDI 7 | 7 | 0 |
1 | STO 5 | 7 | 7 |
2 | LDI 3 | 3 | 7 |
3 | ADD 5 | 10 | 7 |
4 | STP | 10 | 7 |
#
0 1 2 3 4 5 6 7 8 9 10 11 4 5 6 7 8 9 10 11 4 12 |
Instruction
LDI 3 STO 15 INP 0 STO 14 JZR 12 LOD 15 ADD 15 STO 15 LOD 14 SUB 13 STO 14 JMP 4 JZR 12 LOD 15 ADD 15 STO 15 LOD 14 SUB 13 STO 14 JMP 4 JZR 12 STP 0 |
Accumulator
3 3 2 2 2 3 6 6 2 1 1 1 1 6 12 12 1 0 0 0 0 0 |
N
0 0 0 2 2 2 2 2 2 2 1 1 1 1 1 1 1 1 0 0 0 0 |
P
0 3 3 3 3 3 3 6 6 6 6 6 6 6 6 12 12 12 12 12 12 12 |