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]
3 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]3 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
Which term is used to identify the connection of computers that are physically close to one another?
marta [7]

Answer: Local Area Network (LAN)

Explanation:

A Local Area Network (LAN) is a computer network that interconnects computers within a limited physical area such as a residence, school, laboratory, university campus or office building.

An example of  LAN network is "Phone, Computer and TV connected to a single network (such as a Home Network) via Cables, Wifi, Bluetooth or Hotspot". When the devices are interconnected or connected to a LAN, it becomes accessible between each other.

A simplest example of a LAN Device is a <em>Home Router.</em>

6 0
3 years ago
Read 2 more answers
What are the two ways to print a document?
guajiro [1.7K]

Answer:

ctrl+p or find the print button on the page

5 0
3 years ago
Which of the following is an example of how the healthcare industry uses computer programming? (5 points)
IgorC [24]
3-D prosthetics would most likely be the answer, also, don’t copy links it’s most likely not the answer anyways.
5 0
2 years ago
Uso de las redes sociales como el uso de una impresora en casa se satisfacen estás tres etapas
Svetradugi [14.3K]

Question: what question is this?

7 0
2 years ago
What is the storage of a modern hard disk drive?
Alinara [238K]

Answer:

80 gigs of storage

Explanation:

it gives a bunch of room because of the calculations the vomputer

3 0
3 years ago
Other questions:
  • Drag the tiles to the correct boxes to complete the pairs.
    7·2 answers
  • Software that people commonly use in the workplace to make their lives easier is called
    5·1 answer
  • Alcohol damages your __________, making it more difficult to understand how far away other objects are.
    14·1 answer
  • Does anybody know if that apple watch is actually worth what it costs?
    9·2 answers
  • The text defines ________________ as the obsessive use of computers, or the unauthorized access and use of networked computer sy
    14·1 answer
  • Create an application named Percentages whose main() method holds two double variables. Assign values to the variables. Pass bot
    14·1 answer
  • What is emerging as a major business area of innovation that offers a flexible collection of computers on the internet that can
    6·1 answer
  • Write a program great_circle.python that takes four float arguments x1 y1 x2 y2
    15·1 answer
  • Hey should I get a r()blox gift card if so what amount 5 dollars 10 or 100
    14·1 answer
  • What is the initial step to exploring solutions to a problem?
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!