Question
Making choices by comparison and jump You will recall from the discussion of algorithms in the first three chapters of the text that we can
Making choices by comparison and jump
You will recall from the discussion of algorithms in the first three chapters of the text that we can test data for certain properties and make a decision about which statements to execute as a result of what we find. Suppose we want to display the smaller of two input values. The algorithm might compare the two numbers and, if the first is smaller than the second, then display the first; otherwise, the algorithm will display the second.
To observe this algorithm as a machine language program, load the file example3.mac from the EXAMPLES folder. Run the program a couple of times with different input values to get a sense that it does what it is supposed to do.
Download the document lab_09_04.docx. Using the tables within the document complete the following.
For each of the instructions up to the halt instruction, enter the instruction and your interpretation of the instruction in the first table. Then reset and step through the execution of the program using the binary value for 5 for the first input and the binary value for 7 for the second input. Record the address of the instruction being executed and the values stored in the top four registers (pc, ir, r, and ccr) immediately after executing the instruction. What happened to the ccr register after the comparison took place? Did the machine execute one jump instruction or two? Now reset and repeat the procedure by reversing the order of the two input values.
Once you have completed the tables and answered the questions, save your file with your last name in the file name (Example: lab_09_04_Jones.doc). To upload and submit your assignment, click the Choose File button below to find and select your saved document.
Stepping with first input value 5 and second input value 7 : What happened to the value in cor? How many jumps were executed? Stepping with first input value 5 and second input value 7 : What happened to the value in cor? How many jumps were executed? Stepping with first input value 7 and second input value 5 : What happened to the value in cor? How many jumps were executedStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started