Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CODE IN ASSEMBLY LANGUAGE For this program you will find the average of 5 numbers stored in an array. ALL numbers will be stored as

CODE IN ASSEMBLY LANGUAGE

For this program you will find the average of 5 numbers stored in an array.

ALL numbers will be stored as DWORDs except the size of the array, called numElems which is stored as a WORD and initialized to be the constant 5.

The .code section of your program must not contain any constants.

The program will involve two loops.

Inside the first loop you will prompt the user for five numbers, each of which is 50 or less. The user must press ENTER after each number is input. Store each number in the DWORD array, and accumulate the sum of the numbers in a DWORD data item called theSum. You must use indirect addressing using square brackets to access the contents of the array, either to read it or write it.

The second loop will write out the contents of the array to the terminal. Again, square brackets must be used to access the array elements.

Finally, you will calculate and display the average of the numbers input. This requires a division using the idiv (integer divide) instruction. You will use this instruction to produce a 16 bit result in ax. Used this way, the idiv instuction requires the most significant part of the dividend in dx. In this case dx is set to 0. The least significant part of the dividend is in ax. In your program, this instruction will look as follows: idiv numElems.

Note that since the result you accumulated in theSum the first loop is a 32 bit quantity, you will need to use PTR to get the least significant part of this quantity into ax in preparation to do the divide.

The output of the program looks as follows:

Input an integer less than 50 and press ENTER: 24

Input an integer less than 50 and press ENTER: 30

Input an integer less than 50 and press ENTER: 46

Input an integer less than 50 and press ENTER: 32

Input an integer less than 50 and press ENTER: 18

The 5 numbers input are: 24 30 46 32 18

The average of the five numbers input is: 30

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

Algorithmic Trading Navigating The Digital Frontier

Authors: Alex Thompson

1st Edition

B0CHXR6CXX, 979-8223284987

More Books

Students also viewed these Databases questions

Question

10. Describe the relationship between communication and power.

Answered: 1 week ago