Question: This is in Assembly Language x86 MASM Create a procedure to fill a 12 element array with numbers entered by the user. Create another procedure
This is in Assembly Language x86 MASM
Create a procedure to fill a 12 element array with numbers entered by the user.
Create another procedure that subtracts from the last element of the array all the other numbers and then places the result in the first element of the array. Use a loop to do the calculations. Do not copy this array to any other array. Do not create extra arrays. It is not necessary, and it would be a waste of memory space. Use the TYPE, and LENGTHOF operators to make the program as flexible as possible to support the array size and type being changed in the future.
When dealing with an array, the procedure has to receive the array parameters via register parameters. This means that, before the procedure, you have to place in registers the array offset, length and type. These registers become the procedure parameters and have to be documented in the procedure header, to show other programmers how to use your procedure. As an example, in main you can write:
main proc ... mov esi, OFFSET myArray ;//Sets esi register to first index mov ecx, LENGTHOF myArray ;//Sets counter to the length of the array mov edi, TYPE myArray; // edi holds the type of the array call InputValues ... main endp
and then in InputValues procedure use those 3 registers to fill the array. By doing so, your procedure becomes universal and can be reused no matter of the name of the array, size, type of the array, or the array memory location.
Once you have finished the calculations create another procedure that uses a loop to print out the array. Again, send to the procedure the array data as already explained.
Output any appropriate messages to the display that you feel are needed to make the program clear to the user. Your main procedure should be short, having just a few calls to the procedures described.
Requirements
You are not allowed to use hardcoded numbers like the array size, 12, in the procedures, or type 4, etc. If I change the array size to 14, your program should still work as described.
Document your procedures. You need to show what parameters the procedure uses and for what in your procedure header. This is shown in your textbook page 146, "Documenting Procedures".
Both procedures should be present. Do not place all your code in main.
Messages to the user have to be placed in the main program.
As explained above, use procedure register parameters to send to the procedure the array data: offset, type, length.
Here is an example on how your program should run:
Please enter 12 numbers: 1 2 3 4 5 6 7 8 9 10 11 12 Here is the calculated array: -54 2 3 4 5 6 7 8 9 10 11 12
Verify it builds and runs
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
