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
NikAS [45]
4 years ago
7

Write a MIPS assembly language program that accomplishes the following tasks:The program will prompt the user to enter an intege

r k between 1 and 10. If the entered k is out of range just have the program exit. Depending on the k value implement the following cases:case 1: if 1 <= k < 5 Have n (n>= 0) be prompted from the user. compute Func(n): if (n = 0 or n = 1) then Func(n) = 20 else Func(n) = 5*Func(n-2) + n; Display a result_message together with the numeric value of the result. Repeat (meaning prompt the user for n)case 2: if 5 <= k <= 10 Display a joke. Your program should be well documented with comments. Your console output should include helpful prompts for the user.
Computers and Technology
1 answer:
Svetlanka [38]4 years ago
4 0

Answer:

Here's the code below

Explanation:

# All the comment will start with #

# MIPS is assembly language program.

# we store the all the data inside .data

.data:

k: .asciiz "Enter the kth value:\n"

.text

.globl main

li $s0, 0 # $s0 = 0

li $t0, 0 # $t0 = 0

la $n0, k # $n0 is kth value address

syscall # call print_string()

li $v0, 0 # $v0

syscall

move $n0, $v0 # $a0 = user input or "int n"

addi $sp, $sp, -4 # move the stack pointer down

sw $ra, 0 ($sp) # save the return address for main

jal fncheck # call fncheck(n);

fncheck:

beq $n, 0, fnfirst #if n==0 then fnfirst

beq $n, 0, fnfirst #if n==0 then fnfirst

ble $n0, 5, fnrec # if (n <=5) then 5

bge $n0, 5, fnjoke

#first function for n 0 and 1

fnfirst:

li $t0, 0 # initialize $t0 = 0

addi $t0, $t0, 20 # $t0 = 20

move $v0, $t0 # return 20

jr $ra

#function to execute 5*function1(n-2) + n;

fnrec:

sub $sp, $sp, 12 # store 3 registers

sw $ra, 0($sp) # $ra is the first register

sw $n0, 4($sp) # $n0 is the second register

addi $n0, $n0, -2 # $a0 = n - 2

jal function1

sw $v0, 8($sp) # store $v0, the 3rd register to be stored

lw $n0, 4($sp) # retrieve original value of n

lw $t0, 8($sp) # retrieve first function result (function1 (n-2))

mul $t0, $t0, 5 # $t0 = 5 * function1(n-2)

add $v0, $v0, $t0

lw $ra, 0($sp) # retrieve return address

addi $sp, $sp, 12

jr $ra

#function to print joke

fnjoke:

la "Joke section"

You might be interested in
In Microsoft Word, when you highlight existing text you want to replace, you are in
Lina20 [59]
The correct answer is C. Typeover mode

This is when you select a text and can then type over it and it automatically replaces it with what you're writing. It also creates a little box that lets you edit the selected part easily if that's what you need with things like bold or italic or change the text color.
4 0
3 years ago
All of the following are computer hardware servicing tools EXCEPT​
andrey2020 [161]

Answer:

Shovel

Explanation:

7 0
3 years ago
Which web design concept is most closely related to elements that symbolize the real world? A. node B. landmark c.metaphor IN D.
sergij07 [2.7K]

Answer:

landmark

Explanation:

6 0
3 years ago
What is the first step when creating a 3-D range name?
Airida [17]

Answer:

Open the Name Manager, and click New.

Explanation:

3 0
2 years ago
In 2004, ICQ users were enticed by a sales message from a supposed anti-virus vendor. On the vendor's site, a small program call
Elis [28]

Answer:

Trojan horse

Explanation:

Trojan, also known as Trojan horse is a type of malware that ensures that its users are misled of its true purpose. They are a common type of virus and are very dangerous in such a way that they can even hide within other programs that are harmless. Once installed, Trojan will infect every file on your computer and can even steal information or totally infiltrate your system.

8 0
3 years ago
Other questions:
  • WILL MARK BRAINLYIST
    15·2 answers
  • Chdtp aoxophg gr72 ae9&gt;3 zqqz
    12·1 answer
  • Which one of the following is an example of hacktivism according to you and why?
    11·1 answer
  • A certain database has numerous tables, but they do not share any fields in common. this database will not be as powerful as oth
    15·2 answers
  • Cliff just started working with a client who has a very disorganized AdWords account. What’s an effective way for him to begin r
    15·1 answer
  • Raul converts numbers in base 10 to base 2. Which answer best defends why Raul would need to do this?
    12·1 answer
  • The ________ identifies staff reaction and response times as well as inefficiencies or previously unidentified vulnerabilities.
    5·1 answer
  • A programmer needs to understand sequencing to determine whether the order of steps will affects the outcome of the program.
    11·1 answer
  • Sendddd meeeee memessss plsssssss
    8·2 answers
  • Which of the following is a method which can be used to delete a page from a publication?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!