Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Your code ( In uVision, ARM Assembly ) should do the following: Have one read - only, six value integer array called Input; one read
Your code In uVision, ARM Assembly should do the following:
Have one readonly, six value integer array called Input; one readwrite integer array with six slots reserved called Output; and a single readwrite byte called Odds.
Loop through and read in values from Input one at a time until you read all six values, at which point youll exit the loop.
For each value read in from Input, do the following:
o If the value is negative: clear all but bits and then set bit
o If the value is positive, nonzero: clear only bits through
o If the value is zero: leave it alone
o Store this newly modified value into Output
o Count the number of odd values read in from Input; youll store this number at the Odds label once the loop has executed.
Below is an example Input array and its corresponding Output array.
Input dcd xxCDxxAAAAAAAA
;Output: xxDxx
xx
;the value for Odd for the above would be
I have included the code I have written that has not worked properly:
AREA RESET, CODE
THUMB
ENTRY
LDR ROInput ; Load address of Input array into RO
LDR ROutput ; Load address of Output array into R
LDR ROdds ; Initialize Odds
loop
LDR RR # ; Load next value from Input array into R
CMP R # ; Compare value with zero
BLT negative ; Branch if less than zero
CMP R # ; Compare value with zero again
BEQ storevalue ; Branch if equal to zero
B positive ; Branch to positive if above conditions are not met
negative
AND R R #x ; Clear all but bits and
ORR R R #x; Set bit
B storevalue
positive
AND R R #xF ; Clear bits and
B storevalue
storevalue
STR RR # ; Store modified value into Output array
TST R # ; Test if value is odd
ADDNE R R # ; Increment odd count if value is odd
ADD R R # ; Increment loop counter
CMP R # ; Compare loop counter with
BLT loop ; Loop if counter is less than
STRB RR ; Store odd count into Odds
AREA Program, DATA
Input DCD xxCDxxAAAAAAAA
AREA Program CODE, READWRITE
Output SPACE ; integers bytes each bytes
Odds SPACE ; byte for storing the count of odd values
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