part a write a program to evaluate the first 20


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  

:                  0x9de3bfc0

(gdb)

0x2294   :              0x90820012

(gdb)

0x2298   :              0x1cbff75a

(gdb)

0x229c   :            0x92100012

(gdb)

0x22a0   :            0x81c7e008

(gdb)

0x22a4   :            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

Request for Solution File

Ask an Expert for Answer!!
Application Programming: part a write a program to evaluate the first 20
Reference No:- TGS0443235

Expected delivery within 24 Hours