Answered step by step
Verified Expert Solution
Question
1 Approved Answer
MASM PROGRAM - ARRAYS Write and test a MASM program to perform the following tasks (check the Requirements section for specifics on program modularization): Introducethe
MASM PROGRAM - ARRAYS
Write and test a MASM program to perform the following tasks (check the Requirements section for specifics on program modularization):
- Introducethe program.
- Declareglobal constantsARRAYSIZE,LO, andHI.GenerateARRAYSIZErandom integers in the range fromLOtoHI(inclusive), storing them in consecutive elements of arrayrandArray(e.g. forLO= 20 andHI= 30, generate values from the set [20, 21, ... 30] )
- ARRAYSIZEshould be initially set to 200,
- LOshould be initially set to 15
- HIshould be initially set to 50
- Hint:RunRandomizeonce inmainto generate a random seed, then useRandomRangeto generate each random number.
Program Requirements
- The programmustbe constructed using procedures.At leastthe following procedures/parameters are required: NOTE:Regarding the syntax used below... procName{parameters:varA(value, input),varB(reference, output)} indicates that procedureprocNamemust be passedvarAas a value andvarBas a reference, and thatvarAis an input parameter andvarBis an output parameter.You may use more parameters than those specified but try to only use them if youneedthem.
- main
- introduction{parameters:intro1(reference, input),intro2(reference, input), ...)
- fillArray{parameters:someArray(reference, output)}NOTE:LO,HI,ARRAYSIZEwill be used as globals within this procedure.
- sortList{parameters:someArray(reference, input/output)}NOTE:ARRAYSIZEwill be used as a global within this procedure.
- exchangeElements(if your sorting algorithm exchanges element positions): {parameters:someArray[i](reference. input/output),someArray[j](reference, input/output), where i and j are the indexes of elements to be exchanged}
- displayMedian{parameters:someTitle(reference, input),someArray(reference, input)}NOTE:ARRAYSIZEwill likely be used as a global within this procedure.
- displayList{parameters:someTitle(reference, input),someArray(reference, input)}NOTE:ARRAYSIZEwill likely be used as a global within this procedure.
- countList{parameters:someArray1(reference, input),someArray2(reference, output)}NOTE:LO,HI, and ARRAYSIZEwill be used as globals within this procedure.
- Procedures (exceptmain)must notreference data segment variables by name. There is asignificantpenalty attached to violations of this rule.randArray,counts, titles for the sorted/unsorted lists, etc... should be declared in the .data precedingmain, butmustbe passed to procedures on the stack.
- ConstantsLO,HI, andARRAYSIZEmay be used as globals.
- Parametersmustbe passed on the system stack, by value or by reference, as noted above (see Module 7, Exploration 1 - Passing Parameters on the Stack for method).
- Strings/arraysmustbe passed by reference.
- Since you will not be using globals (except the constants) the programmustuse one (or more) of the addressing modes from the explorations (e.g.Register IndirectorIndexed Operandsaddressing for reading/writing array elements, andBase+Offsetaddressing for accessing parameters on the runtime stack.) See Module 7, Exploration 2 - 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, andARRAYSIZEmustbe declared as constants. NOTE: Wewillbe changing these constant values to ensure they are implemented correctly. Expect ranges as follows LO: 5 to 20 HI: 30 to 60 ARRAYSIZE: 20 to 1000
- Theremustbe only one procedure to display arrays. This proceduremustbe called three times:
- to display the unsorted array
- to display the sorted array
- to display the counts array
- All listsmustbe identified when they are displayed (use thesomeTitleparameter for thedisplayListprocedure).
- Proceduresmayuse local variables when appropriate.
- The programmustbe fully documented and laid out according to the CS271 Style Guide Download CS271 Style Guide. This includes a complete header block for identification, description, etc., a comment outline to explain each section of code, and proper procedure headers/documentation.
Notes
- You are now allowed to use theUSESdirective, but only for preserving/restoring registers. You may not use its extended syntax to create local labels for stack-passed parameters.
- The Irvine library provides procedures for generating random numbers. CallRandomizeonce at the beginning of the program (to set up so you don't get the same sequence every time), and callRandomRangeto get a pseudo-random number. See the documentation in the CS271 Irvine Procedure Reference Download CS271 Irvine Procedure Referencefor more information on using these procedures.
- The median is calculated after the array is sorted. It is the "middle" element of the sorted list. If the number of elements is even, the median is the average of the middle two elements.
- Expected results:
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started