Skip to content

Instantly share code, notes, and snippets.

@feuery
Last active August 21, 2016 14:25
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 feuery/fbaf2aba67d7d41d6c2698e12449f27c to your computer and use it in GitHub Desktop.
Save feuery/fbaf2aba67d7d41d6c2698e12449f27c to your computer and use it in GitHub Desktop.
PUSH 'iszero
LAMBDA
PUSH 0
PEQ
RET
PUSH 'waszero
LAMBDA
MULTIPLY CX
RET
PUSH 'wasntzero
LAMBDA
APPLY 'kertoma
RET
PUSH 'counter-needs-init
LAMBDA
PUSH CX
PUSH NIL
PEQ
RET
PUSH 'init_counter
LAMBDA
MOV CX 0
RET
PUSH 'kertoma
LAMBDA
PUSH 'init_counter
PUSH 'counter-needs-init
BRANCH_NO_ELS
MOV AX ;; AX sisältää meiän kerrottavan
PUSH 1
DEC AX BX ;; BX sisältää AX-1
PUSH BX
INC CX
PUSH 'wasntzero
PUSH 'waszero
PUSH 'iszero
BRANCH
RET
PUSH 3
APPLY 'kertoma
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment