Question: this is my code, i have errors, can you change it: . orig x 3 0 0 0 ; Initialize the stack pointer. Don't worry

this is my code, i have errors, can you change it: .orig x3000
; Initialize the stack pointer. Don't worry about what that means for now.
ld r6, stack_start_addr ; DO NOT MODIFY, AND DON'T USE R6, OTHER THAN FOR BACKUP/RESTORE
; call start subroutine
lea r5, start
jsrr r5
;---------------------------------------------------------------------------------
; Start Subroutine
;---------------------------------------------------------------------------------
start
ld r1, input_array
ld r5, get_input_string
jsrr r5
ld r2, convert_to_upper
jsrr r2
ld r4, check_palindrome
jsrr r4
ld r1, input_array
ld r2, negative_one
not r2, r2
add r2, r2, #1
START_LOOP
add r7, r4, r2
brn NOT_PALINDROME
lea r0, success_msg
PUTS
lea r0, success_msg_end
PUTS
br EXIT_PROGRAM
NOT_PALINDROME
lea r0, failure_msg
PUTS
lea r0, failure_msg_end
PUTS
EXIT_PROGRAM
halt
; your local data goes here
get_input_string .FILL x3200
check_palindrome .FILL x3400
convert_to_upper .FILL x3600
stack_start_addr .FILL xFE00 ; DO NOT MODIFY THIS LINE OF CODE
input_array .FILL x4000
negative_one .FILL #49
success_msg .STRINGZ "The string"
success_msg_end .STRINGZ " is a palindrome
"
failure_msg .STRINGZ "The string"
failure_msg_end .STRINGZ " is not a palindrome
"
.end
; your subroutines go below here
;------------------------------------------------------------------------
; Subroutine: GET_INPUT_STRING
; Parameter (R1): The starting address of the character array
; Postcondition: The subroutine has prompted the user to input a string,
; terminated by the [ENTER] key (the "sentinel"), and has stored
; the received characters in an array of characters starting at (R1).
; the array is NULL-terminated; the sentinel character is NOT stored.
; Return Value (R5): The number of non-sentinel chars read from the user.
; R1 contains the starting address of the array unchanged.
;-------------------------------------------------------------------------
.ORIG x3200
add r6, r6, #-1
str r1, r6, #0
add R6, R6, #-1
str R7, R6, #0
add R6, R6, #-1
str R2, R6, #0
add R6, R6, #-1
str R3, R6, #0
ld r2, enter_key
not r2, r2
add r2, r2, #1
lea r0, prompt_msg
puts
and r0, r0, #0
add r0, r0, x0A
and r5, r5, #0
READ_LOOP
and r0, r0, #0
GETC
OUT
add r3, r0, r2
BRz END_INPUT
str r0, r1, #0
add r1, r1, #1
add r5, r5, #1
BR READ_LOOP
END_INPUT
ldr r2, r6, #0
add R6, R6, #1
ldr r3, r6, #0
add R6, R6, #1
ldr r7, r6, #0
add R6, R6, #1
ldr r1, r6, #0
add R6, R6, #1
ret
;data
prompt_msg .STRINGZ "Enter a string: "
enter_key .FILL #10
.end
;-------------------------------------------------------------------------
; Subroutine: CHECK_PALINDROME
; Parameter (R1): The starting address of a null-terminated string
; Parameter (R5): The number of characters in the array.
; Postcondition: The subroutine has determined whether the string at (R1)
; is a palindrome or not, and returns a flag to that effect.
; Return Value: R4{1 if the string is a palindrome, 0 otherwise}
;-------------------------------------------------------------------------
.orig x3400
ld r4, flag_true
add r2, r5, #-1
add r5, r5, #-1
add r2, r1, r2
CHECK_LOOP
add r6, r6, #-1
str r1, r6, #0
add R6, R6, #-1
str R7, R6, #0
add R6, R6, #-1
str R5, R6, #0
add R6, R6, #-1
str R3, R6, #0
ldr r3, r1, #0
ldr r7, r2, #0
not r7, r7
add r7, r7, #1
add r2, r2, #-1
add r1, r1, #1
add r3, r3, r7
brz SKIP_COMPARE
ld r4, flag_false
SKIP_COMPARE
add r5, r5, #-2
brnz END_CHECK
jsr CHECK_LOOP
END_CHECK
ldr r3, r6, #0
add R6, R6, #1
ldr r5, r6, #0
add R6, R6, #1
ldr r7, r6, #0
add R6, R6, #1
ldr r1, r6, #0
add R6, R6, #1
ret
flag_false .FILL #48
flag_true .FILL #49
palindrome_address .FILL x3400
.end
;-------------------------------------------------------------------------
; Subroutine: CONVERT_TO_UPPER
; Parameter (R1): Starting address of a null-terminated string
; Postcondition: The subroutine has converted the string to upper-case
; in-place i.e. the upper-case string has replaced the original string
; No return value, no output, but R1 still contains the array address, unchanged
;------------------------------------

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 Finance Questions!