Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Modify larger.s to let the user to enter three numbers and output the largest value # larger.s-- prints the larger of two numbers specified

1. Modify larger.s to let the user to enter three numbers and output the largest value

# larger.s-- prints the larger of two numbers specified # at runtime by the user. # Registers used: # $t0 - used to hold the first number. # $t1 - used to hold the second number. # $t2 - used to store the larger of $t1 and $t2. # $v0 - syscall parameter and return value. # $a0 - syscall parameter. .text

main: ## Get first number from user, put into $t0. li $v0, 5 # load syscall read_int into $v0. syscall # make the syscall. add $t0, $v0, $zero # move the number read into $t0.

## Get second number from user, put into $t1.

li $v0, 5 # load syscall read_int into $v0. syscall # make the syscall. add $t1, $v0, $zero # move the number read into $t1.

## put the larger of $t0 and $t1 into $t2.

slt $t2, $t0, $t1 # If $t0 < $t1, $t2 is 1, bne $t2, $zero,First # if $t2 is 1, go to First add $t2, $t0, $zero j Print # copy $t0 into $t2 First: add $t2, $t1, $zero

## Print out $t2.

Print: add $a0, $t2, $zero # move the number to print into $a0. li $v0, 1 # load syscall print_int into $v0. syscall # make the syscall.

## exit the program.

li $v0, 10 # syscall code 10 is for exit. syscall # make the syscall.

# end of larger.s

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Professional Microsoft SQL Server 2012 Administration

Authors: Adam Jorgensen, Steven Wort

1st Edition

1118106881, 9781118106884

More Books

Students also viewed these Databases questions

Question

=+such as the dirigenti in Italy?

Answered: 1 week ago

Question

=+ Are there closed-shop requirements or practices?

Answered: 1 week ago