Evaluate the fibonacci series

Assignment Help Programming Languages
Reference no: EM131657

Part A

Write a program to evaluate the first 20 numbers of Fibonacci series. Use the stack (memory) to store the calculated series. Your debugger output should look like the following screenshot.

Part  B

Modify the program matrixmul.s to add two matrices and store it in a third matrix. Your output could show all three matrices in memory.

Note : Make sure you DO NOT Copy & Paste the above snapshot. You have to make the snapshot of your own program. Please send this with assembly code and a snapshot of debugger session with all important output.

Part -C

Modify the subroutine to add two complex numbers (Slide -1) to multiply two complex numbers. Your debugger output should be in the format shown in Slide -2.The product of two complex numbers a + ib and c + id is given by (ac - bd) + i(bc + ad)

Slide -1

/**

struct complex complex_add(struct complex* c1, struct complex* c2) {

       struct complex c;

       c.re = c1->re + c2->re;

       c.im = c1->im + c2->im;

       return c;

}

**/

.global complex_add

complex_add:

save %sp, -96, %sp

ld [%fp + 64], %l0

!add and store real part

ld [%i0 + re_offset], %o0

ld [%i1 + re_offset], %o1

add %o0, %o1, %o0

st %o0, [%l0 + re_offset]

!add and store im part

ld [%i0 + im_offset], %o0

ld [%i1 + im_offset], %o1

add %o0, %o1, %o0

st %o0, [%l0 + im_offset]

ret

restore

Slide -2 is bellow

/**

main()

{

struct complex c, c1, c2;

c1 = complex_set(1,2);

c2 = complex_set(2,3);

 

c = complex_add(&c1, &c2);

}

**/

 

Slide -2

.global main

main:

save %sp, (-92+str3_offset)&-8 , %sp

!initialize the first structure

add %fp, str1_offset, %l0

st %l0, [%sp+64]

mov 1, %o0

mov 2, %o1

call complex_set

nop

!initialize the second structure

add %fp, str2_offset, %l1

st %l1, [%sp+64]

mov 2, %o0

mov 3, %o1

call complex_set

nop

!add the complex numbers stored in the two structures

add %fp, str3_offset, %l2

st %l2, [%sp+64]

mov %l0, %o0

mov %l1, %o1

call complex_add

nop

mov 1, %g1

ta 0

Part -D

a. Translate the following machine language into assemble language:

(gdb)   x/x   &main

0x2290   <main>:                  0x9de3bfc0

(gdb)

0x2294   <main+4>:              0x90820012

(gdb)

0x2298   <main+8>:              0x1cbff75a

(gdb)

0x229c   <main+12>:            0x92100012

(gdb)

0x22a0   <main+16>:            0x81c7e008

(gdb)

0x22a4   <main+20>:            0x81e80000

                        Please see the b. bellow 

b. Translate the following assembly language program into machine code:

           .global main

main:  save     %sp, -64, %sp

         mov          4,      %l1  

         mov         -2, %l2

loop:   addcc    %l1,  %l2,  %l0  

         ble,a   loop

         sub    %l1,  1,  %l1

         mov         1, %g1

          ta        0

Reference no: EM131657

Questions Cloud

Write a program for find greatest common divisor : Write code for a recursive implementation of Euclid's algorithm
Laplace transforms : Calculation of a Laplace Transform from first principles
Benchmarking : What is the need for benchmarking?
Market research report : Market Research Report
Evaluate the fibonacci series : Write a program to evaluate the first 20 numbers of Fibonacci series.
Prepare a power curve for this decision rule : Prepare a power curve for this decision rule
Methods : Assignment describe the basic working of methods. How to write a method in java and how to call a method.
Loops and files : Convert an algorithm using control structures into Java and write a while loop
Explain the median housing price in a community : Explain the median housing price in a community

Reviews

Write a Review

Programming Languages Questions & Answers

  Create a custom application using eclipse

Create a custom Application Using Eclipse Android Development

  Hubspot: inbound marketing and web 2.0

Hubspot: Inbound Marketing and Web 2.0

  Create a simple shell

Create a simple shell. Basically your shell should read the line from standard input, parse the line with command and arguments, and operate the command with arguments.

  Create a multi-threaded competition

Create a multi-threaded competition in which opposing Robin Hoods will attack one another and try to take each other's gold coins.

  Ethics and social responsibility

Ethics and social responsibility at McDonalds

  Design a program that models the worms behavior

Design a program that models the worm's behavior.

  Writing a class

Build a class for a type called Fraction

  Top-down recursive descent parser

Write a hand-coded top-down recursive descent parser.

  Write a program that uses the curve class hierarchy

Write a program that uses the curve class hierarchy. The program should define several different objects, output their area, circumference, etc. It should also use the printcurve function.

  Discussion: html/css

Discussion: HTML/CSS,  "JavaScript Placement"  Please respond to the following: Compare and contrast the process of adding JavaScript and a Cascading Style Sheet to a Website. Determine if they can be used simultaneously in a page. If so, explain wh..

  Write a prolog program using swi proglog

Write a Prolog program using swi proglog

  Building instruction set simulators

Building Instruction Set Simulators

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd