-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathset_logic.go
More file actions
147 lines (110 loc) · 5.14 KB
/
Copy pathset_logic.go
File metadata and controls
147 lines (110 loc) · 5.14 KB
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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
package cpu
// This is the implementation of the AND instructions.
//
// This will change the flags of the Core it's run in.
func (c *Core) and_impl(with byte) {
c.A = c.A & with
if c.A == 0 {
c.Flags = c.Flags | FLAG_ZERO
} else {
c.Flags = c.Flags & ^FLAG_ZERO
}
if c.A&0b10000000 > 0 {
c.Flags = c.Flags | FLAG_NEGATIVE
} else {
c.Flags = c.Flags & ^FLAG_NEGATIVE
}
}
// This is the implementation of the ORA instructions.
//
// This will change the flags of the Core it's run in.
func (c *Core) ora_impl(with byte) {
c.A = c.A | with
if c.A == 0 {
c.Flags = c.Flags | FLAG_ZERO
} else {
c.Flags = c.Flags & ^FLAG_ZERO
}
if c.A&0b10000000 > 0 {
c.Flags = c.Flags | FLAG_NEGATIVE
} else {
c.Flags = c.Flags & ^FLAG_NEGATIVE
}
}
// This is the implementation of the EOR instructions.
//
// This will change the flags of the Core it's run in.
func (c *Core) eor_impl(with byte) {
c.A = c.A ^ with
if c.A == 0 {
c.Flags = c.Flags | FLAG_ZERO
} else {
c.Flags = c.Flags & ^FLAG_ZERO
}
if c.A&0b10000000 > 0 {
c.Flags = c.Flags | FLAG_NEGATIVE
} else {
c.Flags = c.Flags & ^FLAG_NEGATIVE
}
}
// Bitwise AND Accumulator with Memory - Absolute
func (c *Core) AND____a(addr uint16) { c.PC += 3; c.and_impl(c.Memory[addr]) }
// Bitwise AND Accumulator with Memory - Absolute indexed with X
func (c *Core) AND___ax(addr uint16) { c.PC += 3; c.and_impl(c.Memory[addr+uint16(c.X)]) }
// Bitwise AND Accumulator with Memory - Absolute indexed with Y
func (c *Core) AND___ay(addr uint16) { c.PC += 3; c.and_impl(c.Memory[addr+uint16(c.Y)]) }
// Bitwise AND Accumulator with Memory - Immediate
func (c *Core) AND__Imm(literal byte) { c.PC += 2; c.and_impl(literal) }
// Bitwise AND Accumulator with Memory - Zero Page
func (c *Core) AND__ZPg(zp byte) { c.PC += 2; c.and_impl(c.Memory[zp]) }
// Bitwise AND Accumulator with Memory - Zero Page Indexed Indirect
func (c *Core) AND_IZPx(zp byte) { c.PC += 2; c.and_impl(c.Memory[c.indirectZpX(zp)]) }
// Bitwise AND Accumulator with Memory - Zero Page indexed with X
func (c *Core) AND__ZPx(zp byte) { c.PC += 2; c.and_impl(c.Memory[(zp+c.X)&0xFF]) }
// Bitwise AND Accumulator with Memory - Zero Page Indirect Indexed with Y
func (c *Core) AND_IZPy(zp byte) { c.PC += 2; c.and_impl(c.Memory[c.indirectZpY(zp)]) }
// Bitwise OR Accumulator with Memory - Absolute
func (c *Core) ORA____a(addr uint16) { c.PC += 3; c.ora_impl(c.Memory[addr]) }
// Bitwise OR Accumulator with Memory - Absolute indexed with X
func (c *Core) ORA___ax(addr uint16) { c.PC += 3; c.ora_impl(c.Memory[addr+uint16(c.X)]) }
// Bitwise OR Accumulator with Memory - Absolute indexed with Y
func (c *Core) ORA___ay(addr uint16) { c.PC += 3; c.ora_impl(c.Memory[addr+uint16(c.Y)]) }
// Bitwise OR Accumulator with Memory - Immediate
func (c *Core) ORA__Imm(literal byte) { c.PC += 2; c.ora_impl(literal) }
// Bitwise OR Accumulator with Memory - Zero Page
func (c *Core) ORA__ZPg(zp byte) { c.PC += 2; c.ora_impl(c.Memory[zp]) }
// Bitwise OR Accumulator with Memory - Zero Page Indexed Indirect
func (c *Core) ORA_IZPx(zp byte) { c.PC += 2; c.ora_impl(c.Memory[c.indirectZpX(zp)]) }
// Bitwise OR Accumulator with Memory - Zero Page indexed with X
func (c *Core) ORA__ZPx(zp byte) { c.PC += 2; c.ora_impl(c.Memory[(zp+c.X)&0xFF]) }
// Bitwise OR Accumulator with Memory - Zero Page Indirect Indexed with Y
func (c *Core) ORA_IZPy(zp byte) { c.PC += 2; c.ora_impl(c.Memory[c.indirectZpY(zp)]) }
// Bitwise Exclusive OR Accumulator with Memory - Absolute
func (c *Core) EOR____a(addr uint16) { c.PC += 3; c.eor_impl(c.Memory[addr]) }
// Bitwise Exclusive OR Accumulator with Memory - Absolute indexed with X
func (c *Core) EOR___ax(addr uint16) { c.PC += 3; c.eor_impl(c.Memory[addr+uint16(c.X)]) }
// Bitwise Exclusive OR Accumulator with Memory - Absolute indexed with Y
func (c *Core) EOR___ay(addr uint16) { c.PC += 3; c.eor_impl(c.Memory[addr+uint16(c.Y)]) }
// Bitwise Exclusive OR Accumulator with Memory - Immediate
func (c *Core) EOR__Imm(literal byte) { c.PC += 2; c.eor_impl(literal) }
// Bitwise Exclusive OR Accumulator with Memory - Zero Page
func (c *Core) EOR__ZPg(zp byte) { c.PC += 2; c.eor_impl(c.Memory[zp]) }
// Bitwise Exclusive OR Accumulator with Memory - Zero Page Indexed Indirect
func (c *Core) EOR_IZPx(zp byte) { c.PC += 2; c.eor_impl(c.Memory[c.indirectZpX(zp)]) }
// Bitwise Exclusive OR Accumulator with Memory - Zero Page indexed with X
func (c *Core) EOR__ZPx(zp byte) { c.PC += 2; c.eor_impl(c.Memory[(zp+c.X)&0xFF]) }
// Bitwise Exclusive OR Accumulator with Memory - Zero Page Indirect Indexed with Y
func (c *Core) EOR_IZPy(zp byte) { c.PC += 2; c.eor_impl(c.Memory[c.indirectZpY(zp)]) }
// 65c02 Instructions/Implementations below this line
// Bitwise AND Accumulator with Memory - Zero Page Indirect
//
// CMOS 65c02
func (c *Core) AND__IZP(zp uint8) { c.PC += 2; c.and_impl(c.Memory[c.indirectZp(zp)]) }
// Bitwise ORA Accumulator with Memory - Zero Page Indirect
//
// CMOS 65c02
func (c *Core) ORA__IZP(zp uint8) { c.PC += 2; c.ora_impl(c.Memory[c.indirectZp(zp)]) }
// Bitwise Exclusive OR Accumulator with Memory - Zero Page Indirect
//
// CMOS 65c02
func (c *Core) EOR__IZP(zp uint8) { c.PC += 2; c.eor_impl(c.Memory[c.indirectZp(zp)]) }