Skip to content

Instantly share code, notes, and snippets.

@cotto
Created June 9, 2011 15:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cotto/1017046 to your computer and use it in GitHub Desktop.
Save cotto/1017046 to your computer and use it in GitHub Desktop.
m0 gotos as values
.version 0
.chunk "hello"
.constants
0 "at start"
1 "at end: goto worked!"
2 "at end: goto failed :("
.metadata
.bytecode
set_imm I0, 0, 0
set_imm S0, 0, 0
deref S0, CONSTS, S0
print_s I0, S0, x
set_imm I3, do_print
goto I3, x, x
goto dont_print, x
do_print:
set_imm S0, 0, 1
deref S0, CONSTS, I0
print_s I0, S0, x
exit I0, x, x
dont_print:
set_imm S0, 0, 2
deref S0, CONSTS, I0
print_s I0, S0, x
exit I0, x, x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment