Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is the code we have to modify, The question is after the code. I need the SOLUTION as a MIPS code # Comments. Anything

This is the code we have to modify, The question is after the code. I need the SOLUTION as a MIPS code

# Comments. Anything after # is comments. # Lab 3 # MARS Example .data # data segment nl: .asciiz " " # ASCII for a new line .align 2 # aligned at word boundary name: .asciiz "CSC34300: Lab 3-1: YOUR NAME (YOUR STUDENT ID) " .align 2 msg1: .asciiz "Fibonacci Series Element " #note the space .align 2 msg2: .asciiz " is " #note the spaces .text # Code segment .globl main # declare main to be global main: la $a0,name # load the address of "name" into $a0 li $v0,4 # system call, type 4, print an string($a0) syscall # call the "OS" li $t2,0 # $t2=0; initial value of F(n-2) li $t1,1 # $t1=1; initial value of F(n-1) li $t3,10 # $t3 is the counter to be decremented li $t4,2 # $t4=2; index, n. loop: add $t0,$t1,$t2 # F(n) = F(n-1) + F(n-2) la $a0,msg1 # $a0 = address of message 1 li $v0,4 # system call, type 4, print an string($a0) syscall move $a0,$t4 # $t4 contains the current value of n li $v0,1 # system call, type 1, print an integer $a0 syscall la $a0,msg2 # $a0=address of "msg2" li $v0,4 # system call, type 4, print an string syscall move $a0,$t0 # $a0= $t0, which is F(n) li $v0,1 # system call, type 1, print an integer $a0 syscall la $a0,nl # $a0= address of "nl" li $v0,4 # system call, type 4, print an string syscall addi $t4,$t4,1 # $t4 = $t4 + 1; increment n move $t2,$t1 # $t2 = $t1; old F(n-2) because old F(n-1) move $t1,$t0 # $t1 = $t0; old F(n-2) because old F(n) addi $t3,$t3,-1 # $t3 = $t3 - 1; decrement the counter bne $0,$t3,loop # continue if $t3 is not 0 Exit: li $v0,10 # System call, type 10, standard exit syscall # ...and call the OS

Question:Objectives The code in Task 1 prints out the Fibonacci numbers once they are computed. In this part of the lab, you perform similar tasks in two steps. In the first step, you store Fibonacci numbers into an array. In the second step, you print out the numbers in the array. In addition, you will also experiment with signed and unsigned numbers. The code in Task 1 assumes signed integers. You can compute one more Fibonacci number with unsigned numbers.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Temporal Databases Research And Practice Lncs 1399

Authors: Opher Etzion ,Sushil Jajodia ,Suryanarayana Sripada

1st Edition

3540645195, 978-3540645191

More Books

Students also viewed these Databases questions

Question

Question Who can establish a Keogh retirement plan?

Answered: 1 week ago