Skip to content

Commit

Permalink
Add sm83 tests 0x30 to 0x3f
Browse files Browse the repository at this point in the history
  • Loading branch information
Javier-varez committed May 12, 2024
1 parent e56e868 commit bd970ee
Show file tree
Hide file tree
Showing 17 changed files with 663 additions and 1 deletion.
66 changes: 66 additions & 0 deletions sm83/tests/data/add_hl_sp.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
## ADD HL, SP
## 1 8
## - 0 H C

[nominal]
cycles = 8

[nominal.entry_state]
h = 0x05
l = 0xFF
sp = 0xAABB
flags = ['Z', 'N']

[nominal.exit_state]
h = 0xB0
l = 0xBA
sp = 0xAABB
pc = 0x1
flags = ['Z', 'H']

[nominal.program]
instructions = [
0x39, # add HL, SP
]

[flags]
cycles = 8

[flags.entry_state]
h = 0x55
l = 0xFF
sp = 0xAABB
flags = ['N']

[flags.exit_state]
h = 0x00
l = 0xBA
sp = 0xAABB
pc = 0x1
flags = ['C', 'H']

[flags.program]
instructions = [
0x39, # add HL, SP
]

[no_carry]
cycles = 8

[no_carry.entry_state]
h = 0x11
l = 0x22
sp = 0xAABB
flags = ['N']

[no_carry.exit_state]
h = 0xBB
l = 0xDD
sp = 0xAABB
pc = 0x1
flags = []

[no_carry.program]
instructions = [
0x39, # add HL, SP
]
44 changes: 44 additions & 0 deletions sm83/tests/data/ccf.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
[clear_carry]
cycles = 4

[clear_carry.entry_state]
flags = ['C', 'N', 'H', 'Z']

[clear_carry.exit_state]
flags = ['Z']
pc = 0x01

[clear_carry.program]
instructions = [
0x3F, # ccf
]

[set_carry]
cycles = 4

[set_carry.entry_state]
flags = ['N', 'H', 'Z']

[set_carry.exit_state]
flags = ['C', 'Z']
pc = 0x01

[set_carry.program]
instructions = [
0x3F, # ccf
]

[test_z_flag]
cycles = 4

[test_z_flag.entry_state]
flags = ['N', 'H']

[test_z_flag.exit_state]
flags = ['C']
pc = 0x01

[test_z_flag.program]
instructions = [
0x3F, # ccf
]
64 changes: 64 additions & 0 deletions sm83/tests/data/dec_a.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
[no_overflow]
cycles = 4

[no_overflow.entry_state]
a = 0xFF

[no_overflow.exit_state]
a = 0xFE
pc = 0x01
flags = ['N']

[no_overflow.program]
instructions = [
0x3D, # dec A
]

[underflow]
cycles = 4

[underflow.entry_state]
a = 0x00

[underflow.exit_state]
a = 0xFF
pc = 0x01
flags = ['N', 'H']

[underflow.program]
instructions = [
0x3D, # dec A
]

[zflag]
cycles = 4

[zflag.entry_state]
a = 0x1

[zflag.exit_state]
a = 0x0
pc = 0x01
flags = ['N', 'Z']

[zflag.program]
instructions = [
0x3D, # dec A
]

[cflag]
cycles = 4

[cflag.entry_state]
a = 0x1
flags = ['C']

[cflag.exit_state]
a = 0x0
pc = 0x01
flags = ['N', 'Z', 'C']

[cflag.program]
instructions = [
0x3D, # dec A
]
39 changes: 39 additions & 0 deletions sm83/tests/data/dec_ind_hl.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[nominal]
cycles = 12

[nominal.entry_state]
h = 0x12
l = 0xFE
flags = ['C']

[nominal.exit_state]
h = 0x12
l = 0xFE
pc = 0x01
memory = { 0x12FE = [0xFF] }
flags = ['C', 'N', 'H']

[nominal.program]
instructions = [
0x35, # dec [HL]
]

[zero]
cycles = 12

[zero.entry_state]
h = 0x12
l = 0xFE
memory = { 0x12FE = [0x01] }

[zero.exit_state]
h = 0x12
l = 0xFE
pc = 0x01
memory = { 0x12FE = [0x00] }
flags = ['Z', 'N']

[zero.program]
instructions = [
0x35, # dec [HL]
]
29 changes: 29 additions & 0 deletions sm83/tests/data/dec_sp.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[no_underflow]
cycles = 8

[no_underflow.entry_state]
sp = 0x12FF

[no_underflow.exit_state]
sp = 0x12FE
pc = 0x1

[no_underflow.program]
instructions = [
0x3B, # dec SP
]

[underflow]
cycles = 8

[underflow.entry_state]
sp = 0x1300

[underflow.exit_state]
sp = 0x12FF
pc = 0x1

[underflow.program]
instructions = [
0x3B, # dec SP
]
66 changes: 66 additions & 0 deletions sm83/tests/data/inc_a.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
[no_overflow]
cycles = 4

[no_overflow.entry_state]
a = 0xFE
flags = ['N']

[no_overflow.exit_state]
a = 0xFF
pc = 0x01

[no_overflow.program]
instructions = [
0x3C, # inc a
]

[overflow]
cycles = 4

[overflow.entry_state]
a = 0xFF
flags = ['N']

[overflow.exit_state]
a = 0x00
pc = 0x01
flags = ['Z', 'H']

[overflow.program]
instructions = [
0x3C, # inc a
]

[half_carry]
cycles = 4

[half_carry.entry_state]
a = 0x2F
flags = ['N']

[half_carry.exit_state]
a = 0x30
pc = 0x01
flags = ['H']

[half_carry.program]
instructions = [
0x3C, # inc a
]

[carry]
cycles = 4

[carry.entry_state]
a = 0x2F
flags = ['N', 'C']

[carry.exit_state]
a = 0x30
pc = 0x01
flags = ['H', 'C']

[carry.program]
instructions = [
0x3C, # inc a
]
39 changes: 39 additions & 0 deletions sm83/tests/data/inc_ind_hl.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
[nominal]
cycles = 12

[nominal.entry_state]
h = 0x12
l = 0xFE
flags = ['C', 'N']

[nominal.exit_state]
h = 0x12
l = 0xFE
pc = 0x01
memory = { 0x12FE = [0x01] }
flags = ['C']

[nominal.program]
instructions = [
0x34, # inc [HL]
]

[zero]
cycles = 12

[zero.entry_state]
h = 0x12
l = 0xFE
memory = { 0x12FE = [0xFF] }

[zero.exit_state]
h = 0x12
l = 0xFE
pc = 0x01
memory = { 0x12FE = [0x00] }
flags = ['Z', 'H']

[zero.program]
instructions = [
0x34, # inc [HL]
]
29 changes: 29 additions & 0 deletions sm83/tests/data/inc_sp.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
[no_overflow]
cycles = 8

[no_overflow.entry_state]
sp = 0x12FE

[no_overflow.exit_state]
sp = 0x12FF
pc = 0x01

[no_overflow.program]
instructions = [
0x33, # inc SP
]

[overflow]
cycles = 8

[overflow.entry_state]
sp = 0x12FF

[overflow.exit_state]
sp = 0x1300
pc = 0x01

[overflow.program]
instructions = [
0x33, # inc SP
]
Loading

0 comments on commit bd970ee

Please sign in to comment.