Gnome_101 0 Light Poster

Hey all,

I've got the following program which needs to print the original string, then the edited one. ( we are to replace the lower case b's with B's)

.data
 prompt: .asciiz "baseball"
 length: .asciiz "The length of the string is (in hex) "
.text
 .globl main

main:
la $a0,prompt
addi $t2,98
addi $v0,4
syscall

check:
 lb $t0,0($a0)
 addi $a0,$a0,1							 # add one to base
 
 beq $t0,$t2,replace
check2:
 jal store
 beq $t0,$zero,exit
 addi $t1,$t1,1							 #counter for length
 j check

replace:
 
 addi $t0,$t0,-20
 j check2 
 
store:
 addi $sp,$sp,-1 
 sb $t0,0($gp)							   #pop values into memory
 jr $ra

printit:
 
 lb $a0,0($sp)							   # loads the fist value into $s0
 sub $v0,$v0,$v0 	   #clear $v0
 
 add $v0,4								   # set for print sting
 syscall
 addi $t3,$t3,1
 addi $sp,$sp,1
 
 bne $t3,$t1,printit 
 jr $ra

exit:
 jal printit
 sub $v0,$v0,$v0
 addi $v0,10
 syscall #exit sys call

This code will run, but when it gets to printing the bytes it prints (null)

Can anyone help?

thanks
Gnome

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.