class GB::Opcodes
Defined in:
crab/gb/opcodes.cr
Constant Summary
-
PREFIXED =
[->(cpu : CPU) do
cpu.inc_pc
cpu.b = (cpu.b << 1) + (cpu.b >> 7)
cpu.f_z = cpu.b == 0
cpu.f_c = cpu.b & 1
cpu.f_n = false
cpu.f_h = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.c = (cpu.c << 1) + (cpu.c >> 7)
cpu.f_z = cpu.c == 0
cpu.f_c = cpu.c & 1
cpu.f_n = false
cpu.f_h = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.d = (cpu.d << 1) + (cpu.d >> 7)
cpu.f_z = cpu.d == 0
cpu.f_c = cpu.d & 1
cpu.f_n = false
cpu.f_h = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.e = (cpu.e << 1) + (cpu.e >> 7)
cpu.f_z = cpu.e == 0
cpu.f_c = cpu.e & 1
cpu.f_n = false
cpu.f_h = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.h = (cpu.h << 1) + (cpu.h >> 7)
cpu.f_z = cpu.h == 0
cpu.f_c = cpu.h & 1
cpu.f_n = false
cpu.f_h = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.l = (cpu.l << 1) + (cpu.l >> 7)
cpu.f_z = cpu.l == 0
cpu.f_c = cpu.l & 1
cpu.f_n = false
cpu.f_h = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.memory_at_hl = (cpu.memory_at_hl << 1) + (cpu.memory_at_hl >> 7)
cpu.f_z = cpu.memory_at_hl == 0
cpu.f_c = cpu.memory_at_hl & 1
cpu.f_n = false
cpu.f_h = false
return 16
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = (cpu.a << 1) + (cpu.a >> 7)
cpu.f_z = cpu.a == 0
cpu.f_c = cpu.a & 1
cpu.f_n = false
cpu.f_h = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.b = (cpu.b >> 1) + (cpu.b << 7)
cpu.f_z = cpu.b == 0
cpu.f_c = cpu.b & 128
cpu.f_n = false
cpu.f_h = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.c = (cpu.c >> 1) + (cpu.c << 7)
cpu.f_z = cpu.c == 0
cpu.f_c = cpu.c & 128
cpu.f_n = false
cpu.f_h = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.d = (cpu.d >> 1) + (cpu.d << 7)
cpu.f_z = cpu.d == 0
cpu.f_c = cpu.d & 128
cpu.f_n = false
cpu.f_h = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.e = (cpu.e >> 1) + (cpu.e << 7)
cpu.f_z = cpu.e == 0
cpu.f_c = cpu.e & 128
cpu.f_n = false
cpu.f_h = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.h = (cpu.h >> 1) + (cpu.h << 7)
cpu.f_z = cpu.h == 0
cpu.f_c = cpu.h & 128
cpu.f_n = false
cpu.f_h = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.l = (cpu.l >> 1) + (cpu.l << 7)
cpu.f_z = cpu.l == 0
cpu.f_c = cpu.l & 128
cpu.f_n = false
cpu.f_h = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.memory_at_hl = (cpu.memory_at_hl >> 1) + (cpu.memory_at_hl << 7)
cpu.f_z = cpu.memory_at_hl == 0
cpu.f_c = cpu.memory_at_hl & 128
cpu.f_n = false
cpu.f_h = false
return 16
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = (cpu.a >> 1) + (cpu.a << 7)
cpu.f_z = cpu.a == 0
cpu.f_c = cpu.a & 128
cpu.f_n = false
cpu.f_h = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
carry = cpu.b & 128
cpu.b = (cpu.b << 1) + (cpu.f_c ? 1 : 0)
cpu.f_z = cpu.b == 0
cpu.f_c = carry
cpu.f_n = false
cpu.f_h = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
carry = cpu.c & 128
cpu.c = (cpu.c << 1) + (cpu.f_c ? 1 : 0)
cpu.f_z = cpu.c == 0
cpu.f_c = carry
cpu.f_n = false
cpu.f_h = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
carry = cpu.d & 128
cpu.d = (cpu.d << 1) + (cpu.f_c ? 1 : 0)
cpu.f_z = cpu.d == 0
cpu.f_c = carry
cpu.f_n = false
cpu.f_h = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
carry = cpu.e & 128
cpu.e = (cpu.e << 1) + (cpu.f_c ? 1 : 0)
cpu.f_z = cpu.e == 0
cpu.f_c = carry
cpu.f_n = false
cpu.f_h = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
carry = cpu.h & 128
cpu.h = (cpu.h << 1) + (cpu.f_c ? 1 : 0)
cpu.f_z = cpu.h == 0
cpu.f_c = carry
cpu.f_n = false
cpu.f_h = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
carry = cpu.l & 128
cpu.l = (cpu.l << 1) + (cpu.f_c ? 1 : 0)
cpu.f_z = cpu.l == 0
cpu.f_c = carry
cpu.f_n = false
cpu.f_h = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
carry = cpu.memory_at_hl & 128
cpu.memory_at_hl = (cpu.memory_at_hl << 1) + (cpu.f_c ? 1 : 0)
cpu.f_z = cpu.memory_at_hl == 0
cpu.f_c = carry
cpu.f_n = false
cpu.f_h = false
return 16
end, ->(cpu : CPU) do
cpu.inc_pc
carry = cpu.a & 128
cpu.a = (cpu.a << 1) + (cpu.f_c ? 1 : 0)
cpu.f_z = cpu.a == 0
cpu.f_c = carry
cpu.f_n = false
cpu.f_h = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
carry = cpu.b & 1
cpu.b = (cpu.b >> 1) + (cpu.f_c ? 128 : 0)
cpu.f_z = cpu.b == 0
cpu.f_c = carry
cpu.f_n = false
cpu.f_h = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
carry = cpu.c & 1
cpu.c = (cpu.c >> 1) + (cpu.f_c ? 128 : 0)
cpu.f_z = cpu.c == 0
cpu.f_c = carry
cpu.f_n = false
cpu.f_h = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
carry = cpu.d & 1
cpu.d = (cpu.d >> 1) + (cpu.f_c ? 128 : 0)
cpu.f_z = cpu.d == 0
cpu.f_c = carry
cpu.f_n = false
cpu.f_h = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
carry = cpu.e & 1
cpu.e = (cpu.e >> 1) + (cpu.f_c ? 128 : 0)
cpu.f_z = cpu.e == 0
cpu.f_c = carry
cpu.f_n = false
cpu.f_h = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
carry = cpu.h & 1
cpu.h = (cpu.h >> 1) + (cpu.f_c ? 128 : 0)
cpu.f_z = cpu.h == 0
cpu.f_c = carry
cpu.f_n = false
cpu.f_h = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
carry = cpu.l & 1
cpu.l = (cpu.l >> 1) + (cpu.f_c ? 128 : 0)
cpu.f_z = cpu.l == 0
cpu.f_c = carry
cpu.f_n = false
cpu.f_h = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
carry = cpu.memory_at_hl & 1
cpu.memory_at_hl = (cpu.memory_at_hl >> 1) + (cpu.f_c ? 128 : 0)
cpu.f_z = cpu.memory_at_hl == 0
cpu.f_c = carry
cpu.f_n = false
cpu.f_h = false
return 16
end, ->(cpu : CPU) do
cpu.inc_pc
carry = cpu.a & 1
cpu.a = (cpu.a >> 1) + (cpu.f_c ? 128 : 0)
cpu.f_z = cpu.a == 0
cpu.f_c = carry
cpu.f_n = false
cpu.f_h = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_c = cpu.b & 128
cpu.b = cpu.b << 1
cpu.f_z = cpu.b == 0
cpu.f_n = false
cpu.f_h = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_c = cpu.c & 128
cpu.c = cpu.c << 1
cpu.f_z = cpu.c == 0
cpu.f_n = false
cpu.f_h = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_c = cpu.d & 128
cpu.d = cpu.d << 1
cpu.f_z = cpu.d == 0
cpu.f_n = false
cpu.f_h = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_c = cpu.e & 128
cpu.e = cpu.e << 1
cpu.f_z = cpu.e == 0
cpu.f_n = false
cpu.f_h = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_c = cpu.h & 128
cpu.h = cpu.h << 1
cpu.f_z = cpu.h == 0
cpu.f_n = false
cpu.f_h = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_c = cpu.l & 128
cpu.l = cpu.l << 1
cpu.f_z = cpu.l == 0
cpu.f_n = false
cpu.f_h = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_c = cpu.memory_at_hl & 128
cpu.memory_at_hl = cpu.memory_at_hl << 1
cpu.f_z = cpu.memory_at_hl == 0
cpu.f_n = false
cpu.f_h = false
return 16
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_c = cpu.a & 128
cpu.a = cpu.a << 1
cpu.f_z = cpu.a == 0
cpu.f_n = false
cpu.f_h = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_c = cpu.b & 1
cpu.b = (cpu.b >> 1) + (cpu.b & 128)
cpu.f_z = cpu.b == 0
cpu.f_n = false
cpu.f_h = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_c = cpu.c & 1
cpu.c = (cpu.c >> 1) + (cpu.c & 128)
cpu.f_z = cpu.c == 0
cpu.f_n = false
cpu.f_h = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_c = cpu.d & 1
cpu.d = (cpu.d >> 1) + (cpu.d & 128)
cpu.f_z = cpu.d == 0
cpu.f_n = false
cpu.f_h = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_c = cpu.e & 1
cpu.e = (cpu.e >> 1) + (cpu.e & 128)
cpu.f_z = cpu.e == 0
cpu.f_n = false
cpu.f_h = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_c = cpu.h & 1
cpu.h = (cpu.h >> 1) + (cpu.h & 128)
cpu.f_z = cpu.h == 0
cpu.f_n = false
cpu.f_h = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_c = cpu.l & 1
cpu.l = (cpu.l >> 1) + (cpu.l & 128)
cpu.f_z = cpu.l == 0
cpu.f_n = false
cpu.f_h = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_c = cpu.memory_at_hl & 1
cpu.memory_at_hl = (cpu.memory_at_hl >> 1) + (cpu.memory_at_hl & 128)
cpu.f_z = cpu.memory_at_hl == 0
cpu.f_n = false
cpu.f_h = false
return 16
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_c = cpu.a & 1
cpu.a = (cpu.a >> 1) + (cpu.a & 128)
cpu.f_z = cpu.a == 0
cpu.f_n = false
cpu.f_h = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.b = (cpu.b << 4) + (cpu.b >> 4)
cpu.f_z = cpu.b == 0
cpu.f_n = false
cpu.f_h = false
cpu.f_c = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.c = (cpu.c << 4) + (cpu.c >> 4)
cpu.f_z = cpu.c == 0
cpu.f_n = false
cpu.f_h = false
cpu.f_c = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.d = (cpu.d << 4) + (cpu.d >> 4)
cpu.f_z = cpu.d == 0
cpu.f_n = false
cpu.f_h = false
cpu.f_c = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.e = (cpu.e << 4) + (cpu.e >> 4)
cpu.f_z = cpu.e == 0
cpu.f_n = false
cpu.f_h = false
cpu.f_c = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.h = (cpu.h << 4) + (cpu.h >> 4)
cpu.f_z = cpu.h == 0
cpu.f_n = false
cpu.f_h = false
cpu.f_c = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.l = (cpu.l << 4) + (cpu.l >> 4)
cpu.f_z = cpu.l == 0
cpu.f_n = false
cpu.f_h = false
cpu.f_c = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.memory_at_hl = (cpu.memory_at_hl << 4) + (cpu.memory_at_hl >> 4)
cpu.f_z = cpu.memory_at_hl == 0
cpu.f_n = false
cpu.f_h = false
cpu.f_c = false
return 16
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = (cpu.a << 4) + (cpu.a >> 4)
cpu.f_z = cpu.a == 0
cpu.f_n = false
cpu.f_h = false
cpu.f_c = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_c = cpu.b & 1
cpu.b = cpu.b >> 1
cpu.f_z = cpu.b == 0
cpu.f_n = false
cpu.f_h = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_c = cpu.c & 1
cpu.c = cpu.c >> 1
cpu.f_z = cpu.c == 0
cpu.f_n = false
cpu.f_h = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_c = cpu.d & 1
cpu.d = cpu.d >> 1
cpu.f_z = cpu.d == 0
cpu.f_n = false
cpu.f_h = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_c = cpu.e & 1
cpu.e = cpu.e >> 1
cpu.f_z = cpu.e == 0
cpu.f_n = false
cpu.f_h = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_c = cpu.h & 1
cpu.h = cpu.h >> 1
cpu.f_z = cpu.h == 0
cpu.f_n = false
cpu.f_h = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_c = cpu.l & 1
cpu.l = cpu.l >> 1
cpu.f_z = cpu.l == 0
cpu.f_n = false
cpu.f_h = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_c = cpu.memory_at_hl & 1
cpu.memory_at_hl = cpu.memory_at_hl >> 1
cpu.f_z = cpu.memory_at_hl == 0
cpu.f_n = false
cpu.f_h = false
return 16
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_c = cpu.a & 1
cpu.a = cpu.a >> 1
cpu.f_z = cpu.a == 0
cpu.f_n = false
cpu.f_h = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.b & (1 << 0)) == 0
cpu.f_n = false
cpu.f_h = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.c & (1 << 0)) == 0
cpu.f_n = false
cpu.f_h = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.d & (1 << 0)) == 0
cpu.f_n = false
cpu.f_h = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.e & (1 << 0)) == 0
cpu.f_n = false
cpu.f_h = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.h & (1 << 0)) == 0
cpu.f_n = false
cpu.f_h = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.l & (1 << 0)) == 0
cpu.f_n = false
cpu.f_h = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.memory_at_hl & (1 << 0)) == 0
cpu.f_n = false
cpu.f_h = true
return 12
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.a & (1 << 0)) == 0
cpu.f_n = false
cpu.f_h = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.b & (1 << 1)) == 0
cpu.f_n = false
cpu.f_h = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.c & (1 << 1)) == 0
cpu.f_n = false
cpu.f_h = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.d & (1 << 1)) == 0
cpu.f_n = false
cpu.f_h = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.e & (1 << 1)) == 0
cpu.f_n = false
cpu.f_h = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.h & (1 << 1)) == 0
cpu.f_n = false
cpu.f_h = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.l & (1 << 1)) == 0
cpu.f_n = false
cpu.f_h = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.memory_at_hl & (1 << 1)) == 0
cpu.f_n = false
cpu.f_h = true
return 12
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.a & (1 << 1)) == 0
cpu.f_n = false
cpu.f_h = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.b & (1 << 2)) == 0
cpu.f_n = false
cpu.f_h = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.c & (1 << 2)) == 0
cpu.f_n = false
cpu.f_h = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.d & (1 << 2)) == 0
cpu.f_n = false
cpu.f_h = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.e & (1 << 2)) == 0
cpu.f_n = false
cpu.f_h = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.h & (1 << 2)) == 0
cpu.f_n = false
cpu.f_h = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.l & (1 << 2)) == 0
cpu.f_n = false
cpu.f_h = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.memory_at_hl & (1 << 2)) == 0
cpu.f_n = false
cpu.f_h = true
return 12
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.a & (1 << 2)) == 0
cpu.f_n = false
cpu.f_h = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.b & (1 << 3)) == 0
cpu.f_n = false
cpu.f_h = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.c & (1 << 3)) == 0
cpu.f_n = false
cpu.f_h = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.d & (1 << 3)) == 0
cpu.f_n = false
cpu.f_h = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.e & (1 << 3)) == 0
cpu.f_n = false
cpu.f_h = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.h & (1 << 3)) == 0
cpu.f_n = false
cpu.f_h = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.l & (1 << 3)) == 0
cpu.f_n = false
cpu.f_h = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.memory_at_hl & (1 << 3)) == 0
cpu.f_n = false
cpu.f_h = true
return 12
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.a & (1 << 3)) == 0
cpu.f_n = false
cpu.f_h = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.b & (1 << 4)) == 0
cpu.f_n = false
cpu.f_h = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.c & (1 << 4)) == 0
cpu.f_n = false
cpu.f_h = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.d & (1 << 4)) == 0
cpu.f_n = false
cpu.f_h = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.e & (1 << 4)) == 0
cpu.f_n = false
cpu.f_h = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.h & (1 << 4)) == 0
cpu.f_n = false
cpu.f_h = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.l & (1 << 4)) == 0
cpu.f_n = false
cpu.f_h = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.memory_at_hl & (1 << 4)) == 0
cpu.f_n = false
cpu.f_h = true
return 12
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.a & (1 << 4)) == 0
cpu.f_n = false
cpu.f_h = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.b & (1 << 5)) == 0
cpu.f_n = false
cpu.f_h = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.c & (1 << 5)) == 0
cpu.f_n = false
cpu.f_h = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.d & (1 << 5)) == 0
cpu.f_n = false
cpu.f_h = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.e & (1 << 5)) == 0
cpu.f_n = false
cpu.f_h = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.h & (1 << 5)) == 0
cpu.f_n = false
cpu.f_h = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.l & (1 << 5)) == 0
cpu.f_n = false
cpu.f_h = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.memory_at_hl & (1 << 5)) == 0
cpu.f_n = false
cpu.f_h = true
return 12
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.a & (1 << 5)) == 0
cpu.f_n = false
cpu.f_h = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.b & (1 << 6)) == 0
cpu.f_n = false
cpu.f_h = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.c & (1 << 6)) == 0
cpu.f_n = false
cpu.f_h = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.d & (1 << 6)) == 0
cpu.f_n = false
cpu.f_h = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.e & (1 << 6)) == 0
cpu.f_n = false
cpu.f_h = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.h & (1 << 6)) == 0
cpu.f_n = false
cpu.f_h = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.l & (1 << 6)) == 0
cpu.f_n = false
cpu.f_h = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.memory_at_hl & (1 << 6)) == 0
cpu.f_n = false
cpu.f_h = true
return 12
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.a & (1 << 6)) == 0
cpu.f_n = false
cpu.f_h = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.b & (1 << 7)) == 0
cpu.f_n = false
cpu.f_h = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.c & (1 << 7)) == 0
cpu.f_n = false
cpu.f_h = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.d & (1 << 7)) == 0
cpu.f_n = false
cpu.f_h = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.e & (1 << 7)) == 0
cpu.f_n = false
cpu.f_h = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.h & (1 << 7)) == 0
cpu.f_n = false
cpu.f_h = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.l & (1 << 7)) == 0
cpu.f_n = false
cpu.f_h = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.memory_at_hl & (1 << 7)) == 0
cpu.f_n = false
cpu.f_h = true
return 12
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.a & (1 << 7)) == 0
cpu.f_n = false
cpu.f_h = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.b = cpu.b & (~(1 << 0))
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.c = cpu.c & (~(1 << 0))
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.d = cpu.d & (~(1 << 0))
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.e = cpu.e & (~(1 << 0))
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.h = cpu.h & (~(1 << 0))
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.l = cpu.l & (~(1 << 0))
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.memory_at_hl = cpu.memory_at_hl & (~(1 << 0))
return 16
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = cpu.a & (~(1 << 0))
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.b = cpu.b & (~(1 << 1))
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.c = cpu.c & (~(1 << 1))
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.d = cpu.d & (~(1 << 1))
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.e = cpu.e & (~(1 << 1))
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.h = cpu.h & (~(1 << 1))
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.l = cpu.l & (~(1 << 1))
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.memory_at_hl = cpu.memory_at_hl & (~(1 << 1))
return 16
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = cpu.a & (~(1 << 1))
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.b = cpu.b & (~(1 << 2))
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.c = cpu.c & (~(1 << 2))
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.d = cpu.d & (~(1 << 2))
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.e = cpu.e & (~(1 << 2))
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.h = cpu.h & (~(1 << 2))
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.l = cpu.l & (~(1 << 2))
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.memory_at_hl = cpu.memory_at_hl & (~(1 << 2))
return 16
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = cpu.a & (~(1 << 2))
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.b = cpu.b & (~(1 << 3))
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.c = cpu.c & (~(1 << 3))
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.d = cpu.d & (~(1 << 3))
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.e = cpu.e & (~(1 << 3))
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.h = cpu.h & (~(1 << 3))
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.l = cpu.l & (~(1 << 3))
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.memory_at_hl = cpu.memory_at_hl & (~(1 << 3))
return 16
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = cpu.a & (~(1 << 3))
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.b = cpu.b & (~(1 << 4))
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.c = cpu.c & (~(1 << 4))
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.d = cpu.d & (~(1 << 4))
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.e = cpu.e & (~(1 << 4))
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.h = cpu.h & (~(1 << 4))
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.l = cpu.l & (~(1 << 4))
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.memory_at_hl = cpu.memory_at_hl & (~(1 << 4))
return 16
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = cpu.a & (~(1 << 4))
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.b = cpu.b & (~(1 << 5))
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.c = cpu.c & (~(1 << 5))
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.d = cpu.d & (~(1 << 5))
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.e = cpu.e & (~(1 << 5))
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.h = cpu.h & (~(1 << 5))
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.l = cpu.l & (~(1 << 5))
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.memory_at_hl = cpu.memory_at_hl & (~(1 << 5))
return 16
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = cpu.a & (~(1 << 5))
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.b = cpu.b & (~(1 << 6))
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.c = cpu.c & (~(1 << 6))
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.d = cpu.d & (~(1 << 6))
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.e = cpu.e & (~(1 << 6))
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.h = cpu.h & (~(1 << 6))
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.l = cpu.l & (~(1 << 6))
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.memory_at_hl = cpu.memory_at_hl & (~(1 << 6))
return 16
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = cpu.a & (~(1 << 6))
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.b = cpu.b & (~(1 << 7))
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.c = cpu.c & (~(1 << 7))
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.d = cpu.d & (~(1 << 7))
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.e = cpu.e & (~(1 << 7))
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.h = cpu.h & (~(1 << 7))
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.l = cpu.l & (~(1 << 7))
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.memory_at_hl = cpu.memory_at_hl & (~(1 << 7))
return 16
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = cpu.a & (~(1 << 7))
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.b = cpu.b | (1 << 0)
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.c = cpu.c | (1 << 0)
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.d = cpu.d | (1 << 0)
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.e = cpu.e | (1 << 0)
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.h = cpu.h | (1 << 0)
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.l = cpu.l | (1 << 0)
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.memory_at_hl = cpu.memory_at_hl | (1 << 0)
return 16
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = cpu.a | (1 << 0)
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.b = cpu.b | (1 << 1)
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.c = cpu.c | (1 << 1)
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.d = cpu.d | (1 << 1)
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.e = cpu.e | (1 << 1)
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.h = cpu.h | (1 << 1)
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.l = cpu.l | (1 << 1)
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.memory_at_hl = cpu.memory_at_hl | (1 << 1)
return 16
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = cpu.a | (1 << 1)
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.b = cpu.b | (1 << 2)
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.c = cpu.c | (1 << 2)
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.d = cpu.d | (1 << 2)
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.e = cpu.e | (1 << 2)
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.h = cpu.h | (1 << 2)
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.l = cpu.l | (1 << 2)
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.memory_at_hl = cpu.memory_at_hl | (1 << 2)
return 16
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = cpu.a | (1 << 2)
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.b = cpu.b | (1 << 3)
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.c = cpu.c | (1 << 3)
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.d = cpu.d | (1 << 3)
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.e = cpu.e | (1 << 3)
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.h = cpu.h | (1 << 3)
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.l = cpu.l | (1 << 3)
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.memory_at_hl = cpu.memory_at_hl | (1 << 3)
return 16
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = cpu.a | (1 << 3)
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.b = cpu.b | (1 << 4)
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.c = cpu.c | (1 << 4)
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.d = cpu.d | (1 << 4)
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.e = cpu.e | (1 << 4)
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.h = cpu.h | (1 << 4)
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.l = cpu.l | (1 << 4)
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.memory_at_hl = cpu.memory_at_hl | (1 << 4)
return 16
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = cpu.a | (1 << 4)
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.b = cpu.b | (1 << 5)
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.c = cpu.c | (1 << 5)
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.d = cpu.d | (1 << 5)
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.e = cpu.e | (1 << 5)
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.h = cpu.h | (1 << 5)
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.l = cpu.l | (1 << 5)
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.memory_at_hl = cpu.memory_at_hl | (1 << 5)
return 16
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = cpu.a | (1 << 5)
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.b = cpu.b | (1 << 6)
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.c = cpu.c | (1 << 6)
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.d = cpu.d | (1 << 6)
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.e = cpu.e | (1 << 6)
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.h = cpu.h | (1 << 6)
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.l = cpu.l | (1 << 6)
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.memory_at_hl = cpu.memory_at_hl | (1 << 6)
return 16
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = cpu.a | (1 << 6)
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.b = cpu.b | (1 << 7)
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.c = cpu.c | (1 << 7)
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.d = cpu.d | (1 << 7)
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.e = cpu.e | (1 << 7)
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.h = cpu.h | (1 << 7)
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.l = cpu.l | (1 << 7)
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.memory_at_hl = cpu.memory_at_hl | (1 << 7)
return 16
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = cpu.a | (1 << 7)
return 8
end]
-
UNPREFIXED =
[->(cpu : CPU) do
cpu.inc_pc
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
u16 = cpu.memory[cpu.pc].to_u16
cpu.inc_pc
u16 = u16 | (cpu.memory[cpu.pc].to_u16 << 8)
cpu.inc_pc
cpu.bc = u16
return 12
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.memory[cpu.bc] = cpu.a
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.bc = cpu.bc &+ 1
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_h = (cpu.b & 15) == 15
cpu.b = cpu.b &+ 1
cpu.f_z = cpu.b == 0
cpu.f_n = false
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.b = cpu.b &- 1
cpu.f_z = cpu.b == 0
cpu.f_h = (cpu.b & 15) == 15
cpu.f_n = true
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
u8 = cpu.memory[cpu.pc]
cpu.inc_pc
cpu.b = u8
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = (cpu.a << 1) + (cpu.a >> 7)
cpu.f_c = cpu.a & 1
cpu.f_z = false
cpu.f_n = false
cpu.f_h = false
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
u16 = cpu.memory[cpu.pc].to_u16
cpu.inc_pc
u16 = u16 | (cpu.memory[cpu.pc].to_u16 << 8)
cpu.inc_pc
cpu.memory[u16] = cpu.sp
return 20
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_h = ((cpu.hl & 4095).to_u32 + (cpu.bc & 4095)) > 4095
cpu.hl = cpu.hl &+ cpu.bc
cpu.f_c = cpu.hl < cpu.bc
cpu.f_n = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = cpu.memory[cpu.bc]
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.bc = cpu.bc &- 1
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_h = (cpu.c & 15) == 15
cpu.c = cpu.c &+ 1
cpu.f_z = cpu.c == 0
cpu.f_n = false
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.c = cpu.c &- 1
cpu.f_z = cpu.c == 0
cpu.f_h = (cpu.c & 15) == 15
cpu.f_n = true
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
u8 = cpu.memory[cpu.pc]
cpu.inc_pc
cpu.c = u8
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = (cpu.a >> 1) + (cpu.a << 7)
cpu.f_c = cpu.a & 128
cpu.f_z = false
cpu.f_n = false
cpu.f_h = false
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.inc_pc
cpu.memory.stop_instr
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
u16 = cpu.memory[cpu.pc].to_u16
cpu.inc_pc
u16 = u16 | (cpu.memory[cpu.pc].to_u16 << 8)
cpu.inc_pc
cpu.de = u16
return 12
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.memory[cpu.de] = cpu.a
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.de = cpu.de &+ 1
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_h = (cpu.d & 15) == 15
cpu.d = cpu.d &+ 1
cpu.f_z = cpu.d == 0
cpu.f_n = false
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.d = cpu.d &- 1
cpu.f_z = cpu.d == 0
cpu.f_h = (cpu.d & 15) == 15
cpu.f_n = true
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
u8 = cpu.memory[cpu.pc]
cpu.inc_pc
cpu.d = u8
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
carry = cpu.a & 128
cpu.a = (cpu.a << 1) + (cpu.f_c ? 1 : 0)
cpu.f_c = carry
cpu.f_z = false
cpu.f_n = false
cpu.f_h = false
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
i8 = cpu.memory[cpu.pc].to_i8!
cpu.inc_pc
cpu.pc = cpu.pc &+ i8
return 12
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_h = ((cpu.hl & 4095).to_u32 + (cpu.de & 4095)) > 4095
cpu.hl = cpu.hl &+ cpu.de
cpu.f_c = cpu.hl < cpu.de
cpu.f_n = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = cpu.memory[cpu.de]
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.de = cpu.de &- 1
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_h = (cpu.e & 15) == 15
cpu.e = cpu.e &+ 1
cpu.f_z = cpu.e == 0
cpu.f_n = false
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.e = cpu.e &- 1
cpu.f_z = cpu.e == 0
cpu.f_h = (cpu.e & 15) == 15
cpu.f_n = true
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
u8 = cpu.memory[cpu.pc]
cpu.inc_pc
cpu.e = u8
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
carry = cpu.a & 1
cpu.a = (cpu.a >> 1) + (cpu.f_c ? 128 : 0)
cpu.f_c = carry
cpu.f_z = false
cpu.f_n = false
cpu.f_h = false
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
i8 = cpu.memory[cpu.pc].to_i8!
cpu.inc_pc
if cpu.f_nz
cpu.pc = cpu.pc &+ i8
return 12
end
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
u16 = cpu.memory[cpu.pc].to_u16
cpu.inc_pc
u16 = u16 | (cpu.memory[cpu.pc].to_u16 << 8)
cpu.inc_pc
cpu.hl = u16
return 12
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.memory[( (cpu.hl = cpu.hl &+ 1) &- 1)] = cpu.a
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.hl = cpu.hl &+ 1
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_h = (cpu.h & 15) == 15
cpu.h = cpu.h &+ 1
cpu.f_z = cpu.h == 0
cpu.f_n = false
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.h = cpu.h &- 1
cpu.f_z = cpu.h == 0
cpu.f_h = (cpu.h & 15) == 15
cpu.f_n = true
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
u8 = cpu.memory[cpu.pc]
cpu.inc_pc
cpu.h = u8
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
if cpu.f_n
if cpu.f_c
cpu.a = cpu.a &- 96
end
if cpu.f_h
cpu.a = cpu.a &- 6
end
else
if cpu.f_c || cpu.a > 153
cpu.a = cpu.a &+ 96
cpu.f_c = true
end
if cpu.f_h || (cpu.a & 15) > 9
cpu.a = cpu.a &+ 6
end
end
cpu.f_z = cpu.a == 0
cpu.f_h = false
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
i8 = cpu.memory[cpu.pc].to_i8!
cpu.inc_pc
if cpu.f_z
cpu.pc = cpu.pc &+ i8
return 12
end
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_h = ((cpu.hl & 4095).to_u32 + (cpu.hl & 4095)) > 4095
cpu.f_c = cpu.hl > 32767
cpu.hl = cpu.hl &+ cpu.hl
cpu.f_n = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = cpu.memory[( (cpu.hl = cpu.hl &+ 1) &- 1)]
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.hl = cpu.hl &- 1
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_h = (cpu.l & 15) == 15
cpu.l = cpu.l &+ 1
cpu.f_z = cpu.l == 0
cpu.f_n = false
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.l = cpu.l &- 1
cpu.f_z = cpu.l == 0
cpu.f_h = (cpu.l & 15) == 15
cpu.f_n = true
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
u8 = cpu.memory[cpu.pc]
cpu.inc_pc
cpu.l = u8
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = ~cpu.a
cpu.f_n = true
cpu.f_h = true
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
i8 = cpu.memory[cpu.pc].to_i8!
cpu.inc_pc
if cpu.f_nc
cpu.pc = cpu.pc &+ i8
return 12
end
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
u16 = cpu.memory[cpu.pc].to_u16
cpu.inc_pc
u16 = u16 | (cpu.memory[cpu.pc].to_u16 << 8)
cpu.inc_pc
cpu.sp = u16
return 12
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.memory[( (cpu.hl = cpu.hl &- 1) &+ 1)] = cpu.a
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.sp = cpu.sp &+ 1
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_h = (cpu.memory_at_hl & 15) == 15
cpu.memory_at_hl = cpu.memory_at_hl &+ 1
cpu.f_z = cpu.memory_at_hl == 0
cpu.f_n = false
return 12
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.memory_at_hl = cpu.memory_at_hl &- 1
cpu.f_z = cpu.memory_at_hl == 0
cpu.f_h = (cpu.memory_at_hl & 15) == 15
cpu.f_n = true
return 12
end, ->(cpu : CPU) do
cpu.inc_pc
u8 = cpu.memory[cpu.pc]
cpu.inc_pc
cpu.memory_at_hl = u8
return 12
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_n = false
cpu.f_h = false
cpu.f_c = true
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
i8 = cpu.memory[cpu.pc].to_i8!
cpu.inc_pc
if cpu.f_c
cpu.pc = cpu.pc &+ i8
return 12
end
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_h = ((cpu.hl & 4095).to_u32 + (cpu.sp & 4095)) > 4095
cpu.hl = cpu.hl &+ cpu.sp
cpu.f_c = cpu.hl < cpu.sp
cpu.f_n = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = cpu.memory[( (cpu.hl = cpu.hl &- 1) &+ 1)]
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.sp = cpu.sp &- 1
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_h = (cpu.a & 15) == 15
cpu.a = cpu.a &+ 1
cpu.f_z = cpu.a == 0
cpu.f_n = false
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = cpu.a &- 1
cpu.f_z = cpu.a == 0
cpu.f_h = (cpu.a & 15) == 15
cpu.f_n = true
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
u8 = cpu.memory[cpu.pc]
cpu.inc_pc
cpu.a = u8
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_c = !cpu.f_c
cpu.f_n = false
cpu.f_h = false
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.b = cpu.b
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.b = cpu.c
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.b = cpu.d
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.b = cpu.e
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.b = cpu.h
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.b = cpu.l
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.b = cpu.memory_at_hl
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.b = cpu.a
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.c = cpu.b
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.c = cpu.c
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.c = cpu.d
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.c = cpu.e
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.c = cpu.h
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.c = cpu.l
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.c = cpu.memory_at_hl
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.c = cpu.a
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.d = cpu.b
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.d = cpu.c
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.d = cpu.d
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.d = cpu.e
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.d = cpu.h
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.d = cpu.l
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.d = cpu.memory_at_hl
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.d = cpu.a
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.e = cpu.b
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.e = cpu.c
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.e = cpu.d
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.e = cpu.e
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.e = cpu.h
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.e = cpu.l
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.e = cpu.memory_at_hl
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.e = cpu.a
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.h = cpu.b
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.h = cpu.c
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.h = cpu.d
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.h = cpu.e
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.h = cpu.h
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.h = cpu.l
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.h = cpu.memory_at_hl
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.h = cpu.a
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.l = cpu.b
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.l = cpu.c
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.l = cpu.d
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.l = cpu.e
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.l = cpu.h
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.l = cpu.l
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.l = cpu.memory_at_hl
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.l = cpu.a
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.memory_at_hl = cpu.b
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.memory_at_hl = cpu.c
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.memory_at_hl = cpu.d
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.memory_at_hl = cpu.e
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.memory_at_hl = cpu.h
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.memory_at_hl = cpu.l
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.halt
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.memory_at_hl = cpu.a
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = cpu.b
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = cpu.c
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = cpu.d
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = cpu.e
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = cpu.h
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = cpu.l
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = cpu.memory_at_hl
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = cpu.a
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_h = ((cpu.a & 15) + (cpu.b & 15)) > 15
cpu.a = cpu.a &+ cpu.b
cpu.f_z = cpu.a == 0
cpu.f_c = cpu.a < cpu.b
cpu.f_n = false
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_h = ((cpu.a & 15) + (cpu.c & 15)) > 15
cpu.a = cpu.a &+ cpu.c
cpu.f_z = cpu.a == 0
cpu.f_c = cpu.a < cpu.c
cpu.f_n = false
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_h = ((cpu.a & 15) + (cpu.d & 15)) > 15
cpu.a = cpu.a &+ cpu.d
cpu.f_z = cpu.a == 0
cpu.f_c = cpu.a < cpu.d
cpu.f_n = false
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_h = ((cpu.a & 15) + (cpu.e & 15)) > 15
cpu.a = cpu.a &+ cpu.e
cpu.f_z = cpu.a == 0
cpu.f_c = cpu.a < cpu.e
cpu.f_n = false
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_h = ((cpu.a & 15) + (cpu.h & 15)) > 15
cpu.a = cpu.a &+ cpu.h
cpu.f_z = cpu.a == 0
cpu.f_c = cpu.a < cpu.h
cpu.f_n = false
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_h = ((cpu.a & 15) + (cpu.l & 15)) > 15
cpu.a = cpu.a &+ cpu.l
cpu.f_z = cpu.a == 0
cpu.f_c = cpu.a < cpu.l
cpu.f_n = false
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_h = ((cpu.a & 15) + (cpu.memory_at_hl & 15)) > 15
cpu.a = cpu.a &+ cpu.memory_at_hl
cpu.f_z = cpu.a == 0
cpu.f_c = cpu.a < cpu.memory_at_hl
cpu.f_n = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_h = ((cpu.a & 15) + (cpu.a & 15)) > 15
cpu.f_c = cpu.a > 127
cpu.a = cpu.a &+ cpu.a
cpu.f_z = cpu.a == 0
cpu.f_n = false
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
carry = cpu.f_c ? 1 : 0
cpu.f_h = (((cpu.a & 15) + (cpu.b & 15)) + carry) > 15
cpu.a = cpu.a &+ (cpu.b &+ carry)
cpu.f_z = cpu.a == 0
cpu.f_c = cpu.a < (cpu.b.to_u16 + carry)
cpu.f_n = false
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
carry = cpu.f_c ? 1 : 0
cpu.f_h = (((cpu.a & 15) + (cpu.c & 15)) + carry) > 15
cpu.a = cpu.a &+ (cpu.c &+ carry)
cpu.f_z = cpu.a == 0
cpu.f_c = cpu.a < (cpu.c.to_u16 + carry)
cpu.f_n = false
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
carry = cpu.f_c ? 1 : 0
cpu.f_h = (((cpu.a & 15) + (cpu.d & 15)) + carry) > 15
cpu.a = cpu.a &+ (cpu.d &+ carry)
cpu.f_z = cpu.a == 0
cpu.f_c = cpu.a < (cpu.d.to_u16 + carry)
cpu.f_n = false
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
carry = cpu.f_c ? 1 : 0
cpu.f_h = (((cpu.a & 15) + (cpu.e & 15)) + carry) > 15
cpu.a = cpu.a &+ (cpu.e &+ carry)
cpu.f_z = cpu.a == 0
cpu.f_c = cpu.a < (cpu.e.to_u16 + carry)
cpu.f_n = false
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
carry = cpu.f_c ? 1 : 0
cpu.f_h = (((cpu.a & 15) + (cpu.h & 15)) + carry) > 15
cpu.a = cpu.a &+ (cpu.h &+ carry)
cpu.f_z = cpu.a == 0
cpu.f_c = cpu.a < (cpu.h.to_u16 + carry)
cpu.f_n = false
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
carry = cpu.f_c ? 1 : 0
cpu.f_h = (((cpu.a & 15) + (cpu.l & 15)) + carry) > 15
cpu.a = cpu.a &+ (cpu.l &+ carry)
cpu.f_z = cpu.a == 0
cpu.f_c = cpu.a < (cpu.l.to_u16 + carry)
cpu.f_n = false
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
carry = cpu.f_c ? 1 : 0
cpu.f_h = (((cpu.a & 15) + (cpu.memory_at_hl & 15)) + carry) > 15
cpu.a = cpu.a &+ (cpu.memory_at_hl &+ carry)
cpu.f_z = cpu.a == 0
cpu.f_c = cpu.a < (cpu.memory_at_hl.to_u16 + carry)
cpu.f_n = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
carry = cpu.f_c ? 1 : 0
cpu.f_h = (((cpu.a & 15) + (cpu.a & 15)) + carry) > 15
cpu.f_c = cpu.a > 127
cpu.a = cpu.a &+ (cpu.a &+ carry)
cpu.f_z = cpu.a == 0
cpu.f_n = false
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_h = (cpu.a & 15) < (cpu.b & 15)
cpu.f_c = cpu.a < cpu.b
cpu.a = cpu.a &- cpu.b
cpu.f_z = cpu.a == 0
cpu.f_n = true
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_h = (cpu.a & 15) < (cpu.c & 15)
cpu.f_c = cpu.a < cpu.c
cpu.a = cpu.a &- cpu.c
cpu.f_z = cpu.a == 0
cpu.f_n = true
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_h = (cpu.a & 15) < (cpu.d & 15)
cpu.f_c = cpu.a < cpu.d
cpu.a = cpu.a &- cpu.d
cpu.f_z = cpu.a == 0
cpu.f_n = true
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_h = (cpu.a & 15) < (cpu.e & 15)
cpu.f_c = cpu.a < cpu.e
cpu.a = cpu.a &- cpu.e
cpu.f_z = cpu.a == 0
cpu.f_n = true
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_h = (cpu.a & 15) < (cpu.h & 15)
cpu.f_c = cpu.a < cpu.h
cpu.a = cpu.a &- cpu.h
cpu.f_z = cpu.a == 0
cpu.f_n = true
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_h = (cpu.a & 15) < (cpu.l & 15)
cpu.f_c = cpu.a < cpu.l
cpu.a = cpu.a &- cpu.l
cpu.f_z = cpu.a == 0
cpu.f_n = true
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_h = (cpu.a & 15) < (cpu.memory_at_hl & 15)
cpu.f_c = cpu.a < cpu.memory_at_hl
cpu.a = cpu.a &- cpu.memory_at_hl
cpu.f_z = cpu.a == 0
cpu.f_n = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_h = (cpu.a & 15) < (cpu.a & 15)
cpu.f_c = cpu.a < cpu.a
cpu.a = cpu.a &- cpu.a
cpu.f_z = cpu.a == 0
cpu.f_n = true
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
to_sub = cpu.b.to_u16 + (cpu.f_c ? 1 : 0)
cpu.f_h = (cpu.a & 15) < ((cpu.b & 15) + (cpu.f_c ? 1 : 0))
cpu.f_c = cpu.a < to_sub
cpu.a = cpu.a &- to_sub
cpu.f_z = cpu.a == 0
cpu.f_n = true
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
to_sub = cpu.c.to_u16 + (cpu.f_c ? 1 : 0)
cpu.f_h = (cpu.a & 15) < ((cpu.c & 15) + (cpu.f_c ? 1 : 0))
cpu.f_c = cpu.a < to_sub
cpu.a = cpu.a &- to_sub
cpu.f_z = cpu.a == 0
cpu.f_n = true
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
to_sub = cpu.d.to_u16 + (cpu.f_c ? 1 : 0)
cpu.f_h = (cpu.a & 15) < ((cpu.d & 15) + (cpu.f_c ? 1 : 0))
cpu.f_c = cpu.a < to_sub
cpu.a = cpu.a &- to_sub
cpu.f_z = cpu.a == 0
cpu.f_n = true
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
to_sub = cpu.e.to_u16 + (cpu.f_c ? 1 : 0)
cpu.f_h = (cpu.a & 15) < ((cpu.e & 15) + (cpu.f_c ? 1 : 0))
cpu.f_c = cpu.a < to_sub
cpu.a = cpu.a &- to_sub
cpu.f_z = cpu.a == 0
cpu.f_n = true
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
to_sub = cpu.h.to_u16 + (cpu.f_c ? 1 : 0)
cpu.f_h = (cpu.a & 15) < ((cpu.h & 15) + (cpu.f_c ? 1 : 0))
cpu.f_c = cpu.a < to_sub
cpu.a = cpu.a &- to_sub
cpu.f_z = cpu.a == 0
cpu.f_n = true
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
to_sub = cpu.l.to_u16 + (cpu.f_c ? 1 : 0)
cpu.f_h = (cpu.a & 15) < ((cpu.l & 15) + (cpu.f_c ? 1 : 0))
cpu.f_c = cpu.a < to_sub
cpu.a = cpu.a &- to_sub
cpu.f_z = cpu.a == 0
cpu.f_n = true
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
to_sub = cpu.memory_at_hl.to_u16 + (cpu.f_c ? 1 : 0)
cpu.f_h = (cpu.a & 15) < ((cpu.memory_at_hl & 15) + (cpu.f_c ? 1 : 0))
cpu.f_c = cpu.a < to_sub
cpu.a = cpu.a &- to_sub
cpu.f_z = cpu.a == 0
cpu.f_n = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
to_sub = cpu.a.to_u16 + (cpu.f_c ? 1 : 0)
cpu.f_h = (cpu.a & 15) < ((cpu.a & 15) + (cpu.f_c ? 1 : 0))
cpu.f_c = cpu.a < to_sub
cpu.a = cpu.a &- to_sub
cpu.f_z = cpu.a == 0
cpu.f_n = true
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = cpu.a & cpu.b
cpu.f_z = cpu.a == 0
cpu.f_n = false
cpu.f_h = true
cpu.f_c = false
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = cpu.a & cpu.c
cpu.f_z = cpu.a == 0
cpu.f_n = false
cpu.f_h = true
cpu.f_c = false
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = cpu.a & cpu.d
cpu.f_z = cpu.a == 0
cpu.f_n = false
cpu.f_h = true
cpu.f_c = false
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = cpu.a & cpu.e
cpu.f_z = cpu.a == 0
cpu.f_n = false
cpu.f_h = true
cpu.f_c = false
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = cpu.a & cpu.h
cpu.f_z = cpu.a == 0
cpu.f_n = false
cpu.f_h = true
cpu.f_c = false
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = cpu.a & cpu.l
cpu.f_z = cpu.a == 0
cpu.f_n = false
cpu.f_h = true
cpu.f_c = false
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = cpu.a & cpu.memory_at_hl
cpu.f_z = cpu.a == 0
cpu.f_n = false
cpu.f_h = true
cpu.f_c = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = cpu.a & cpu.a
cpu.f_z = cpu.a == 0
cpu.f_n = false
cpu.f_h = true
cpu.f_c = false
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = cpu.a ^ cpu.b
cpu.f_z = cpu.a == 0
cpu.f_n = false
cpu.f_h = false
cpu.f_c = false
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = cpu.a ^ cpu.c
cpu.f_z = cpu.a == 0
cpu.f_n = false
cpu.f_h = false
cpu.f_c = false
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = cpu.a ^ cpu.d
cpu.f_z = cpu.a == 0
cpu.f_n = false
cpu.f_h = false
cpu.f_c = false
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = cpu.a ^ cpu.e
cpu.f_z = cpu.a == 0
cpu.f_n = false
cpu.f_h = false
cpu.f_c = false
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = cpu.a ^ cpu.h
cpu.f_z = cpu.a == 0
cpu.f_n = false
cpu.f_h = false
cpu.f_c = false
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = cpu.a ^ cpu.l
cpu.f_z = cpu.a == 0
cpu.f_n = false
cpu.f_h = false
cpu.f_c = false
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = cpu.a ^ cpu.memory_at_hl
cpu.f_z = cpu.a == 0
cpu.f_n = false
cpu.f_h = false
cpu.f_c = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = cpu.a ^ cpu.a
cpu.f_z = cpu.a == 0
cpu.f_n = false
cpu.f_h = false
cpu.f_c = false
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = cpu.a | cpu.b
cpu.f_z = cpu.a == 0
cpu.f_n = false
cpu.f_h = false
cpu.f_c = false
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = cpu.a | cpu.c
cpu.f_z = cpu.a == 0
cpu.f_n = false
cpu.f_h = false
cpu.f_c = false
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = cpu.a | cpu.d
cpu.f_z = cpu.a == 0
cpu.f_n = false
cpu.f_h = false
cpu.f_c = false
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = cpu.a | cpu.e
cpu.f_z = cpu.a == 0
cpu.f_n = false
cpu.f_h = false
cpu.f_c = false
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = cpu.a | cpu.h
cpu.f_z = cpu.a == 0
cpu.f_n = false
cpu.f_h = false
cpu.f_c = false
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = cpu.a | cpu.l
cpu.f_z = cpu.a == 0
cpu.f_n = false
cpu.f_h = false
cpu.f_c = false
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = cpu.a | cpu.memory_at_hl
cpu.f_z = cpu.a == 0
cpu.f_n = false
cpu.f_h = false
cpu.f_c = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = cpu.a | cpu.a
cpu.f_z = cpu.a == 0
cpu.f_n = false
cpu.f_h = false
cpu.f_c = false
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.a &- cpu.b) == 0
cpu.f_h = (cpu.a & 15) < (cpu.b & 15)
cpu.f_c = cpu.a < cpu.b
cpu.f_n = true
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.a &- cpu.c) == 0
cpu.f_h = (cpu.a & 15) < (cpu.c & 15)
cpu.f_c = cpu.a < cpu.c
cpu.f_n = true
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.a &- cpu.d) == 0
cpu.f_h = (cpu.a & 15) < (cpu.d & 15)
cpu.f_c = cpu.a < cpu.d
cpu.f_n = true
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.a &- cpu.e) == 0
cpu.f_h = (cpu.a & 15) < (cpu.e & 15)
cpu.f_c = cpu.a < cpu.e
cpu.f_n = true
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.a &- cpu.h) == 0
cpu.f_h = (cpu.a & 15) < (cpu.h & 15)
cpu.f_c = cpu.a < cpu.h
cpu.f_n = true
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.a &- cpu.l) == 0
cpu.f_h = (cpu.a & 15) < (cpu.l & 15)
cpu.f_c = cpu.a < cpu.l
cpu.f_n = true
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.a &- cpu.memory_at_hl) == 0
cpu.f_h = (cpu.a & 15) < (cpu.memory_at_hl & 15)
cpu.f_c = cpu.a < cpu.memory_at_hl
cpu.f_n = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.f_z = (cpu.a &- cpu.a) == 0
cpu.f_h = (cpu.a & 15) < (cpu.a & 15)
cpu.f_c = cpu.a < cpu.a
cpu.f_n = true
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
if cpu.f_nz
cpu.memory.tick_components
cpu.pc = cpu.memory.read_word(cpu.sp)
cpu.sp = cpu.sp + 2
return 20
end
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.bc = cpu.memory.read_word((cpu.sp = cpu.sp + 2) - 2)
return 12
end, ->(cpu : CPU) do
cpu.inc_pc
u16 = cpu.memory[cpu.pc].to_u16
cpu.inc_pc
u16 = u16 | (cpu.memory[cpu.pc].to_u16 << 8)
cpu.inc_pc
if cpu.f_nz
cpu.pc = u16
return 16
end
return 12
end, ->(cpu : CPU) do
cpu.inc_pc
u16 = cpu.memory[cpu.pc].to_u16
cpu.inc_pc
u16 = u16 | (cpu.memory[cpu.pc].to_u16 << 8)
cpu.inc_pc
cpu.pc = u16
return 16
end, ->(cpu : CPU) do
cpu.inc_pc
u16 = cpu.memory[cpu.pc].to_u16
cpu.inc_pc
u16 = u16 | (cpu.memory[cpu.pc].to_u16 << 8)
cpu.inc_pc
if cpu.f_nz
cpu.memory.tick_components
cpu.memory[cpu.sp = cpu.sp - 2] = cpu.pc
cpu.pc = u16
return 24
end
return 12
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.memory.tick_components
cpu.memory[cpu.sp = cpu.sp - 2] = cpu.bc
return 16
end, ->(cpu : CPU) do
cpu.inc_pc
u8 = cpu.memory[cpu.pc]
cpu.inc_pc
cpu.f_h = ((cpu.a & 15) + (u8 & 15)) > 15
cpu.a = cpu.a &+ u8
cpu.f_z = cpu.a == 0
cpu.f_c = cpu.a < u8
cpu.f_n = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.memory.tick_components
cpu.memory[cpu.sp = cpu.sp - 2] = cpu.pc
cpu.pc = 0_u16
return 16
end, ->(cpu : CPU) do
cpu.inc_pc
if cpu.f_z
cpu.memory.tick_components
cpu.pc = cpu.memory.read_word(cpu.sp)
cpu.sp = cpu.sp + 2
return 20
end
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.pc = cpu.memory.read_word(cpu.sp)
cpu.sp = cpu.sp + 2
return 16
end, ->(cpu : CPU) do
cpu.inc_pc
u16 = cpu.memory[cpu.pc].to_u16
cpu.inc_pc
u16 = u16 | (cpu.memory[cpu.pc].to_u16 << 8)
cpu.inc_pc
if cpu.f_z
cpu.pc = u16
return 16
end
return 12
end, ->(cpu : CPU) do
cpu.inc_pc
cycles = Opcodes::PREFIXED[cpu.memory[cpu.pc]].call(cpu)
return cycles
end, ->(cpu : CPU) do
cpu.inc_pc
u16 = cpu.memory[cpu.pc].to_u16
cpu.inc_pc
u16 = u16 | (cpu.memory[cpu.pc].to_u16 << 8)
cpu.inc_pc
if cpu.f_z
cpu.memory.tick_components
cpu.memory[cpu.sp = cpu.sp - 2] = cpu.pc
cpu.pc = u16
return 24
end
return 12
end, ->(cpu : CPU) do
cpu.inc_pc
u16 = cpu.memory[cpu.pc].to_u16
cpu.inc_pc
u16 = u16 | (cpu.memory[cpu.pc].to_u16 << 8)
cpu.inc_pc
cpu.memory.tick_components
cpu.memory[cpu.sp = cpu.sp - 2] = cpu.pc
cpu.pc = u16
return 24
end, ->(cpu : CPU) do
cpu.inc_pc
u8 = cpu.memory[cpu.pc]
cpu.inc_pc
carry = cpu.f_c ? 1 : 0
cpu.f_h = (((cpu.a & 15) + (u8 & 15)) + carry) > 15
cpu.a = cpu.a &+ (u8 &+ carry)
cpu.f_z = cpu.a == 0
cpu.f_c = cpu.a < (u8.to_u16 + carry)
cpu.f_n = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.memory.tick_components
cpu.memory[cpu.sp = cpu.sp - 2] = cpu.pc
cpu.pc = 8_u16
return 16
end, ->(cpu : CPU) do
cpu.inc_pc
if cpu.f_nc
cpu.memory.tick_components
cpu.pc = cpu.memory.read_word(cpu.sp)
cpu.sp = cpu.sp + 2
return 20
end
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.de = cpu.memory.read_word((cpu.sp = cpu.sp + 2) - 2)
return 12
end, ->(cpu : CPU) do
cpu.inc_pc
u16 = cpu.memory[cpu.pc].to_u16
cpu.inc_pc
u16 = u16 | (cpu.memory[cpu.pc].to_u16 << 8)
cpu.inc_pc
if cpu.f_nc
cpu.pc = u16
return 16
end
return 12
end, ->(cpu : CPU) do
cpu.inc_pc
return 0
end, ->(cpu : CPU) do
cpu.inc_pc
u16 = cpu.memory[cpu.pc].to_u16
cpu.inc_pc
u16 = u16 | (cpu.memory[cpu.pc].to_u16 << 8)
cpu.inc_pc
if cpu.f_nc
cpu.memory.tick_components
cpu.memory[cpu.sp = cpu.sp - 2] = cpu.pc
cpu.pc = u16
return 24
end
return 12
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.memory.tick_components
cpu.memory[cpu.sp = cpu.sp - 2] = cpu.de
return 16
end, ->(cpu : CPU) do
cpu.inc_pc
u8 = cpu.memory[cpu.pc]
cpu.inc_pc
cpu.f_h = (cpu.a & 15) < (u8 & 15)
cpu.f_c = cpu.a < u8
cpu.a = cpu.a &- u8
cpu.f_z = cpu.a == 0
cpu.f_n = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.memory.tick_components
cpu.memory[cpu.sp = cpu.sp - 2] = cpu.pc
cpu.pc = 16_u16
return 16
end, ->(cpu : CPU) do
cpu.inc_pc
if cpu.f_c
cpu.memory.tick_components
cpu.pc = cpu.memory.read_word(cpu.sp)
cpu.sp = cpu.sp + 2
return 20
end
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.ime = true
cpu.pc = cpu.memory.read_word(cpu.sp)
cpu.sp = cpu.sp + 2
return 16
end, ->(cpu : CPU) do
cpu.inc_pc
u16 = cpu.memory[cpu.pc].to_u16
cpu.inc_pc
u16 = u16 | (cpu.memory[cpu.pc].to_u16 << 8)
cpu.inc_pc
if cpu.f_c
cpu.pc = u16
return 16
end
return 12
end, ->(cpu : CPU) do
cpu.inc_pc
return 0
end, ->(cpu : CPU) do
cpu.inc_pc
u16 = cpu.memory[cpu.pc].to_u16
cpu.inc_pc
u16 = u16 | (cpu.memory[cpu.pc].to_u16 << 8)
cpu.inc_pc
if cpu.f_c
cpu.memory.tick_components
cpu.memory[cpu.sp = cpu.sp - 2] = cpu.pc
cpu.pc = u16
return 24
end
return 12
end, ->(cpu : CPU) do
cpu.inc_pc
return 0
end, ->(cpu : CPU) do
cpu.inc_pc
u8 = cpu.memory[cpu.pc]
cpu.inc_pc
to_sub = u8.to_u16 + (cpu.f_c ? 1 : 0)
cpu.f_h = (cpu.a & 15) < ((u8 & 15) + (cpu.f_c ? 1 : 0))
cpu.f_c = cpu.a < to_sub
cpu.a = cpu.a &- to_sub
cpu.f_z = cpu.a == 0
cpu.f_n = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.memory.tick_components
cpu.memory[cpu.sp = cpu.sp - 2] = cpu.pc
cpu.pc = 24_u16
return 16
end, ->(cpu : CPU) do
cpu.inc_pc
u8 = cpu.memory[cpu.pc]
cpu.inc_pc
cpu.memory[65280 &+ u8] = cpu.a
return 12
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.hl = cpu.memory.read_word((cpu.sp = cpu.sp + 2) - 2)
return 12
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.memory[65280 &+ cpu.c] = cpu.a
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
return 0
end, ->(cpu : CPU) do
cpu.inc_pc
return 0
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.memory.tick_components
cpu.memory[cpu.sp = cpu.sp - 2] = cpu.hl
return 16
end, ->(cpu : CPU) do
cpu.inc_pc
u8 = cpu.memory[cpu.pc]
cpu.inc_pc
cpu.a = cpu.a & u8
cpu.f_z = cpu.a == 0
cpu.f_n = false
cpu.f_h = true
cpu.f_c = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.memory.tick_components
cpu.memory[cpu.sp = cpu.sp - 2] = cpu.pc
cpu.pc = 32_u16
return 16
end, ->(cpu : CPU) do
cpu.inc_pc
i8 = cpu.memory[cpu.pc].to_i8!
cpu.inc_pc
r = cpu.sp &+ i8
cpu.f_h = (((cpu.sp ^ i8) ^ r) & 16) != 0
cpu.f_c = (((cpu.sp ^ i8) ^ r) & 256) != 0
cpu.sp = r
cpu.f_z = false
cpu.f_n = false
return 16
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.pc = cpu.hl
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
u16 = cpu.memory[cpu.pc].to_u16
cpu.inc_pc
u16 = u16 | (cpu.memory[cpu.pc].to_u16 << 8)
cpu.inc_pc
cpu.memory[u16] = cpu.a
return 16
end, ->(cpu : CPU) do
cpu.inc_pc
return 0
end, ->(cpu : CPU) do
cpu.inc_pc
return 0
end, ->(cpu : CPU) do
cpu.inc_pc
return 0
end, ->(cpu : CPU) do
cpu.inc_pc
u8 = cpu.memory[cpu.pc]
cpu.inc_pc
cpu.a = cpu.a ^ u8
cpu.f_z = cpu.a == 0
cpu.f_n = false
cpu.f_h = false
cpu.f_c = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.memory.tick_components
cpu.memory[cpu.sp = cpu.sp - 2] = cpu.pc
cpu.pc = 40_u16
return 16
end, ->(cpu : CPU) do
cpu.inc_pc
u8 = cpu.memory[cpu.pc]
cpu.inc_pc
cpu.a = cpu.memory[65280 &+ u8]
return 12
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.af = cpu.memory.read_word((cpu.sp = cpu.sp + 2) - 2)
cpu.f_z = cpu.af & (1 << 7)
cpu.f_n = cpu.af & (1 << 6)
cpu.f_h = cpu.af & (1 << 5)
cpu.f_c = cpu.af & (1 << 4)
return 12
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.a = cpu.memory[65280 &+ cpu.c]
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.ime = false
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
return 0
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.memory.tick_components
cpu.memory[cpu.sp = cpu.sp - 2] = cpu.af
return 16
end, ->(cpu : CPU) do
cpu.inc_pc
u8 = cpu.memory[cpu.pc]
cpu.inc_pc
cpu.a = cpu.a | u8
cpu.f_z = cpu.a == 0
cpu.f_n = false
cpu.f_h = false
cpu.f_c = false
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.memory.tick_components
cpu.memory[cpu.sp = cpu.sp - 2] = cpu.pc
cpu.pc = 48_u16
return 16
end, ->(cpu : CPU) do
cpu.inc_pc
i8 = cpu.memory[cpu.pc].to_i8!
cpu.inc_pc
cpu.hl = cpu.sp &+ i8
cpu.f_h = (((cpu.sp ^ i8) ^ cpu.hl) & 16) != 0
cpu.f_c = (((cpu.sp ^ i8) ^ cpu.hl) & 256) != 0
cpu.f_z = false
cpu.f_n = false
return 12
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.sp = cpu.hl
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
u16 = cpu.memory[cpu.pc].to_u16
cpu.inc_pc
u16 = u16 | (cpu.memory[cpu.pc].to_u16 << 8)
cpu.inc_pc
cpu.a = cpu.memory[u16]
return 16
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.scheduler.schedule_gb(4, Proc(Nil).new do
cpu.ime = true
end, Scheduler::EventType::IME)
return 4
end, ->(cpu : CPU) do
cpu.inc_pc
return 0
end, ->(cpu : CPU) do
cpu.inc_pc
return 0
end, ->(cpu : CPU) do
cpu.inc_pc
u8 = cpu.memory[cpu.pc]
cpu.inc_pc
cpu.f_z = (cpu.a &- u8) == 0
cpu.f_h = (cpu.a & 15) < (u8 & 15)
cpu.f_c = cpu.a < u8
cpu.f_n = true
return 8
end, ->(cpu : CPU) do
cpu.inc_pc
cpu.memory.tick_components
cpu.memory[cpu.sp = cpu.sp - 2] = cpu.pc
cpu.pc = 56_u16
return 16
end]