Last active
December 11, 2015 01:19
-
-
Save dforsyth/4522879 to your computer and use it in GitHub Desktop.
win gridc
This file contains hidden or 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
PUSH 0 | |
DUPN << 8 | |
CALL << @main | |
END | |
@look_north | |
# return | |
# call ffi | |
PUSH @look | |
PUSH @north | |
CALLFF << 2 | |
STORE retval | |
PUSH retval | |
RETURN | |
# end @look_north | |
@look_east | |
# return | |
# call ffi | |
PUSH @look | |
PUSH @east | |
CALLFF << 2 | |
STORE retval | |
PUSH retval | |
RETURN | |
# end @look_east | |
@look_south | |
# return | |
# call ffi | |
PUSH @look | |
PUSH @south | |
CALLFF << 2 | |
STORE retval | |
PUSH retval | |
RETURN | |
# end @look_south | |
@look_west | |
# return | |
# call ffi | |
PUSH @look | |
PUSH @west | |
CALLFF << 2 | |
STORE retval | |
PUSH retval | |
RETURN | |
# end @look_west | |
@pull_north | |
# call ffi | |
PUSH @pull | |
PUSH @north | |
CALLFF << 2 | |
POP | |
# return | |
PUSH 0 | |
RETURN | |
# end @pull_north | |
@pull_east | |
# call ffi | |
PUSH @pull | |
PUSH @east | |
CALLFF << 2 | |
POP | |
# return | |
PUSH 0 | |
RETURN | |
# end @pull_east | |
@pull_south | |
# call ffi | |
PUSH @pull | |
PUSH @south | |
CALLFF << 2 | |
POP | |
# return | |
PUSH 0 | |
RETURN | |
# end @pull_south | |
@pull_west | |
# call ffi | |
PUSH @pull | |
PUSH @west | |
CALLFF << 2 | |
POP | |
# return | |
PUSH 0 | |
RETURN | |
# end @pull_west | |
@pull_direction | |
# call equal | |
DUP | |
PEEK << 0 | |
EQUAL | |
IFFGOTO << @L0 | |
# return | |
# call pull_north | |
CALL << @pull_north | |
STORE retval | |
POP | |
PUSH retval | |
RETURN | |
@L0 | |
@L1 | |
# call equal | |
DUP | |
PEEK << 1 | |
EQUAL | |
IFFGOTO << @L2 | |
# return | |
# call pull_east | |
CALL << @pull_east | |
STORE retval | |
POP | |
PUSH retval | |
RETURN | |
@L2 | |
@L3 | |
# call equal | |
DUP | |
PEEK << 2 | |
EQUAL | |
IFFGOTO << @L4 | |
# return | |
# call pull_south | |
CALL << @pull_south | |
STORE retval | |
POP | |
PUSH retval | |
RETURN | |
@L4 | |
@L5 | |
# call equal | |
DUP | |
PEEK << 3 | |
EQUAL | |
IFFGOTO << @L6 | |
# return | |
# call pull_west | |
CALL << @pull_west | |
STORE retval | |
POP | |
PUSH retval | |
RETURN | |
@L6 | |
@L7 | |
# return | |
POP | |
PUSH 0 | |
RETURN | |
# end @pull_direction | |
@push_north | |
# call ffi | |
PUSH @push | |
PUSH @north | |
CALLFF << 2 | |
POP | |
# return | |
PUSH 0 | |
RETURN | |
# end @push_north | |
@push_east | |
# call ffi | |
PUSH @push | |
PUSH @east | |
CALLFF << 2 | |
POP | |
# return | |
PUSH 0 | |
RETURN | |
# end @push_east | |
@push_south | |
# call ffi | |
PUSH @push | |
PUSH @south | |
CALLFF << 2 | |
POP | |
# return | |
PUSH 0 | |
RETURN | |
# end @push_south | |
@push_west | |
# call ffi | |
PUSH @push | |
PUSH @west | |
CALLFF << 2 | |
POP | |
# return | |
PUSH 0 | |
RETURN | |
# end @push_west | |
@move_north | |
# call ffi | |
PUSH @move | |
PUSH @north | |
CALLFF << 2 | |
POP | |
# return | |
PUSH 0 | |
RETURN | |
# end @move_north | |
@move_east | |
# call ffi | |
PUSH @move | |
PUSH @east | |
CALLFF << 2 | |
POP | |
# return | |
PUSH 0 | |
RETURN | |
# end @move_east | |
@move_south | |
# call ffi | |
PUSH @move | |
PUSH @south | |
CALLFF << 2 | |
POP | |
# return | |
PUSH 0 | |
RETURN | |
# end @move_south | |
@move_west | |
# call ffi | |
PUSH @move | |
PUSH @west | |
CALLFF << 2 | |
POP | |
# return | |
PUSH 0 | |
RETURN | |
# end @move_west | |
@move_direction | |
# call equal | |
DUP | |
PEEK << 0 | |
EQUAL | |
IFFGOTO << @L8 | |
# return | |
# call move_north | |
CALL << @move_north | |
STORE retval | |
POP | |
PUSH retval | |
RETURN | |
@L8 | |
@L9 | |
# call equal | |
DUP | |
PEEK << 1 | |
EQUAL | |
IFFGOTO << @L10 | |
# return | |
# call move_east | |
CALL << @move_east | |
STORE retval | |
POP | |
PUSH retval | |
RETURN | |
@L10 | |
@L11 | |
# call equal | |
DUP | |
PEEK << 2 | |
EQUAL | |
IFFGOTO << @L12 | |
# return | |
# call move_south | |
CALL << @move_south | |
STORE retval | |
POP | |
PUSH retval | |
RETURN | |
@L12 | |
@L13 | |
# call equal | |
DUP | |
PEEK << 3 | |
EQUAL | |
IFFGOTO << @L14 | |
# return | |
# call move_west | |
CALL << @move_west | |
STORE retval | |
POP | |
PUSH retval | |
RETURN | |
@L14 | |
@L15 | |
# return | |
POP | |
PUSH 0 | |
RETURN | |
# end @move_direction | |
@survey | |
# call look_north | |
CALL << @look_north | |
PEEK << 0 | |
ADD << 4 | |
POKE | |
# call look_east | |
CALL << @look_east | |
PEEK << 1 | |
ADD << 4 | |
POKE | |
# call look_south | |
CALL << @look_south | |
PEEK << 2 | |
ADD << 4 | |
POKE | |
# call look_west | |
CALL << @look_west | |
PEEK << 3 | |
ADD << 4 | |
POKE | |
# return | |
PUSH 0 | |
RETURN | |
# end @survey | |
@clear | |
# assign n | |
PUSH 0 | |
@L16 | |
# call less | |
DUP | |
# call add | |
PEEK << 3 | |
PUSH 1 | |
ADD | |
LESS | |
IFFGOTO << @L17 | |
PUSH -1 | |
PEEK << -2 | |
ADD << 4 | |
POKE | |
# call add | |
DUP | |
PUSH 1 | |
ADD | |
PUSH -1 | |
POKE | |
GOTO << @L16 | |
@L17 | |
# return | |
POP | |
PUSH 0 | |
RETURN | |
# end @clear | |
@pull_resources | |
# assign n | |
PUSH 0 | |
@L18 | |
# call less | |
DUP | |
# call add | |
PEEK << 3 | |
PUSH 1 | |
ADD | |
LESS | |
IFFGOTO << @L21 | |
# call equal | |
DUP | |
ADD << 4 | |
PEEK | |
PUSH @cell_resource | |
EQUAL | |
IFFGOTO << @L19 | |
# call pull_direction | |
DUP | |
CALL << @pull_direction | |
POP | |
# return | |
POP | |
PUSH 1 | |
RETURN | |
@L19 | |
@L20 | |
GOTO << @L18 | |
@L21 | |
# return | |
POP | |
PUSH 0 | |
RETURN | |
# end @pull_resources | |
@push_bots | |
# call equal | |
PEEK << 3 | |
ADD << 4 | |
PEEK | |
PUSH @cell_robot | |
EQUAL | |
IFFGOTO << @L24 | |
# call equal | |
PEEK << 1 | |
ADD << 4 | |
PEEK | |
PUSH @cell_empty | |
EQUAL | |
IFFGOTO << @L22 | |
# call move_east | |
CALL << @move_east | |
POP | |
GOTO << @L23 | |
@L22 | |
# call push_west | |
CALL << @push_west | |
POP | |
@L23 | |
# return | |
PUSH 1 | |
RETURN | |
@L24 | |
@L25 | |
# call equal | |
PEEK << 1 | |
ADD << 4 | |
PEEK | |
PUSH @cell_robot | |
EQUAL | |
IFFGOTO << @L28 | |
# call equal | |
PEEK << 3 | |
ADD << 4 | |
PEEK | |
PUSH @cell_empty | |
EQUAL | |
IFFGOTO << @L26 | |
# call move_west | |
CALL << @move_west | |
POP | |
GOTO << @L27 | |
@L26 | |
# call push_east | |
CALL << @push_east | |
POP | |
@L27 | |
# return | |
PUSH 1 | |
RETURN | |
@L28 | |
@L29 | |
# call equal | |
PEEK << 0 | |
ADD << 4 | |
PEEK | |
PUSH @cell_robot | |
EQUAL | |
IFFGOTO << @L32 | |
# call equal | |
PEEK << 2 | |
ADD << 4 | |
PEEK | |
PUSH @cell_empty | |
EQUAL | |
IFFGOTO << @L30 | |
# call move_south | |
CALL << @move_south | |
POP | |
GOTO << @L31 | |
@L30 | |
# call push_north | |
CALL << @push_north | |
POP | |
@L31 | |
# return | |
PUSH 1 | |
RETURN | |
@L32 | |
@L33 | |
# call equal | |
PEEK << 2 | |
ADD << 4 | |
PEEK | |
PUSH @cell_robot | |
EQUAL | |
IFFGOTO << @L36 | |
# call equal | |
PEEK << 0 | |
ADD << 4 | |
PEEK | |
PUSH @cell_empty | |
EQUAL | |
IFFGOTO << @L34 | |
# call move_north | |
CALL << @move_north | |
POP | |
GOTO << @L35 | |
@L34 | |
# call push_south | |
CALL << @push_south | |
POP | |
@L35 | |
# return | |
PUSH 1 | |
RETURN | |
@L36 | |
@L37 | |
# return | |
PUSH 0 | |
RETURN | |
# end @push_bots | |
@move_clear | |
# assign n | |
PUSH 0 | |
@L38 | |
# call less | |
DUP | |
# call add | |
PEEK << 3 | |
PUSH 1 | |
ADD | |
LESS | |
IFFGOTO << @L41 | |
# call equal | |
DUP | |
ADD << 4 | |
PEEK | |
PUSH @cell_empty | |
EQUAL | |
IFFGOTO << @L39 | |
# call move_direction | |
DUP | |
CALL << @move_direction | |
POP | |
# return | |
POP | |
PUSH 1 | |
RETURN | |
@L39 | |
@L40 | |
# call add | |
DUP | |
PUSH 1 | |
ADD | |
PUSH -1 | |
POKE | |
GOTO << @L38 | |
@L41 | |
# return | |
POP | |
PUSH 0 | |
RETURN | |
# end @move_clear | |
@main | |
PUSH 0 | |
PUSH 0 | |
POKE | |
PUSH 1 | |
PUSH 1 | |
POKE | |
PUSH 2 | |
PUSH 2 | |
POKE | |
PUSH 3 | |
PUSH 3 | |
POKE | |
@L42 | |
PUSH 1 | |
IFFGOTO << @L47 | |
# call clear | |
CALL << @clear | |
POP | |
# call survey | |
CALL << @survey | |
POP | |
# call pull_resources | |
CALL << @pull_resources | |
IFFGOTO << @L43 | |
GOTO << @L46 | |
@L43 | |
# call move_clear | |
CALL << @move_clear | |
IFFGOTO << @L44 | |
GOTO << @L45 | |
@L44 | |
# call push_bots | |
CALL << @push_bots | |
POP | |
@L45 | |
@L46 | |
GOTO << @L42 | |
@L47 | |
# return | |
PUSH 0 | |
RETURN | |
# end @main | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment