Click to See Complete Forum and Search --> : help!what's wrong with this code?


v1ru5
March 23rd, 2006, 12:24 AM
#Output format must be:
#"answer = CAGEKI"
############################################
# text segment #
############################################
.text


.globl __start

main:




#-------------------Start Cut------------------------
la $a1, chararray # &chararray
li $t4,3



loop:
lb $t0, 0($a1)
lb $t1, 1($a1)

sb $t0, 1($a1)
sb $t1, 0($a1)

addiu $t0, $t0, -32
addiu $t1, $t1, -32
addi $t4,$t4,-1

bnez $t4,loop #branch to loop if not at end of string



la $a0, ans #print string before result

li $v0,4
syscall


move $a0,$a1 #print result

li $v0,4
syscall

li $v0, 10
syscall










#-------------------End Cut--------------------------




#############################################


# data segment #


#############################################



.data


chararray: .asciiz "acegik"


ans: .asciiz "answer="


endl: .asciiz "\n"


#End of file



the output must be CAGEKI, all uppercase
no idea how to do it :(