Answered step by step
Verified Expert Solution
Link Copied!

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 null-terminated read only integer array called Inputs and a read/write array called Outputs with space reserved for up to ten integers.
Have a subroutine called Cubes that takes the value in r0 and cubes it (so returned r0= passed r03
Have a subroutine called MathFun that performs 4x3+x/8+17 and returns the result in r0. The value for x will be passed in r0 and the mul/div instructions should not be used. Treat r0 as signed. This subroutine should call the Cubes subroutine as needed.
Have a subroutine called ShiftFun that shifts the value in r0 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 r0.
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 0xFFFFFFF7,0x18,0x2222,0x51,0x80000000
;0xFFFFFFF7 is odd, so youd call MathFun and get 0xFFFFF4AC
;0x00000018 is even and positive (MSB=0), so youd call ShiftFun and shift
left 3 to get 0x00000C0
;0x00002222 is even and positive, so youd call ShiftFun and shift left 3 to
get 0x00011110
;0x00000051 is odd, so youd call MathFun and get 0x000818C0
;0x08000000 is even and negative, so youd call ShiftFun and rotate right 5
to get 0x04000000
Here is the code I have so far that does not work:
AREA RESET, CODE
THUMB
ENTRY
Main
ldr ro,=Input
1drrl,=output
strb r4,[r0],#1
cmp rl, #0
beq Done
tst rl, #1
beq ShiftFun
b MathFun
mov r2,#0
mov r3,#0
Cubes
push {1l}
mul r3,r2,r2
mul r2,r3,r2
bx lr
MathFun
push {lis
bl Cubes
lsr ro,#3
adds r4,r2,r0
adds r4, #0x10001
pop {lr}
ShiftFun
cmp ro, #0
bge ShiftFunPositive
ror r4,#5
bx lr
ShiftFunPositive
push {1l}
1 sl 4,#3
strb r4,[r1]
bx lr
Done
b.
Input ded 0xFFFFFFF7,0x18,0x2222,0x51,0x80000000
AREA HW7b, DATA
Output space 10
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