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. In sum.s write code the uses scanf that puts the numbers in inputtxt 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 inputtxt 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 numbers in inputtxt Note: In order to divide by the number of elements in this case a power of 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
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
