Question: Provide me the code correctly so that I can get the correct output from the input You are to write simple MSP 4 3 0
Provide me the code correctly so that I can get the correct output from the input
You are to write simple MSP assembly functions for a program that will take a decimal number and a base as input and output the value in that specified base. For example:
E
LQ
SZ
Sa
T
xM
funcbaseS
file "funcbaseS
text
global base
; this function uses both approaches
; possibly calling otherbase
;
; the value to convert is in r
; the base is specified in r and
; the current index is given in r
base:
ret
funcconvertS
file "funcconvertS
text
global convert
; this function has to figure
; out which conversion function
; to call
;
; it receives the decimal value
; in r and the base to convert
; to in r
convert:
mov # r
call #otherbase
mov # r
ret
funclogS
file "funclogS
text
global log
; this function calculates
; log base of a value
;
; the value should be in r
log:
ret
funcotherbase.S
file "funcotherbase.S
text
global otherbase
; this function uses modulo and
; divide to convert the decimal
; value to the specified base
;
; the value to convert is in r
; the base is specified in r and
; the current index is given in r
otherbase:
mov #buf, r ; buf
add r r ; bufindex
mov.b #r ; bufindex
ret
funcpowerbase.S
file "funcpowerbase.S
text
global powerbase
; this function uses mask and
; shift to convert the decimal
; value to the specified base
;
; the value to convert is in r
; the base is specified in r and
; the current index is given in r
powerbase:
ret
funcrshiftS
file "funcrshiftS
text
global rshift
; this function should shift the
; a value a specified number of times
;
; the value to shift is in r and
; the number of times to right shift
; is specified in r
rshift:
ret
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
