How to load and save binary data on the C128 and Plus/4

Commodore LogoThanks to BASIC 7.0’s powerful commands we can load and save arbitrary sections of memory to disk using BLOAD and BSAVE.

This was useful for dealing with machine code as well as raw image data. Both commands work on the C128 and Plus/4, but sadly the C64 was lacking in this area.

BLOAD and BSAVE work much like DLOAD and DSAVE with the addition that you can specify a section of memory – like this:

// save contents of the 40 column display
BSAVE "FILENAME", P1024 TO P2023

// save the contents of hi-res graphics and colour separately
BSAVE "IMAGE", P8192 TO P16181
BSAVE "COLOURS", P7168 TO P8167

// save graphics and colour information together
BSAVE "FULL IMAGE", P7168 TO P16181

BLOAD doesn’t need additional parameters and will load a file back into memory where it originally resided – just like the standard LOAD “FILE”,8,1 (with the 1 at the end). You can however provide the starting memory and make the file load somewhere else instead:

// load file to a different place in memory
BLOAD "FILENAME", P10000




Jay is the CEO and founder of WP Hosting, a boutique style managed WordPress hosting and support service. He has been working with Plesk since version 9 and is a qualified Parallels Automation Professional. In his spare time he likes to develop iOS apps and WordPress plugins, or draw on tablet devices. He blogs about his coding journey at http://wpguru.co.uk and http://pinkstone.co.uk.