Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Exercise [Arrays - Part 1] Step 1: Create a new ASSEMBLY project using Keil Software (1) Make sure you use the M3 option Step 2: Use the following template by copying it to your Assembly file: AREA Lab_05_Your FirstName_YourLastName, CODE, READONLY EXPORT _main _main MOV RO, _ 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. storeValues Loop Store the value of R1 to address of RO, 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. readValues Loop ;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: We are trying to evaluate the following formula, where R1 = 1, and R2= 20: R2 R3 = 20 (R2) = (210) n=R1 n=1 Step 4: Make sure you replace the highlighted lines in Step 2 with the correct code. Hint: You don't need more than one instruction line for each highlighted line! Step 5: You should have the following results at the end Value Register Core RO R1 R2 0x20001058 0x00000015 0x00000014 0x000000D2 0x00000014 R3 R4 Exercise [Arrays - Part 2] Step 1: Create a new ASSEMBLY project using Keil Software (1) Make sure you use the M3 option Step 2: Copy the following template to your assembly file: AREA Lab_06_Your FirstName_YourLastName, CODE, READONLY EXPORT_main _main MOV RO, 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. store Values Loop STR R1, [RO], #4;Store the value of R1 to address of RO, 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 storeValues Loop; 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 RO, SP; readValues Loop LDR R4, [RO], #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 readValues Loop; Stay in the loop if R1 is less than or equal to R2 stop B stop END Step 3: Change Your FirstName to your first name. Change YourLastName to your last name. This is the same program that we used for Lab 05. 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 readValues Loop 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 readValues Loop loop. Step 6: You should have the same sum result as we had in Lab 05.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

App Inventor

Authors: David Wolber, Hal Abelson

1st Edition

1449397484, 9781449397487

More Books

Students also viewed these Programming questions

Question

Briefly discuss Aristotles approach to dreaming.

Answered: 1 week ago