I am trying to reverse a string input by the user and reverse the string whenever * is hit. For example, if i put abc and hit * i should get abc**cba back. There're 2 functions used it this recursive function which are echo (obtain the input key) and putchar (display the input key). For some reason, my code doesn't give me the * but a weird symbol instead when being echoed back while all of the other keys are fine. Can someone give me a suggestion? Here is my code. Thank you.
recursive:
addi $sp, $sp, -12
sw $ra, 4($sp)
sw $t0, 8($sp)
jal echo
addi $t0, $0, 0x2a
sb $v0, 0($sp)
# lw $a0, 0($sp)
bne $t0, $v0, recursive
jal putchar
lbu $a0, 12($sp)
lw $ra, 4($sp)
lw $t0, 8($sp)
addi $sp, $sp, 12
jr $ra # Return
Here is the C program I am trying to translate from
void recursive()
{ char c;
c = echo();
if (c!="*") recursive();
putchar(c);
}