Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using Indirect Operands addressing Passing parameters on the runtime stack Generating random numbers Working with arrays WRITTEN IN ASSEMBLY Write and test a MASM program

  1. Using Indirect Operands addressing
  2. Passing parameters on the runtime stack
  3. Generating "random" numbers
  4. Working with arrays

WRITTEN IN ASSEMBLY

Write and test a MASM program to perform the following tasks (check the Requirements section for specifics on program modularization):

  1. Introduce the program.
  2. Generate ARRAYSIZE random integers in the range [LO = 10 ... HI = 29], storing them in consecutive elements of an array randArray. ARRAYSIZE should be set to 200. HINT: Use Irvines RandomRange and Randomize procedures to generate each random number.
  3. Display the list of integers before sorting, 20 numbers per line with one space between each value.
  4. Sort the list in ascending order (i.e., smallest first).
  5. Calculate and display the median value of randArray, rounded to the nearest integer. (Using Round Half Up (Links to an external site.) rounding)
  6. Display the sorted randArray, 20 numbers per line with one space between each value.
  7. Generate an array counts which holds the number of times each value [10, 29] is seen in randArray. For example, counts[0] should equal the number instances of the value `10` in array. counts[14] should equal the number of instances of the value `24` in randArray.
  8. Display the array counts, 20 numbers per line with one space between each value.

Program Requirements

  1. 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.
  2. LO, HI, and ARRAYSIZE must be declared as constants. NOTE: We will be changing these constant value to ensure they are implemented correctly. Expect ranges as follows LO: 7 to 12 HI: 27 to 32 ARRAYSIZE: 180 to 220
  3. Strings must be passed by reference.
  4. The program must use Register Indirect addressing for array elements, and Base+Offset addressing for accessing parameters on the runtime stack.
  5. The program must be constructed using procedures. At least the following procedures/parameters 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.
    1. main
    2. introduction {parameters: intro1 (reference, input), intro2 (reference, input), ...)
    3. fillArray {parameters: someArray (reference, output), LO (value, input), HI (value, input), ARRAYSIZE (value, input)}
    4. sortList {parameters: someArray (reference, input/output), ARRAYSIZE (value, input)}
    5. 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}
    6. displayMedian {parameters: someTitle (reference, input), someArray (reference, input), ARRAYSIZE (value, input)}
    7. displayList {parameters: someTitle (reference, input), someArray (reference, input), ARRAYSIZE (value, input)}
    8. countList {parameters: someArray1 (reference, input), ARRAYSIZE (value, input), someArray2 (reference, output), LO (value, input), HI (value, input)}
  6. Parameters must be passed on the system stack, by value or by reference (as noted above).
  7. There must be just one procedure to display arrays. This procedure must be called three times:
    1. to display the unsorted array
    2. to display the sorted array
    3. to display the counts array
  8. All lists must be identified when they are displayed (use the someTitle parameter for the displayList procedure).
  9. Procedures (except main) must not reference data segment variables or constants by name. randArray, counts, titles for the sorted/unsorted lists, etc... should be declared in the .data section, but must be passed to procedures on the stack.
  10. Procedures may use local variables when appropriate.
  11. The program must be fully documented and laid out according to the 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.

EXAMPLE OUTPUT:

Generating, Sorting, and Counting Random integers! Programmed by ......... This program generates 200 random numbers in the range [10 ... 29], displays the original list, sorts the list, displays the median value of the list, displays the  list sorted in ascending order, then displays the number of instances of each  generated value, starting with the number of 10s. Your unsorted random numbers: 11 24 18 19 26 10 19 15 11 20 16 21 21 19 24 18 12 10 19 20 12 13 13 21 13 21 15 20 28 24 28 14 16 20 28 21 29 24 11 19 24 13 22 19 20 10 12 13 13 15 13 26 27 24 17 17 27 21 21 18 15 15 24 25 13 17 26 27 29 27 27 15 29 18 20 21 23 20 12 13 22 15 19 20 22 18 13 16 20 22 15 23 18 22 12 29 18 18 12 24 20 14 16 14 18 18 14 22 18 11 12 21 15 16 21 21 29 13 26 16 17 15 13 21 10 20 12 24 28 10 18 18 19 28 20 26 23 15 16 16 13 22 28 24 24 12 23 15 24 12 18 24 22 15 19 23 13 27 16 24 29 15 24 28 18 23 28 21 16 23 22 10 24 12 20 16 25 17 25 12 23 22 18 15 23 16 13 24 12 13 24 24 14 15 19 13 25 18 28 13 The median value of the array: 19 Your sorted random numbers: 10 10 10 10 10 10 11 11 11 11 12 12 12 12 12 12 12 12 12 12 12 12 12 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 13 14 14 14 14 14 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 15 16 16 16 16 16 16 16 16 16 16 16 16 17 17 17 17 17 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 18 19 19 19 19 19 19 19 19 19 19 20 20 20 20 20 20 20 20 20 20 20 20 20 21 21 21 21 21 21 21 21 21 21 21 21 21 22 22 22 22 22 22 22 22 22 22 23 23 23 23 23 23 23 23 23 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 24 25 25 25 25 26 26 26 26 26 27 27 27 27 27 27 28 28 28 28 28 28 28 28 28 29 29 29 29 29 29 Your list of instances of each generated number, starting with the number of 10s: 6 4 13 18 5 16 12 5 17 10 13 13 10 9 19 4 5 6 9 6 Goodbye, and thanks for using this program!

let me know if this helped! or you need anything else

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

Ehs 2.0 Revolutionizing The Future Of Safety With Digital Technology

Authors: Tony Mudd

1st Edition

B0CN69B3HW, 979-8867463663

More Books

Students also viewed these Databases questions

Question

Prepare a short profile of Henry words worth Longfellow?

Answered: 1 week ago

Question

What is RAM as far as telecommunication is concerned?

Answered: 1 week ago

Question

Question 1: What is reproductive system? Question 2: What is Semen?

Answered: 1 week ago

Question

Describe the sources of long term financing.

Answered: 1 week ago

Question

Influences on Nonverbal Communication?

Answered: 1 week ago