Question: Exercise 1: Write ARM code to implement the following C operation. int s = 0; for ( i = 0; i < 10; i++) {
Exercise 1:
Write ARM code to implement the following C operation. int s = 0; for ( i = 0; i < 10; i++) { s = s + i*i;) 
code, readwrite AREA SumSquares, ENTRY MOV r0, #0 MOV r1,#0 MUL r2, r0,r0 ADD rl,rl,r2 ADDS r0 , r0,#1 CMP r0,#10 BNE Loop END :loop counter i preset to0 Loop ;calc i*i ;test for end icontinue until all added We can improve this code by counting down rather than up to remove the comparison. We can also use the multiply and accumulate operation to perform the i and addition AREA SumSquares2, code, readwrite ENTRY MOV r0 , #9 MOV r1,#0 MLA rl,r0,r0,rl calc i*i SUBS ro,ro,#1 BNE Loop END ;loop counter i preset to 9 Loop ; continue until all added code, readwrite AREA SumSquares, ENTRY MOV r0, #0 MOV r1,#0 MUL r2, r0,r0 ADD rl,rl,r2 ADDS r0 , r0,#1 CMP r0,#10 BNE Loop END :loop counter i preset to0 Loop ;calc i*i ;test for end icontinue until all added We can improve this code by counting down rather than up to remove the comparison. We can also use the multiply and accumulate operation to perform the i and addition AREA SumSquares2, code, readwrite ENTRY MOV r0 , #9 MOV r1,#0 MLA rl,r0,r0,rl calc i*i SUBS ro,ro,#1 BNE Loop END ;loop counter i preset to 9 Loop ; continue until all added