EEL 3801 Help solving this problem!! 1.) You are tasked to prompt the user to en
ID: 3559304 • Letter: E
Question
EEL 3801
Help solving this problem!!
1.) You are tasked to prompt the user to enter a string. The string consists of zero or more English words
separated by a space without punctuation. Your program should count the number of words, and display
this count to the console.
More formally, write MIPS assembly code in MARS to prompt and allow the user to enter a line of text.
The text entered will be a string of English words without punctuation, except for spaces between any
adjacent English words, along with a single period as the final character of the string. Count the number
of English words, and finally output this number in decimal on the console display.
2.) You are tasked to prompt the user to enter a string. The string consists of zero or more English words
separated by a space without punctuation. Your program should determine the Reading Level of the string
based on the number of letters in the longest word, according to the scale listed in Table 1.
More formally, write a MIPS assembly code in MARS to prompt and allow the user to enter a line of text.
The text entered will be a string of English words without punctuation, except for spaces between any
adjacent English words, along with a single period as the final character of the string. Count the number
of letters in each English word to identify the longest such word in the string. Calculate the Reading Level
according to Table 1 below and output this result on the console display.
Thanks ahead of time. Willing to show what code I have attempted if you would like to see.
Explanation / Answer
.data
mainPhrase1:
.asciiz "Enter a string of words (upto 100 characters including white spaces: "
inputbuffer:
.space 100
small:
.asciiz " Elementary Level "
medium:
.asciiz " High School Level "
large:
.asciiz " College Level "
words:
.asciiz " words "
rev:
.asciiz " case changed string: "
.text
li $v0, 4 # service 4 is print string
la $a0, mainPhrase1
syscall
li $v0, 8 # service 8 is read string
la $a0,inputbuffer
li $a1,100
syscall
li $t1,0
li $t2,0
li $t3,32 #ascii value of space
li $t5,10
li $t4,1
loop:
beq $a1,$0,end
lbu $t0,0($a0)
beq $t5,$t0 end
beq $0,$t0 end
beq $t0,$t3,newword
xori $t0,0x20
sb $t0,0($a0)
addiu $t2,$t2,1
addiu $a0,$a0,1
subiu $a1,$a1,1
b loop
end:
bgt $t1,$t2,loop1
move $t1,$t2
loop1:
li $v0, 1 # service 1 is print integer
add $a0,$t4,$0
syscall
li $v0, 4 # service 4 is print string
la $a0, words
syscall
li $v0, 1 # service 1 is print integer
move $a0,$t1
syscall
li $t3,4
bgt $t3,$t1 printsmall
li $t3,10
bgt $t3,$t1 printmedium
b printlarge
InfLoop : j InfLoop # stay here for infinite time
newword:
addiu $a0,$a0,1
bgt $t1,$t2,loop
move $t1,$t2
li $t2,0
addiu $t4,$t4,1
b loop
printsmall:
li $v0, 4 # service 4 is print string
la $a0, small
syscall
b InfLoop
printmedium:
li $v0, 4 # service 4 is print string
la $a0, medium
syscall
b InfLoop
printlarge:
li $v0, 4 # service 4 is print string
la $a0, large
syscall
b InfLoop
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.