Can someone try to fix this code ?? Thank you. .data Prompt: .asciiz \"How many
ID: 3883936 • Letter: C
Question
Can someone try to fix this code ?? Thank you.
.data
Prompt: .asciiz "How many positive number that is devisable by you want to add? "
Prompt1: .asciiz "Enter a number: "
NewLine: .asciiz " "
Error: .asciiz "****Error: "
Success: .asciiz " is divisible by 6"
Fail: .asciiz " is not divisible by 6"
RestMessage: .asciiz " is not in the range of 1 to 100."
RestMessage1: .asciiz " is not a positive number"
Result: .asciiz "The Sum of the positive numbers between 1 and 100 that are devisable by 6, is: "
.text
Main:
addi $t6, $zero, 6
la $a0, Prompt
addi $v0, $zero, 4
syscall
addi $v0, $zero, 5
syscall
jal PrintNewLine
move $s0, $v0
addi $s1, $zero, 0
Loop:
la $a0, Prompt1
addi $v0, $zero, 4
syscall
addi $v0, $zero, 5
syscall
move $t0, $v0
blt $t0, 0, Lt
bgt $t0, 100, Gt
Else: div $t0, $t6
mfhi $t1
bne $t1, 0, No
Yes: add $s1, $s1, $t0
add $s0, $s0, 1
move $a2, $t0
jal PrintSuccess
jal PrintNewLine
b End
No: move $a2, $t0
jal PrintFail
jal PrintNewLine
End:
b Here
Lt: move $a2, $t0
la $a3, RestMessage1
jal PrintError
jal PrintNewLine
b Here
Gt: move $a2, $t0
la $a3, RestMessage
jal PrintError
jal PrintNewLine
Here:
addi $s0, $s0, -1
bne $s0, 0, Loop
la $a0, Result
addi $v0, $zero, 4
syscall
move $a0, $s1
addi $v0, $zero, 1
syscall
addi $v0, $zero, 10
syscall
PrintError: la $a0, Error
addi $v0, $zero, 4
syscall
move $a0, $a2
addi $v0, $zero, 1
syscall
move $a0, $a3
addi $v0, $zero, 4
syscall
jr $ra
PrintSuccess: move $a0, $a2
addi $v0, $zero, 1
syscall
la $a0, Success
addi $v0, $zero, 4
syscall
jr $ra
PrintFail: move $a0, $a2
addi $v0, $zero, 1
syscall
la $a0, Fail
addi $v0, $zero, 4
syscall
jr $ra
PrintNewLine: la $a0, NewLine
addi $v0, $zero, 4
syscall
jr $ra
Explanation / Answer
I have modified the code with a new code.
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.