Created
June 28, 2022 15:06
-
-
Save Ismael-VC/1f7d3c79bea11ea7fa4f4c77ee42c822 to your computer and use it in GitHub Desktop.
8-bit fibonacci sequence
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%CALL { JSR2 } | |
%RTN { JMP2r } | |
%NOT { #01 EOR } | |
%DEBUG { #01 #0e DEO } | |
|0100 @main | |
#00 | |
&while | |
DUPk | |
#0d GTH NOT ,&body JCN | |
,&end JMP | |
&body | |
;fib CALL | |
SWP | |
INC | |
,while JMP | |
&end | |
POP2 | |
BRK | |
@fib ( n -- n' ) | |
DUPk | |
#01 EQU | |
SWP | |
#00 EQU | |
ORA NOT | |
,&recurse JCN | |
,&end JMP | |
&recurse | |
DUP | |
#01 SUB ;fib CALL | |
SWP | |
#02 SUB ;fib CALL | |
ADD | |
&end | |
RTN |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment