Skip to content

Instantly share code, notes, and snippets.

@desg
Last active December 11, 2015 02:39
Show Gist options
  • Save desg/4532556 to your computer and use it in GitHub Desktop.
Save desg/4532556 to your computer and use it in GitHub Desktop.
@sweep
# assign n
PUSH 100
@L0
DUP
IFFGOTO << @L7
# call ffi
PUSH @LOOK
PUSH @EAST
CALLFF << 2
IFFGOTO << @L1
# call ffi
PUSH @PULL
PUSH @EAST
CALLFF << 2
POP
@L1
@L2
# call ffi
PUSH @LOOK
PUSH @WEST
CALLFF << 2
IFFGOTO << @L3
# call ffi
PUSH @PULL
PUSH @WEST
CALLFF << 2
POP
@L3
@L4
# call ffi
PUSH @LOOK
PEEK << -3
CALLFF << 2
IFFGOTO << @L5
# call ffi
PUSH @PULL
PEEK << -3
CALLFF << 2
POP
@L5
@L6
# call ffi
PUSH @MOVE
PEEK << -3
CALLFF << 2
POP
# call sub
DUP
PUSH 1
SUB
PUSH -1
POKE
GOTO << @L0
@L7
# return
POPN << 2
PUSH 0
RETURN
# end @sweep
@main
@L8
PUSH 1
IFFGOTO << @L9
# call sweep
PUSH @NORTH
CALL << @sweep
POP
# call ffi
PUSH @MOVE
PUSH @EAST
CALLFF << 2
POP
# call ffi
PUSH @MOVE
PUSH @EAST
CALLFF << 2
POP
# call ffi
PUSH @MOVE
PUSH @EAST
CALLFF << 2
POP
# call sweep
PUSH @SOUTH
CALL << @sweep
POP
# call ffi
PUSH @MOVE
PUSH @EAST
CALLFF << 2
POP
# call ffi
PUSH @MOVE
PUSH @EAST
CALLFF << 2
POP
# call ffi
PUSH @MOVE
PUSH @EAST
CALLFF << 2
POP
GOTO << @L8
@L9
# return
PUSH 0
RETURN
# end @main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment