.data msg: .asciiz "hello world" endl: .asciiz "\n" .text .globl main main: addi $sp,$sp,-1 #Decrement sp sb $0,0($sp) #Store 0 at the top of stack la $t1, msg # Load address of msg L0: lb $t0,0($t1) # Load the current character beq $t0,$0, L1 # If 0, we're done loading the string. Move on addi $sp,$sp,-1 # Decrement sp sb $t0,0($sp) # Store current character on top of stack addi $t1,$t1,1 # Move to the next character j L0 L1: la $t1,msg # Load address of msg again L2: lb $t0,0($sp) # Load charcter from top of stack addi $sp,$sp,1 # Increment sp sb $t0,0($t1) # Store current character in memory beq $t0, $0, L3 # If we get 0, we're done (We put 0 in stack for this check). addi $t1,$t1,1 # Next memory location j L2 L3: la $a0,msg # Print the reversed string li $v0,4 syscall la $a0,endl # Print "\n" li $v0,4 syscall li $v0,10 # Exit syscall