1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Norma-Jean [14]
3 years ago
12

(Assignment 1, individual) Create proc3.s Study the proc3.c and re-write the same program in MIPS with the following requirement

s: 1. Local variables mapping: a. main(): x -> $s0, y -> $s1 b. sum(): p -> $s0, q -> $s1 2. Input arguments mappings: a. sum(): m -> $a0, n-> $a1 b. sub(): a -> $a0, b-> $a1 3. All return values from a function must be stored in V registers in ascending order (i.e. $v0, $v1). 4. Use of stack memory according to register conven
Computers and Technology
1 answer:
Vedmedyk [2.9K]3 years ago
8 0

Answer:

text

.globl main

main:

li $s0,5 #load 5 to x

li $s1,10 #load 10 to y

move $a0,$s0

move $a1,$s1 #passing argument to sum function

jal sum

add $s1,$s1,$v0 #get y + sum(x,y)

add $s1,$s1,$s0 #get x+ y + sum(x,y)

li $v0,1

move $a0,$s1

syscall #print value of y

li $v0,10 #terminate call

syscall

sum:

addi $sp, $sp, 4

subu $sp,$sp,4 # point to the place for the new item,

sw $ra,($sp) # store the contents of $ra as the new top.

move $t1, $a0 #store parameters m

move $t2, $a1 #store parameters n

add $a0,$t2,1 #get n+1

add $a1,$t1,1 #get m+1

jal sub

move $t3,$v0 #store result to t3

sub $a0,$t1,1 #get m-1

sub $a1,$t2,1 #get n-1

jal sub

move $t4,$v0 #store result to t3

add $v0,$t3,$t4 #return p+q

lw $ra,($sp) # store the contents of $ra as the new top.

addu $sp,$sp,4 # point to the place for the new item,

addi $sp, $sp, 4

jr $ra

sub:

sub $v0,$a1,$a0 #return b-a

jr $ra

Explanation:

text

.globl main

main:

li $s0,5 #load 5 to x

li $s1,10 #load 10 to y

move $a0,$s0

move $a1,$s1 #passing argument to sum function

jal sum

add $s1,$s1,$v0 #get y + sum(x,y)

add $s1,$s1,$s0 #get x+ y + sum(x,y)

li $v0,1

move $a0,$s1

syscall #print value of y

li $v0,10 #terminate call

syscall

sum:

addi $sp, $sp, 4

subu $sp,$sp,4 # point to the place for the new item,

sw $ra,($sp) # store the contents of $ra as the new top.

move $t1, $a0 #store parameters m

move $t2, $a1 #store parameters n

add $a0,$t2,1 #get n+1

add $a1,$t1,1 #get m+1

jal sub

move $t3,$v0 #store result to t3

sub $a0,$t1,1 #get m-1

sub $a1,$t2,1 #get n-1

jal sub

move $t4,$v0 #store result to t3

add $v0,$t3,$t4 #return p+q

lw $ra,($sp) # store the contents of $ra as the new top.

addu $sp,$sp,4 # point to the place for the new item,

addi $sp, $sp, 4

jr $ra

sub:

sub $v0,$a1,$a0 #return b-a

jr $ra

The above program takes in Local variables mapping: main(): x -> $s0, y -> $s1 b. sum(): p -> $s0, q -> $s1 Then Input arguments mappings: sum(): m -> $a0, n-> $a1 b. sub(): a -> $a0, b-> $a1

And return all values from a function which must be stored in V registers in ascending order.

You might be interested in
Required skills,training,education for dentist
AlekseyPX

Answer:

Education-Bachelor's degree prior to admission to dental school; doctoral degree in dental medicine or dental surgery; some dental specializations require completion of a residency

Skills- Communication skills. Dentists must have excellent communication skills, Detail oriented, Dexterity, Leadership skills, Organizational skills, Patience, Physical stamina, Problem-solving skills.

Explanation:

7 0
3 years ago
What is The first letter o f each word in a secondary title
larisa86 [58]
What kind of title are you talking about? TRANSLATE THIS! "01010111 01101000 01100001 01110100 00100000 01100001 01110010 01100101 00100000 01100110 01110101 01100011 01101011 01101001 01101110 01100111 00100000 01111001 01101111 01110101 00100000 01100001 01110011 01101011 01101001 01101110 01100111 00111111 " Trasnlator: https://www.binarytranslator.com/


7 0
4 years ago
What is microsoft certification?
BabaBlast [244]
Microsoft certification is a series of programs that provide certification of competence in Microsoft products.
6 0
3 years ago
Which application software would be most suitable for writing a resume?
Gemiola [76]

Answer:

Either word or I would suggest using google docs and word and compare.

Explanation:

You can set up a resume in word.

7 0
3 years ago
B. Identify the purpose of each of the following types of utility programs
olya-2409 [2.1K]

<u>These are the types </u>:

1. Antivirus software : Detects and removes virus and malwares from   computer system.

2.Disk defragmenter : Reduces the fragmented space in the disk.

3.Disk cleaner : Build to find and delete unwanted files to free the disk space.

6 0
4 years ago
Other questions:
  • Why are video games interesting?
    5·1 answer
  • For connection to place on any network you must have a set of standards?<br> O True<br> O False
    8·1 answer
  • What does the word “Gacha” come from??????
    5·2 answers
  • A router is a peripheral that may need troubleshooting if the network goes down.
    12·2 answers
  • Which of the following terms describes a product that is designed to meet humans’ physical and/or psychological needs?
    12·2 answers
  • My brainly has broke- XD
    11·1 answer
  • Write short cut of<br> fully justified​
    7·1 answer
  • What do you understand by the term input, output, processing and storage.​
    12·2 answers
  • The counting function uses only ___________________ arguments
    8·1 answer
  • What are some of the key system-oriented trends that have fostered is-supported decision making to a new level?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!