Skip to content

Instantly share code, notes, and snippets.

@hitode909
Created October 15, 2008 08:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hitode909/16883 to your computer and use it in GitHub Desktop.
Save hitode909/16883 to your computer and use it in GitHub Desktop.
* N: NUMBER OF INPUT
N: EQU 80H
* CUR: CURRENT RESULT (AND RESULT)
CUR: EQU 81H
* P1: PREVIOUS RESULT
P1: EQU 82H
* P2: PRE-PREVIOUS RESULT
P2: EQU 83H
* SET LOOP COUNTER
LD IX, [N]
* CUR <- 0, FIN
LD ACC, 0
ST ACC, [CUR]
* FIN CHECK
SUB IX, 1
BZ FIN
* P1 <- CUR, CUR <- 1
LD ACC, [CUR]
ST ACC, [P1]
LD ACC, 1
ST ACC, [CUR]
* FIN CHECK
SUB IX, 1
BZ FIN
* P2 <- P1, P1 <- CUR
LOOP: LD ACC, [P1]
ST ACC, [P2]
LD ACC, [CUR]
ST ACC, [P1]
* CUR <- P1 + P2
LD ACC, [P2]
ADD ACC, [P1]
ST ACC, [CUR]
* FIN CHECK
SUB IX, 1
BP LOOP
* FIN
FIN: HLT
END
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment