Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Textbook is Invitation to Computer Science 7th edition FIGURE 5.21 Address 100 101 102 Contents Value of a Value ofb Value of c Algorithmic notation
Textbook is Invitation to Computer Science 7th edition
FIGURE 5.21 Address 100 101 102 Contents Value of a Value ofb Value of c Algorithmic notation Machine language instruction sequences Address Contents (commentary) LOAD 101 ADD 102 STORE 100 Put the value of b into register R Add c to register R. It now holds &+C Store the contents of register R into a 1. Set a to the value b+ 50 51 52 Compare aand b 2. If a >b then 50 COMPARE 100, 101 and set candition JUMPGT 54 MOVE 101, 102 JUMP 55 MOVE 100, 102 codes. Go to location 54 a>b Get here if a sb, so move b into c and skip the next nstruction. set c to the value a 51 Else set c to the value b 53 54 Move a into c 3. [56%) Assume that (i) the variables a, b, and c are stored in memory locations 100, 101, and 102, respectively, (ii) the five integer values +4, -1, 0, +12, and +1 are stored in memory locations 300, 301, 302, 303, and 304, respectively. and (iii) the code sequence you are writing begins in memory location 40. Using any of the machine language instructions shown in Section 5.2.4 of the Textbook, translate the following algo- rithmic operations into machine language code. Do not give binary but rather use the style of instruction presentation shown in Figure 5.21 on page 255 of the Textbook. Set c to the value of-1 for b-4 to 12 do if a 0 then Set c to the value of c - a else Set a to the value of b - c Set c to the value of c+1 FIGURE 5.21 Address 100 101 102 Contents Value of a Value ofb Value of c Algorithmic notation Machine language instruction sequences Address Contents (commentary) LOAD 101 ADD 102 STORE 100 Put the value of b into register R Add c to register R. It now holds &+C Store the contents of register R into a 1. Set a to the value b+ 50 51 52 Compare aand b 2. If a >b then 50 COMPARE 100, 101 and set candition JUMPGT 54 MOVE 101, 102 JUMP 55 MOVE 100, 102 codes. Go to location 54 a>b Get here if a sb, so move b into c and skip the next nstruction. set c to the value a 51 Else set c to the value b 53 54 Move a into c 3. [56%) Assume that (i) the variables a, b, and c are stored in memory locations 100, 101, and 102, respectively, (ii) the five integer values +4, -1, 0, +12, and +1 are stored in memory locations 300, 301, 302, 303, and 304, respectively. and (iii) the code sequence you are writing begins in memory location 40. Using any of the machine language instructions shown in Section 5.2.4 of the Textbook, translate the following algo- rithmic operations into machine language code. Do not give binary but rather use the style of instruction presentation shown in Figure 5.21 on page 255 of the Textbook. Set c to the value of-1 for b-4 to 12 do if a 0 then Set c to the value of c - a else Set a to the value of b - c Set c to the value of c+1Step 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