Page 2 of 2

Re: nestest log with bus cycles

Posted: Fri Jan 20, 2017 4:19 pm
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!

Re: nestest log with bus cycles

Posted: Fri Jan 20, 2017 6:21 pm
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.

Re: nestest log with bus cycles

Posted: Fri Jan 20, 2017 6:35 pm
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.

Re: nestest log with bus cycles

Posted: Fri Jan 20, 2017 7:16 pm
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.

Re: nestest log with bus cycles

Posted: Fri Jan 20, 2017 10:44 pm
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.

Re: nestest log with bus cycles

Posted: Sun Oct 15, 2017 3:31 pm
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.

Re: nestest log with bus cycles

Posted: Sun Oct 15, 2017 3:33 pm
by lidnariq

Re: nestest log with bus cycles

Posted: Sun Oct 15, 2017 3:37 pm
by Rational
Thank you so much dude. I never saw it specified elsewhere before.

Re: nestest log with bus cycles

Posted: Sun Oct 15, 2017 3:38 pm
by lidnariq
Is there another place we could put that information that would have helped you find it on your own?

Re: nestest log with bus cycles

Posted: Sun Oct 15, 2017 3:48 pm
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