So I am trying to reverse a string inputed by a user and I am getting an error on one line of my code the line is lw $t3, $t0($t1) #load value. Why can I not do this?
.data
prompt: .asciiz "Enter in a string: "
backwards: .asciiz "That string backwards is: "
newLine: .asciiz "\n"
.text
main:
la $a0, prompt #call opening prompt
li $v0, 4 #output string
syscall
li $v0, 8 #read a string
syscall
la $a0, newLine #call opening prompt
li $v0, 4 #output string
syscall
#$a0 is the string $a1 is the length of the string
move $t0, $a0 #move a0 to t0
move $t1, $a1 #move a1 to t1
li $v0, 11 #code to print char
Loop:
sub $t1, $t1, 1
lw $t3, $t0($t1) #load value
lb $a0, ($t3) #load the byte
syscall #print byte
bnez $a1, Loop
li $v0, 10 #terminating
syscall