Question: Design a subroutine called change_array, which has the following function. The subroutine will process an array of longword-sized values stored in memory, as follows. For

Design a subroutine called "change_array", which has the following function. The subroutine will process an array of longword-sized values stored in memory, as follows. For each value in the array, if it is more than 100, then change it to 100; if it is less than 0, then change it to a positive value with the same magnitude if it is not more than 100 and not less than 0, then change it to 0. The input parameters of the subroutine are: starting address and length (i.e., the number of longword-sized values) of the array to be processed. The two input parameters are passed by using address register A4 and data register D4, respectively. In other words, if your main program will call the subroutine to process a specific array, the main program should first store to A4 the starting address of the specific array, and store to D4 the length of the specific array, and then call the subroutine. In the subroutine, by using A4 and D4, it can locate the array to be processed. All registers used by the subroutine must be preserved. Also design one segment of your main program to call the subroutine to process a specific array which has 50 longword-sized values stored at memory starting from address 0x00002000
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
