Question

Prompt: Write a code in MARS MIPS that uses a stack to recursively compute the series...

Prompt: Write a code in MARS MIPS that uses a stack to recursively compute the series from 1 to 10.

Homework Answers

Answer #1

Greetings!!

Code:

main:
addi $a0,$0,1       #arguement set in register a0

jal series       #call function

addi $v0,$0,10       #termination parameter
syscall

series:
beq $a0,11,done       #check upper limit
addi $v0,$0,1       #parameter for display number
syscall           #display
addi $a0,$a0,1       #increment number
jal series       #recursive call to the function
done:
jr $ra

Output screenshot:

Hope this helps

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Prompt: Write a code in MARS MIPS that utilizes a stack to recursively compute the factorial...
Prompt: Write a code in MARS MIPS that utilizes a stack to recursively compute the factorial of user input "x". I have a little experience with stacks but how can I set up a stack so that it accepts an input from a user? Thank you!
Use MARS to write and simulate a MIPS assembly language program to swap two of the...
Use MARS to write and simulate a MIPS assembly language program to swap two of the integers in an integer array. The program should include the Swap function to swap the integers and the main function to call the Swap function. Download the template file “P4_template.asm” provided on Blackboard. Add your code to this file. Do not modify any of the code provided in the file. The main function should: • Pass the starting address of the array in $a0....
a) Write a series of C++ statements (ADT functions) that uses push()and to create a stack...
a) Write a series of C++ statements (ADT functions) that uses push()and to create a stack S1 capable of holding 10 elements and which actually stores the following, the top of the stack being theleftmost element:〈12,2,3,6,5〉 b) Then write a series of statements usingpop()to take those elements out from the stack and enqueue() them all in a queue Q capable of holding 15 elements. Show that queue.(front to be the leftmost element). c) Finally create a second stack S2 in...
In MIPS/MARS 1)Write a program that prints your name in a Triangle.
In MIPS/MARS 1)Write a program that prints your name in a Triangle.
Write a piece of R code to compute the following series: em = 1 + 0.8...
Write a piece of R code to compute the following series: em = 1 + 0.8 (1*80%) + 0.64 (0.8*80%) + 0.512 (0.64*80%) + … em = function(n, r = 0.8){ Body of code }
C++ code: How to add a file to read/write to a code that prompt user to...
C++ code: How to add a file to read/write to a code that prompt user to add (write) infos and read infos from the file?
(MIPS Assembly Language): Write the following sequence of code using *native* MIPS instructions: x = x...
(MIPS Assembly Language): Write the following sequence of code using *native* MIPS instructions: x = x - y[0] + y[1]; In memory x, y are stored beginning at 0x010000cc. Use registers $s1 for x,  and $s2 for the base address of y. Make sure your code includes all necessary declarations such that it could run in SPIM.
Without using move or li, write MIPS assembly language using MARS simulator to print a half...
Without using move or li, write MIPS assembly language using MARS simulator to print a half pyramid depending on a value n of a user input. Such that if n = 5 were entered the following would be printed: 1 1 2 1 2 3 1 2 3 4 1 2 3 4 5
Write a program in Mars MIPS Assembly Language that asks the user for an 8-digit hexadecimal...
Write a program in Mars MIPS Assembly Language that asks the user for an 8-digit hexadecimal and then prints out its 32-bit binary representation, the operation of the function, the format (I, R, or J), the fields associated with the format (op, rs, rt, imm, shamt, funct), and the instruction associated with the hexadecimal. All five parts must be written as functions.
In MIPS assembly, write an assembly language version of the following C code segment: int A[100],...
In MIPS assembly, write an assembly language version of the following C code segment: int A[100], B[100]; for (i=1; i < 100; i++) { A[i] = A[i-1] + B[i]; }
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT