6502.org Forum  Projects  Code  Documents  Tools  Forum
It is currently Sat Nov 23, 2024 9:01 pm

All times are UTC




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: 6502 timing question
PostPosted: Mon Jun 30, 2003 12:45 pm 
Offline

Joined: Mon Jun 30, 2003 12:42 pm
Posts: 2
what does it mean when they say, add an extra cycle when page boundry is crossed??
like an instruction takes 5 cycles but it takes 6 if a page boundry was crossed. just how big are the pages?? every FF bytes?? is it relative to the current IP?? how would I go about calculating this?

Thanks for you time guys,

Tim


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Mon Jun 30, 2003 2:49 pm 
Offline

Joined: Wed Sep 04, 2002 4:08 pm
Posts: 57
Location: Iowa
Unless the timing of your program is critical or you're looking to highly optimize your program, you shouldn't need to worry about it, but for those cases when you do...

The page boundaries are every 256 bytes (that would be $100, or nearly $FF as you stated). Page boundaries aren't relative to the IP (or PC as it's called in the 6502). If your PC is at $04F0 and branches to $0510, that's crossing a page boundary at $0500, and relative instructions (branches and index mode addressing) need the extra cycle.

For the really curious, the reason why is because the 6502 uses the same 8-bit ALU to calculate addresses from offsets and index registers as it does for accumulator arithmetic. Within a page for example, branching ahead $20 bytes from $0470 means the ALU takes one cycle to add and put the $90 part of $0490 in the PC low; the $04 part doesn't need to be changed at all. However, crossing a page boundary by branching $20 bytes ahead from $04F0 takes two cycles, because the ALU has to calculate $F0 + $20 = $10 in one cycle, and then use the carry to increment the $04 in PC-high on the next cycle, to come up with $0510 in both PC low and PC high.

Scott


Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: Tue Jul 22, 2003 5:30 am 
Offline

Joined: Mon Jun 30, 2003 12:42 pm
Posts: 2
Scott,

Thanks for clearing this up for me. I'm working on an emulator so this helps out a lot.

Thanks,
Tim


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

All times are UTC


Who is online

Users browsing this forum: barnacle and 13 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: