6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Thu May 09, 2024 6:34 pm

All times are UTC




Post new topic Reply to topic  [ 4 posts ] 
Author Message
PostPosted: Fri Jul 22, 2022 11:16 am 
Offline
User avatar

Joined: Sat Mar 09, 2019 10:49 am
Posts: 3
Hi all;

I was reading through the instruction timing chart (table 6-5) of WDC's W65C02S datasheet (February 2004), as one does, and got a little confused when it comes to the behaviour of the BBRx and BBSx instructions.

It is my understanding that they have only 1 addressing mode which is really a kind of juxtaposition of zeropage and relative addressing (how it's described in Bruce Clark's 65C02 tutorial here. Some sources identify this as a bonefide addressing mode, but WDC just call it relative (e.g. c.f. table 6-4).

Looking at the documented bus behaviour of BBRx and BBSx, however, the confusing part is that these sets of of instructions have 2 slightly different entries, one classifed as relative and one classified as zeropage.

The first (relative) goes like this:
Attachment:
File comment: WDC instruction timing chart entry for BBRx and BBSx, classified as Relative
BBSRx_REL.png
BBSRx_REL.png [ 41.53 KiB | Viewed 588 times ]

Whereas the second (zeropage) goes like this:
Attachment:
File comment: WDC instruction timing chart entry for BBRx and BBSx, classified as ZeroPage
BBSRx_ZP.png
BBSRx_ZP.png [ 42.89 KiB | Viewed 588 times ]

I also note that the first (relative) description adds a note that an additional cycle is taken if the branch is taken, whereas Bruce's document mentioned in the above states that:
Quote:
Unlike other branch instructions, BBR and BBS always take the same number of cycles (five) whether the branch is taken or not
This seems to correspond better with the second (ZP) entry from the WDC datasheet.

So my question is whether there is some distinction in the instruction timing that I am overlooking that warrants these 2 different descriptions or whether it is simply an error in the datasheet.

Thanks in advance.

[Edit: This should have been posted in General Discussions but I cannot figure out how to remedy that so maybe a moderator can move it.]


Top
 Profile  
Reply with quote  
PostPosted: Fri Jul 22, 2022 1:15 pm 
Offline

Joined: Sun Jun 29, 2014 5:42 am
Posts: 337
Here's how the 6502 Decoder treats these instruction.
Code:
   // Example: BBR0, $50, +6
   // 0 8f 1 1 1 <opcode>
   // 1 50 1 0 1 <op1> i.e. ZP address
   // 2 01 1 0 1 <mem rd>
   // 3 01 1 0 1 <mem rd>
   // 4 06 1 0 1 <op2> i.e. Branch relative target
   // 5 20 1 0 1 (<branch taken penalty>)
   // 6          (<page crossed penalty>)

The instruction is 5, 6 or 7 cycles, depending on whether the branch is taken, and whether it's to a different page.

This is certainly correct for the Rockwell implemenation, and I would expect it would be the same for the WDC implementation.


Top
 Profile  
Reply with quote  
PostPosted: Fri Jul 22, 2022 1:34 pm 
Offline
User avatar

Joined: Fri Dec 11, 2009 3:50 pm
Posts: 3354
Location: Ontario, Canada
Yes, the instruction is 5, 6 or 7 cycles. With Bruce's approval, Garth & I have some edits on the go to correct that little error and to add more info re the C02's undocumented NOPs.

-- Jeff

_________________
In 1988 my 65C02 got six new registers and 44 new full-speed instructions!
https://laughtonelectronics.com/Arcana/ ... mmary.html


Top
 Profile  
Reply with quote  
PostPosted: Fri Jul 22, 2022 1:43 pm 
Offline
User avatar

Joined: Tue Mar 05, 2013 4:31 am
Posts: 1373
I use the BBSx/BBRx instructions quite a bit. It's always been a bit confusing as various documentations do not match. The Eyes/Lichty handbook shows these instructions under the Rockwell section in the back of the book. They only show as 5 clock cycles to execute.

As these are relative branch instructions, one would expect an additional clock cycle to be added if the branch is taken, but I've not found any WDC documentation that describes this. Also, the extra clock cycle is the page boundary is crossed would also be expected.

_________________
Regards, KM
https://github.com/floobydust


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 10 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to: