-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathset_incdec.go
More file actions
89 lines (68 loc) · 2.52 KB
/
Copy pathset_incdec.go
File metadata and controls
89 lines (68 loc) · 2.52 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
package cpu
// The implementation of the increment instructions.
//
// This will change the flags of the Core it's run in, and will change the value
// at the pointer passed into it.
func (c *Core) inc_impl(where *byte) {
*where++
if (*where) == 0 {
c.Flags = c.Flags | FLAG_ZERO
} else {
c.Flags = c.Flags & ^FLAG_ZERO
}
if (*where)&0b10000000 > 0 {
c.Flags = c.Flags | FLAG_NEGATIVE
} else {
c.Flags = c.Flags & ^FLAG_NEGATIVE
}
}
// The implementation of the decrement instructions.
//
// This will change the flags of the Core it's run in, and will change the value
// at the pointer passed into it.
func (c *Core) dec_impl(where *byte) {
*where--
if (*where) == 0 {
c.Flags = c.Flags | FLAG_ZERO
} else {
c.Flags = c.Flags & ^FLAG_ZERO
}
if (*where)&0b10000000 > 0 {
c.Flags = c.Flags | FLAG_NEGATIVE
} else {
c.Flags = c.Flags & ^FLAG_NEGATIVE
}
}
// Increment Memory by One - Absolute
func (c *Core) INC____a(addr uint16) { c.PC += 3; c.inc_impl(&c.Memory[addr]) }
// Increment Memory by One - Absolute indexed with X
func (c *Core) INC___ax(addr uint16) { c.PC += 3; c.inc_impl(&c.Memory[addr+uint16(c.X)]) }
// Increment Memory by One - Zero Page
func (c *Core) INC__ZPg(zp byte) { c.PC += 2; c.inc_impl(&c.Memory[zp]) }
// Increment Memory by One - Zero Page indexed with X
func (c *Core) INC__ZPx(zp byte) { c.PC += 2; c.inc_impl(&c.Memory[(zp+c.X)&0xFF]) }
// Increment X by One - Implied
func (c *Core) INX____i() { c.PC += 1; c.inc_impl(&c.X) }
// Increment Y by One - Implied
func (c *Core) INY____i() { c.PC += 1; c.inc_impl(&c.Y) }
// Decrement Memory by One - Absolute
func (c *Core) DEC____a(addr uint16) { c.PC += 3; c.dec_impl(&c.Memory[addr]) }
// Decrement Memory by One - Absolute indexed with X
func (c *Core) DEC___ax(addr uint16) { c.PC += 3; c.dec_impl(&c.Memory[addr+uint16(c.X)]) }
// Decrement Memory by One - Zero Page
func (c *Core) DEC__ZPg(zp byte) { c.PC += 2; c.dec_impl(&c.Memory[zp]) }
// Decrement Memory by One - Zero Page indexed with X
func (c *Core) DEC__ZPx(zp byte) { c.PC += 2; c.dec_impl(&c.Memory[(zp+c.X)&0xFF]) }
// Decrement X by One - Implied
func (c *Core) DEX____i() { c.PC += 1; c.dec_impl(&c.X) }
// Decrement Y by One - Implied
func (c *Core) DEY____i() { c.PC += 1; c.dec_impl(&c.Y) }
// 65c02 Instructions/Implementations below this line
// Increment Accumulator by One - Implied
//
// CMOS 65c02
func (c *Core) INA____i() { c.PC += 1; c.inc_impl(&c.A) }
// Decrement Accumulator by One - Implied
//
// CMOS 65c02
func (c *Core) DEA____i() { c.PC += 1; c.dec_impl(&c.A) }