stalllucy
February 24th, 2009, 05:58 PM
HI everyone again...
I hava done a program simply counts the letters in a sentence (Code is below) and print out information about it.
MY PRINT OUT IS LIKE THIS
#######################
Message: "Hello World"
Vovwel analysis: =0, =1, =0, =2, =0
#######################
Vowel analysis part suppose tobe like this
Vovwel analysis: a=0, e=1, i=0, o=2, u=0
.....................
In my code i read all letters from
char: asciiz "aeiou"
and it needs to print it in sequence, here in my code i specify the place it needs to codes to be written...
I ve tride like that
move $a0, $t4
li $v0, 4
syscall
but it gives null
.text
.globl main
main:
li $t1,0
li $t2,0
li $t3,0
la $a0,prompt
li $v0,4
syscall
la $a0,str
syscall
la $a0,jump
syscall
la $a0,prompt2
li $v0,4
syscall
loopChar:
lb $t4,char($t3) # $t4 holds the next letter(a,e,u,i,o) to scan
#
li $t2,0 # After each letter, we need the clear memory
li $t1,0 # $t2 is holds the number of letter in sentence, $t1 each letter of sentence
#
beqz $t4,end
loop:
lb $t0,str($t1)
beqz $t0,print
bne $t0,$t4,con
add $t2,$t2,1
con:
add $t1,$t1,1
j loop
print:
# CODES NEED TO COME HERE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
la $a0,txt
li $v0,4
syscall
move $a0,$t2
li $v0,1
syscall
la $a0,txt2
li $v0,4
syscall
#
add $t3,$t3,1 # add 1 to array of char(a,e,i,o,u) before to move loopChar section
#
j loopChar
end:
li $v0,10 # (usual quit)
syscall
.data
str: .asciiz "Hello world"
#
jump: .asciiz "\n\n"
prompt: .asciiz "Messeage: "
prompt2: .asciiz "Vowel Anlyiys: "
#
char: .asciiz "aeiou"
#
txt: .asciiz "="
txt2: .asciiz ", "
I hava done a program simply counts the letters in a sentence (Code is below) and print out information about it.
MY PRINT OUT IS LIKE THIS
#######################
Message: "Hello World"
Vovwel analysis: =0, =1, =0, =2, =0
#######################
Vowel analysis part suppose tobe like this
Vovwel analysis: a=0, e=1, i=0, o=2, u=0
.....................
In my code i read all letters from
char: asciiz "aeiou"
and it needs to print it in sequence, here in my code i specify the place it needs to codes to be written...
I ve tride like that
move $a0, $t4
li $v0, 4
syscall
but it gives null
.text
.globl main
main:
li $t1,0
li $t2,0
li $t3,0
la $a0,prompt
li $v0,4
syscall
la $a0,str
syscall
la $a0,jump
syscall
la $a0,prompt2
li $v0,4
syscall
loopChar:
lb $t4,char($t3) # $t4 holds the next letter(a,e,u,i,o) to scan
#
li $t2,0 # After each letter, we need the clear memory
li $t1,0 # $t2 is holds the number of letter in sentence, $t1 each letter of sentence
#
beqz $t4,end
loop:
lb $t0,str($t1)
beqz $t0,print
bne $t0,$t4,con
add $t2,$t2,1
con:
add $t1,$t1,1
j loop
print:
# CODES NEED TO COME HERE!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
la $a0,txt
li $v0,4
syscall
move $a0,$t2
li $v0,1
syscall
la $a0,txt2
li $v0,4
syscall
#
add $t3,$t3,1 # add 1 to array of char(a,e,i,o,u) before to move loopChar section
#
j loopChar
end:
li $v0,10 # (usual quit)
syscall
.data
str: .asciiz "Hello world"
#
jump: .asciiz "\n\n"
prompt: .asciiz "Messeage: "
prompt2: .asciiz "Vowel Anlyiys: "
#
char: .asciiz "aeiou"
#
txt: .asciiz "="
txt2: .asciiz ", "