Self modifying code to save 2 bytes

This commit is contained in:
Neil McPhail 2024-10-21 16:23:30 +00:00
parent c2b615098e
commit a3adb86add

View File

@ -1,5 +1,7 @@
org 51000 org 51000
counter EQU inc_counter + 1
zero_counter: zero_counter:
xor a xor a
@ -51,13 +53,10 @@ key_5:
call play call play
inc_counter: inc_counter:
ld a, (counter) ld a, 0 ;This value will be modified by the running code
add a, 5 add a, 5
cp 25 cp 25
jr nz, set_counter jr nz, set_counter
jr zero_counter jr zero_counter
counter:
defb 0
INCLUDE "sample.asm" INCLUDE "sample.asm"