Skip to content

Instantly share code, notes, and snippets.

@jamesoff
Last active December 1, 2015 19:16
Show Gist options
  • Save jamesoff/80669316bf4c5ab1a03d to your computer and use it in GitHub Desktop.
Save jamesoff/80669316bf4c5ab1a03d to your computer and use it in GitHub Desktop.
TIS-100 saves
@0
MOV UP, DOWN
@1
MOV RIGHT, DOWN
@2
MOV UP, LEFT
@3
MOV UP, DOWN
@4
MOV UP, DOWN
@5
MOV UP, DOWN
@6
MOV UP, RIGHT
@7
MOV LEFT, DOWN
@0
MOV UP, ACC
SAV
MOV 999, ACC
LOOP:
SUB 1
JGZ LOOP
SWP
MOV ACC, DOWN
@1
MOV RIGHT, ACC
SWP
SWP
SWP
SWP
SWP
SWP
SWP
SWP
SWP
SWP
SWP
SWP
MOV ACC, DOWN
@2
MOV UP, LEFT
@3
MOV UP, ACC
MOV ACC, DOWN
@4
MOV UP, DOWN
@5
MOV UP, ACC
MOV ACC, DOWN
@6
MOV UP, RIGHT
@7
MOV LEFT, DOWN
@0
@1
MOV UP, ACC
ADD ACC
MOV ACC, DOWN
@2
@3
@4
MOV UP, DOWN
@5
@6
@7
MOV UP, RIGHT
@8
MOV LEFT, DOWN
@9
@0
@1
MOV UP, DOWN
MOV UP, RIGHT
@2
MOV LEFT, ACC
ADD ACC
MOV ACC, DOWN
@3
@4
MOV UP, ACC
ADD ACC
MOV ACC, RIGHT
@5
MOV ANY, DOWN
@6
@7
@8
MOV UP, DOWN
@9
@0
@1
MOV UP, ACC
MOV ACC, RIGHT
SUB RIGHT
MOV ACC, DOWN
@2
MOV UP, ACC
SAV
SUB LEFT
MOV ACC, DOWN
SWP
MOV ACC, LEFT
@3
@4
@5
MOV UP, DOWN
@6
MOV UP, DOWN
@7
@8
MOV UP, DOWN
@9
MOV UP, DOWN
@10
@0
@1
MOV UP, ACC
MOV ACC, DOWN
MOV ACC, RIGHT
@2
MOV UP, ACC
MOV ACC, DOWN
SUB LEFT
MOV ACC, DOWN
@3
@4
@5
MOV UP, ACC
SUB RIGHT
MOV ACC, DOWN
@6
MOV UP, LEFT
MOV UP, DOWN
@7
@8
MOV UP, DOWN
@9
MOV UP, DOWN
@10
@0
MOV UP, DOWN
@1
@2
@3
@4
MOV UP, DOWN
@5
MOV UP, RIGHT
@6
GO:
MOV LEFT, ACC
MOV ACC, RIGHT
JGZ OUTPUT
MOV 0, DOWN
JMP GO
OUTPUT:
MOV 1, DOWN
@7
GO:
MOV LEFT, ACC
MOV ACC, RIGHT
JEZ OUTPUT
MOV 0, DOWN
JMP GO
OUTPUT:
MOV 1,DOWN
@8
GO:
MOV LEFT, ACC
JLZ OUTPUT
MOV 0, DOWN
JMP GO
OUTPUT:
MOV 1, DOWN
@0
@1
GO:
MOV RIGHT, ACC
JGZ DISCARD
MOV UP, DOWN
JMP GO
DISCARD:
MOV UP, NIL
MOV 0, DOWN
@2
MOV UP, ACC
MOV ACC, LEFT
MOV ACC, RIGHT
@3
GO:
MOV LEFT, ACC
JLZ DISCARD
MOV UP, DOWN
JMP GO
DISCARD:
MOV UP, NIL
MOV 0, DOWN
@4
@5
MOV UP, RIGHT
@6
MOV LEFT, ACC
ADD RIGHT
MOV ACC, DOWN
@7
MOV UP, LEFT
@8
@9
MOV UP, DOWN
@10
@0
@1
MOV UP, ACC
MOV ACC, RIGHT
NOP
NOP
MOV ACC, DOWN
@2
MOV UP, ACC
SAV
SUB LEFT
JLZ MOO
NOP
NOP
MOO:
SWP
MOV ACC, DOWN
@3
@4
@5
MOV UP, RIGHT
@6
MOV ANY, DOWN
@7
@8
@9
MOV UP, DOWN
MOV UP, DOWN
MOV 0, DOWN
@10
@0
@1
MOV UP, ACC
MOV ACC, RIGHT
MOV ACC, RIGHT
@2
MOV UP, ACC
SAV
SUB LEFT
JLZ MOO
SWP
MOV LEFT, DOWN
MOV ACC, DOWN
JRO -7
MOO:
SWP
MOV ACC, DOWN
MOV LEFT, DOWN
@3
@4
@5
@6
MOV ANY, DOWN
@7
@8
@9
MOV UP, DOWN
MOV UP, DOWN
MOV 0, DOWN
@10
@0
@1
MOV UP, ACC
MOV ACC, RIGHT
MOV ACC, DOWN
@2
# START WITH COUNT
SWP
MOV LEFT, ACC
JNZ TICK
SWP
MOV ACC, DOWN
MOV 0, ACC
JRO -6
TICK:
SWP
ADD 1
@3
MOV RIGHT, ACC
MOV ACC, RIGHT
@4
# START WITH SUM
SWP
MOV UP, ACC
JEZ OUTPUT
MOV ACC, LEFT
SWP
ADD LEFT
JRO -6
OUTPUT:
SWP
MOV ACC, DOWN
MOV 0, ACC
@5
MOV UP, DOWN
@6
@7
@8
MOV UP, DOWN
@9
MOV UP, DOWN
@10
@0
@1
MOV UP, ACC
MOV ACC, RIGHT
MOV ACC, DOWN
@2
# START WITH COUNT
SWP
MOV LEFT, ACC
JNZ TICK
SWP
MOV ACC, DOWN
MOV 0, ACC
JRO -6
TICK:
SWP
ADD 1
@3
MOV RIGHT, ACC
MOV ACC, RIGHT
@4
# START WITH SUM
SWP
MOV UP, ACC
JEZ OUTPUT
MOV ACC, LEFT
SWP
ADD LEFT
JRO -6
OUTPUT:
SWP
MOV ACC, DOWN
MOV 0, ACC
@5
MOV UP, DOWN
@6
## NO SWP
@7
@8
MOV UP, DOWN
@9
MOV UP, DOWN
@10
@0
MOV 0, ACC
LOOP:
MOV ACC, RIGHT
MOV RIGHT, ACC
JMP LOOP
@1
MOV UP, ACC
SAV
SUB LEFT
MOV ACC, DOWN
SWP
MOV ACC, LEFT
@2
@3
@4
@5
MOV UP, ACC
JGZ NOFLIP
NEG
NOFLIP:
SUB 10
MOV ACC, DOWN
@6
@7
@8
GO:
MOV UP, ACC
JLZ SMALLER
MOV 1, RIGHT
JMP GO
SMALLER:
MOV 0, RIGHT
@9
MOV LEFT, DOWN
@10
$placeholder
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment