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

Re: AUX memory question



Dennis Jenkins <dennis@usb.com> wrote:

> Here comes the good stuff (A real implementation using the soft
> switches):
> 
> David Empson wrote:
> >
> > The stub routines to access the auxiliary language card area are as
> > follows:
> > 
> > RDAUX1   SEI                ; No interrupts!
> >          LDX C088           ; Read-enable language card bank 1
> >          STA C009           ; Switch in auxiliary language card, etc.
> >          LDA xxxx           ; Read target location (patched)
> >          STA C008           ; Switch in main language card, etc.
> >          LDX C08A           ; Switch the ROM back in
> >          CLI                ; Enable interrupts
> >          RTS
> > [etc]
> 
> Since the above code is for hitting the language card at >$bfff, I
> assume that I can leave the above code in my main code segment (er, um,
> whatever it is called...) in MAIN memory.

Correct.  (I should have suggested that in the first place - there is no
need to have extra stub routines in $0200-$03DF.)

> Is this correct, or do I need to shove it all into zero page (along
> with my other stubs)?

You _cannot_ put this code in zero page, because the STA C009
instruction will switch out the zero page!

> > The C008/C009 switch controls both read and write access, unlike the
> > switches for the main $0200-$BFFF area, but note the different
> > instruction sequences needed to control read enable and read/write
> > enable for the language card area.  (You could set up the language card
> > for write-only access using C081 or C089 instead of C083 or C08B, but it
> > won't make the code any shorter.)
> 
> Why did they bother with write only access to this ram?

The major benefit is that it allows code in ROM to remain available for
use while copying data into the language card.  For example, the
standard memory move routine provided by the monitor can be used to copy
data from main memory (or ROM) into the language card area.

One example of this is late versions of DOS 3.3, which were able to save
disk space on the system master by not including a copy of the monitor
firmware in the FPBASIC and INTBASIC files (saving 8 sectors per file).
The LOADER.OBJ0 program reads whichever file is appropriate into the
language card at $D000-$F7FF (using the write-only mode), then copies
the monitor firmware from the ROM to the language card ($F800-$FFFF).
This means that you end up with the "native" monitor firmware for the
machine.

By comparison, earlier versions of DOS 3.3 included a copy of the
"autostart" (Apple ][+) monitor ROM in FPBASIC and INTBASIC.  If you run
this version on an Apple //e, then you lose several //e-specific
features if you switch to Integer BASIC.  The 80-column firmware has a
workaround for this: if it detects the "wrong" monitor in the language
card, it copies the monitor firmware from the ROM.

> > [Disconnecting /RAM]
> 
> I never thought about being "polite".  In my normal usage of an Apple
> II, I reboot it quite often.  Rebooting (or doing -prodos) reinitializes
> /RAM.  I can add code to re-attach and reformat /RAM, but I will now
> have to make sure that I don't trash important memory areas that ProDOS
> would like me to preserve.  I'll try to find that technote.

The only memory areas you need to protect are auxiliary memory zero page
($0080-$00FF) and auxiliary memory $0200-$03FF.

Reattaching /RAM is basically the reverse process for removing it.  The
only extra step is to issue a FORMAT call to its device driver (which
requires a few steps to get the memory into the right state).  This will
create a fresh directory on /RAM (unlike formatting other volumes).

If you don't have all the details, I should be able to E-Mail you a copy
of the relevant technotes.

> If I am free to use the RAM in the language card, then I assume that
> ProDOS 'lives' in the upper 16K (or 12K?) of the AUX memory proper,
> accessed via the ALTZP switch?

Apart from the /RAM driver code, ProDOS lives entirely in main memory:
$BF00-$BFFF is the global page (entry points, data structures, hook
routines, etc.), and the kernel is in $D000-$FFFF (main memory language
card).  There is also the quit code (program selector) in the second
language card bank ($D100-$D3FF).

I'm not sure what you mean about "the upper 16K of AUX memory proper".
That is the auxiliary language card area, which I was telling you how to
use in my previous message in this thread.

Have you seen a complete diagram of the 128K IIe memory map?  It
certainly helps when trying to understand all this.  Here is a rough
version (not to scale vertically).

         MAIN RAM         AUX RAM            I/O             ROM

      ______________   ______________
0000 |Main zero page| |Aux zero page |
     |______________| |______________|
0100 |  Main stack  | |  Aux stack   |
     |______________| |______________|
0200 |              | |              |
     |              | |              |
0300 |              | |              |
     |______________| |______________|
0400 |              | |              |
     |              | |              |
     | Main text/GR | |  Aux text/GR |
     |              | |              |
     |    page 1    | |    page 1X   |
     |              | |              |
     |              | |              |
     |______________| |______________|
0800 |              | |              |
     |              | |              |
     | Main text/GR | |  Aux text/GR |
     |              | |              |
     |    page 2    | |    page 2X   |
     |              | |              |
     |              | |              |
     |______________| |______________|
0C00 |              | |              |
     |              | |              |
           ...              ...
     |              | |              |
     |______________| |______________|
2000 |              | |              |
     |              | |              |
     | Main Hi-res  | |  Aux Hi-res  |
     |              | |              |
     |    page 1    | |    page 1X   |
     |              | |              |
     |              | |              |
     |______________| |______________|
4000 |              | |              |
     |              | |              |
     | Main Hi-res  | |  Aux Hi-res  |
     |              | |              |
     |    page 2    | |    page 2X   |
     |              | |              |
     |              | |              |
     |______________| |______________|
6000 |              | |              |
     |              | |              |
     |              | |              |
           ...              ...
     |              | |              |
     |              | |              |
BFFF |______________| |______________|  _____________ 
C000                                   | Motherboard |
                                       |     I/O     |
                                       |_____________|
C090                                   |  Slot I/O   |
                                       |  (DEVSEL)   |
                                       |_____________|  _____________ 
C100                                   |             | |             |
                                       | Slot CX ROM | |  Int CX ROM |
                                       |   (IOSEL)   | |             |
                                       |             | |             |
                                       |_____________| |_____________|
C300                                   | Slot C3 ROM | |  Int C3 ROM |
                                       |   (IOSEL)   | |             |
                                       |_____________| |_____________|
C400                                   |             | |             |
                                       |             | |             |
                                       | Slot CX ROM | |  Int CX ROM |
                                       |   (IOSEL)   | |             |
                                       |             | |             |
                                       |             | |             |
                                       |             | |             |
                                       |_____________| |_____________|
C800                                   |             | |             |
                                       |   Slot ROM  | |             |
                                       |  (IOSTROBE) | |  Int C3 ROM |
                                       |             | |             |
                                       |    shared   | |             |
                                       |   between   | |             |
                                       |    slots    | |             |
CFFF  ______  ______   ______  ______  |_____________| |_____________|
D000 |      ||      | |      ||      |                 |             |
     | Main || Main | |  Aux ||  Aux |                 |             |
     |      ||      | |      ||      |                 |             |
     |  LC  ||  LC  | |  LC  ||  LC  |                 |             |
     |      ||      | |      ||      |                 |             |
     | bank || bank | | bank || bank |                 |             |
     |   1  ||   2  | |   1  ||   2  |                 |  Applesoft  |
     |______||______| |______||______|                 |             |
E000 |              | |              |                 |    BASIC    |
     |              | |              |                 |             |
     |              | |              |                 |     ROM     |
     |              | |              |                 |             |
     |              | |              |                 |             |
     |     Main     | |      Aux     |                 |             |
     |              | |              |                 |             |
     |   Language   | |   Language   |                 |             |
     |              | |              |                 |             |
     |     Card     | |     Card     |                 |             |
     |              | |              |                 |             |
     |              | |              |                 |.............|
F800 |              | |              |                 |   Monitor   |
     |              | |              |                 |             |
     |              | |              |                 |     ROM     |
FFFF |______________| |______________|                 |_____________|

(If you have a RAMWorks or similar bank-switched card in the auxiliary
slot, then any 64K bank on the card can be switched into the auxiliary
memory space.  "Normal" auxiliary memory, which contains the video
buffers, is bank 0 on the card.)


The major soft-switches for bank switching control areas as follows:

AUXZP/MAINZP selects main or auxiliary RAM in 0000-01FF (zero page and
stack), and in D000-FFFF (language card), for read/write access.  The
language card area is further affected by language card soft-switches
(see later).

RDMAIN/RDAUX selects main or auxiliary RAM in 0200-BFFF for read access
only.  Text page 1/1X and Hi-res page 1/1X may be excluded depending on
the state of the 80STORE and HIRES soft-switches.

WRMAIN/WRAUX selects main or auxiliary RAM in 0200-BFFF for write access
only.  Text page 1/1X and Hi-res page 1/1X may be excluded depending on
the state of the 80STORE and HIRES soft-switches.

80STORE enables 80-column switching of text/lo-res page 1 (0400-07FF).
The active page (main or auxiliary) is determined by the PAGE1/PAGE2
soft switch.  80STORE gives read/write access to whichever page is
active.

If 80STORE and HIRES are both enabled, then PAGE1/PAGE2 also control
switching of hi-res page 1 (2000-3FFF).

There is no special bank switching support for text or hi-res page 2/2X.
Using the double resolution modes with these pages requires using
another bank switching technique.

SLOTCXROM/INTCXROM determines whether the slot address space or
motherboard ROM is enabled for $C100-$C2FF and $C400-$C7FF.

SLOTC3ROM/INTC3ROM determines whether the slot address space or
motherboard ROM is enabled for $C300-$C3FF.

The $C800-$CFFF area (I/O Stobe) is shared between all slots, and may be
used by the internal ROM if INTC3ROM is active.  An access to the
$CN00-$CNFF page (N=1 to 7) enables the expansion ROM space for slot N,
if supported by that card.  An access to $CFFF disables the expansion
ROM space for all cards.

I listed the language card soft-switches in an earlier article in this
thread (message ID <1epcaw8.16zv8ma1pa69hcN%dempson@actrix.gen.nz>).
There are eight of them, and between them they control selection of RAM
bank 1 or 2, read enable for RAM or ROM, and write enable for RAM.