Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ;calculateFib - Calculate fibonacci numbers and display
- mov ecx, fibNth ;sets loop counter to number nth term user requested
- mov edx, 0 ;sets edx counter to track how many terms per line
- fibLoop:
- mov ebx, fib1
- mov eax, fib2
- cmp edx, 5 ;compare edx counter to 5, if equal to 5 print to new line
- jne noNewLine ;if not equal to 5 jump to next dec print statement
- call CrLf
- mov edx, 0 ;reset edx counter to 0
- noNewLine:
- call WriteDec
- push edx ;push edx onto stack to allow use of edx for string
- mov edx, OFFSET spaces
- call WriteString
- pop edx ;pop edx from stack and increment counter for next loop iteration
- inc edx
- add ebx, eax ;add the two terms together to get the next Fib number
- mov fib2, ebx
- mov fib1, eax
- loop fibLoop ;loop if ecx > 0
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement