Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write an assembly program that computes Fibonacci numbers 2-5. a. Assume Fib(0)=

ID: 3638382 • Letter: W

Question

Write an assembly program that computes Fibonacci numbers 2-5.
a. Assume Fib(0)=0 and Fib(1)=1.
b. Store Fib(2) in EAX, Fib(3) in EBX, Fib(4) in ECX and Fib(5) in EDX.
c. Use a LOOP instruction to solve this problem.
d. Execute a DumpRegs to display the results.

2. Write an SC program that calls a subroutine to double a number and store the
result in memory.
a. The program must use the JnS JumpI, and AddI instructions.
b. The source code should show Address, Label, Instruction, and Comment
column

Explanation / Answer

.data fib DWORD 5 dup (0) .code mov edx,offset fibo mov eax,2 mov ebx,3 mov ecx,4 mov edx,5 @@: mov DWORD PTR [edx],eax mov DWORD PTR [edx+4],ebx add eax,ebx add ebx,eax add edx,8 sub ecx,1 jnz @B 2)solution : lod-c 13 ; Set up to call the subroutine with sto N1 ; N1 = 13, N2 =13, and ret_addr = back. lod-c 13 sto N2 lod-c back sto ret_addr jmp double ; Call the subroutine. back: lod Answer ; When the subroutine ends, it returns ; control to this location, and the ; addition of N1 and N2 is in Answer. ; This LOD instruction puts the answer ; in the accumulator. hlt ; Terminate the program by halting the computer.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote