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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started