-
Notifications
You must be signed in to change notification settings - Fork 0
/
CPU_6502_AND_R.go
61 lines (47 loc) · 1.74 KB
/
CPU_6502_AND_R.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
package CPU_6502
import "fmt"
// AND AND Memory with Accumulator
//
// A AND M -> A N Z C I D V
// + + - - - -
//
// addressing assembler opc bytes cyles
// --------------------------------------------
// immediate AND #oper 29 2 2
// zeropage AND oper 25 2 3
// zeropage,X AND oper,X 35 2 4
// absolute AND oper 2D 3 4
// absolute,X AND oper,X 3D 3 4*
// absolute,Y AND oper,Y 39 3 4*
// (indirect,X) AND (oper,X) 21 2 6
// (indirect),Y AND (oper),Y 31 2 5*
func opc_AND(memAddr uint16, mode string, bytes uint16, opc_cycles byte) {
// Update Global Opc_cycles value
Opc_cycles = opc_cycles
// Print internal opcode cycle
debugInternalOpcCycleExtras(opc_cycles)
// Just increment the Opcode cycle Counter
if Opc_cycle_count < opc_cycles+Opc_cycle_extra {
Opc_cycle_count++
// After spending the cycles needed, execute the opcode
} else {
// Read data from Memory (adress in Memory Bus) into Data Bus
memData := dataBUS_Read(memAddr)
// Print Opcode Debug Message
opc_AND_DebugMsg(bytes, mode, memAddr, memData)
A = A & memData
flags_Z(A)
flags_N(A)
// Increment PC
PC += bytes
// Reset Internal Opcode Cycle counters
resetIntOpcCycleCounters()
}
}
func opc_AND_DebugMsg(bytes uint16, mode string, memAddr uint16, memData byte) {
if Debug {
opc_string := debug_decode_opc(bytes)
dbg_show_message = fmt.Sprintf("\n\tOpcode %s [Mode: %s]\tAND AND Memory with Accumulator.\tA = A(%d) & Memory[0x%02X](%d)\t(%d)\n", opc_string, mode, A, memAddr, memData, A&memData)
fmt.Println(dbg_show_message)
}
}