Question: We are using the Teach - Sim CPU - OS simulator. This is my first time using anything of this sorts and I am a
We are using the TeachSim CPUOS simulator. This is my first time using anything of this sorts and I am a little lost with these questions. I am not understanding what they are asking me to do and could use some help in order to do this. Question I have left close together as I have done those already but unsure if they make a difference to what is done with later questions.
Create an instruction, which moves number to register R
Execute the above instruction You do this by doubleclicking on the instruction Observe the result in the CPU Registers view Image
Create an instruction, which moves number to register R
Execute it You do this by doubleclicking on the instruction
Observe the contents of R and R in the CPU Registers view Image
Create an instruction, which adds the contents of R and R
Execute it
Note down which register the result is put in
Create an instruction, which pushes the value in the above register to the top of the program stack, and then execute it Observe the value in Program Stack Image
Create an instruction to push number on top of the program stack and execute it Observe the value in Program Stack Image
Create an instruction to unconditionally jump to the first instruction.
Execute it
Observe the value in the PC register. This is the address of the next instruction to be executed. Make a note of the instruction it is pointing to
Create an instruction to pop the value on top of the Program Stack into register R
Execute it
Create an instruction to pop the value on top of the Program Stack into register R
Execute it
Execute the last instruction once again. What happened? Explain.
Create a compare instruction, which compares values in registers R and R
Manually insert two equal values in registers R and RImage
Execute the above compare instruction.
Which of the status flags OVZN is set ie box is checked
Manually insert a value in first register greater than that in second register.
Execute the compare instruction again.
Which of the status flags OVZN is set?
Manually insert a value in first register smaller than that in second register.
Execute the compare instruction once again.
Which of the status flags OVZN is set?
Create an instruction, which will jump to the first instruction if the values in registers R and R are equal.
Test the above instruction by manually putting equal values in registers R and R then first executing the compare instruction followed by executing the jump instruction Remember: You execute an instruction by doubleclicking on it If it worked the first instruction should be highlighted.
Now that you have some understanding of basic CPU instructions and are able to program the simulator here is a bit of challenge for you: preparing a little program loop. Program loops are extremely useful and are very frequently used by computer programs. Heres what you have to do:
Create an instruction that moves number into register R
Create an instruction that adds number to register R
Create an instruction that compares number and register R
Create an instruction that jumps back to instruction above if R is not equal to number
Create a HLT instruction. Make a note of the instructions to you created above in the box below:
Starting from instruction manually execute instructions to one after the other. What happened when you executed instruction
Now first click on the RESET PROGRAM button see Program Control tab in Image and then highlight instruction above. Next click on the RUN button. Now observe the loop in action. Part B: Refer to the appendix for help with CPU instructions
Produce the code for a conditional statement such that if the value in register R is greater than the value in register R then register R is set to Test it on the simulator.
Produce the code for a loop that repeats times where the value of register R is incremented by every time the loop repeats. Test it on the simulator.
The numbers and are manually pushed on top of stack in that order. Produce the code for a routine that pops two numbers from top of stack multiplies them and pushes the result back to top of stack. The routine repeats this until there is only one number left on top of stack. Test the code on the simulator.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
