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]
2 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]2 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
To find your personal learning style you can
JulsSmile [24]
Https://simplelifestrategies.com/sls-learningstyle/ this list may help ypu decide
6 0
3 years ago
Read 2 more answers
a printer's accessory list includes a maintenance kit with a variety of replaceable parts you should install after 100,000 pages
Triss [41]

Answer:

Laser printer

Explanation:

This is a guess based on experience, but laser printers have rollers, drums, and other various parts that need periodic replacement.

See page 87 of https://www.laserpros.com/img/manuals/hp-manuals/hp-lj-4100-manual.pdf for an example.

4 0
1 year ago
List safety conditions when downloading shareware, free free where, or public domain software
Anit [1.1K]

Answer:

Explanation:

Freeware and shareware programs are softwares which are either free of charge or consist of a free version for a certain trial period. These programs pose a threat of habouring malware or viruses which could damage one's computer and important files and programs. Therefore, it is imperative that carefulness is maintained when trying to get these softwares.

Some of the necessary safety conditions that should be taken include;

1) Appropriate research about the software including taking more about the vendors and reviews.

2.) Once, a healthy review has been identified ; the download can begin with the Downloader ensuring that the download is from the recommended site.

3) Prior to installation the software should be scanned with an active anti-virus program to determine if there is possibility that a virus has creeped in.

4.) Some softwares may require that computer anti-virus be turned off during installation, this is not always a good idea as this act leaves the system vulnerable a d badly exposed.

6 0
2 years ago
Coupon collector is a classic statistic problem with many practical applications. The problem is to pick objects from a set of o
ahrayia [7]

Answer:

Here is the JAVA program:

public class Main {  //class name

public static void main(String[] args) {   //start of main method

//sets all boolean type variables spades, hearts diamonds and clubs to false initially

   boolean spades = false;  

   boolean hearts = false;

   boolean diamonds = false;

   boolean clubs = false;  

   String[] deck = new String[4];  //to store card sequence

   int index = 0;  //to store index position

   int NoOfPicks = 0;  //to store number of picks (picks count)

   while (!spades || !hearts || !diamonds || !clubs) {   //loop starts

       String card = printCard(getRandomCard());  //calls printCard method by passing getRandomCard method as argument to it to get the card

       NoOfPicks++;   //adds 1 to pick count

       if (card.contains("Spades") && !spades) {  //if that random card is a card of Spades and spades is not false

           deck[index++] = card;  //add that card to the index position of deck

           spades = true;  //sets spades to true

       } else if (card.contains("Hearts") && !hearts) {  //if that random card is a card of Hearts and hearts is not false

           deck[index++] = card;  

           hearts = true;   //sets hearts to true

       } else if (card.contains("Diamond") && !diamonds) {  //if that random card is a card of Diamond and diamonds is not false

           deck[index++] = card;

           diamonds = true;  //sets diamonds to true

       } else if (card.contains("Clubs") && !clubs) {  if that random card is a card of Clubs and clubs is not false

           deck[index++] = card;

           clubs = true;         }     }   //sets clubs to true

   for (int i = 0; i < deck.length; i++) {  //iterates through the deck i.e. card sequence array

       System.out.println(deck[i]);     }  //prints the card number in deck

   System.out.println("Number of picks: " + NoOfPicks);  }   //prints number of picks

public static int getRandomCard() {  //gets random card

   return (int) (Math.random() * 52); }   //generates random numbers of 52 range

public static String printCard(int cardNo) {   //displays rank number and suit

   String[] suits = { "Spades", "Hearts", "Diamonds", "Clubs", };  //array of suits

   String[] rankCards = { "Ace", "2", "3", "4", "5", "6", "7", "8", "9", "10",

           "Jack", "Queen", "King" };   //array of rank

  int suitNo = cardNo / 13;  //divides card number by 13 and stores to suitNo

 int rankNo = cardNo % 13;   //takes modulo of card number and 13 and store it to rankNo

   return rankCards[rankNo] + " of " + suits[suitNo];  }}  //returns rankCard at rankNo index and suits at suitNo index

Explanation:

The program is explained in the comments attached with each line of code. The screenshot of the program along with its output is attached.

8 0
3 years ago
"in program arrays12.java a swap method is called. does the swap method exchange parameter values x and y?"
horrorfan [7]
<h2>Yes the swap method exchange parameter values if passed by reference or the value gets changed inside the function.</h2>

Explanation:

Since the program is not given, I will try to guide you about the mode of parameters.

The meaning of swap is interchanging the values. It can be done by using temporary variable or without using it (if the values are integers).

While passing the parameters, there are two ways, call by value/pass by value and call by reference/ pass by reference.

If call by value, then the value gets swapped only inside the function and will not reflected in the calling portion. Call by reference is other way round.

6 0
3 years ago
Other questions:
  • Demonstrate your grasp of the Unix file system by constructing a directory structure as follows: In your home ( ~ ) directory, c
    11·1 answer
  • Which of the following decimal (base-10) values is equivalent to the binary (base-2) value 101001?
    15·1 answer
  • What command would you use to list the text files in your
    7·1 answer
  • 8. A pattern of being late for work or for appointments is usually
    12·1 answer
  • What are some fun games to play on you phone?
    12·2 answers
  • Given the following sets, for each set operation provide the elements of the resulting set in set notation or using a well-known
    5·1 answer
  • Light is a key formal element that film artists and technicians carefully manipulate to create mood, reveal character, and conve
    15·1 answer
  • Suppose a process in Host C has a UDP socket with port number 6789. Suppose both Host A and Host B each send a UDP segment to Ho
    8·1 answer
  • Each of these is a step in cEach of these is a step in conflict resolution: Evaluate solutions suggested. Define the problem. De
    7·1 answer
  • When an organizatin needs a program to do a very specific job, it mayhire someone to write _____ software.​
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!