Question: Looping by comparison and jump Recall from the text that many algorithms require that a block of instructions be run repeatedly, until a condition becomes

Looping by comparison and jump

Recall from the text that many algorithms require that a block of instructions be run repeatedly, until a condition becomes true (you have been doing this yourself in the previous exercisesinterpreting and stepping through an instruction, until the program halts). For example, we might want to input an arbitrary number of numbers and compute and display their average. We would first input the number of numbers expected, save this value in an extra memory location for a counter, and set a running total to zero. Then, we would input a number, add it to the running total, and subtract one from the counter, until the counter became zero. After the loop was finished, we would divide the total by the number of numbers expected and display the result.

A simpler algorithm that illustrates looping in machine language is in the file example4.mac. Load that program now. The algorithm displays all of the integer values between an input value and 1 inclusive, assuming that the input value is greater than 0. Run the program once to verify that this is the case. Then step through it to observe the behavior of the loop more closely.

Download the document lab_09_05.docx. Using the document complete the following.

In the table enter your interpretation of each instruction as you make the first pass through the loop. What would happen if the input value were zero? What would happen if the input value were a negative number?

Once you have completed the table and answered the questions, save your file with your last name in the file name.To upload and submit your assignment, click the Choose File button below to find and select your saved document. Looping by comparison and jump Recall from the text that many algorithms

What would happen if the input value were rero? What would happen if the input value were a ne gative number

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 Databases Questions!