Subject: [stella] Overlays with DASM From: "Andrew Davie" <adavie@xxxxxxxxxxxxx> Date: Wed, 7 Feb 2001 12:05:53 +1100 |
Just thought I'd pass this on. As I'm trying to optimise RAM usage, I'd been using a general scratchpad variable ("temp") and using that in the code wherever I need to. I managed the allocation and meaning of the variables manually. That is, I might know that "temp+1" is the variable for the line #, etc., etc. It works, but it is prone to error. So, I was thinking of a better way, and came up with this... org $80 temp ds 8 ; general area for variable overlays ; other RAM variable declarations here.... ; and now come the 'overlays'... these effectively use the 'temp' RAM location, referenced by other names... ; overlay section 1 org temp ; <--- this is the bit that is the trick overlayvar1 ds 1 ; effectively 'temp' overlayvar2 ds 2 ; effectively 'temp+1' overlayvar3 ds 2 ; effectively 'temp+3' ; overlay section 2 org temp ; ANOTHER overlay on the 'temp' variable linecounter ds 1 ; effectively 'temp' indirect ds 2 ; effectively 'temp+1' ; etc... ; overlay section 3 org temp sect3var ds 8 ; can't add more in this overlay (#3) as it's already used all of 'temp's size This all works fine... as long as you remember that when you are using variables in overlays, you can't use two different overlays at the same time. That is, the same routine (or section of code) CANNOT use variables in overlay section 1 AND overlay section 2. It's not that much of a restriction, and allows you to use nice variable names throughout your code. Just be careful your overlays don't get bigger than the general area allocated for each section. The advantages of this system are that you can CLEARLY see what your variables are, and you only have to change sizes/declarations/usage in a single place (the RAM overlay declaration)... not hunt through your code when you decide to change usage. Cheers A -- _ _ _| _ _ _| _ * _ _ , (_|| )(_|( (/_\/\/ (_|(_|\/(_(/_ ,~' L_|\ ,-' \ see my Museum of Soviet Calculators at ( \ http://www.taswegian.com/MOSCOW/soviet.html \ __ / L,~' "\__/ @--> v - Archives (includes files) at http://www.biglist.com/lists/stella/archives/ Unsub & more at http://www.biglist.com/lists/stella/
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [stella] Qb/Demo background ani, Andrew Davie | Thread | [stella] getting desperate, Andrew Davie |
Re: [stella] Qb/Demo background ani, Andrew Davie | Date | Re: [stella] Qb/Demo background ani, Manuel Polik |
Month |