Skip to content

Instantly share code, notes, and snippets.

@sogaiu
Last active March 5, 2025 07:39
Show Gist options
  • Save sogaiu/0852651705b5b33933d48e8e33956043 to your computer and use it in GitHub Desktop.
Save sogaiu/0852651705b5b33933d48e8e33956043 to your computer and use it in GitHub Desktop.
DS can be negative
(defn f
[]
(var i 32768)
(while (pos? i)
(when (= i 32768)
(print "boo!"))
(-- i)))
(comment
(disasm f :bytecode)
# =>
'@[(ldc 1 0)
(push 1)
(ldc 3 1)
(call 2 3)
(jmpno 2 10)
(ldc 4 0)
(eq 3 1 4)
(jmpno 3 5)
(ldc 4 2)
(push 4)
(ldc 5 3)
(call 4 5)
(subim 1 1 1)
(jmp -12)
(retn)]
(disasm f :constants)
# =>
@[32768 pos? "boo!" print]
)
(defn main
[& _]
(getline "Press Enter to start.")
(f))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment