| View previous topic :: View next topic |
| Author |
Message |
Newbie
Joined: 12 Jun 2007 Posts: 8
|
Posted: Mon Feb 04, 2002 8:59 am Post subject: refresh me on this...cache!? |
|
|
Does the commodore 64 have a cache I have to take into consideration when addressing???? |
|
| Back to top |
|
 |
C64 Games Programmer


Joined: 07 Jan 2002 Posts: 2181 Location: Finland
|
Posted: Mon Feb 04, 2002 11:06 am Post subject: No |
|
|
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 |
|
 |
Newbie
Joined: 12 Jun 2007 Posts: 8
|
Posted: Tue Feb 05, 2002 10:12 am Post subject: |
|
|
What size is the pages, are they 256-bytes blocks? |
|
| Back to top |
|
 |
C64 Games Programmer


Joined: 07 Jan 2002 Posts: 2181 Location: Finland
|
Posted: Tue Feb 05, 2002 11:34 am Post subject: Yes |
|
|
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 |
|
 |
Newbie
Joined: 12 Jun 2007 Posts: 8
|
Posted: Tue Feb 05, 2002 1:01 pm Post subject: |
|
|
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.  |
|
| Back to top |
|
 |
C64 Games Programmer


Joined: 07 Jan 2002 Posts: 2181 Location: Finland
|
Posted: Tue Feb 05, 2002 2:05 pm Post subject: Yep, it isn't critical most of the time.. |
|
|
Raster-timing crucial code is maybe one where it really matters
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  ) |
|
| Back to top |
|
 |
Newbie
Joined: 12 Jun 2007 Posts: 8
|
Posted: Tue Feb 05, 2002 3:39 pm Post subject: |
|
|
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?
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 |
|
 |
C64 Games Programmer


Joined: 07 Jan 2002 Posts: 2181 Location: Finland
|
Posted: Tue Feb 05, 2002 3:42 pm Post subject: Do you use ASM/Basic mixed? |
|
|
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 |
|
 |
Groupie


Joined: 30 Dec 2001 Posts: 234 Location: Espaņa
|
Posted: Wed Feb 06, 2002 10:19 am Post subject: Do you use ASM/Basic mixed? |
|
|
| 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 |
|
 |
|