The Programmer's Guide to TRSDOS Version 6 - Tim Mann's Home ...
The Programmer's Guide to TRSDOS Version 6 - Tim Mann's Home ...
The Programmer's Guide to TRSDOS Version 6 - Tim Mann's Home ...
Create successful ePaper yourself
Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.
8.8 MEMORY BANK SWITCHING<br />
This section discusses the techniques of using the @BANK SuperVisor Call. <strong>The</strong> control of<br />
an assembly-coded application operating in a memory banked environment requires a high<br />
degree of skill in assembly language coding and should not be undertaken by the novice.<br />
<strong>The</strong> professional is advised <strong>to</strong> carefully read the information contained in this section<br />
which discusses how bank switching is supported within the operating system.<br />
<strong>The</strong> DOS can support eight multiple RAM banks of 32K each in addition <strong>to</strong> a resident 32K<br />
bank. This brings the <strong>to</strong>tal RAM configuration <strong>to</strong> 288K. <strong>The</strong> non-resident RAM banks are<br />
designated as banks zero through seven. <strong>The</strong> 32K of bank zero (generally considered as<br />
"high memory") and the resident 32K are considered the standard 64K of the DOS. Banks one<br />
through seven may be used for buffers or data s<strong>to</strong>rage. Through sophisticated techniques,<br />
they can even be used <strong>to</strong> s<strong>to</strong>re executable code. An entire bank is reserved for a<br />
particular function. <strong>The</strong> system maintains a pointer (HIGH$) for bank 0 only. At any one<br />
time, only one of the banks are resident. All are imaged at address X'8000' through<br />
X'FFFF'. When a bank transfer is performed, the specified bank becomes addressable and<br />
the previous bank is no longer available. Since memory refresh is performed on all banks,<br />
nothing in the previously resident bank is altered during whatever time it is not<br />
addressable (i.e. not resident).<br />
<strong>The</strong> DOS provides support in accessing this additional RAM by means of the @BANK<br />
SuperVisor Call (SVC-102). Let's take a look at how this RAM is handled. When the<br />
operating system is booted, it examines what banks of RAM are installed in the machine.<br />
<strong>The</strong> DOS maintains a byte bit-map with each bit representing one of the banks of RAM. This<br />
byte is called "Bank Available RAM" (BAR), and its information is set when the DOS is<br />
booted. BAR bit-0 corresponds <strong>to</strong> bank 0, BAR bit-1 corresponds <strong>to</strong> bank 1, and so on <strong>to</strong><br />
BAR bit-7 corresponding <strong>to</strong> bank 7. A machine may have only one bank, bank 0.<br />
Another byte bit-map is used <strong>to</strong> indicate whether a bank is reserved or available for use.<br />
This byte is designated the "Bank Used RAM" (BUR). Again, a bit assignment corresponds<br />
one-for-one with the bank number. <strong>The</strong> management of any memory space within a particular<br />
bank of RAM (excluding bank 0) is the sole responsibility of the application program<br />
"reserving" a particular bank.<br />
<strong>The</strong> DOS I/O device handler will always enable bank 0 upon execution of any character I/O<br />
service request (@PUT, @GET, @CTL, as well as those other character I/O SVCs that use<br />
@PUT/@GET/@CTL). <strong>The</strong> DOS also enables bank 0 at the initial entry <strong>to</strong> the task processor<br />
and when a disk I/O communications function is requested. This requires that any device<br />
driver or filter that is relocated <strong>to</strong> high memory (X'8000'-X'FFFF') must reside in bank<br />
0. <strong>The</strong> same holds true for interrupt task routines and disk drivers/filters. <strong>The</strong> system<br />
provides this restriction <strong>to</strong> make sure that any filter, driver, or task routine that<br />
control passes <strong>to</strong> will be occupying enabled RAM memory. If a RAM bank other than 0 was<br />
resident during these operations, it would be res<strong>to</strong>red upon return from the<br />
device/drive/task handler. <strong>The</strong> limitation will ensure that device I/O, task processing,<br />
and disk I/O will never be impacted due <strong>to</strong> bank switching of RAM by an application.<br />
Another restriction requires that the stack pointer (SP) is not pointing <strong>to</strong> an adddress<br />
above X'7FFE' when a bank transfer is requested. This is because that stack range would<br />
have placed the stack in the memory region that is being swapped thereby making the stack<br />
contents erroneous. <strong>The</strong> @BANK SVC will inhibit the request and return an "SVC parameter<br />
error" if this condition is violated. It is acceptable for an interrupt task, filter<br />
module, or driver that is located in the bank switched address range <strong>to</strong> perform a bank<br />
transfer <strong>to</strong> another bank provided the necessary linkage and stack area is being utilized.<br />
This will be discussed later in more detail.<br />
All bank transfer requests must be performed using the @BANK SVC. This SVC provides five<br />
functions - four of which are interoga<strong>to</strong>ry in nature. One of the functions performs<br />
8-21