Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please use Assembly Language, make sure your code will compile on visual studio.

ID: 3678816 • Letter: P

Question

Please use Assembly Language, make sure your code will compile on visual studio.

using INCLUDE irvine32.inc

If you want to reply, do not copy someone's code!!!!!!!!!!!!!!!

a. Create a procedure (GetInput) that asks the user for N, j and k. This procedure will not receive anything from the calling procedure. N, j and k will be unsigned values and will have to be passed back to the calling procedure via registers. N is a number between 0 and 50 and j < k. if N is greater than 50, ask the user for another number. If j >= k ask the user to re-enter those numbers.


b. Create a procedure (ArrayFill) that fills an array of doublewords with N (N < 50) random integers, making sure the values fall within the range j…k inclusive. When calling the procedure, pass a pointer to the array that will hold the data, pass N, and pass the values of j and k. Preserve all register values between calls to the procedure.
Since we cannot generate an array on the fly, you may declare an array of DWORDs that is 50 elements long.


c. Write a procedure (RandomColor) that randomly generates an integer between 0 and 9. Use this integer along with the hint below to pick what color will be used when displaying text.
The probabilities for each color are: Blue = 30% Red = 10% Green = 60%
HINT: If the integer is between 0-2 (inclusive), choose blue If the integer = 3, choose red If the integer is in the range 4-9 (inclusive), choose green.


d. Create a menu (MainMenu) that provides the following options.
1) Print Randomly Generated Arrays 2) Repeat 3) Quit
You must use cmp and jcond in the menu. DO NOT USE table-driven selection for your menu.

Option 1 requires the user to enter the requested values.

Option 2 prints the randomly generated arrays again with previously entered values. (You do not have to error check that there are previously entered values.)

Option 3 – cleanly exit. No segmentation faults etc. If the user enters an invalid option, redisplay the menu and ask for a valid option.

Explanation / Answer

a) GetInput:

b) ArrayFills: We have already discussed that the data definition directives to the assembler are used for allocating storage for variables. The variable could also be initialized with some specific value. The initialized value could be specified in hexadecimal, decimal or binary form.

The data definition directives can also be used for defining a one-dimensional array. Let us define a one-dimensional array of numbers.

c) RandomColor: