Question: Create a new ASSEMBLY project using Keil Software. Make sure you use the M3 option Use the following template by copying it to your Assembly

Create a new ASSEMBLY project using Keil Software. Make sure you use the M3 option

Use the following template by copying it to your Assembly file:

__main

MOV R0, ___; Replace ___ with base register.

MOV R1, #1 ; R1 will be used to increment the loop.

MOV R2, #20; R2 will represent the number of iterations.

MOV R3, #0 ; R3 will be used to hold the sum of the array.

storeValuesLoop

;Store the value of R1 to address of R0, then auto increment the address by 4. Hint use STR instruction.

ADD R1, #1; Increment the Loop by adding 1 to R1

CMP R1, R2; Compare R1 & R2 to determine if we need to exit the loop or not

BLE storeValuesLoop; Stay in the loop if R1 is less than or equal to R2

MOV R1, #1 ;

Reset R1 to start from the beginning again for the 2nd loop.

_____________ ; Reset _____________ with the code to reset the pointer to be able to use it in the 2n loop below.

readValuesLoop

;Read the value of current iteration to R4. Hint use LDR instruction.

ADD R3, R4 ; Add the value your read [R4] to the sum [R3]

ADD R1, #1; Increment the Loop by adding 1 to R1

CMP R1, R2; Compare R1 & R2 to determine if we need to exit the loop or not

BLE readValuesLoop; Stay in the loop if R1 is less than or equal to R2

stop B stop

END

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!