Question: .data textout : .asciiz The program requests an input: .text main : # this is the start of the bit you're going to make into

.data

textout: .asciiz "The program requests an input:"

.text

main:

# this is the start of the bit you're going to make into a called procedure

# print text, get an input

la $a0 textout

li $v0 4

syscall

li $v0 5

syscall

move $s0, $v0 #copy the first value to $s0

#print out some more text, read in another value

li $v0 4

syscall

li $v0 5

syscall

move $s1, $v0# move result into $s1

add $s2 $s0, $s1 #add $s1 and $s2

#end of bit you need to make into a called procedure

#done

li $v0 10

syscall

Lab completion for today:

Make the relevant portion above into a called procedure. This relevant portion reads in two values ($s0 and $s1), and adds them up ($s2). So this procedure needs to push $s0, $s1 and $s2 onto the stack, read in two values, add them up, and then restore those $s0, $s1, and $s2 back to their original values).

To store values you need to get the stack pointer, then use sw to store the word

To restore values you need to get the stack pointer, and load the value, in the correct order, into the right location

USE MARS FOR THE CODING

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!