Question: please write code using coldfire assembly language 1. (15 points) Design a subroutine called change array, which has the following function. The subroutine will process
1. (15 points) 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. Also design a main program to call the subroutine to process a specific array which has 50 longword-sized values stored at memory starting from address 0x00002000 Note that at the beginning of your main program, you do not know the exact initial value in any data or address register. All registers used by the subroutine must be preserved. 1. (15 points) 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. Also design a main program to call the subroutine to process a specific array which has 50 longword-sized values stored at memory starting from address 0x00002000 Note that at the beginning of your main program, you do not know the exact initial value in any data or address register. All registers used by the subroutine must be preserved
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
