I am new to MIPS and the stack is a bit puzzling to me. I am trying to swap the char values between two strings. This is also my first time posting here, if I am violating etiquette let me know!
My swap method --
copyString: # back up all registers you will use!
push($t0)
push($t1)
push($t2)
push($t3)
push($t6)
# retrieve values from the stack!!!
lw $t1, 20($sp)
lw $t0, 24($sp)
li $t6, 0 # LCV for the loop
copyStringBytes:
bge $t6, 6, endCopyString # Leave the loop when we have looped 6 times
lb $t2, ($t0)
lb $t3, ($t1)
sb $t3, ($t0)
sb $t2, ($t1)
addi $t0, $t0, 1
addi $t1, $t1, 1
addi $t6, $t6, 1
b copyStringBytes
endCopyString:
pop($t6)
pop($t3)
pop($t2)
pop($t1)
pop($t0)
addi $sp, $sp, 8 # deallocate 2 parameters
jr $ra
Im not sure if I am sending the correct registers to the stack before implementing the swap function? Any help is appreciated and if there are tutors with time this evening please message me.