### DCP Indirect Indexed

Posted:

**Wed May 06, 2020 2:28 pm**Hey guys, I'm implementing my 6502 core and running through the nestest log. So far I'm pretty accurate across the board, but I'm struggling a little with this DCP instruction. Here is a snippet of the nestest log for context:
and here is from my own log:
So calculating the indirect indexed address using the following args:

ZP@FF = 0x48

ZP@00 = 0x05

Y = 0xFF

0x0548 + 0xFF = 0x0647 (page cross)

Nesdev wiki has the following:
Specifically opcode 0xD3, 8 cycles + 1 page cross = 9 cycles. What am I not understanding?

Code: Select all

```
EA15 A9 EB LDA #$EB A:36 X:02 Y:9D P:67 SP:FB PPU:319,151 CYC:17277
EA17 8D 47 06 STA $0647 = 36 A:EB X:02 Y:9D P:E5 SP:FB PPU:325,151 CYC:17279
EA1A A9 48 LDA #$48 A:EB X:02 Y:9D P:E5 SP:FB PPU:337,151 CYC:17283
EA1C 85 45 STA $45 = 32 A:48 X:02 Y:9D P:65 SP:FB PPU: 2,152 CYC:17285
EA1E A9 05 LDA #$05 A:48 X:02 Y:9D P:65 SP:FB PPU: 11,152 CYC:17288
EA20 85 46 STA $46 = 04 A:05 X:02 Y:9D P:65 SP:FB PPU: 17,152 CYC:17290
EA22 A0 FF LDY #$FF A:05 X:02 Y:9D P:65 SP:FB PPU: 26,152 CYC:17293
EA24 20 31 FA JSR $FA31 A:05 X:02 Y:FF P:E5 SP:FB PPU: 32,152 CYC:17295
FA31 24 01 BIT $01 = FF A:05 X:02 Y:FF P:E5 SP:F9 PPU: 50,152 CYC:17301
FA33 18 CLC A:05 X:02 Y:FF P:E5 SP:F9 PPU: 59,152 CYC:17304
FA34 A9 40 LDA #$40 A:05 X:02 Y:FF P:E4 SP:F9 PPU: 65,152 CYC:17306
FA36 60 RTS A:40 X:02 Y:FF P:64 SP:F9 PPU: 71,152 CYC:17308
EA27 D3 45 *DCP ($45),Y = 0548 @ 0647 = EB A:40 X:02 Y:FF P:64 SP:FB PPU: 89,152 CYC:17314
EA29 EA NOP A:40 X:02 Y:FF P:64 SP:FB PPU:113,152 CYC:17322
```

Code: Select all

```
A:36 X:02 Y:9D P:01100111=67 SP:FB Cycles:17277 $EA15: A9 LDA #EB
A:EB X:02 Y:9D P:11100101=E5 SP:FB Cycles:17279 $EA17: 8D STA $0647
A:EB X:02 Y:9D P:11100101=E5 SP:FB Cycles:17283 $EA1A: A9 LDA #48
A:48 X:02 Y:9D P:01100101=65 SP:FB Cycles:17285 $EA1C: 85 STA $45 = 48
A:48 X:02 Y:9D P:01100101=65 SP:FB Cycles:17288 $EA1E: A9 LDA #05
A:05 X:02 Y:9D P:01100101=65 SP:FB Cycles:17290 $EA20: 85 STA $46 = 5
A:05 X:02 Y:9D P:01100101=65 SP:FB Cycles:17293 $EA22: A0 LDY #FF
A:05 X:02 Y:FF P:11100101=E5 SP:FB Cycles:17295 $EA24: 20 JSR $FA31
A:05 X:02 Y:FF P:11100101=E5 SP:F9 Cycles:17301 $FA31: 24 BIT $01 = FF
A:05 X:02 Y:FF P:11100101=E5 SP:F9 Cycles:17304 $FA33: 18 CLC
A:05 X:02 Y:FF P:11100100=E4 SP:F9 Cycles:17306 $FA34: A9 LDA #40
A:40 X:02 Y:FF P:01100100=64 SP:F9 Cycles:17308 $FA36: 60 RTS
A:40 X:02 Y:FF P:01100100=64 SP:FB Cycles:17314 $EA27: D3 *DCP ($45), Y = 0548 @ 0647 = EB
A:40 X:02 Y:FF P:01100100=64 SP:FB Cycles:17323 $EA29: EA NOP
```

ZP@FF = 0x48

ZP@00 = 0x05

Y = 0xFF

0x0548 + 0xFF = 0x0647 (page cross)

Nesdev wiki has the following:

Code: Select all

```
DCP (d,X) ($C3 dd; 8 cycles)
DCP d ($C7 dd; 5 cycles)
DCP a ($CF aa aa; 6 cycles)
DCP (d),Y ($D3 dd; 8 cycles)
DCP d,X ($D7 dd; 6 cycles)
DCP a,Y ($DB aa aa; 7 cycles)
DCP a,X ($DF aa aa; 7 cycles)
```