Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Need help with coding assignment in uVision using ARM assembly. The code should do the following: Have a null - terminated read only integer array
Need help with coding assignment in uVision using ARM assembly. The code should do the following:
Have a nullterminated read only integer array called Inputs and a readwrite array called Outputs with space reserved for up to ten integers.
Have a subroutine called Cubes that takes the value in r and cubes it so returned r passed r
Have a subroutine called MathFun that performs xx and returns the result in r The value for x will be passed in r and the muldiv instructions should not be used. Treat r as signed. This subroutine should call the Cubes subroutine as needed.
Have a subroutine called ShiftFun that shifts the value in r three times to the left if its positive when treated as signed or rotates it five times to the right if its negative. The new value will also be returned in r
Within the Main part of the code, youll loop through the Inputs array until you reach the null termination. For each value in Inputs, youll call MathFun if its odd and ShiftFun if its even, then store the returned result in the corresponding Outputs array slot.
Example Inputs and Outputs arrays:
Inputs dcd xFFFFFFFxxxx
;xFFFFFFF is odd, so youd call MathFun and get xFFFFFAC
;x is even and positive MSB so youd call ShiftFun and shift
left to get xC
;x is even and positive, so youd call ShiftFun and shift left to
get x
;x is odd, so youd call MathFun and get xC
;x is even and negative, so youd call ShiftFun and rotate right
to get x
Here is the code I have so far that does not work:
AREA RESET, CODE
THUMB
ENTRY
Main
ldr Input
output
strb r#
cmp rl #
beq Done
tst rl #
beq ShiftFun
b MathFun
mov #
mov #
Cubes
push
mul
mul
lr
MathFun
push lis
bl Cubes
lsr #
adds
adds r #x
pop
ShiftFun
cmp ro #
bge ShiftFunPositive
ror #
bx lr
ShiftFunPositive
push
sl #
strb rr
lr
Done
b
Input ded xFFFFFFFxxxx
AREA HWb DATA
Output space
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