Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hi can i get help with this assemply language code. ############################

ID: 3870548 • Letter: H

Question

Hi can i get help with this assemply language code.

###########################################################

# Program Description

Write a program using MIPS instruction set that will read a series of even non-negative integers (greater than or equal to zero) one by one until either the total count of valid numbers read becomes 10 or user has entered a cardinal value ( -9). At the end, the program will print the sum of the valid numbers read, total count of valid numbers read and the integer average of the valid numbers read. It will store these three integers in named static variables before the program ends. If an invalid number is entered the program will ignore it and print an error message.

###########################################################

# Register Usage

# $t0=0 #valid num

# $t1 #sum of the valid num

# $t2 #total count of valid num

# $t3 #integer average of valid num

# $t4

# $t5

# $t6

# $t7

# $t8

# $t9

###########################################################

.data

num_p: .asciiz "input the num"

sum_p: .asciiz "Input the sum of the num"

total_p: .asciiz ""

average_p: .asciiz ""

error_p: .asciiz ""

###########################################################

.text

main:

input_num:

li $v0, 4 #prompt for number

la $a0, num_p

syscall

li $v0, 5 #input num

syscall

bgtz $v0, valid_num # branch to valid with if $v0 > 0

li $v0, 4 # otherwise print error msg

la $a0, error_p

syscall

b input_num # branch to input_ num re-enter

valid_num:

move $t0, $v0 # move valid num to $t0

input_sum:

li $v0, 10 #End Program

syscall

###########################################################

Explanation / Answer

Any further help.Please comment.I will try to help you.Thank you

MIPS CODE:-

###########################################################

# Register Usage

# $t0=0 #valid num

# $t1 #sum of the valid num

# $t2 #total count of valid num

# $t3 #integer average of valid num

# $t4

# $t5

# $t6

# $t7

# $t8

# $t9

###########################################################

.data

num_p: .asciiz "input the num"

sum_p: .asciiz "Input the sum of the num"

total_p: .asciiz "The sum of valid numbers is :"

average_p: .asciiz "The average of the valid numbers is:"

error_p: .asciiz "Invalid number Please try again"

###########################################################

.text

main:

li $t4,10 #loop counter

li $t2,0 #sum intialized with zero

li $t5,-9

input_num:

be $t4,$0,LOOP_END #condition for loop

li $v0, 4 #prompt for number

la $a0, num_p

syscall

li $v0, 5 #input num

syscall

bgtz $v0, valid_num # branch to valid with if $v0 > 0

be $v0,$t5,LOOP_END

li $v0, 4 # otherwise print error msg

la $a0, error_p

syscall

b input_num # branch to input_ num re-enter

valid_num:

move $t0, $v0 # move valid num to $t0

input_sum:

add $t1,$t1,$t0

addi $t2,$t2,1

addi $t4,$t4,-1

b input_num # branch to input_num for entering next number

LOOP_END:

li $v0, 4 # print the total

la $a0, total_p

syscall

li $v0,1

addi $a0,$0,$t1

syscall

div $t1,$t2

mflo $t3 # quotient to $t3 which contains the integer average

li $v0, 4 # print the average

la $a0, average_p

syscall

li $v0,1

addi $a0,$0,$t3

syscall

li $v0, 10 #End Program

syscall

###########################################################

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote