the task is to randomly change around the middle characters of a word but keep the first letter and the last letter in the same place. i'm new to mips and am finding this quite difficult. here's what i have so far, it rearranges the word whilst keeping the last letter intact but i dont know how to keep the first letter in the same place? any help would be much appreciated. thanks
.data
String: .asciiz "library\n" length: .word 7
.text
.globl main
main: lw $t0, length
jal print
j exit
print: la $a0,String li $v0,4 syscall bgtz $t0, MoveString jr $ra
MoveString: lb $t1, String li $t2, 0 move $a1, $a0 lb $t3, length sub $t3, $t3, 2
MoveStringLoop:
lb $t4, 1($a1)
sb $t4, 0($a1)
add $a1, $a1, 1
add $t2, $t2, 1
blt $t2, $t3, MoveStringLoop
sb $t1, 0($a1)
sub $t0, $t0, 1
b print
exit: li $v0, 10 syscall
Aucun commentaire:
Enregistrer un commentaire