subject

Subroutines in MIPS Determines the minimum of two integers Functions within the MIPS slides describe how one can use subroutines (also called procedures, functions, and methods) in MIPS. Because of the importance of subroutines in modern programming, most hardware designers include mechanisms to help programmers. In a high-level language like C or Java, most of the details of subroutine calling are hidden from the programmer. MIPS has special registers to send information to and from a subroutine. The registers $a0, $a1, $a2, $a3 are used to pass arguments (or parameters) into the subroutine. The registers $v0 and $v1 are used to pass arguments (or parameters) back from the subroutine. The stack (and stack pointer register $sp) is used for a variety of things when using subroutines. The stack is used to pass additional parameters to and from subroutines. It is also used to hold temporary values in memory that a subroutine may need. Most importantly, it is used to save the current state so the subroutine can return back to the caller once it has completed. This includes the frame pointer ($fp), the return address register ($ra), and the caller-saved registers ($s0-$s7). Imagine you would like a program that reads two integers from the user, determine the smaller of the two, then prints the minimum value. One way to do this would be to have a subroutine that takes two arguments and returns the smaller of the two. The program shown below illustrates one way to do this.

I need the code for the section prompted below:

## min_btw_2num. asm-- takes two numbers A and B
## Compare A and B
## Print out the smaller one
## Registers used:
## You can define by yourself!
.data
p1: .asciiz "Please enter the 1st integer: "
p2: .asciiz "Please enter the 2nd integer: "
.text
main:
# Get numbers from user
li $v0, 4 # Load 4=print_string into $v0
la $a0, p1 # Load address of first prompt into $a0
syscall # Output the prompt via syscall
li $v0, 5 # Load 5=read_int into $v0
syscall # Read an integer via syscall
add $s0, $v0, $zero # Copy from $v0 to $s0
li $v0, 4 # Load 4=print_string into $v0
la $a0, p2 # Load address of second prompt into $a0
syscall # Output the prompt via syscall
li $v0, 5 # Load 5=read_int into $v0
22
syscall # Read an integer via syscall
add $s1, $v0, $zero # Copy from $v0 to $s1
# Compute minimum
add $a0,$s0,$0 # Put argument ($s0) in $a0
add $a1,$s1,$0 # Put argument ($s1) in $a1
jal minimum # Call minimum function, result in $v0
# Output results
add $a0, $v0, $zero # Load sum of inupt numbers into $a0
li $v0, 1 # Load 1=print_int into $v0
syscall # Output the prompt via syscall
# Exit
li $v0, 10 # exit
syscall
# minimum function to compute min($a0, $a1):
||
|Put your code here|
||
return:

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 16:00
An english teacher would like to divide 8 boys and 10 girls into groups, each with the same combination of boys and girls and nobody left out. what is the greatest number of groups that can be formed?
Answers: 2
question
Computers and Technology, 24.06.2019 09:30
What is the definition of digital literacy?
Answers: 1
question
Computers and Technology, 24.06.2019 11:40
100 pts. first person gets brainliest
Answers: 2
question
Computers and Technology, 24.06.2019 13:00
Which one of the following functions is not available on the autosum tool? sum average if max
Answers: 3
You know the right answer?
Subroutines in MIPS Determines the minimum of two integers Functions within the MIPS slides describe...
Questions
question
Mathematics, 11.02.2021 23:30
question
Mathematics, 11.02.2021 23:30
Questions on the website: 13722367