Question: Adding on to the code in Figure 1 2. In the new file part2.s, take the code which calculates the number of consecutive 1's and

Adding on to the code in Figure 1

Adding on to the code in Figure 1 2. In the new

2. In the new file part2.s, take the code which calculates the number of consecutive 1's and make it into a subroutine called ONES. Have the subroutine use register r4 to receive the input data and register r2 for returning the result. 3. Add more words in memory starting from the label TEST_NUM. You can add as many words as you like, but include at least 10 words. To terminate the list include the word 0 at the end-check for this 0 entry in your main program to determine when all of the items in the list have been processed. 4. In your main program, call the newly-created subroutine in a loop for every word of data that you placed in memory. Keep track of the longest string of 1's in any of the words, and have this result in register r10 when your program completes execution. 5. Make sure to use breakpoints or single-stepping in the Monitor Program to observe what happens each time the ONES subroutine is called. text global _start start: Idwr9. TEST_NUM(r0 Load the data into r9 */ r10, r0 /* r10 will hold the result * mov beq r9, ro, END srli and addir10, r10, 0x01 LOOP Loop until r9 contains no more Is * I* Count the 1s by shifting the number and*/ /*ANDing it with the shifted result *I r9, r9, rll Increment the counter/ LOOP END: END * Wait here */ TEST_NUM: word 0x3fabedef .end * The number to be tested* Figure 1: Assembly-language program that counts consecutive ones 2. In the new file part2.s, take the code which calculates the number of consecutive 1's and make it into a subroutine called ONES. Have the subroutine use register r4 to receive the input data and register r2 for returning the result. 3. Add more words in memory starting from the label TEST_NUM. You can add as many words as you like, but include at least 10 words. To terminate the list include the word 0 at the end-check for this 0 entry in your main program to determine when all of the items in the list have been processed. 4. In your main program, call the newly-created subroutine in a loop for every word of data that you placed in memory. Keep track of the longest string of 1's in any of the words, and have this result in register r10 when your program completes execution. 5. Make sure to use breakpoints or single-stepping in the Monitor Program to observe what happens each time the ONES subroutine is called. text global _start start: Idwr9. TEST_NUM(r0 Load the data into r9 */ r10, r0 /* r10 will hold the result * mov beq r9, ro, END srli and addir10, r10, 0x01 LOOP Loop until r9 contains no more Is * I* Count the 1s by shifting the number and*/ /*ANDing it with the shifted result *I r9, r9, rll Increment the counter/ LOOP END: END * Wait here */ TEST_NUM: word 0x3fabedef .end * The number to be tested* Figure 1: Assembly-language program that counts consecutive ones

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!