Assume registers EAX and EBX are as they are in 2 and EDX an

Assume registers EAX and EBX are as they are in 2 and EDX and ECX are 0x00A30040 and 0x00000001. State which register each respective result gets stored and the value. sub eax, 0x10 add eax, ebx inc edx 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(l) = 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.

Solution

Answer:

3)The register which each respective result gets stored and the values are as below :

a.The register is eax

b.The register is eax

c.The register is edx

d.The register is ecx

4.

Assembly Language Code :

.zero 1
fibonacci(int):
push rbp
mov rbp, rsp
push rbx
sub rsp, 24
mov DWORD PTR [rbp-20], edi
mov eax, DWORD PTR [rbp-20]
cmp eax, 1
je .L2
mov eax, DWORD PTR [rbp-20]
test eax, eax
jne .L3
.L2:
mov eax, DWORD PTR [rbp-20]
jmp .L4
.L3:
mov eax, DWORD PTR [rbp-20]
sub eax, 1
mov edi, eax
call fibonacci(int)
mov ebx, eax
mov eax, DWORD PTR [rbp-20]
sub eax, 2
mov edi, eax
call fibonacci(int)
add eax, ebx
.L4:
add rsp, 24
pop rbx
pop rbp
ret
.LC0:
.string \"Input the number of terms for Fibonacci Series:\"
.LC1:
.string \"\ Fibonacci Series is as follows\ \"
.LC2:
.string \" \"
main:
push rbp
mov rbp, rsp
push rbx
sub rsp, 24
mov DWORD PTR [rbp-20], 0
mov esi, OFFSET FLAT:.LC0
mov edi, OFFSET FLAT:std::cout
call std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)
lea rax, [rbp-24]
mov rsi, rax
mov edi, OFFSET FLAT:std::cin
call std::basic_istream<char, std::char_traits<char> >::operator>>(int&)
mov esi, OFFSET FLAT:.LC1
mov edi, OFFSET FLAT:std::cout
call std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)
.L7:
mov eax, DWORD PTR [rbp-24]
cmp DWORD PTR [rbp-20], eax
jge .L6
mov eax, DWORD PTR [rbp-20]
mov edi, eax
call fibonacci(int)
mov ebx, eax
mov esi, OFFSET FLAT:.LC2
mov edi, OFFSET FLAT:std::cout
call std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)
mov esi, ebx
mov rdi, rax
call std::basic_ostream<char, std::char_traits<char> >::operator<<(int)
add DWORD PTR [rbp-20], 1
jmp .L7
.L6:
mov eax, 0
add rsp, 24
pop rbx
pop rbp
ret
__static_initialization_and_destruction_0(int, int):
push rbp
mov rbp, rsp
sub rsp, 16
mov DWORD PTR [rbp-4], edi
mov DWORD PTR [rbp-8], esi
cmp DWORD PTR [rbp-4], 1
jne .L11
cmp DWORD PTR [rbp-8], 65535
jne .L11
mov edi, OFFSET FLAT:std::__ioinit
call std::ios_base::Init::Init()
mov edx, OFFSET FLAT:__dso_handle
mov esi, OFFSET FLAT:std::__ioinit
mov edi, OFFSET FLAT:std::ios_base::Init::~Init()
call __cxa_atexit
.L11:
nop
leave
ret
push rbp
mov rbp, rsp
mov esi, 65535
mov edi, 1
call __static_initialization_and_destruction_0(int, int)
pop rbp
ret

 Assume registers EAX and EBX are as they are in 2 and EDX and ECX are 0x00A30040 and 0x00000001. State which register each respective result gets stored and th
 Assume registers EAX and EBX are as they are in 2 and EDX and ECX are 0x00A30040 and 0x00000001. State which register each respective result gets stored and th
 Assume registers EAX and EBX are as they are in 2 and EDX and ECX are 0x00A30040 and 0x00000001. State which register each respective result gets stored and th

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site