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 symbol is used for an assignment statement in a flowchart?
Pavlova-9 [17]

Equal symbol

equal symbol

Within most programming languages the symbol used for assignment is the equal symbol.

4 0
3 years ago
Very few games have any sort of narrative, not even a simple one that involves setting the mood through color, sound, environmen
Vladimir79 [104]

Answer:

B. False

Explanation:

Numerous amount of games have narrative, there is an entire genres built around narratives. Any RPG game has a narrative and even bog standard FPS games have some sort of backstory and effects setting a mood.

6 0
2 years ago
After sending input in the Chinese language to an AI system, Nina got numerous translations in the English language. Which chall
ad-work [718]

Answer:

i think its translation complexity

Explanation:

8 0
3 years ago
What's the best way to change the font size of all your notes pages at once?
pav-90 [236]

i think number 9 is c.

5 0
3 years ago
Which of the following careers is part of the Printing Technology pathway?
torisob [31]
Textile designer i think

6 0
3 years ago
Other questions:
  • An iPad Is An Example Of Which Type Of Computer?
    11·2 answers
  • What is the term for sending emails that imitate legitimate companies?
    6·2 answers
  • 6. While using the HTS, ________________ will help maintain a safe driving environment despite high speeds and a large number of
    12·1 answer
  • What are the top and side margins for a letter typed in standard format?
    5·1 answer
  • function calculate () { var s = 2; var x = 2; var y = 3; if (x &gt; 4) { s=s+ 2; } else if ( y &gt; 4) { s=s+ 4; } else { s+=3;}
    11·1 answer
  • The variable planet_distances is associated with a dictionary that maps planet names to planetary distances from the sun. Write
    12·1 answer
  • What is a Software that interprets commands drom the keyboard and mouse
    13·1 answer
  • What is malware? a type of virus that spreads through a network connection a type of virus that targets programs and files any p
    8·1 answer
  • What statement describes the last step in evaluating<br> information?
    10·1 answer
  • The database cannot be migrated to a different engine because sql server features are used in the application’s net code. The co
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!