Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help with Coding assignment in uVision using ARM Assembly: Have a read - only array of eight bytes named Unpacked and a read /

Need help with Coding assignment in uVision using ARM Assembly:
Have a read-only array of eight bytes named Unpacked and a read/write integer named Packed. We'll be condensing the Unpacked array into a single integer called Packed where the four most significant bits (bits 31,30,29,28) represent the first value in Unpacked, the next four bits (bits 27,26,25,24) represent the second value in Unpacked, etc., down to the four least significant bits (3,2,1,0) representing the final/eighth value in the Unpacked array. You'll achieve this by looping through the Unpacked array and placing the lower four bits of each of the byte values into register three (r3) based upon the following criteria:
If the byte value is between decimal zero and nine, inclusive, just use the
lowest four bits
If the byte value is anything else, use 0xF (2_1111) to represent it in r3
Each time through the loop, you'll need to shift r3 to make room for the "new" four
bits you'll be adding.
Once the looping is completed, store r3 as the Packed integer value.
Below are some example Unpacked arrays and their corresponding Packed integers.
Unpacked dcb 9,8,7,6,5,4,3,2
; Packed will be 0x98765432
Unpacked dcb 3,2,1,0,12,5,6,9
; Packed will be 0x3210F569
Unpacked dcb 4,13,7,8,10,2,9,-3
; Packed will be 0x4F78F29F
Posted below is the code I have tried thus far and has not been successful. Please Help.AREA RESET, CODE
THUMB
ENTRY
Main
LDR RO,=Unpacked ; Load the address of Unpacked array into RO
MOV Rl, #0 ; Initialize Rl to 0(accumulator for Packed)
loop
LDR R2,[R0], #1 ; Load byte from Unpacked into R2, and increment the pointer
CMP R2, #9 ; Compare the byte value with 9
BLE unpacked_value ; Branch if less than or equal to 9
MOV R2, #0xF ; Set R2 to OxF if byte value >9
unpacked_value
AND ?bar(R)2,R2, #0xF ; Mask out only the lower 4 bits of R2
ORR R1, R1, R2, LSL #28; Shift R2 into position and OR with accumulator
LDR R3,[R0, #8]
CMP RO, R3 ;Compare RO with the end of Unpacked array
BLT loop ; Branch back to loop if R0 is less than (Unpacked +8)
Store
LDR RO,= Packed
STRB R1,[RO] ; Store the final packed integer value
B. ; Branch to end ; Infinite loop to stop execution
AREA HW5, CODE, READONLY
Unpacked dcb 9,8,7,6,5,4,3,2 ; Example Unpacked array
Packed dcd 0
END
image text in transcribed

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

Database Processing Fundamentals Design

Authors: Marion Donnie Dutton Don F. Seaman

14th Edition Globel Edition

1292107634, 978-1292107639

More Books

Students also viewed these Databases questions

Question

How many Tables Will Base HCMSs typically have? Why?

Answered: 1 week ago

Question

What is the process of normalization?

Answered: 1 week ago