Skip to content

Instantly share code, notes, and snippets.

@Trimad
Created December 9, 2017 21:25
Show Gist options
  • Save Trimad/901cfdb93143f01aa4ba659083777f7b to your computer and use it in GitHub Desktop.
Save Trimad/901cfdb93143f01aa4ba659083777f7b to your computer and use it in GitHub Desktop.
;Tristan Madden
;10/07/2017
.386
.model flat,stdcall
.stack 4096
ExitProcess proto,dwExitCode:dword
.data
n WORD 6
fibo WORD 1
fiboPrev WORD 1
temp WORD 1
answer WORD 0
.code
main proc
movzx ecx, n ;ecx needs to be (n-2)
sub ecx, 2 ;ecx needs to be (n-2)
mov ax, n
.IF (ax <= 1)
mov ax, n
mov answer, ax
.ENDIF
L1:
;int temp = fibo;
mov bx, fibo
mov temp, bx
;fibo += fiboPrev;
mov ax, fiboPrev
add fibo, ax
;fiboPrev = temp;
mov fiboPrev, bx
loop L1
mov ax, fibo
mov answer, ax
invoke ExitProcess,0
main endp
end main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment