Does anyone know how to do this? This is part of a homework assignement that I\'
ID: 3544787 • Letter: D
Question
Does anyone know how to do this? This is part of a homework assignement that I'm working on and I need major help. Here's how it works:
Write a MIPS program named that prints out the minimum of several integers entered by the user with each integer being 4-bytes. The program should prompt the user to enter the number of integers that will be entered, and then prompt for each of those integer numbers. It should then print out the minimum of the integers entered. You may assume that all user inputs are valid (i.e., no characters) and the user inputs at least one integer number.
Here is a sample tun of the expected program:
You must use appropriate and meaningful label names throughout the program. The program must also be generously commented on to receive full credit. Any nontrival line of assembly language code should be commented.
Explanation / Answer
please rate - thanks
.data
prompt: .asciiz "How many numbers do you have(must be at least 1)? "
result: .asciiz "The smallest number entered is: "
enter: .asciiz "Enter a number: "
.text
.globl main
main:
la $a0,prompt #ask how many numbers
li $v0,4
syscall
li $v0,5
syscall #get how many numbers
move $t1,$v0 #t1 is count
la $a0,enter #ask for and get 1st number
li $v0,4 #assume it is the smallest
syscall
li $v0,5
syscall
move $t2,$v0 #$t2 is smallest
loop:
addi $t1,$t1,-1 #more numbers?
beqz $t1,done #counter 0? if yes done
la $a0,enter #prompt for and get number
li $v0,4
syscall
li $v0,5
syscall
bge $v0,$t2,loop #new number not smallest go get next
move $t2,$v0 #new number is smallest, put it in t2
j loop
done:
la $a0,result #print results
li $v0,4
syscall
li $v0,1
move $a0,$t2
syscall
li $v0,10
syscall
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.