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;) student submitted image, transcription available below

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

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!