nestest log with bus cycles

Discuss emulation of the Nintendo Entertainment System and Famicom.

Moderator: Moderators

blashyrk
Posts: 2
Joined: Fri Jan 20, 2017 3:12 pm

Re: nestest log with bus cycles

Post by blashyrk »

lidnariq wrote:No, because the instruction pointer already points to $D000 by the time the offset is going to be added. (Hence why relative branches have an effective displacement of -126 to +129 bytes)
Thank you!
User avatar
Zepper
Formerly Fx3
Posts: 3262
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

Re: nestest log with bus cycles

Post by Zepper »

lidnariq wrote:No, because the instruction pointer already points to $D000 by the time the offset is going to be added. (Hence why relative branches have an effective displacement of -126 to +129 bytes)
Yes. Cycle 3 is the answer.

Code: Select all

CFFE  F0 05     BEQ $D005 
    #   address  R/W description
       --- --------- --- ---------------------------------------------
        1     PC      R  fetch opcode, increment PC
        2     PC      R  fetch operand, increment PC
        3     PC      R  Fetch opcode of next instruction,
                         If branch is taken, add operand to PCL.
                         Otherwise increment PC.
        4+    PC*     R  Fetch opcode of next instruction.
                         Fix PCH. If it did not change, increment PC.
        5!    PC      R  Fetch opcode of next instruction,
                         increment PC.
So, right, PC is at $D000 when adding the operand byte.
Last edited by Zepper on Fri Jan 20, 2017 7:17 pm, edited 1 time in total.
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: nestest log with bus cycles

Post by lidnariq »

You know how I was talking about a language barrier before?

Here's his question, emphasis mine:
blashyrk wrote:Shouldn't an extra cycle be added at this point because we're branching from CFFE -> D005?
Please reread his question and my answer until you understand that I answered the question correctly.
User avatar
Zepper
Formerly Fx3
Posts: 3262
Joined: Fri Nov 12, 2004 4:59 pm
Location: Brazil
Contact:

Re: nestest log with bus cycles

Post by Zepper »

lidnariq wrote:Please reread his question and my answer until you understand that I answered the question correctly.
Did I answer incorrectly? I edited slightly my post to be crystal clear.
tepples
Posts: 22708
Joined: Sun Sep 19, 2004 11:12 pm
Location: NE Indiana, USA (NTSC)
Contact:

Re: nestest log with bus cycles

Post by tepples »

Think of it this way: Look at the address of the opcode that would be executed if the branch were not taken. If the taken and not-taken opcode are in the same page, there is no page crossing penalty cycle.

In the present case of a branch at $CFFE, this not-taken instruction is at $D000. The taken instruction is $D005, which is in the same page as $D000.
Rational
Posts: 3
Joined: Sun Oct 15, 2017 3:22 pm

Re: nestest log with bus cycles

Post by Rational »

I am also sorry but I must resurrect this thread. There is something that I simply don't get.

I have been using this log to run my CPU through some tests and I actually don't understand at all what is happening to the "log registers" whenever it calls PHP followed by PHA.

If you look at line 73, the accumulator is set with the value 0x7F. Two lines before, it uses PHP when the Status Register is set at 0x6F, and just after it calls immediately PLA, which is supposed to pull back the same value (0x6F) and store it into the Accumulator...no ?
Unless PHP or PLA are supposed to modify the value in question, is there someone who can explain to me why the log is specifying the value 0x7F for the accumulator in this very specific line ?

EDIT : Same pattern for lines 82/83/84. Stores 0x64, retrieve 0x74. Each time the original value is met again by the use of AND instruction.
Last edited by Rational on Sun Oct 15, 2017 3:35 pm, edited 1 time in total.
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: nestest log with bus cycles

Post by lidnariq »

Rational
Posts: 3
Joined: Sun Oct 15, 2017 3:22 pm

Re: nestest log with bus cycles

Post by Rational »

Thank you so much dude. I never saw it specified elsewhere before.
lidnariq
Posts: 11432
Joined: Sun Apr 13, 2008 11:12 am

Re: nestest log with bus cycles

Post by lidnariq »

Is there another place we could put that information that would have helped you find it on your own?
Rational
Posts: 3
Joined: Sun Oct 15, 2017 3:22 pm

Re: nestest log with bus cycles

Post by Rational »

lidnariq wrote:Is there another place we could put that information that would have helped you find it on your own?
No it is put in the right place. The thing is I already read this page before but it was for another reason. I completely forgot about these lines talking about PHP and BRK.

Usually I use this http://www.obelisk.me.uk/6502/reference.html or the Levanthal's 6502 book.

Once again thank you for your quick help :D
Post Reply