CPU Quirks
Moderator: Moderators
CPU Quirks
I am aware of a few CPU quirks, like the dummy write on INC. Is there a list somewhere of the other quirks, or can one of you walking NES information archives whip one up? Much appreciated! ;D
There's the error on wrap for the JMP Indirect instruction, you ask to do an indirect jmp at ($1FF) and it reads the 16-bit jump address from $1FF and $100 instead of $1FF and $200.
Then there's the extra cycle for when some instructions cross pages when adding X or Y.
Then there's the zeropage instructions which wrap back to the zeropage when you add a X to them instead of advancing to the $100 page.
Then there's the extra cycle for when some instructions cross pages when adding X or Y.
Then there's the zeropage instructions which wrap back to the zeropage when you add a X to them instead of advancing to the $100 page.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
I think there are dummy reads for the wrong offset when there's a penalty cycle. Not 100% sure here, but I think when instructions like LDA xxxx,X cross to the next page, it will read from the incorrect page, then read from the correct page.
Wonder if this could be used to read both PPUSTAT and PPUDATA from one instruction?
Wonder if this could be used to read both PPUSTAT and PPUDATA from one instruction?
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
I think all the "read-modify-write" instructions (including shift instructions) do that.
What's bad is that some games want to see the dummy write, and not the real write afterwards. Good ol MMC1 games and INC xxxx to write FF as the dummy value.
What's bad is that some games want to see the dummy write, and not the real write afterwards. Good ol MMC1 games and INC xxxx to write FF as the dummy value.
Here come the fortune cookies! Here come the fortune cookies! They're wearing paper hats!
It seems that this is a good idea then! There are a few things still confusing me, take for example LDA (xx,X) (Assume all reads/writes consume 1 CPU cycle):
Read Instruction (PC)
Read Zero Page Address (PC + 1)
Add X, with wrapping
Read Low Byte ($00)
Read High Byte ($20)
Read Data ($2000)
This sequence totals 5 cycles, but the actual instruction requires 6.. Where is the missing cycle coming from?
EDIT: That would be great tokumaru!
Read Instruction (PC)
Read Zero Page Address (PC + 1)
Add X, with wrapping
Read Low Byte ($00)
Read High Byte ($20)
Read Data ($2000)
This sequence totals 5 cycles, but the actual instruction requires 6.. Where is the missing cycle coming from?
EDIT: That would be great tokumaru!
The 6502.org forums have details about instruction execute and the PLA (programmable logic array, not to be confused with 'pull accumulator').
The following links mainly discuss how the 6502 handles to so called "illegal instructions". However, they also contain clues about what the 6502 does on each clock cycle while executing an instruction.
http://forum.6502.org/viewtopic.php?t=1406
http://www.pagetable.com/?p=39
Once this data is gathered, I think that it would make an excellent addition to the wiki.
EDIT:
http://www.geocities.jp/team_zero_three/FC/index_e.html
(search for first use of the word "dummy")
http://nesdev.com/bbs/viewtopic.php?p=11288#11288
EDIT #2: Found this on the geocities.jp page:
The following links mainly discuss how the 6502 handles to so called "illegal instructions". However, they also contain clues about what the 6502 does on each clock cycle while executing an instruction.
http://forum.6502.org/viewtopic.php?t=1406
http://www.pagetable.com/?p=39
Once this data is gathered, I think that it would make an excellent addition to the wiki.
EDIT:
http://www.geocities.jp/team_zero_three/FC/index_e.html
(search for first use of the word "dummy")
http://nesdev.com/bbs/viewtopic.php?p=11288#11288
EDIT #2: Found this on the geocities.jp page:
Although the FC/NES 6502 is not completely same as the general NMOS6502 chip, it has been verified that the FC/NES 6502 also has undocumented instructions and executes RMWW for RMW instructions.
It would be so counter-intuitive, but how awesome would it be to do a cycle by cycle CPU emulation? Like LDA:
It would be a huge pain in the ass, but I think it would be neato!
Code: Select all
int LDA(int cycles)
{
static int ldaCycles=0;
while (cycles > 0)
{
switch (ldaCycles)
{
case 0: // fetch address?
...
case x: return (cycles - ldaCycles);
}
}
return 0;
}I initially thought that too, but actually it does emulate cycle by cycle. Check the functions which handle different addressing modes (AM_xxx), every MemGet()/MemSet() increases cycle count.NESICIDE wrote:I didn't come to that conclusion looking at the source for v0.975.tepples wrote:I seem to remember Nintendulator emulates cycle by cycle like that.
Download STREEMERZ for NES from fauxgame.com! — Some other stuff I've done: fo.aspekt.fi