Bob’s Notebook: Bank Switching Notes For A Beginner

See all articles from Sinc-Link v8 n3
Author(s): Bob Mitchell
Publication: Sinc-Link
Pub Details: Sinc-Link v8 n3 (Volume 8, Issue 3)
Date: May/June 1990
Pages: 18

This column will be of interest to those with a RAMDISK added to their TS2068s but will hopefully inspire others to do the same. If you have been using your RAMDISK mainly to store a few pet programs which you use regularly, say this one (Mscript) or ‘Tasword’, then you should know that your RAMDISK can be used for much more than this. One of the other uses for RAMDISK is that of BANK Switching. The use of BANK switching will add greatly to the amount of data that can be stored and used with the TS2068. It will virtually add up to 256K more data storage memory. It does not allow you to have longer BASIC programs; more on this later.

First: Some definitions for use with this article:

HOME BANK: The TS2068 ROM and 48K RAM; in this article, it means ‘the upper 32K from addresses 32768 to 65535’.
DOCK BANK: The upper 32K of the DOCK or cartridge bank as used by the RAMDISK.
CHUNK: 8K of a BANK; there are four CHUNKS in one BANK.

BANK switching might be described as changing (in a split second) the RAM contents in the HOME BANK. The version 3 LKDOS EPROM contains the support routines to perform BANK switching. RAMDISK operates in the 32-64K area and uses port 244 to select any of the ramchips that are mounted. The command OUT 244,240 will switch in (turn ON) the 32K-64K area of the Dock or cartridge BANK; that’s four chunks of 8K each.

OUT 244,0 will turn it OFF (switch if out). Port 7 on the RAMDISK board is used to select the wanted chip. OUT 7,x is used where x is the port address plus a value to turn write protect OFF or ON (64 or 0 respectively). In effect, the lower three bits of x hold the port address and bit 6 holds the value that turns the write protect ON or OFF when LKDOS is not in command. A value of 64 sets BIT 6 which means no write protect while a 0 resets BIT 6 and restores the write protect.

  The eight chips are:     A, B, C, D, E, F, G, H
  with port addresses:     7, 3, 5, 1  6, 2, 4, 0
  The HOME BANK uses port address 8.

To switch in the contents of chip A, I would use:

OUT 244,240  :all four CHUNKS are switched (see below).
OUT 7,71     :71= 7 (chip A) + 64 (turn write prot OFF)

To switch in the contents of the HOME BANK,

OUT 244,0.   :turn off the Dock BANK.
OUT 7,8      :8 for HOME BANK

It is not necessary to switch a whole BANK; one or more of the chunks may be selected. To select chunks the values used with OUT 244 are as follows:

   First chunk 32K-40K======> 16
   Second chunk 40K-48K=====> 32
   Third chunk 48K-56K======> 64
   Fourth chunk 56K-64K=====> 128
These may be combined, eg,
   First two chunks=========> 48
   Last two chunks==========> 192
and so on.
Combining all four chunks
adds up to=================> 240

But if you’re thinking of switching chunks you must know that a chunk cannot be relocated to another memory location. Chunk 1 for example must always go into the same address area (32K-40K). Larry Kenny advised me that relocating to other memory areas would take a lot of extra hardware.

One of the problems in switching BANKs is that the supporting BASIC program must not go higher than 32767, that is, its length cannot exceed about 6000 bytes including space needed for any machine code routines.

I am indebted to Larry Crawford for shedding a great deal of light on this subject when he donated his InterBANK Data Storage Sorting Utility to the public domain. This is available to club members through our library. With it, for example, one may store up to 7936 records of 32 characters each, then search for them by inputting a character string; or sort the list fairly quickly on any of the 32 columns. The record length for any one file can be set for up to 127 characters.

This is a fantastic increase in capacity for long lists and will enable me to enter my complete collection of several thousand 35mm colour slides, a task I have always put off because I would not have been able to search or sort such a long list adequately. Mind you, it has not made the job of entering all the data any easier but at least now, I have a program that will let me do it.

In Larry’s utility the following sequence of events takes place:

When data is loaded from disk, the first 32K is put into the HOME BANK, the next 32K goes into the first RAMDISK BANK, the next 32K into the second RAMDISK BANK and so on. When searching for records, the program looks first at the HOME BANK, then switches in RAMDISK BANKS one by one until all have been checked. When sorting the records (on any column), the BANKS are switched like lightning as record pairs are compared and transposed.

Bob Mitchell [address omitted]