How to save data to your C128 RAM Expansion Unit (REU)

Commodore-Logo-PaddedWith a RAM Expansion Unit (REU), the Commodore 128 could address up to 512k of data. That was huge in the late eighties! All you needed was one of those REUs, plug it into your cartridge port, and so much more super fast memory was at your fingertips.

But even with such a cartridge at hand, how do we actually make use of it from CBM BASIC 7.0? With three funky commands called STASH, FETCH and SWAP. Here’s how we can use them.

The REUs cannot be addressed directly, like other memory in your computer. Instead, data has to be either copied from the C128 to the REU, or vice versa, or swapped out. All three commands take the same four parameters:

  • number of bytes to transfer
  • location in the C128 memory to start
  • REU bank (0-7, depending on the size of the REU)
  • location in the REU bank memory

This sounds more cryptic than it actually is: the largest REU split 512k over 8 banks of 64k, so that the 8bit operating system could address it.

So to store 200 bytes of C128 memory, starting at location 5000, saving it inside the REU’s bank 0, location 0, we can use the STASH command like so:

To retrieve our data later and bring it back to the same C128 location as before, we can use FETCH with the same parameters:

Rather than copying, we can also exchange data in two places by literally swapping it over. Again the parameters are the same:

Enabling REUs in VICE

Although I have a physical C128, I do not have a real REU. Maybe one day I’ll find one on eBay, but until then there’s an easy way to emulate an REU using VICE.

To enable one, head over to Settings – Resource Inspector – Cartridges – REU. Pick the size you like, and even a hard disk location to make the contents of your REU survive restarts.

Screen Shot 2016-01-02 at 09.08.35

Screen Shot 2016-01-02 at 09.09.19

Demo Listing

Here’s a quick test that allows us to store an arbitrary message in memory, then stash or retrieve it from an attached REU.

We don’t see many BASIC listings these days anymore. Enjoy!

About Jay Versluis

Jay is a medical miracle known as a Super Survivor. He runs two YouTube channels, five websites and several podcast feeds. To see what else he's up to, and to support him on his mission to make the world a better place, check out his Patreon Campaign.

Add your voice!