Question: Exercise [Arrays Part 2] Step 1: Create a new ASSEMBLY project using Keil Software Make sure you use the M3 option Make sure you name

Exercise [Arrays Part 2]

Step 1: Create a new ASSEMBLY project using Keil Software

  1. Make sure you use the M3 option
  2. Make sure you name the folder COSC2440_Lab06_YourFirstName_YourLastName

Step 2: Copy the following template to your assembly file:

AREA Lab_06_YourFirstName_YourLastName, CODE, READONLY

EXPORT __main

__main

MOV R0, SP ; 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

STR R1, [R0], #4;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.

MOV R0, SP;

readValuesLoop

LDR R4, [R0], #4;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 3:

Change YourFirstName to your first name.

Change YourLastName to your last name.

Step 4: Modify storeValuesLoop from using the STR-Post-indexed-autoindexing-post-incrementing to STR-Pre-indexed-autoindexing-pre-incrementing.

You are ONLY allowed to modify the highlighted line inside the storeValuesLoop loop.

Step 5: Modify readValuesLoop from using the LDR-Post-indexed-autoindexing-post-incrementing to LDR- indexed-Double Register with Scaling.

You are ONLY allowed to modify the highlighted line inside the readValuesLoop loop.

Step 6: After testing your program, answer the 2 questions in Blackboard quiz by filling the blanks. Make sure that you dont ADD any comments to your code and add only 1 space after each comma.

Example:

For question 1, you will enter: STR R4, [R0], #4

For question 2, you will enter: LDR R4, [R0], #4

Multiple Attempts This test allows multiple attempts.
Force Completion Once started, this test must be completed in one sitting. Do not leave the test before clicking Save and Submit.

Question Completion Status:

QUESTION 1

  1. Please enter in the Blank your modified instruction from Step 4.

    Make sure that you dont ADD any comments to your code and add only 1 space after each comma.

    Example:

    For question 1, you will enter: STR R4, [R0], #4

    For question 2, you will enter: LDR R4, [R0], #4

    Modify storeValuesLoop from using the STR-Post-indexed-autoindexing-post-incrementing to STR-Pre-indexed-autoindexing-pre-incrementing.

    You are ONLY allowed to modify the highlighted line inside the storeValuesLoop loop.

50 points

QUESTION 2

  1. Please enter in the Blank your modified instruction from Step 5.

    Make sure that you dont ADD any comments to your code and add only 1 space after each comma.

    Example:

    For question 1, you will enter: STR R4, [R0], #4

    For question 2, you will enter: LDR R4, [R0], #4

    Modify readValuesLoop from using the STR-Post-indexed-autoindexing-post-incrementing to LDR- indexed-Double Register with Scaling.

    You are ONLY allowed to modify the highlighted line inside the readValuesLoop loop.

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!