unofficial opcodes? $13 SLO

This is an archive of a topic from NESdev BBS, taken in mid-October 2019 before a server upgrade.
View original topic
unofficial opcodes? $13 SLO
by on (#167928)
opcode $13 (SLO, zero page Y indexed), should take 8 cycles, but I'm getting only 6!
Why???

- Reading the opcode takes 1 cycle;
- decoding the adressing mode takes 2 cycles;
- a SLO takes 4 cycles:
Code:
CPUOP(SLO1)
  value = _readvalue(offset); //4th
  _writevalue(offset, value); //5th
  ASL(value);
  writevalue(offset, value); //6th
  //ORA0
  cpu->A |= value;
  SET_SZ_FLAGS(cpu->A);
OPEND
Re: unofficial opcodes? $13 SLO
by on (#167939)
$13 is slo (dd),y (zero page indirect indexed), not slo dd,y (zero page indexed). The dd,y addressing mode exists only for the ldx, stx, lax, and sax instructions.

Thus slo ($02),y takes eight cycles:
  1. Read slo (dd),y opcode
  2. Read address of pointer
  3. Read low byte of pointer from dd
  4. Read high byte of pointer from (dd+1 .mod $100)
  5. Read old value from partly-formed address
  6. Read old value from correct address
  7. Write old value while calculating new value
  8. Write new value
Re: unofficial opcodes? $13 SLO
by on (#167953)
My reference isn't correct after all...
http://www.oxyron.de/html/opcodes02.html

Using this one (old, but gold) now.
http://nesdev.com/6502_cpu.txt
Re: unofficial opcodes? $13 SLO
by on (#168366)
*looks at table*
Quote:
$13: SLO, izy 8

Error being...?
Re: unofficial opcodes? $13 SLO
by on (#168369)
A note at the top of the the oxyron table states that "izy" means (dd),Y. It appears to stand for indirect zero page Y.
Re: unofficial opcodes? $13 SLO
by on (#168379)
SLO always execute the 4th cycle. Normally, this cycle is only executed on page crossing.
Re: unofficial opcodes? $13 SLO
by on (#168380)
What do STA aaaa,X and INC aaaa,X have in common? They always perform the dummy read while adding the index to the address. Likewise, SLO (dd),Y and other unofficial RMW+ALU instructions with (dd),Y are like STA (dd),Y in that they always perform the dummy read.
Re: unofficial opcodes? $13 SLO
by on (#168388)
Dummy reads with the high byte of the address not fixed yet.
Re: unofficial opcodes? $13 SLO
by on (#168427)
The dummy read is always done, even if the address needs no fixing. For example, sta addr, x for x = 0 reads then writes to addr, always.
Re: unofficial opcodes? $13 SLO
by on (#168428)
For pure read instructions using indexed addressing modes (ORA, AND, EOR, ADC, LDA, CMP, SBC, LDX, LDY), the dummy read is skipped if not needed. (Actually, it's the correction read that's skipped once the 6502 realizes that the dummy read was correct.) But for write instructions (STA, STX, STY), read-modify-write instructions (ASL, ROL, LSR, ROR, DEC, INC), and unofficial read-modify-write plus ALU instructions (SLO, RLA, SRE, RRA, DCP, ISC), the dummy read is always performed.
Re: unofficial opcodes? $13 SLO
by on (#168430)
Hmm, a part of my post was left in my head, and not posted :P. I wanted to say that all indexed instructions that involve a write always do the dummy read, because it would be wrong to write at a wrong address. Exception is indexed indirect (OP (zp, x)), because the indexing is done to the indirect address, not to the effective address.