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

Assembly Language fibonacci.asm - computes the following. a. Compute fib(n) for

ID: 3669902 • Letter: A

Question

Assembly Language

fibonacci.asm
- computes the following.

a. Compute fib(n) for n = 2, 3, …, 6 using an array.

b. Store each computed value in an array of the appropriate size and type.

c. Store fib(3) through fib(6) in consecutive bytes of the ebx register starting from the lowest byte; that is, fib(3) is stored in the low byte (bl) of ebx, fib(4) is stored in the next byte (bh), fib(5) is stored in the next byte of ebx and fib(6) is stored in the highest byte.

d. If you don’t know what the Fibonacci sequence is, there is a lot of information online that you can find.

Notes


1. Assume fib(0)=0, fib(1)=1.

2. You may use any instruction/directive/operator through chapter 4 pg 128, including any of the arithmetic operators +, *, /, -.

3. Your program must use indirect operands in some way as discussed in chapter 4.

4. Your program must make one call to DumpRegs before quitting to display the ebx register.

Indirect Operand

• Can be any 32-bit general purpose register

– Surrounded by brackets

• The register is assumed to contain the address of some data

Here is the example for Indirect Operand

.data

byteval BYTE 10h

.code

mov esi, OFFSET byteval

mov al, [esi] ; al = 10h

mov [esi], al

Please comment out the part for A,B,C

Thank you

Explanation / Answer

.Ltext0: .section .rodata .LC0: 0000 25336420 .string "%3d %6d " 20202536 640A00 .text .globl main main: .LFB0: .cfi_startproc 0000 55 pushq %rbp .cfi_def_cfa_offset 16 .cfi_offset 6, -16 0001 4889E5 movq %rsp, %rbp .cfi_def_cfa_register 6 0004 4883EC70 subq $112, %rsp .LBB2: 0008 C745A000 movl $0, -96(%rbp) 000000 000f C745A401 movl $1, -92(%rbp) 000000 0016 C7459C02 movl $2, -100(%rbp) 000000 001d EB27 jmp .L2 .L3: 0042 83459C01 addl $1, -100(%rbp) 001f 8B459C movl -100(%rbp), %eax 0022 83E801 subl $1, %eax 0025 4898 cltq 0027 8B5485A0 movl -96(%rbp,%rax,4), %edx 002b 8B459C movl -100(%rbp), %eax 002e 83E802 subl $2, %eax 0031 4898 cltq 0033 8B4485A0 movl -96(%rbp,%rax,4), %eax 0037 01C2 addl %eax, %edx 0039 8B459C movl -100(%rbp), %eax 003c 4898 cltq 003e 895485A0 movl %edx, -96(%rbp,%rax,4) .L2: 0046 837D9C17 cmpl $23, -100(%rbp) 004a 7ED3 jle .L3 004c C7459C00 movl $0, -100(%rbp) 000000 0053 EB21 jmp .L4 .L5: 0072 83459C01 addl $1, -100(%rbp) 0055 8B459C movl -100(%rbp), %eax 0058 4898 cltq 005a 8B5485A0 movl -96(%rbp,%rax,4), %edx 005e 8B459C movl -100(%rbp), %eax 0061 89C6 movl %eax, %esi 0063 BF000000 movl $.LC0, %edi 00 0068 B8000000 movl $0, %eax 00 006d E8000000 call printf 00 .L4: 0076 837D9C17 cmpl $23, -100(%rbp) 007a 7ED9 jle .L5 .LBE2: 007c B8000000 movl $0, %eax 00 0081 C9 leave .cfi_def_cfa 7, 8 0082 C3 ret .cfi_endproc .LFE0: .Letext0:

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