-
Notifications
You must be signed in to change notification settings - Fork 0
/
test_sets.py
115 lines (109 loc) · 3.83 KB
/
test_sets.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
from constants import *
test_set = [ { "name": "LDN Test",
"initial_memory": [ (LDN<<5)+1, # Load negative from location 1
0x02,
0x04,
0x08,
0x10,
0x20,
0x40,
0xFF],
"expected_accumulator": 0xFE
},
{
"name": "STO Test",
"initial_memory": [ (STO<<5)+1, # Store to location 1
0x02,
0x04,
0x08,
0x10,
0x20,
0x40,
0xFF],
"expected_accumulator": 0x00,
"memory_update": (1, 0),
"expected_pc": 0x01
},
{
"name": "SUB Test",
"initial_accumulator": 76,
"initial_memory": [ (SUB<<5)+4, # Subtract location 4
0x02,
0x04,
0x08,
22,
0x20,
0x40,
0xFF],
"expected_accumulator": 54
},
{
"name": "JMP Test",
"initial_memory": [ (JMP<<5)+2, # Jump to the address in location 2 (0x4) which is 0x5 after the auto-increment.
0x02,
0x04,
0x08,
0x10,
0x20,
0x40,
0xFF],
"expected_accumulator": 0x00,
"expected_pc": 0x05
},
{
"name": "JRP Test",
"initial_memory": [ (JRP<<5)+2, # Jump relative by the address in location 2 (0x4) which is 0x5 after the auto-increment.
0x02,
0x04,
0x08,
0x10,
0x20,
0x40,
0xFF],
"expected_accumulator": 0x00,
"expected_pc": 0x05
},
{
"name": "CMP Test",
"initial_accumulator": 0xF0,
"initial_memory": [ (CMP<<5)+6, # Skip next instruction if accumulator is negative. At the moment, CMP also acts as a sub so we must point it at a zero memory location.
0x02,
0x04,
0x08,
0x10,
0x20,
0x00,
0xFF],
"expected_pc": 0x02
},
{
"name": "Sequenced instruction test",
"initial_accumulator": 0xF0,
"initial_memory": [ (CMP<<5)+6, # Skip next instruction if accumulator is negative. At the moment, CMP also acts as a sub so we must point it at a zero memory location.
0x02,
(SUB<<5)+1,
0x08,
0x10,
0x20,
0x00,
0xFF],
"expected_accumulator": 0xEE,
"expected_pc": 3,
"cycles": 2
},
{
"name": "SUB then LDN",
"initial_accumulator": 0xF0,
"initial_memory": [ (SUB<<5)+2, # Skip next instruction if accumulator is negative. At the moment, CMP also acts as a sub so we must point it at a zero memory location.
(LDN<<5)+3,
0x02,
0x08,
0x10,
0x20,
0x00,
0xFF],
"expected_accumulator": 0xF8,
"expected_pc": 2,
"cycles": 2
}
]