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]
3 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]3 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
Why do Selection Sort and Insertion Sort’s outer loops run 11 iterations if there are 12 elements in the array?
laiz [17]

Answer:

The final case in selection sort is trivially sorted.

The final iteration in insertion sort is not needed.

Explanation:

For selection sort, you make sub arrays and find the smallest element placing it in the front and repeat until sorted.  This guarantees the final element will already be the greatest element, thus it is trivially sorted.

For Insertion sort, you use the initial element and compare it to the previous element and swap if the current is larger than the previous.  Using this sort, you will always perform n-1 comparisons where n is the total amount of elements in the array.  Thus, there are only 11 iterations for a 12 element array.

Cheers.

3 0
3 years ago
Two types of business communications enhanced by desktop publishing are
Likurg_2 [28]
The correct option is D.
The two types of business communication that are enhanced by desktop publishing are internal and external communication. Internal communication refers to the information and ideas that are exchange within the organisation while external communication refers to information and ideas that are exchange between the organisation and the outside world.<span />
4 0
3 years ago
Read 2 more answers
You develop an app, and you don't want anyone to resell it or modify it. This is an example of: A an operating system. B open so
Mars2501 [29]
The answer is C. Proprietary software is when the publisher reserves rights from licensees to modify or share the software.
5 0
3 years ago
Read 2 more answers
In microsoft word, when you highlight existing text you want to replace you are
RSB [31]
You are changing the word
8 0
3 years ago
Where is voice data stored in Android?
Dafna1 [17]
Inside its internal hard-drive and your google account!
8 0
3 years ago
Other questions:
  • Suppose a computer can execute 1 billion instructions/sec and that a system call takes 1000 instructions, including the trap and
    10·1 answer
  • Ooooooooooooooooooooooooooooh im blinded by the lightssssssssss
    11·1 answer
  • _____ documentation is designed to help programmers and systems analysts understand the application software and maintain it aft
    12·1 answer
  • Which following is one of the basic characters of object-oriented systems : Select one: a. process b. data c. module d. inherita
    6·1 answer
  • A(n) ____ instruction might look like a meaningless string of 0s and 1s, but it actually represents specific operations and stor
    9·1 answer
  • , 13 dB correspond to a power ratio of ....?
    14·1 answer
  • Multiple Choice: We have been assigned the task of developing a software testing tool (tester) that can assess reachability of s
    11·1 answer
  • Write a function solution that, given an array A consisting of N integers, returns the number of fragements of A whose sum equal
    9·1 answer
  • When must an Assured Equipment Grounding Conductor Program (AEGCP) be in place?
    13·1 answer
  • How many 60 KB jpeg files can be stored on a 2 MB folder in your hard drive?​
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!