Memory Expansions Beyond the 130XE: 192K to 1MB and How to Use Them
The 130XE showed how to get past the 6502's 64K limit. Write the right value to PORTB and a 16K window at $4000–$7FFF swaps to one of four extra banks. Using the 130XE's Extra 64K covers that machine and the meaning of PORTB bits 2–5. Hundreds of third-party upgrades took the same idea further, to 192K, 320K, 576K, 1088K and beyond, by borrowing more PORTB bits as bank selectors. The 400 and 800 had their own schemes. This guide shows how the big expansions differ, how a program finds out what is installed, and how to use the memory safely.
What you'll learn: the main bank-selection families, what the borrowed PORTB bits cost you, a tested routine that counts banks on any PORTB expansion without destroying their contents, switching rules for big expansions, the Axlon and Mosaic schemes, and RAMdisk options.
What you need: an expanded XL/XE (or an Ultimate1MB) and an assembler, or atari800, which can emulate most of these configurations: -xe (130XE), -320xe (Compy-Shop), -rambo (320K RAMBO), -576xe, -1088xe, plus -axlon n and -mosaic n for the 400/800 schemes. Altirra's memory-size options cover 128K, 256K, 320K, 576K and 1088K as well.
1. The families
Every PORTB expansion keeps the 130XE's basics: bit 4 = 0 opens the window at $4000–$7FFF, and bits 2–3 pick a bank. They differ in which extra bits they use and in whether ANTIC can see the window separately from the CPU:
| Total RAM | Type | Bank bits | Extra banks | Separate ANTIC access |
|---|---|---|---|---|
| 128K | 130XE | 2, 3 | 4 | Yes |
| 192K | various | 2, 3, 6 | 8 | Depends on the design |
| 256K | RAMBO (ICD RAMBO XL, Buchholz) | 2, 3, 5, 6 | 12 | No |
| 320K | RAMBO / "Atari Magazin" | 2, 3, 5, 6 | 16 | No |
| 320K | Compy-Shop | 2, 3, 6, 7 | 16 | Yes |
| 576K | RAMBO | 1, 2, 3, 5, 6 or 2, 3, 5, 6, 7 | 32 | No |
| 576K | Compy-Shop | 1, 2, 3, 6, 7 | 32 | Yes |
| 1088K | RAMBO | 1, 2, 3, 5, 6, 7 | 64 | No |
The names come from model products: Compy-Shop boards (popular in Europe) kept the 130XE's separate ANTIC bit, and ICD's RAMBO XL used bit 5 as a bank bit instead. The 256K boards replace the main 64K rather than adding to it, so only 12 of their 16 banks are extra. On ICD's RAMBO XL, four bank values simply map onto main memory. Newell's 256KXL used the same bits as RAMBO, but with bit 5 inverted. Newell also made 1MB boards for the 800XL, 65XE and 130XE.
The Ultimate1MB, by Candle, works in plain PORTB terms too. Its setup menu offers four modes: disabled, 320K RAMBO, 576K Compy-Shop and 1088K RAMBO. There is no special access method: its own configuration registers are only visible while setup is unlocked.
2. What the borrowed bits cost
- Bit 5. On RAMBO-type boards it selects banks, so ANTIC sees whatever the CPU sees. Screen memory, display lists, character sets and player/missile data must stay out of $4000–$7FFF while you bank on these machines. The 130XE trick of showing one bank while working in another is not available.
- Bit 7 (self-test ROM) and bit 1 (BASIC ROM). Large boards reuse them. Usually they act as bank bits only while the window is open (bit 4 = 0) and keep their normal job otherwise. Some installations, mostly in Germany, dropped built-in BASIC altogether.
- Self-test priority. With bit 7 = 0 and the OS ROM enabled, the self-test ROM wins at $5000–$57FF on expansions that don't take over the bit. Reads come from ROM there and writes are lost.
- No fixed bank order. Which bit counts as "higher" is invisible to software, because swapping two banks changes nothing a program can see. SpartaDOS X's
MEMINFOlists banks in its own order, but that is a convention.
The practical consequences: keep everything ANTIC needs out of the window, find banks by testing rather than assuming bit patterns, and when you close the window, restore the whole PORTB value you saved. A bank value may have cleared bit 1 or 7, and simply setting bit 4 again would leave BASIC or the self-test ROM switched in.
3. Counting the banks
The detection method is "write a unique value into each bank, then see which ones kept it". This routine tries all 64 combinations of bits 1, 2, 3, 5, 6 and 7 (with bit 4 = 0), so it covers everything up to 1088K:
- Save the first two bytes of the window for every candidate, and of main memory, so nothing is destroyed.
- Working from the last candidate to the first, write each candidate's index and its complement into the window. Where several values reach the same physical bank, the lowest index is written last and wins.
- Write $FF $FF into main memory. Values that only reach main RAM, as on a stock 64K machine or the aliased banks of a 256K RAMBO, can no longer match.
- Read back from the first candidate to the last. A candidate that still holds its own index is a new bank: record its PORTB value.
- Put every saved byte back.
The base value keeps the current OS, BASIC and self-test bits, so on a 130XE running BASIC the banks come back as $81, $85, $89 and $8D. The routine must sit outside $4000–$7FFF and outside $A000–$BFFF, since a candidate may switch BASIC in.
PORTB = $D301
WIN = $4000 ; test bytes: first two bytes of the window
; Returns Y = number of extra banks; their PORTB values in BANKS
detect lda PORTB ; remember the original setting
sta oldpb
and #%10000011 ; keep OS, BASIC and self-test bits; bit 4 = 0
sta base ; opens the window
ldx #63 ; candidate X: index bits 0-5 flip PORTB
mk1 stx tmp ; bits 2,3,5,6,1,7
lda base
ldy #0
mk2 lsr tmp
bcc mk3
eor bitmap,y
mk3 iny
cpy #6
bne mk2
sta cand,x
dex
bpl mk1
lda oldpb
ora #$10 ; window closed: main memory
sta PORTB
lda WIN
sta main0
lda WIN+1
sta main1
ldx #63 ; 1. save the test bytes of every candidate
sv lda cand,x
sta PORTB
lda WIN
sta save0,x
lda WIN+1
sta save1,x
dex
bpl sv
ldx #63 ; 2. tag each candidate with its index and the
tg lda cand,x ; complement, last to first: where two values
sta PORTB ; select the same bank, the lowest index wins
stx WIN
txa
eor #$FF
sta WIN+1
dex
bpl tg
lda oldpb ; 3. tag main memory with $FF $FF, so values
ora #$10 ; that just reach main RAM never match
sta PORTB
lda #$FF
sta WIN
sta WIN+1
ldx #0 ; 4. a candidate is a new bank only if it still
stx found ; holds its own tag
rd lda cand,x
sta PORTB
cpx WIN
bne rd2
txa
eor #$FF
cmp WIN+1
bne rd2
ldy found
lda cand,x
sta banks,y
inc found
rd2 inx
cpx #64
bne rd
ldx #63 ; 5. put everything back
rs lda cand,x
sta PORTB
lda save0,x
sta WIN
lda save1,x
sta WIN+1
dex
bpl rs
lda oldpb
ora #$10
sta PORTB
lda main0
sta WIN
lda main1
sta WIN+1
lda oldpb
sta PORTB
ldy found
rts
bitmap dta $04,$08,$20,$40,$02,$80
tmp dta 0
base dta 0
oldpb dta 0
main0 dta 0
main1 dta 0
found dta 0
cand .ds 64
save0 .ds 64
save1 .ds 64
banks .ds 64
Run in atari800, it reports 0 banks on a 64K 800XL, 4 on a 130XE, 16 on both 320K types (Compy-Shop values such as $C3 use bit 6; RAMBO values such as $A3 use bit 5), 32 on the 576XE and 64 on the 1088XE. If a DOS or RAMdisk is already using extended memory, some of these banks are taken. SpartaDOS X's MEMINFO lists the free ones with their PORTB values.
4. Using the banks
All the 130XE rules apply: never switch from code or data inside the window, keep interrupt handlers out of it, and save and restore PORTB around your work. With the table in hand, moving data in and out is simple. This routine copies a page into a bank. It was tested on the 1088XE setting by filling two different banks and reading the first one back intact:
; copy 256 bytes from BUF to the start of bank X (an index into BANKS)
tobank lda banks,x
sta PORTB ; window on, bank X selected
ldy #0
cp lda buf,y
sta WIN,y
iny
bne cp
lda oldpb ; back to main memory: the full saved value
sta PORTB
rts
For bulk storage, think in 16K units: level data, graphics to copy into place, sample data (see Playing Digitised Samples Through POKEY) or an overlay of code that you copy down to main memory before running it.
5. The 400/800: Axlon and Mosaic
The 400 and 800 have no PORTB banking, because port B reads joysticks 3 and 4 there. Two other schemes appeared instead:
- Axlon (RAMDISK/RAMPOWER 128, and many compatibles since): 16K banks also appear at $4000–$7FFF, selected by writing the bank number to any address from $CFC0 to $CFFF (by convention $CFFF, 53247) or its mirror at $0FC0–$0FFF. Bank 0 is normal memory. The scheme allows up to 255 extra banks, about 4MB, and modern boards from 512K to 4MB use it.
- Mosaic: 4K banks at $C000–$CFFF. Writing to $FFC0 + n (65472 + n) enables bank n, and writing to $FF00–$FFBF or $FFE4–$FFFF switches them all off. Up to 36 banks fit.
The tag-and-read-back idea from section 3 carries over to both; only the way a bank is selected changes.
6. RAMdisks
Using extended memory as a fast drive needs no programming at all:
- DOS 2.5
RAMDISK.SYShandles only the 130XE's four banks (as D8:). - MyDOS 4.5 sets up a RAMdisk of up to a megabyte with its O option: choose Axlon or XE type, the size and the control address ($D301 for PORTB, $CFFF for Axlon). Newell shipped MyDOS with its boards.
- SpartaDOS X loads
RAMDISK.SYSwith a drive number and a bank count, up to three RAMdisks. By default it leaves four banks free for BASIC XE. - BW-DOS supports RAMdisks of up to 1MB on Axlon or PORTB memory.
Remember that a RAMdisk owns its banks. Programs that bank-switch directly must avoid them. BASIC XE's EXTEND, for example, refuses to start (error 60) when DOS 2.5's RAMdisk already holds the 130XE banks.
Troubleshooting
- The routine finds 0 banks on an Ultimate1MB. Extended memory is disabled in its setup menu.
- 12 banks instead of 16. A 256K board that replaces main memory: four of its values map onto main RAM and are correctly rejected.
- Display garbage while banking. The machine has no separate ANTIC access (RAMBO-type), and something ANTIC reads lives in $4000–$7FFF.
- BASIC vanished or the self-test screen appeared. You closed the window with ORA #$10 instead of restoring the saved PORTB value.
- Lock-up the moment you switch. The switching code, its data or an interrupt handler is in the window.
Further reading
- comp.sys.atari.8bit FAQ, sections 1.14 (memory map and banked memory) and 6.12 (the full list of memory upgrades).
- Avery Lee, Altirra Hardware Reference Manual, sections 2.6–2.7: bank switching, extended memory and bit reuse.
- Mapping the Atari, location 54017 (PORTB).
- The ICD RAMBO XL manual, and the SpartaDOS X Programmer's Guide for its extended-memory management calls.
- On this site: Using the 130XE's Extra 64K, MyDOS 4.5, SpartaDOS X, BW-DOS, BASIC XL and BASIC XE, and the hardware entries for the ICD RAMBO XL, Newell 256KXL, Axlon RAMPOWER, Mosaic RAM boards and Ultimate1MB.
Credits
- Picture: The bank-counting routine from section 3 on atari800's 1088XE setting: 64 extra banks, with the PORTB value that selects each one. — Program authors; screenshot by the site
- Altirra Hardware Reference Manual (Avery Lee), sections 2.5-2.7: PORTB, bank switching, extended memory, bit reuse, main memory aliasing, Table 1 extended memory configurations; U1MB chapter — Avery Lee (Altirra)
- Altirra 4.40 help — Options: Hardware, memory size options — Screenshot from Avery Lee's Altirra page, virtualdub.org
- comp.sys.atari.8bit FAQ (Michael Current), 1.14 memory map and banked memory; 6.12 What types of memory upgrades are there for the Atari? — Michael Current (comp.sys.atari.8bit FAQ)
- Atariki — Obsługa standardowego rozszerzenia pamięci RAM (PORTB expansion table, bit reuse, size-detection procedure) — Atariki contributors
- AtariAge — Accessing U1M RAM Banks (U1MB uses plain PORTB banking; no defined bit order; SDX MEMINFO) — AtariAge forum members
- Mapping the Atari (revised) — 54017 PORTB — AtariArchives.org
