Assume registers EAX and EBX are as they are in 2 and EDX and ECX are 0 times 00
ID: 2246727 • Letter: A
Question
Assume registers EAX and EBX are as they are in 2 and EDX and ECX are 0 times 00A30040 and 0 times 00000001. State which register each respective result gets stored and the value. a. sub eax, 0 times 10 b. add eax, ebx c. inc edx d. dec ecx Fibonacci Numbers. Write an x86 assembly language program using Intel syntax that uses a loop to calculate the first seven values of the Fibonacci number sequence, described by the following formula: Fib(1) = 1, Fib(2) = 1, Fib(n) = Fib(n - 1) + Fib(n - 2). Place each value in the EAX register and display it with a call DumpRegs statement (see Section 3.2) inside the loop.Explanation / Answer
Q -
a and b cannot be solved as their values are not provided
c- inc EDX
so the final result will be stored in register EDX and with value 0x00A30041 as it is an increment instruction so it will increment the value by 1.
d- dec ECX
so again the final result will be stored in ECX register with value 0x00000000 as it is decrementing the value by 1.
Q- fibonacci series utpo first seven values of sequence
X86-64 GCC 5.2 program -
.LC0:
.string "Fibonacci series"
.LC1:
.string "%d "
main:
push rbp
mov rbp, rsp
sub rsp, 16
mov DWORD PTR [rbp-8], 0
mov edi, OFFSET FLAT:.LC0
call puts
mov DWORD PTR [rbp-4], 1
jmp .L2
.L3:
mov eax, DWORD PTR [rbp-8]
mov edi, eax
call Fib(int)
mov esi, eax
mov edi, OFFSET FLAT:.LC1
mov eax, 0
call printf
add DWORD PTR [rbp-8], 1
add DWORD PTR [rbp-4], 1
.L2:
cmp DWORD PTR [rbp-4], 7
setle al
test al, al
jne .L3
mov eax, 0
leave
ret
Fib(int):
push rbp
mov rbp, rsp
push rbx
sub rsp, 24
mov DWORD PTR [rbp-20], edi
cmp DWORD PTR [rbp-20], 0
jne .L6
mov eax, 0
jmp .L7
.L6:
cmp DWORD PTR [rbp-20], 1
jne .L8
mov eax, 1
jmp .L7
.L8:
mov eax, DWORD PTR [rbp-20]
sub eax, 1
mov edi, eax
call Fib(int)
mov ebx, eax
mov eax, DWORD PTR [rbp-20]
sub eax, 2
mov edi, eax
call Fib(int)
lea eax, [rbx+rax]
.L7:
add rsp, 24
pop rbx
leave
ret
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.