Jump to content
IGNORED

Memory Management and Cartridges


Recommended Posts

I can not say that I came up with original programing techniques but like anyone else, we read, we see, we do.

I learned early in my hobby that this is the way you set up memory space in order to have  a variable or array.

 

WIDGETS:  DS 20

BOOMERS: DS 10

 

You get the idea.

The person I learned this technique, the code I have seen, still uses this till this day.  If it works for him then it works.  No worries.

What I have found is that this also uses up space on a cartridge.  You can say, well you have 32k to use up.  Well, that is not the point.  It is not efficient use of resources to where you can use that space for other things.

 

So, here is a better way that defines memory the way it was meant to be and does not use PROM space other than the compiled code.

 

USER_CRAM:        EQU $7090 ; START OF USER COLECO RAM.  You can start at $7000 but BIOS uses that area.  You should be able to even use $7080 or more but I use $7090 to be safe.
ORG USER_CRAM  ; USED TO PROTECT AREA BELOW USER CRAM

 

NPC_MEM:       EQU USER_CRAM
KEY:                EQU NPC_MEM+08*40

 

As you might see the label KEY is tacked on after the NPC_MEM which is 8*40 or 320 bytes.

 

NPC_MEM starts at the label USER_CRAM (Coleco Ram)

USER_CRAM starts at $7090, for my purposes, and is ORG'ed to protect the space below it.

If you tack on labels on the end of the previous label + (how many bytes you need), it defines that space in memory and takes no space from your PROM.

 

If you know a better way to do all of this then please share but, in my experience, using DS may give you what you want at the end of the day but it will take from the PROM.

It might be fine for small values but what if you need 700 bytes of memory and use DS.  That just increased the size of your PROM by almost 1k for no good reason.

 

Another aspect of this Chaining Memory locations is if you have to move the entire structure all you have to do is change the first element in the chain's address.  In my example it is USER_CRAM.


Back in the day if you wanted to define memory space I would do it as follows.
BOB:   EQU $7000

SLOB:  EQU $7020
KNOB: EQU $7022

and so forth.

So, if you needed more space for BOB you would have to alter every other label that came after.
So, Chaining has a great advantage and again, does not take up unnecessary PROM space.

Edited by Captain Cozmos
  • Like 1
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...