Answered step by step
Verified Expert Solution
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 readonly array of eight bytes named Unpacked and a readwrite integer named Packed. We'll be condensing the Unpacked array into a single integer called Packed where the four most significant bits bits represent the first value in Unpacked, the next four bits bits represent the second value in Unpacked, etc., down to the four least significant bits representing the finaleighth 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 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 xF to represent it in
Each time through the loop, you'll need to shift r to make room for the "new" four
bits you'll be adding.
Once the looping is completed, store as the Packed integer value.
Below are some example Unpacked arrays and their corresponding Packed integers.
Unpacked dcb
; Packed will be x
Unpacked dcb
; Packed will be xF
Unpacked dcb
; Packed will be xFFF
Posted below is the code I have tried thus far and has not been successful. Please Help.AREA RESET, CODE
THUMB
ENTRY
Main
LDR ROUnpacked ; Load the address of Unpacked array into RO
MOV Rl # ; Initialize Rl to accumulator for Packed
loop
LDR RR # ; Load byte from Unpacked into R and increment the pointer
CMP R # ; Compare the byte value with
BLE unpackedvalue ; Branch if less than or equal to
MOV R #xF ; Set R to OxF if byte value
unpackedvalue
AND #xF ; Mask out only the lower bits of R
ORR R R R LSL #; Shift R into position and OR with accumulator
LDR RR #
CMP RO R ;Compare RO with the end of Unpacked array
BLT loop ; Branch back to loop if R is less than Unpacked
Store
LDR Packed
STRB RRO ; Store the final packed integer value
B ; Branch to end ; Infinite loop to stop execution
AREA HW CODE, READONLY
Unpacked dcb ; Example Unpacked array
Packed dcd
END
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started