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

# 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.

1-Type and execute the code in following program, record the value of each register. 2- Discuss the importance and value of register sv0 in using syscall. 3- Write a program in mips assembly that will prompt the user to enter his/her name and then print it out.

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.