Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advanced Oracle Solaris 11 System Administration

Authors: Bill Calkins

1st Edition

0133007170, 9780133007176

More Books

Students also viewed these Databases questions

Question

Discuss health care in the global environment.

Answered: 1 week ago