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
netineya [11]
3 years ago
10

Write a MIPS assembly language program that prompts for a user to enter how many floating point numbers to enter, then prompts t

o enter a series of floating point numbers and reads in numbers and store them in an array, then prints the original content of the array. Then it repeats it for a second array, and compare numbers from two arrays, and if a number in the first array is larger than the number of the second array of the same index, it swaps them. Then it should print the result contents for both arrays.
Computers and Technology
1 answer:
Natalija [7]3 years ago
5 0

Answer:

See explaination

Explanation:

.data

arraysize: .word 10

counter: .word 1

alreadystored: .word 0

num: .space 40 # reserve 40 bytes from the starting address of array

inputmsg: .asciiz "Enter a floating point number:\n"

outputmsg: .asciiz "The array contains the following numbers: \n"

.text

.globl main

main:

lw $t1, counter #counter

lw $t2, arraysize #max length of array

la $t0, num # base address of the array

#set initial flag for duplicate array element 0=entered value not present in array,1= entered value exists in array

li $t3,0 #reset the flag for alreadystored to 0

Loop 1:

# print input message prompt

la $a0, inputmsg

li $v0, 4

syscall

# get user entered keyboard input

li $v0, 6

syscall

# move user entered value from $f0 to array base address

s.s $f0, 0($t0)

#load the value at address pointed by $t0 to register $f1

l.s $f1,0($t0)

#compare the entered value in register $f0 to the value stored in $f1

c.eq.s $f1,$f0

#jump to loop2 if the values are not equal ie if the entered value is not duplicate then increment the array index and compare with next array element

bc1f loop2

#else make the value of flag alreadystored =1

li $t3,1

# if no duplicate then move to the next position in the array, increment loop counter

loop2:

addi $t0, $t0, 4

addi $t1, $t1, 1

ble $t1, $t2, Loop1

# reset loop counter, and array address for printing out the array elements

lw $t1,counter

la $t0, num

# print output message prompt

la $a0, outputmsg

li $v0, 4

syscall

print_array:

# print array elements

l.s $f12, 0($t0)

li $v0, 2

syscall

# print space

la $a0, 32

li $v0, 11

syscall

# increment loop counter and move to next array element

addi $t1, $t1, 1

addi $t0, $t0, 4

ble $t1, $t2, print_array

#Exit

li $v0,10

syscall

You might be interested in
There exists a data type Date with member function Increment that increments the current Date object by one. The ++ operator is
nalin [4]

Answer:

Date Date::operator++( int )

{

Date temp = *this;

Increment();

return temp;

}

Explanation:

Of options 1 through 4, only option 4 correctly implement the post increment of the ++ operator.

Interpreting each line of option for and comparing it to other options

Line 1: Date Date::operator++( int )

This declares the data type and its ++ operator

This is same for all options

Line 2: The Date type needs to be declared

In option 4, it was declared correctly as Date temp = *this;  using a pointer variable *this.

Here, option 2 is removed from the list of possible options.

Comparing other options

Line 3: The member increment option needs to be declared after the declaration of the date type variable.

This is correctly declared as Increment();  in option 4

Here, option 3 is removed from the list of possible options.

Comparing other options

Line 4: The value declared variable temp needs to be returned the way it was declared (without pointer indicator)

Hence, option 4 is best appropriate

3 0
3 years ago
What data unit is encapsulated inside a packet?
viva [34]

Answer: datagram

Explanation:

7 0
3 years ago
Read 2 more answers
Which components are involved with input? Output? Processing? Storage?
VMariaS [17]

Answer: Output

input keyboard mouse joystick graphics tablet trackball touchpad touchscreen microphone sensor      

Processing     processor (CPU) processor (GPU) memory motherboard

Output printer monitor touchscreen plotter speakers headphones motor data projector

Explanation:

5 0
2 years ago
Read 2 more answers
Create a lottery game application. Generate three random numbers (see Appendix D for help in doing so), each between 0 and 9. Al
Pachacha [2.7K]

