In: Computer Science
ASSEMBLY X86, using VISUAL STUDIOS 2019 Please follow ALL directions!
Write a program that calculates and printout the first 6
Fibonacci numbers.
Fibonacci sequence is described by the following formula:
Fib(0) = 0, Fib(1) = 1, Fib(2) = Fib(0)+ Fib(1), Fib(n) = Fib(n-1)
+ Fib(n-2).
(sequence 0 1 1 2 3 5 8 13 21 34 ...)
Have your program print out "The first six numbers in the
Fibonacci Sequence are".
Then the numbers should be neatly printed out, with each number on
its own line.
Uses WriteInt for the printing
You MUST calculate each value in the series (using registers and
the ADD operation)
You may also use memory location (variables) if you wish Remember,
to print a value
you must have or put it into the EAX register (then call
WriteInt)
Name the source file as per course naming convention
ie 302proj01yourusername.asm where youusername is you campus
login
(or first part of campus email)
Formate you code correctly (indent and comment block at top)
Input: Null
output: The first six numbers in the Fibonacci Sequence are
0
1
1
2
3
5
Code
msg db 'The first six numbers in the Fibonacci Sequence are', 0x0d, 0x0a, '$'
main PROCEDURE:
mov dx,msg;
mov ah,9;
int 0x21;
mov eax,1;
call WriteInt;
mov ebx,0 ;
mov edx,1;
mov ecx,6 ;
L2:
mov eax,ebx ;
add eax,edx;
call WriteInt;
mov ebx,edx;
mov edx,eax;
Loop L2;
exit
main ENDP
END main