Question: Write a M.I.P.S program that asks user how many positive number that is devisable by 6 you want to add? //Part Missing in the code
Write a M.I.P.S program that asks user how many positive number that is devisable by 6 you want to add? //Part Missing in the code: when user is asked how many positive numbers you want to add, program should set a range a user can type such as a number between 1 and 20
.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 " Error2: .asciiz " is not in the range of 1 to 100. " Error3: .asciiz " is not a positive number " Error4: .asciiz " is not in the range of 1 to 20. " Result: .asciiz "The Sum of the positive numbers between 1 and 100 that are devisable by 6, is: " .text main: li $v0,4 la $a0, str1 syscall li $v0,4 la $a0, str2 syscall 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 beq $t0, 0, Eq 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 Eq: move $a2, $t0 la $a3, Error2 jal PrintError jal PrintNewLine b Here Lt: move $a2, $t0 la $a3, Error3 jal PrintError jal PrintNewLine b Here Gt: move $a2, $t0 la $a3, Error2 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 li $v0, 10 syscall 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
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
