Commodore 64 (C64) Forum Index
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 
refresh me on this...cache!?

 
Post new topic   Reply to topic    Commodore 64 (C64) Forum Index -> Scene
View previous topic :: View next topic  
Author Message
beerlord
Newbie


Joined: 12 Jun 2007
Posts: 8

PostPosted: Mon Feb 04, 2002 8:59 am    Post subject: refresh me on this...cache!? Reply with quote

Does the commodore 64 have a cache I have to take into consideration when addressing????
Back to top
View user's profile Send private message
Lasse
C64 Games Programmer
C64 Games Programmer


Joined: 07 Jan 2002
Posts: 2181
Location: Finland

PostPosted: Mon Feb 04, 2002 11:06 am    Post subject: No Reply with quote

No. Only thing to take into account is that conditional jumps and indexed addressing take one cycle more if they cross page boundaries.
Back to top
View user's profile Send private message Visit poster's website
beerlord
Newbie


Joined: 12 Jun 2007
Posts: 8

PostPosted: Tue Feb 05, 2002 10:12 am    Post subject: Reply with quote

What size is the pages, are they 256-bytes blocks?
Back to top
View user's profile Send private message
Lasse
C64 Games Programmer
C64 Games Programmer


Joined: 07 Jan 2002
Posts: 2181
Location: Finland

PostPosted: Tue Feb 05, 2002 11:34 am    Post subject: Yes Reply with quote

Yes. A page cross happens when the high byte of the address changes because of a branch or indexed address

For example:
lda $01f0,X ;when X is $10 or greater it will pagecross

or
$0ffc beq $1003 ;pagecross
Back to top
View user's profile Send private message Visit poster's website
beerlord
Newbie


Joined: 12 Jun 2007
Posts: 8

PostPosted: Tue Feb 05, 2002 1:01 pm    Post subject: Reply with quote

1 cycle more doesn't seem like much, but maybe if I do lots of table lookups I should take care to place tables within pages then...
For branches, I guess I could check in the monitor (after assembling) if a branch in a timecritical loop cross a page...
It could make a difference. Idea
Back to top
View user's profile Send private message
Lasse
C64 Games Programmer
C64 Games Programmer


Joined: 07 Jan 2002
Posts: 2181
Location: Finland

PostPosted: Tue Feb 05, 2002 2:05 pm    Post subject: Yep, it isn't critical most of the time.. Reply with quote

Raster-timing crucial code is maybe one where it really matters Smile
Especially when using assembler; as the code grows and gets shifted in memory some branches might pagecross..

One quite obvious optimization is also to use zeropage for the most frequently used variables/(small) tables. (probably you knew this, but anyway Smile )
Back to top
View user's profile Send private message Visit poster's website
beerlord
Newbie


Joined: 12 Jun 2007
Posts: 8

PostPosted: Tue Feb 05, 2002 3:39 pm    Post subject: Reply with quote

Yes. But I have always been a bit unsure about which values I can mess with in zeropage. I always use 02,03 and fb,fc,fd,fe of course...But which adresses are dangerous to alter? Confused
If I wanted to build a little table or something? I think I crashed my program sometime when trying to do that...And I think its hard to know which adresses in 0page shouldnt be altered just by looking in the prog.reference guide..
(The only one I understand the working of is 01, and the one which sets the screen.(dont remember number))

Hmm...
Back to top
View user's profile Send private message
Lasse
C64 Games Programmer
C64 Games Programmer


Joined: 07 Jan 2002
Posts: 2181
Location: Finland

PostPosted: Tue Feb 05, 2002 3:42 pm    Post subject: Do you use ASM/Basic mixed? Reply with quote

If you use also BASIC in your program in theory you can only touch $02 and $FB-$FE (not really much) Experiment to find what more you can mess with..

Because the division goes pretty much so that $03-$7f is for BASIC and $80-$fa for KERNAL, in pure ASM programs the first part can be used without worry even in conjunction with using KERNAL for disk access etc.
Back to top
View user's profile Send private message Visit poster's website
MorGor
Groupie
Groupie


Joined: 30 Dec 2001
Posts: 234
Location: Espaņa

PostPosted: Wed Feb 06, 2002 10:19 am    Post subject: Do you use ASM/Basic mixed? Reply with quote

Lasse wrote:

If you use also BASIC in your program in theory you can only touch $02 and $FB-$FE (not really much) Experiment to find what more you can mess with..


Well, not exactly. There are a few more that you can change, with BASIC still working properly. You would need a good documentation of the zeropage addresses to find out which addresses you may use under which circumstances. I had a brief look at one of my older coding efforts, where I used...

$57 - $ 5a
$9e, $9f
$a5, $a6

...with BASIC still working.
There may be some constraints for the use of these addresses, but I don't remember exactly how it was. Some of these addresses ($57-$5a ?) are used by the cassette load routines, so if you don't use cassette, you can safely regard them as "free". Also, there may be addresses that BASIC uses only temporarily, that is, they are messed up by BASIC calls, but they are otherwise free.
A last solution to the problem of getting more zeropage addresses free would be to "cache" (LDA PHA) and restore them (PLA STA). This would mean that you lose some of the timing advantages, though.
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Commodore 64 (C64) Forum Index -> Scene All times are GMT
Page 1 of 1

 
Jump to:  
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 vote in polls in this forum
Tip: Get C64 Forever for super-comfy C64 emulation with pre-installed games, demos and other goodies!


Powered by phpBB © 2001, 2005 phpBB Group