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
MakcuM [25]
4 years ago
13

Write a MIPS program to continuously generate the following series of integers: 1, 2, 3, 6, 9, 18, 27, 54, 81, and so on. Use st

andard MIPS programming conventions. Use the jump instruction to generate an infinite loop. Write a subroutine EVEN that returns a 1 if the argument is even, else it returns a 0. You must call this subroutine with jal and return from it with jr. The MIPS program must be converted into machine code and placed in the instruction memory. The sequence can be computed by adding the value to itself if it is odd and by adding the previous value to it if it is even. Before replacing the test program in the instruction memory, make sure that your design works for the provided Test-Program.
Computers and Technology
1 answer:
Pachacha [2.7K]4 years ago
3 0

Answer:

Explanation:

Here is a working solution in MIPS

.data

space: .asciiz ", "

.text

li $t1, 1       #Start at 1

li $t2, 1       #Store last value

li $t4, 1000    #terminate at 1000

li $t7, 2       #For division (divide by 2)

loop:

li $v0, 1

add $a0, $t1, $zero #print $t1

syscall

div $t1, $t7      #divide $t1 by 2

mfhi $t5          #get the remainder

move $t6, $t1     #hang on to what $t1 was originally

beqz $t5, even    #if the remainder is 0, it's even

add $t1,$t1,$t1    #it's odd, so add to itself

move $t2, $t6      #store what $t1 was originally to last value

bgt $t1, $t4, done #if the number is over 1000, we're done

li $v0, 4           #Print a comma and space

la $a0, space

syscall

j loop

even:

add $t1,$t1,$t2    #set $t1 = $t1 + Last value ($t2)

move $t2, $t6      #store what $t1 was originally to last value

bgt $t1, $t4, done #if the number is over 1000, we're done

li $v0, 4           #Print a comma and space

la $a0, space

syscall

j loop

done:

You might be interested in
What will be the value of x after the following code is executed? int x = 10; do { x *= 20; } while (x < 5); A. 10 B. 200 C.
dezoksy [38]

Answer:

Option B is the correct answer.

Explanation:

  • In the above code, the loop will execute only one time because the loop condition is false and it is the Do-While loop and the property of the Do-while loop is to execute on a single time if the loop condition is false.
  • Then the statement "x*=20;" will execute one and gives the result 200 for x variable because this statement means "x=x*20".
  • SO the 200 is the answer for the X variable which is described above and it is stated from option B. Hence it is the correct option while the other is not because--
  1. Option A states that the value is 10 but the value is 200.
  2. Option C states that this is an infinite loop but the loop is executed one time.
  3. Option D states that the loop will not be executed but the loop is executed one time
6 0
3 years ago
Read 2 more answers
Stay at least _____ behind the vehicle ahead of you at all times.
fenix001 [56]

Answer:

B 4 seconds

Explanation:

You should stay 4 seconds away from a vehicle at all times at the same speed as the other vehicle or vehicles.

6 0
3 years ago
Read 2 more answers
Without a/an ________. a computer is useless
Len [333]
Without a/an Operating system. a computer is useless
3 0
3 years ago
Mezcla de una señal con otra para facilitar su transporte o transmisión.
Brrunno [24]

Answer:

telecomunicaciones

Explanation:

6 0
3 years ago
Cerinţa
Firdavs [7]
Uummmm English please
4 0
3 years ago
Other questions:
  • Enter the number 2568 into the box below
    14·1 answer
  • Incident damage ____ is the rapid determination of the scope of the breach of the confidentiality, integrity, and availability o
    6·1 answer
  • What was the ENIAC computer and how was it used/what for?
    9·1 answer
  • Bran is writing a book on operation system errors. Help him complete the sentences.
    7·1 answer
  • Which of the following answers refers to a system containing mappings of domain names to various types of data, such as numerica
    15·1 answer
  • David owns a retail business that just implemented a web app to supplement sales. He needs to choose an attribution partner to i
    15·1 answer
  • The repeated use of electronic communications, such as chat rooms and email, to seek out, harass, or frighten someone is called
    12·1 answer
  • An administrator has created a new custom object in a sandbox environment and now is ready to deploy in production. How can the
    11·1 answer
  • What is the binary conversion of 179.187.223.21?
    11·2 answers
  • You are a software engineer at a company where management routinely encourages you and your colleagues to use pirated software.
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!