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 Teach-Sim CPU-OS 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 1-8 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.
1. Create an instruction, which moves number 5 to register R00.
2. Execute the above instruction (You do this by double-clicking on the instruction). Observe the result in the CPU Registers view (Image 4).
3. Create an instruction, which moves number 7 to register R01.
4. Execute it (You do this by double-clicking on the instruction)
5. Observe the contents of R00 and R01 in the CPU Registers view (Image 4).
6. Create an instruction, which adds the contents of R00 and R01.
7. Execute it.
8. Note down which register the result is put in.
9. 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 5).
10. Create an instruction to push number 2 on top of the program stack and execute it. Observe the value in Program Stack (Image 5).
11. Create an instruction to unconditionally jump to the first instruction.
12. Execute it.7
13. 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?
14. Create an instruction to pop the value on top of the Program Stack into register R02.
15. Execute it.
16. Create an instruction to pop the value on top of the Program Stack into register R03.
17. Execute it.
18. Execute the last instruction once again. What happened? Explain.
19. Create a compare instruction, which compares values in registers R04 and R05.
20. Manually insert two equal values in registers R04 and R05(Image 4).
21. Execute the above compare instruction.
22. Which of the status flags OV/Z/N is set (i.e. box is checked)?
23. Manually insert a value in first register greater than that in second register.
24. Execute the compare instruction again.
25. Which of the status flags OV/Z/N is set?
26. Manually insert a value in first register smaller than that in second register. 8
27. Execute the compare instruction once again.
28. Which of the status flags OV/Z/N is set?
29. Create an instruction, which will jump to the first instruction if the values in registers R04 and R05 are equal.
30. Test the above instruction by manually putting equal values in registers R04 and R05, then first executing the compare instruction followed by executing the jump instruction (Remember: You execute an instruction by double-clicking on it). If it worked the first instruction should be highlighted.
31. 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:
1. Create an instruction that moves number 0 into register R01
2. Create an instruction that adds number 1 to register R01
3. Create an instruction that compares number 10 and register R01
4. Create an instruction that jumps back to instruction 2 above if R01 is not equal to number 10.
5. Create a HLT instruction. Make a note of the instructions 1 to 5 you created above in the box below:
6. Starting from instruction 1 manually execute instructions 1 to 4 one after the other. What happened when you executed instruction 4?
7. Now first click on the RESET PROGRAM button (see Program Control tab in Image 1) and then highlight instruction 1 above. Next click on the RUN button. Now observe the loop in action. 910 Part B: (Refer to the appendix for help with CPU instructions)
1. Produce the code for a conditional statement such that if the value in register R02 is greater than (>) the value in register R01 then register R03 is set to 8. Test it on the simulator.
2. Produce the code for a loop that repeats 5 times where the value of register R02 is incremented by 2 every time the loop repeats. Test it on the simulator.
3. The numbers 4,-3,5 and -6 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 blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!