Answered step by step
Verified Expert Solution
Link Copied!

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 read-only, six value integer array called Input; one read/write integer array with six slots reserved called Output; and a single read/write 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 12 and 9, then set bit 3
o If the value is positive, non-zero: clear only bits 7 through 4
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 0x42,0xCD,-3,0x7319,0,0xAAAAAAAA
;Output: 0x00000002,0x0000000D,0x00001204,0x00007309,
0x00000000,0x0000204
;the value for Odd for the above would be 3
I have included the code I have written that has not worked properly:
AREA RESET, CODE
THUMB
ENTRY
LDR RO,=Input ; Load address of Input array into RO
LDR R1,=Output ; Load address of Output array into R1
LDR R3,=Odds ; Initialize Odds
loop
LDR R4,[R0], #4 ; Load next value from Input array into R4
CMP R4, #0 ; Compare value with zero
BLT negative ; Branch if less than zero
CMP R4, #0 ; Compare value with zero again
BEQ store_value ; Branch if equal to zero
B positive ; Branch to positive if above conditions are not met
negative
AND R4, R4, #0x1200 ; Clear all but bits 12 and 9
ORR R4, R4, #0x04; Set bit 3
B store_value
positive
AND R4, R4, #0xF0 ; Clear bits 7,6,5, and 4
B store_value
store_value
STR R4,[R1], #4 ; Store modified value into Output array
TST R4, #1 ; Test if value is odd
ADDNE R3, R3, #1 ; Increment odd count if value is odd
ADD R2, R2, #1 ; Increment loop counter
CMP R2, #6 ; Compare loop counter with 6
BLT loop ; Loop if counter is less than 6
STRB R3,[R3] ; Store odd count into Odds
AREA Program, DATA
Input DCD 0x42,0xCD,-3,0x7319,0,0xAAAAAAAA
AREA Program2, CODE, READWRITE
Output SPACE 24 ; 6 integers *4 bytes each =24 bytes
Odds SPACE 0 ; 1 byte for storing the count of odd values
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

Concepts Of Database Management

Authors: Joy L. Starks, Philip J. Pratt, Mary Z. Last

9th Edition

1337093424, 978-1337093422

More Books

Students also viewed these Databases questions

Question

What is the most important part of any HCM Project Map and why?

Answered: 1 week ago