Skip to content

Commit

Permalink
Add sm83 tests 0xc0 to 0xff
Browse files Browse the repository at this point in the history
  • Loading branch information
Javier-varez committed May 12, 2024
1 parent ffeb173 commit 4af6b6d
Show file tree
Hide file tree
Showing 52 changed files with 1,871 additions and 0 deletions.
72 changes: 72 additions & 0 deletions sm83/tests/data/adc_a_n8.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
[no_carry]
cycles = 8

[no_carry.entry_state]
a = 0x12
flags = ['Z', 'N', 'C', 'H']

[no_carry.exit_state]
a = 0xF7
flags = []
pc = 2

[no_carry.program]
instructions = [
0xCE, # adc a, 0xE4
0xE4,
]


[half_carry]
cycles = 8

[half_carry.entry_state]
a = 0x12
flags = ['Z', 'N', 'C', 'H']

[half_carry.exit_state]
a = 0xF2
flags = ['H']
pc = 2

[half_carry.program]
instructions = [
0xCE, # adc a, 0xDF
0xDF,
]

[carry]
cycles = 8

[carry.entry_state]
a = 0x12
flags = ['Z', 'N', 'C', 'H']

[carry.exit_state]
a = 0x07
flags = ['C']
pc = 2

[carry.program]
instructions = [
0xCE, # adc a, 0xF4
0xF4,
]

[zero]
cycles = 8

[zero.entry_state]
a = 0x01
flags = ['Z', 'N', 'C', 'H']

[zero.exit_state]
a = 0x00
flags = ['C', 'H', 'Z']
pc = 2

[zero.program]
instructions = [
0xCE, # adc a, 0xFE
0xFE,
]
72 changes: 72 additions & 0 deletions sm83/tests/data/add_a_n8.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
[no_carry]
cycles = 8

[no_carry.entry_state]
a = 0x12
flags = ['Z', 'N', 'C', 'H']

[no_carry.exit_state]
a = 0xF6
flags = []
pc = 2

[no_carry.program]
instructions = [
0xC6, # add a, 0xE4
0xE4,
]


[half_carry]
cycles = 8

[half_carry.entry_state]
a = 0x12
flags = ['Z', 'N', 'C', 'H']

[half_carry.exit_state]
a = 0xF1
flags = ['H']
pc = 2

[half_carry.program]
instructions = [
0xC6, # add a, 0xDF
0xDF,
]

[carry]
cycles = 8

[carry.entry_state]
a = 0x12
flags = ['Z', 'N', 'C', 'H']

[carry.exit_state]
a = 0x06
flags = ['C']
pc = 2

[carry.program]
instructions = [
0xC6, # add a, 0xF4
0xF4,
]

[zero]
cycles = 8

[zero.entry_state]
a = 0x01
flags = ['Z', 'N', 'C', 'H']

[zero.exit_state]
a = 0x00
flags = ['C', 'H', 'Z']
pc = 2

[zero.program]
instructions = [
0xC6, # add a, 0xFF
0xFF,
]
53 changes: 53 additions & 0 deletions sm83/tests/data/add_sp_e8.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
[nominal]
cycles = 16

[nominal.entry_state]
sp = 0xFF30
flags = ['Z', 'N']

[nominal.exit_state]
sp = 0xFFAF
pc = 0x2
flags = []

[nominal.program]
instructions = [
0xE8, # add SP, +127
0x7F
]

[flags]
cycles = 16

[flags.entry_state]
sp = 0xFFC0
flags = ['Z', 'N']

[flags.exit_state]
sp = 0xFF40
pc = 0x2
flags = ['C']

[flags.program]
instructions = [
0xE8, # add SP, -128
0x80
]

[half_carry]
cycles = 16

[half_carry.entry_state]
sp = 0xFF0F
flags = ['Z', 'N']

[half_carry.exit_state]
sp = 0xFF10
pc = 0x2
flags = ['H']

[half_carry.program]
instructions = [
0xE8, # add SP, 1
0x01
]
35 changes: 35 additions & 0 deletions sm83/tests/data/and_a_n8.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
[non_zero]
cycles = 8

[non_zero.entry_state]
a = 0xF0
flags = ['Z', 'C', 'H']

[non_zero.exit_state]
a = 0x50
flags = ['H']
pc = 2

[non_zero.program]
instructions = [
0xE6, # and a, 0x5F
0x5F
]

[zero]
cycles = 8

[zero.entry_state]
a = 0xA5
flags = ['C']

[zero.exit_state]
a = 0x00
flags = ['Z', 'H']
pc = 2

[zero.program]
instructions = [
0xE6, # and a, 0x5A
0x5A
]
41 changes: 41 additions & 0 deletions sm83/tests/data/call_a16.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[call1]
cycles = 24

[call1.entry_state]
pc = 0x4054
sp = 0x8012
flags = ['Z', 'N', 'C', 'H']

[call1.exit_state]
sp = 0x8010
pc = 0x1234
memory = { 0x8010 = [0x57, 0x40] }
flags = ['Z', 'N', 'C', 'H']

[call1.program]
base = 0x4054
instructions = [
0xCD, # call 0x1234
0x34,
0x12,
]

[call2]
cycles = 24

[call2.entry_state]
pc = 0x4054
sp = 0x8012

[call2.exit_state]
sp = 0x8010
pc = 0x1234
memory = { 0x8010 = [0x57, 0x40] }

[call2.program]
base = 0x4054
instructions = [
0xCD, # call 0x1234
0x34,
0x12,
]
40 changes: 40 additions & 0 deletions sm83/tests/data/call_c_a16.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[taken]
cycles = 24

[taken.entry_state]
pc = 0x4054
sp = 0x8012
flags = ['C']

[taken.exit_state]
sp = 0x8010
pc = 0x1234
memory = { 0x8010 = [0x57, 0x40] }
flags = ['C']

[taken.program]
base = 0x4054
instructions = [
0xDC, # call C, 0x1234
0x34,
0x12,
]

[not_taken]
cycles = 12

[not_taken.entry_state]
sp = 0x8012
pc = 0x4054

[not_taken.exit_state]
sp = 0x8012
pc = 0x4057

[not_taken.program]
base = 0x4054
instructions = [
0xDC, # call C, 0x1234
0x34,
0x12,
]
40 changes: 40 additions & 0 deletions sm83/tests/data/call_nc_a16.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
[taken]
cycles = 24

[taken.entry_state]
pc = 0x4054
sp = 0x8012

[taken.exit_state]
sp = 0x8010
pc = 0x1234
memory = { 0x8010 = [0x57, 0x40] }

[taken.program]
base = 0x4054
instructions = [
0xD4, # call NC, 0x1234
0x34,
0x12,
]

[not_taken]
cycles = 12

[not_taken.entry_state]
sp = 0x8012
pc = 0x4054
flags = ['C']

[not_taken.exit_state]
sp = 0x8012
pc = 0x4057
flags = ['C']

[not_taken.program]
base = 0x4054
instructions = [
0xD4, # call NC, 0x1234
0x34,
0x12,
]
Loading

0 comments on commit 4af6b6d

Please sign in to comment.