Last active
January 16, 2020 23:18
-
-
Save tobiasvl/121e133a7a3f71784f3b9965618e2a65 to your computer and use it in GitHub Desktop.
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
# switch/case macro, should be followed by a jump table with the same number of entries as cases | |
:macro switch REG { | |
v0 := REG | |
v0 <<= v0 | |
:calc table { HERE + 10 } | |
# for Super-CHIP compatibility, we also load VX for use with jump0 where X is the upper digit of the table's address | |
# note that if the table is located at address 0xA00 or above, we'll clobber necessary registers here! | |
:calc table-reg { table >> 8 } | |
v9 := 0x9 | |
v9 -= v0 | |
if vf == 0 then | |
:breakpoint switch-uses-reserved-registers | |
:byte { 0x80 | table-reg } 0x00 # 8X00, VX := V0 | |
jump0 table | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment