# Used in assignment 4 # Registers used: $t0 - used to hold the first number. -
ID: 2079730 • Letter: #
Question
# Used in assignment 4
# Registers used: $t0 - used to hold the first number.
- used to hold the second number.
- used to hold the difference of the $t1 and $t0. - syscall parameter and return value.
- syscall parameter.
.text
main:
## Get first number from user, put into $t0.
# load syscall read_int into $v0. # make the syscall.
# 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.
move $t1, $v0 # move the number read into $t1.
sub $t2, $t0, $t1 # compute the difference.
## Print out $t2.
move $a0, $t2 # move the number to print into $a0. li $v0, 1 # load syscall print_int into $v0. syscall # make the syscall.
li $v0, 10 # syscall code 10 is for exit.
syscall # make the syscall.
# end of ex2.asm.
Explanation / Answer
2.)Step 1. Load the service number in register $v0.
Step 2. Load argument values, if any, in $a0, $a1, $a2, or $f12 as specified.
Step 3. Issue the SYSCALL instruction.
Step 4. Retrieve return values, if any, from result registers as specified.
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.