Previous page: Memory Allocation Next page:
Service Events   Example ROM 1

Usually, ROMs require some memory they can use to store state information and as a calculation workspace. This memory can be obtained through the service calls &01, &02, &21, &22 and &23 depending on where the ROM wants to store its data.

Calls &01 and &02 allocate memory starting at &E00. Calls &21, &22 and &23 allocate memory in the paged filing system private RAM between &C000 and &DBFF. Memory is allocated a page at a time.

Calls &01 and &21 allocate static memory for filing systems. The Y register will contain the page number of the first page above the current static area. If the filing system requires more space, it should increase the Y register accordingly. Most filing systems will claim space in the filing system RAM using call &21. The current filing system will then have free use of this area. If another filing system is going to start, then the current one will receive service call &0A enabling it to free up this space.

Calls &02 and &22 enable dynamic space to be allocated by any ROM. The Y register will contain the page number of the first available page. ROMs should increase this by the number of pages needed. Note that this must not be increased higher than the current top of the particular area in question (&7F for call &02 and &DC for call &22).

Call &24 enables dynamic space to be allocated in the filing system private RAM below current usage. The Y register will contain the current bottom of usage and should be decremented by the number of pages required.

Once memory has been successfully allocated, it is standard practice to save the page number at the bottom of the allocated area in the location &0DF0+. These 16 locations are provided specifically for this purpose. They are cleared on a hard reset before ROMs are offered memory allocations.

Space in the filing system private RAM is best allocated using call &24. Note that in this area there are a total of 32 pages available for filing system static RAM plus dynamic RAM for other ROMS so space may be tight. At &E00 there are 114 pages but this is shared with the current language as storage (BASIC program, VIEW document, etc) and also by the screen unless a shadow screen mode is used.

The examples here will all require at most one page of RAM and will always allocate this from main memory (at &E00) using service call &02. It is recommended to always use a shadow screen mode to maximise memory utilisation.


Previous page: Memory Allocation Next page:
Service Events   Example ROM 1