Question: Program Description Write and test a MASM program to perform the following tasks ( check the Requirements section for specifics on program modularization ) :
Program Description
Write and test a MASM program to perform the following tasks check the Requirements section for specifics on program modularization:
Introduce the program.
Declare global constants ARRAYSIZE, LO and HI Generate ARRAYSIZE random integers in the range from LO to HI inclusive storing them in consecutive elements of array randArray. eg for LO and HI generate values from the set
ARRAYSIZE should be initially set to
LO should be initially set to
HI should be initially set to
Hint: Call Randomize once in main to generate a random seed. Later, use RandomRange to generate each random number.
Display the list of integers before sorting, numbers per line with one space between each value.
Sort the list in ascending order ie smallest first
Calculate and display the median value of the sorted randArray, rounded to the nearest integer. Using Round Half UpLinks to an external site. rounding
Display the sorted randArray, numbers per line with one space between each value.
Generate an array counts which holds the number of times each value in the range LO HI for default constant values is seen in randArray, even if the number of times a value is seen is zero.
For example with LO counts should equal the number of instances of the value in array. counts should equal the number of instances of the value in randArray. Note that some value may appear zero times and should be reported as zero instances.
Display the array counts, numbers per line with one space between each value.
Program Requirements
The program must be constructed using procedures. At least the following proceduresparameters are required:
NOTE: Regarding the syntax used below...
procName parameters: varA value input varB reference output indicates that procedure procName must be passed varA as a value and varB as a reference, and that varA is an input parameter and varB is an output parameter. You may use more parameters than those specified but try to only use them if you need them.
main
introduction parameters: introreference input introreference input
fillArray parameters: someArray reference output NOTE: LO HI ARRAYSIZE will be used as globals within this procedure.
sortList parameters: someArray reference inputoutput NOTE: ARRAYSIZE will be used as a global within this procedure.
exchangeElements if your sorting algorithm exchanges element positions: parameters: someArrayireference inputoutput someArrayjreference inputoutput where i and j are the indexes of elements to be exchanged
displayMedian parameters: someTitle reference input someArray reference input NOTE: ARRAYSIZE will likely be used as a global within this procedure.
displayList parameters: someTitle reference input someArray reference input arrayLength value input
countList parameters: someArrayreference input someArrayreference output NOTE: LO HI and ARRAYSIZE will be used as globals within this procedure.
Procedures except main must not reference data segment variables by name. There is a significant penalty attached to violations of this rule. randArray, counts, titles for the sortedunsorted lists, etc... should be declared in the data preceding main, but must be passed to procedures on the stack.
Constants LO HI and ARRAYSIZE may be used as globals.
Parameters must be passed on the system stack, by value or by reference, as noted above see Module Exploration Passing Parameters on the Stack for method
Stringsarrays must be passed by reference.
Since you will not be using globals except the constants the program must use one or more of the addressing modes from the explorations eg Register Indirect or Indirect Operands addressing for readingwriting array elements, and BaseOffset addressing for accessing parameters on the runtime stack.
See Module Exploration Arrays in Assembly and Writing to Memory for details.
The programmers name and program title, and a description of program functionality in student's own words to the user must appear in the output.
LO HI and ARRAYSIZE must be declared as constants.
NOTE: We will be changing these constant values to ensure they are implemented correctly. Expect ranges as follows
LO: to
HI: to
ARRAYSIZE: to
There must be only one procedure to display arrays. This procedure must be called three times:
to display the unsorted array
to display the sorted array
to display the counts array
All lists must be identified when they are displayed use the someTitle parameter for the displayList procedure
Procedures may use local variables when appropriate.
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
