Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is assemble language and here is code. .data arrayA: .word 1, 1, 0, 0 arrayB: .word 0xffff, 0xffff, 0xffff, 0xffff .text addi $s0, $zero,

This is assemble language and here is code.

.data

arrayA: .word 1, 1, 0, 0

arrayB: .word 0xffff, 0xffff, 0xffff, 0xffff

.text

addi $s0, $zero, 5 # This is a common way to initialize a register: addi the desired value to $zero

top: addi $s0, $s0, -1

bne $s0, $zero, top

The Fibonacci number sequence is 1, 1, 2, 3, 5, 8, 13, Each number is the sum of the previous two, and the first two numbers are both 1. An array named arrayA will contain sixteen values of the Fibonacci sequence. The array is initialized with the first two 1s of the sequence, and the remaining values of the sequence will be computed using a loop and stored in arrayA.

Write instructions to prepare for a future loop, including the following actions:

Choose a register to use as the loop index counter

Initialize the loop counter to a value of 16.

Put the address of arrayA into a register, using the la instruction.

Write instructions to complete the body of the loop, including the following actions:

Use lw instructions to move two values from stored memory arrayA to registers.

Add those two registers together

Store that sum into the the arrayA at the correct location.

Increment the base address in the register that originally contained the address of arrayA, for use during the next iteration of the loop

Increment the loop counter value

The program should have computed and stored in memory the values of the Fibonacci sequence (1, 1, 2, 3, 5, 8, 13, ). Note that arrayBs initialized data has been overwritten (destroyed) by your program.

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

Joe Celkos Data And Databases Concepts In Practice

Authors: Joe Celko

1st Edition

1558604324, 978-1558604322

More Books

Students also viewed these Databases questions

Question

Why is the System Build Process an iterative process?

Answered: 1 week ago