Question: can you fix my code to have the expected outputs, it assemble but does not have the correct outputs or it doesnt work, if possible

can you fix my code to have the expected outputs, it assemble but does not have the correct outputs or it doesnt work, if possible please show me the full corrected code, thank you!
.ORIG x3000
; Output intro prompt
OutputPrompt:
LD R0, introPromptPtr
PUTS
; Set up flags, counters, accumulators as needed
AND R4, R4, #0
AND R7, R7, #0
AND R2, R2, #0
LD R5, counter
; Get first character, test for '
','+','-', digit/non-digit
GetFirstChar:
GETC
OUT
; Is the very first character ='
'? If so, just quit (no message)!
LD R2, newlineCheck
ADD R2, R2, R0
BRz QuitProg
; Is it ='+'? If so, ignore it, go get digits
LD R2, plusCheck
ADD R2, R2, R0
BRz GetDigits
; Is it ='-'? If so, set neg flag, go get digits
LD R2, minusCheck
ADD R2, R2, R0
BRz SetNegFlag
; Invalid initial character - output error message, start over
BR OutputErrorMessage
SetNegFlag:
ADD R7, R7, #-1
BR GetFirstChar ; Jump back to the beginning
GetDigits:
GETC
OUT
; IF NEWLINE, END PROG
LD R2, newlineCheck
ADD R2, R2, R0
BRz QuitProg
; Is it '0'? If so, it is not a digit - output error message, start over
LD R2, zeroCheck
ADD R2, R2, R0
BRn OutputErrorMessage
; Is it >'9'? If so, it is not a digit - output error message, start over
LD R2, nineCheck
ADD R2, R2, R0
BRp OutputErrorMessage
; If none of the above, the character is a numeric digit - convert it to number & store in target register!
LD R2, zeroCheck ; ASCII TO DECIMAL
NOT R2, R2
ADD R2, R2, #1
ADD R0, R0, R2
LD R3, multiplyFactor
ADD R4, R4, R0 ; Add the current digit to the accumulated result
ADD R4, R4, R4 ; Multiply the accumulated result by 2
ADD R4, R4, R4 ; Multiply the accumulated result by 4
ADD R4, R4, R4 ; Multiply the accumulated result by 8
ADD R4, R4, R0 ; Add the current digit
ADD R5, R5, #-1
BRz QuitProg
BRnp GetDigits
OutputErrorMessage:
LD R0, errorMessagePtr
PUTS
BR GetFirstChar ; Jump back to the beginning
QuitProg:
; IF FLAG IS SET TO NEGATIVE, CONVERT TO NEGATIVE
BRn SetNegative
; OUTPUT NEWLINE
LD R0, newlineCheck
OUT
HALT
SetNegative:
NOT R4, R4
ADD R4, R4, #1
BR QuitProg
; Program Data
introPromptPtr .FILL xB000
errorMessagePtr .FILL xB200
; DATA
counter .FILL #5
newlineCheck .FILL #-10
plusCheck .FILL #-43
minusCheck .FILL #-45
zeroCheck .FILL #-48
nineCheck .FILL #-57
multiplyFactor .FILL #10
.END
; Remote data
.ORIG xB000 ; intro prompt
.STRINGZ "Input a positive or negative decimal number (max 5 digits), followed by ENTER
"
.END
.ORIG xB200 ; error message
.STRINGZ "ERROR: invalid input
"
.END
 can you fix my code to have the expected outputs, it

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!