RISC-style program:
A RISC-style program that computes ANSWER = A × B + C × D
Move | R2, #A | Get the address of A | |
Load | R3, (R2) | Load the operand A | |
Move | R2, #B | Get the address operand of B | |
Load | R4, (R2) | Load the operand B | |
Multiply | R5, R3, R4 | Generate A × B | |
Move | R2, #C | Get the address of the C | |
Load | R3, (R2) | Load the operand C | |
Move | R2, #D | Get the address of the D | |
Load | R4, (R2) | Load the operand D | |
Multiply | R6, R3, R4 | Generate C × D | |
Add | R7, R5, R6 | Compute the final answer | |
Move | R2, #ANSWER | Get the address | |
Store | R7, R2 | Store the answer | |
Next instruction | |||
ORIGIN | 0 × 500 | ||
A: | DATAWORD | 100 | Test data |
B: | DATAWORD | 50 | |
C: | DATAWORD | 20 | |
D: | DATAWORD | 400 | |
ANSWER: | RESERVE | 4 | Space for the answer |
CISC-style program:
A CISC-style program that computes ANSWER = A × B + C × D
Move | R2, A | Load the operand A | |
Multiply | R2, B | Generate A × B | |
Move | R3, C | Load the operand C | |
Multiply | R3, D | Generate C × D | |
Add | R3, R2 | Compute the final answer | |
Move | ANSWER, R3 | Store the answer | |
Next instruction | |||
ORIGIN | 0 × 500 | ||
A: | DATAWORD | 100 | Test data |
B: | DATAWORD | 50 | |
C: | DATAWORD | 20 | |
D: | DATAWORD | 400 | |
ANSWER: | RESERVE | 4 | Space for the answer |