-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCPU_6502_STX_W.go
51 lines (39 loc) · 1.41 KB
/
CPU_6502_STX_W.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
package CPU_6502
import "fmt"
// STX Store Index X in Memory
//
// X -> M N Z C I D V
// - - - - - -
//
// addressing assembler opc bytes cyles
// --------------------------------------------
// zeropage STX oper 86 2 3
// zeropage,Y STX oper,Y 96 2 4
// absolute STX oper 8E 3 4
func opc_STX(memAddr uint16, mode string, bytes uint16, opc_cycles byte) {
// Update Global Opc_cycles value
Opc_cycles = opc_cycles
// Print internal opcode cycle
debugInternalOpcCycle(opc_cycles)
// Just increment the Opcode cycle Counter
if Opc_cycle_count < opc_cycles {
Opc_cycle_count++
// After spending the cycles needed, execute the opcode
} else {
// Write data to Memory (adress in Memory Bus) and update the value in Data BUS
memData := dataBUS_Write(memAddr, X)
// Print Opcode Debug Message
opc_STX_DebugMsg(bytes, mode, memAddr, memData)
// Increment PC
PC += bytes
// Reset Internal Opcode Cycle counters
resetIntOpcCycleCounters()
}
}
func opc_STX_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]\tSTX Store Index X in Memory.\tMemory[0x%02X] = X (%d)\n", opc_string, mode, memAddr, memData)
fmt.Println(dbg_show_message)
}
}