7.2

PROGRAMMING AUXILIARY MEMORY

BANK SWITCHING

Because the 65C02 can address only 64K of memory at one time, in order to utilize the I/c’s auxiliary memory, the computer must switch between the 64K RAM of the main memory and the 64K of auxiliary memory. This is called “bank switching.

Soft switches are locations which control which of the banks of memory is being addressed at a given time. Each soft switch has two control locations assigned to it as Table 8.1 shows. Write to the location that has the effect you desire with a STA, STX, STY instruction or a POKE command from Applesoft.

The soft switch called RANRD selects either the main or auxiliary memory for READ operations. The soft switch RAMWRT selects either main or auxiliary memory for WRITE operations. Read and Write may be set independent of one another so that s program may read data from a location in one bank and write it to another location in the other bank. To access main memory, both RANRD and RAMWRT must be Off; to access auxiliary memory, both must be On.

ALTZP selects locations in one bank or the other for both Read and Write operations in Page 0, the stack, and the language card.

The 8OSTORE switch controls the effects of some of the other switches, and it is particularly important to set it correctly. 8OSTORE must be OFT if RANRD and RAMWRT are to control the entire memory from $0200 to $8FFF. With 80STORE On. the PAGE1 switch can select either main or auxiliary memory. If HIRES is turned Off. PAGE2 will select Text Pagel from either main or auxiliary memory; if HIRES is On. PAGE2 selects Hi—rem Graphics Page 1 and Text Page 1 from main or auxiliary memory. RAMRD and RAMWRT do not affect the Text Page while 80STORE is On. Table 8.1 shows the relationships of these three switches.

Table 8.2

Functions of soft switches 8OSTORE, PAGE2, and HIRES

80STORE:

 

OFF

ON

 

 

 

------------------

--------------------------

PAGE2 OFF

Use RAMRD,RAMWRT

 

Access MAIN Memory (RAMRD

 

 

 

 

RAMWRT no effect)

HIRES OFF

(no effect)

Text Page 1

HIRES ON

 

(no effect)

 

Hi—res Page 1

PAGE2 ON

Access Hi—Res Psge 2

Access AUX. Memory (RAMRD,

 

 

 

 

RANWRT no effect)

HIRES OFF

(no effect)

 

Text Page 1

HIRES ON

 

(no effect)

 

Hi—res Page I

------------------------------------------------------------------

In Table 8.1, the first address given for each soft switch is the location at which the status of the switch can be read. When this location is read in machine language, a 0 (aero) in the high bit (7) indicates the switch is Off, a 1 shows the switch is On. If the location is read from BASIC, a value 0f 127 or less indicates the switch Is Off, 128 or greater indicates On.