[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[no subject]



The Apple III has two different ways ways of accessing beyond the 6502's
64K addressing limit.  The first is a fairly conventional bank-switching
technique.  The Apple III's memory is divided into three areas--a "lower
system bank" from $0000 to $1FFF, an "upper system bank" from $A000 to
$FFFF, and a bank-switched area in between (from $2000 to $9FFF).  The two
"system banks" are constant, and the in-between area can be bank-switched
between as many as 15 32K banks.  The four low-order bits at $FFEF control
which bank is currently switched in--any number from $0 to $E can be
specified ($F is reserved for some unspecified "special purpose").  Not all
fifteen banks may be available--the highest available bank number in a 128K
machine is 3, and the highest available bank in a 256K machine is 7.

The second method is a bizarre thing called "extended addressing."  This
depends on a couple of other bizarre facts:

     * The Apple III"s zero page is not necessarily in memory locations
       $00 through $FF.  The 6502 is separated from memory by a "switch
       box" which (among other things) notices whenever an address of the
       form $00xx is referenced, and fetches (or writes to) memory location
       $nnxx instead, where "nn" is the current contents of memory location
       $FFD0.  This means zero page can by moved anywhere in memory by
       storing a new address at $FFD0.

     * Whenever a given memory location is accessed, the above-mentioned
       "switch box" also fetches the byte at "location XOR $0C00".  (This
       extra byte is used by the video circuitry in 80-column mode.)

Whenever the 6502 uses a (ZP),Y addressing mode, and the zero page register
($FFD0) contains a number from $18 to $1F, the "switch box" uses the
above-mentioned extra byte (called the "Xbyte") to perform "extended
addressing."  If the Xbyte (fetched from page ($FFD0) XOR $0C) is outside
the range $80...$8F, then the indirect memory access occurs normally.
Otherwise the switch box intervenes again and briefly remaps memory just
long enough enough for the indirect memory access.  If the low nibble of
the Xbyte is "n", then the indirect addressing sees a memory map composed
of bank "n" (that's the same bank "n" from the normal bank-switching method
mentioned above) mapped into $0000...$7FFF, and bank "n+1" mapped into
$8000...$FFFF.

...Well, almost.  If the Xbyte is $8F, something special happens.  The
indirect addressing sees the normal Apple III memory map with bank 0
switched into $2000...$9FFF.  As an added bonus, it also sees the RAM
that's hiding under the VIA control registers at $FFD0...$FFEF.  In fact,
this is apparently the ONLY way to get at those 32 bytes of RAM.  Since
this memory is unavailable by other means, the operating system uses it to
store the last valid value of the system clock.

             - Neil Parker
--
Neil Parker                 No cute ASCII art...no cute quote...no cute
nparker@cie-2.uoregon.edu   disclaimer...no deposit, no return...
nparker@cie.uoregon.edu     (This space intentionally left blank:           )