The question is not complete! Here is the complete question and its answer!

Create a lottery game application. Generate three random numbers (see Appendix D for help in doing so), each between 0 and 9. Allow the user to guess three numbers. Compare each of the user’s guesses to the three random numbers and display a message that includes the user’s guess, the randomly determined three-digit number, and the amount of money the user has won as follows:

no matches: 0

any one matching: 10$  

two matching: 1000$  

three matching: 100000$  

Code with Explanation:

#include <iostream>

using namespace std;

int main()

{

int matches=0;

int guess_1, guess_2, guess_3;

int num_1, num_2, num_3;

// get 3 digits from the user

cout<<"Enter first guess digit 0 to 9"<<endl;

cin>>guess_1;

cout<<"Enter second guess digit 0 to 9"<<endl;

cin>>guess_2;

cout<<"Enter third guess digit 0 to 9"<<endl;

cin>>guess_3;

// every time program runs srand() generates new random numbers and rand()%10 makes sure that number is single digit 0 to 9

srand(time(NULL));

num_1=rand()%10;

cout<<"First lottery digit: "<<num_1<<endl;

num_2=rand()%10;

cout<<"Second lottery digit: "<<num_2<<endl;

num_3=rand()%10;

cout<<"Third lottery digit: "<<num_3<<endl;

// store random generated numbers and guess numbers in arrays to compare them

int num[3]= {num_1,num_2,num_3};

int guess[3]={guess_1,guess_2,guess_3};

// compare the arrays to find out how many are matching

   for(int i=0; i<3; i++)

   {

 for(int j=0; j<3; j++)

 {

  if(num[i]==guess[j])

  {    

   matches = matches + 1;

  }

 }

}

cout << "Total Matches are: " <<matches << endl;

// display reward according to the number of matches

if (matches==0)

cout<<"you won: $0"<<endl;

if (matches==1)

cout<<"you won: $10"<<endl;

if (matches==2)

cout<<"you won: $1000"<<endl;

if (matches==3)

cout<<"you won: $100000"<<endl;

return 0;

}

Output:

Enter first guess digit 0 to 9

7

Enter second guess digit 0 to 9

1

Enter third guess digit 0 to 9

5

First lottery digit: 3

Second lottery digit: 7

Third lottery digit: 2

Total Matches are: 1

You won: $10

Enter first guess digit 0 to 9

7

Enter second guess digit 0 to 9

3

Enter third guess digit 0 to 9

4

First lottery digit: 5

Second lottery digit: 4

Third lottery digit: 7

Total Matches are: 2

You won: $1000

5 0
3 years ago
Machine code and Object code is the same right?​
guapka [62]

Answer:

"True" Machine code and Object code is the same.

Explanation:

All code at the same level is considered the same code, so we can say that the machine code, byte code, and the object code with it is of the same type, all of which are considered as the lowest level associated with the common program, these are common. Also known as source code because it is used in translating different languages.

6 0
3 years ago
Other questions:
  • Which functions are performed by server-side code??​
    10·1 answer
  • Which Access database object asks a question about the data stored in a database and displays specific fields and records that a
    15·1 answer
  • What is computing networking​
    5·1 answer
  • Which of the following is a correct definition of the term rectification? A. Rectification is the opposition to current flow in
    14·2 answers
  • Which fingers should you use to type the reach keys?
    12·1 answer
  • Write a program that displays in the title of the window the position of the mouse as the user moves the mouse around the window
    5·1 answer
  • How does light move? Shift? Bounce between different objects?
    9·1 answer
  • One lap around a standard high-school running track is exactly 0.25 miles. Write a program that takes a number of miles as input
    12·1 answer
  • A period in which unemployment is low, business produces many goods and services, and wages are good is called ______.
    8·1 answer
  • Select all correct statements below: Group of answer choices A redundant link's switch port will be blocked by STP until needed.
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!