Add character if equal after same MIPS

Asked

Viewed 24 times

1

I want to do a program in MIPS where after finding a vowel, add the following consonant to it.

For example, after a, add b, after and add f.

At the end it’s like this:

Word introduced: Olae

Final word: Olabef

This here is what I have, but it just replaces a letter and not 2...

.data
string: .asciiz "ola"

a: .ascii "a"
a1: .ascii "ab"

e: .ascii "e"
e1: .ascii "ef"

i: .ascii "i"
i1: .ascii "ij"

o: .ascii "o"
o1: .ascii "op"

u: .ascii "u"
u1: .ascii "uv"

tam: .word 3

.text 

main:
lw $t6, tam #string length
lb $t1, string($t0) #read bit by bit

lh $s0, a #save in register the char that we want to search
lh $s1, a1 #save in register the char that we want to replace


beq $t0, $t6, done

beq $t1, $s0, continua #if the char of (bit by bit) its like the char of         chars, swap it
bne $t1, $s0, else #if not, saves
else:
lb $s0, e
lhu $s1, e1

beq $t1, $s0, continua
bne $t1, $s0, else2

else2:  
lb $s0, i
lh $s1, i1

beq $t1, $s0, continua
bne $t1, $s0, else3

else3:  
lb $s0, o
lh $s1, o1

beq $t1, $s0, continua
bne $t1, $s0, else4                         

else4: 
lb $s0, u
lh $s1, u1

beq $t1, $s0, continua
bne $t1, $s0, store

continua:
la $a0, a
li $v0, 4
syscall
sb $s1, string($t0) #do the swap 
addi $t0, $t0, 1 #+1 in the index
j main 

store:
la $a0, a
li $v0, 4
syscall
sh $t1, string($t0) #saves
addi $t0, $t0, 1 #+1 in the index
j main
done:
li $v0, 10
syscall

Any hint?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.