WRITTEN PROBLEMS
Hand these problems in on paper in class.
f(0) = 5
Δf(0) = 2
Δ2f(0) = 3
Δ3f(0) = 1
Assume that such a computer has three internal storage registers named R1, R2 and R3 and the following machine instructions:
ADD registerA, registerB - Adds the value in registerA to the value in the registerB, storing the result in registerB (overwriting its original value). BNZ register, address - Jump to the instruction at the given address if the contents of the specified register is not zero CLEAR register - Clears the specified storage register (sets it to 0) HALT - Stop the computer LOAD value, register - Loads the specified storage register with the given value (overwriting its original contents) SUB value, register - Subtracts the given value from the contents of the specified register
What computation is performed by each of the following machine programs assuming the computer starts with the instruction at address 100? Show your work.
ADDRESS INSTRUCTION 100 CLEAR R1 101 LOAD 6, R2 102 ADD R2, R1 103 SUB 1, R2 104 BNZ R2, 102 105 HALT ADDRESS INSTRUCTION 100 LOAD 1, R1 101 LOAD 6, R2 102 ADD R1, R1 103 SUB 1, R2 104 BNZ R2, 102 105 HALT ADDRESS INSTRUCTION 100 CLEAR R1 101 LOAD 3, R2 102 LOAD 6, R3 103 ADD R2, R1 104 SUB 1, R3 105 BNZ R3, 103 106 HALT