Amstrad CPC 6128 (and Plus) memory banks

Amstrad CPC and NC systems
Post Reply
norecess
Member
Posts: 73
Joined: Thu Mar 20, 2008 12:58 am

Amstrad CPC 6128 (and Plus) memory banks

Post by norecess »

Amstrad made CPC 464, 664 and 6128 computers. 464 & 664 have 64Kb of memory. 6128 have the same memory scheme, but adds memory-bank support to access the other 64Kb of available memory.

A bank is memory from 0x4000 to 0x7FFF. A bank is 16Kb-long, so there are 4 distinct banks to make the extra 64Kb of memory.

I had to define the following in my custom code..

Code: Select all

#define crBANKSetC0( ) asm( "ld bc, $7f00 \n out (c), c \n ld a, $C0 \n out (c),a" );
#define crBANKSetC4( ) asm( "ld bc, $7f00 \n out (c), c \n ld a, $C4 \n out (c),a" );
#define crBANKSetC5( ) asm( "ld bc, $7f00 \n out (c), c \n ld a, $C5 \n out (c),a" );
#define crBANKSetC6( ) asm( "ld bc, $7f00 \n out (c), c \n ld a, $C6 \n out (c),a" );
#define crBANKSetC7( ) asm( "ld bc, $7f00 \n out (c), c \n ld a, $C7 \n out (c),a" );
Default is crBANKSetC0.

When I just call crBANKSetC4, memory from 0x4000 to 0x3FFF becomes the one in extra-bank called C4. And so on for the three other banks. After using it, I use to get back to default one through a crBANKSetC0 call.

That's why it has been so hard when using large files generated by z88dk. Even when compiled to a low-adress origin, let's say 0x400, my final binary was so large it was using 0x4000 and more as memory. When I switched to a bank different from C0, kaboom, it made the app crash.

Hope this can helps.
Post Reply