forked from koron-go/z80
-
Notifications
You must be signed in to change notification settings - Fork 0
/
op_bitop.go
76 lines (67 loc) · 1.46 KB
/
op_bitop.go
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
package z80
func (cpu *CPU) bitchk8b(b, v uint8) {
var nand uint8 = maskS53 | maskZ | maskH | maskPV | maskN
var or uint8
if v&(0x01<<b) == 0 {
or |= maskZ | maskPV
} else if b == 7 {
or |= maskS
}
or |= maskH
cpu.AF.Lo = cpu.AF.Lo&^nand | or
cpu.LastOpCycles = 12
}
func xopBITbIXdP(cpu *CPU, b, d uint8) {
p := addrOff(cpu.IX, d)
v := cpu.Memory.Get(p)
cpu.bitchk8b(b, v)
cpu.LastOpCycles = 20
}
func xopBITbIYdP(cpu *CPU, b, d uint8) {
p := addrOff(cpu.IY, d)
v := cpu.Memory.Get(p)
cpu.bitchk8b(b, v)
cpu.LastOpCycles = 20
}
func xopSETbIXdP(cpu *CPU, b, d uint8) {
p := addrOff(cpu.IX, d)
v := cpu.Memory.Get(p)
v = cpu.bitset8(b, v)
cpu.Memory.Set(p, v)
cpu.LastOpCycles = 23
}
func xopSETbIYdP(cpu *CPU, b, d uint8) {
p := addrOff(cpu.IY, d)
v := cpu.Memory.Get(p)
v = cpu.bitset8(b, v)
cpu.Memory.Set(p, v)
cpu.LastOpCycles = 23
}
func xopRESbIXdP(cpu *CPU, b, d uint8) {
p := addrOff(cpu.IX, d)
v := cpu.Memory.Get(p)
v = cpu.bitres8(b, v)
cpu.Memory.Set(p, v)
cpu.LastOpCycles = 23
}
func xopRESbIYdP(cpu *CPU, b, d uint8) {
p := addrOff(cpu.IY, d)
v := cpu.Memory.Get(p)
v = cpu.bitres8(b, v)
cpu.Memory.Set(p, v)
cpu.LastOpCycles = 23
}
func xopBITbHLP(cpu *CPU, b uint8) {
p := cpu.HL.U16()
x := cpu.Memory.Get(p)
x = cpu.bitres8(b, x)
cpu.Memory.Set(p, x)
cpu.LastOpCycles = 15
}
func xopSETbHLP(cpu *CPU, b uint8) {
p := cpu.HL.U16()
x := cpu.Memory.Get(p)
x = cpu.bitset8(b, x)
cpu.Memory.Set(p, x)
cpu.LastOpCycles = 15
}