Question: (c) The following nested loop in C program is shown in Figure 2. (i=1 ; for 0; { j-) for { Figure 2 However, the

(c) The following nested loop in C program is shown in Figure 2. (i=1 ; for 0; { j-) for { Figure 2 However, the ARM assembly code, listed in Figure 3 on page 4, is found to be inefficient. Use your knowledge of ARM assembly language to optimize the program. EE3002 / IM2002 : Assume R0 and Rl take on the variables a and b, ; respectively ;R2 contains the j (inner loop) index : R3 contains the i (outer loop) index MOV R3 , #1 CMP BGT done MOV R2 , #6 CMP BLE inner done ADD R0, RO, Rl SUB R2 , R2, #1 loop-outer R3 , #11 loop-inner R2 , #0 loop inner inner done ADD R3, R3, #1 loop outer done done Figure 3 (9 Marks) (c) The following nested loop in C program is shown in Figure 2. (i=1 ; for 0; { j-) for { Figure 2 However, the ARM assembly code, listed in Figure 3 on page 4, is found to be inefficient. Use your knowledge of ARM assembly language to optimize the program. EE3002 / IM2002 : Assume R0 and Rl take on the variables a and b, ; respectively ;R2 contains the j (inner loop) index : R3 contains the i (outer loop) index MOV R3 , #1 CMP BGT done MOV R2 , #6 CMP BLE inner done ADD R0, RO, Rl SUB R2 , R2, #1 loop-outer R3 , #11 loop-inner R2 , #0 loop inner inner done ADD R3, R3, #1 loop outer done done Figure 3 (9 Marks)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
