Question: This lab will introduce you to reading input from the commandline and storing it on the stack. As part of this, you'll learn about the

This lab will introduce you to reading input from the commandline and storing it on the stack. As part of this, you'll learn about the stack pointer sp, how the stack is indexed, and how the scanf function works. 1. In sum.s write code the uses scanf that puts the 10 numbers in input1.txt onto the stack and computes the sum of these numbers. As usual, the code can be compiled like this: armc sum.s. To read in the numbers, you can pipe them into the binary as follows: ./about < input1.txt.2. Once you have finished writing sum.s make a copy of the file, rename it average.s, and modify it so that it computes the average of the 16 numbers in input2.txt. Note: In order to divide by the number of elements (in this case 16--a power of 2) you can use an arithmetic shift right to divide. Shifting all the bits of a binary number to the right changes the value of the number as a whole. Since each bit's position represents a power of two, shifting all the bits to the right once is the same as dividing the number by two. This should help you figure out how many bits you have to shift by to compute the

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!