far ptr support forr Adam memory expansions?

Post Reply
Posts: 104
Joined: Sun Sep 09, 2018 5:44 pm

far ptr support forr Adam memory expansions?

Post by tschak909 »

Memory expansions on the Adam are somewhat interesting.

Of course, if you set port 7F to switch in the memory expansion, it can be put either into the upper 32K or lower 32K of RAM for a 64K block.

Which 64K block depends on the value of port 0x42.

How can this be implemented so Z88DK can use them (e.g. with FAR pointers?)

User avatar
Well known member
Posts: 1448
Joined: Sun Jul 15, 2007 10:01 pm

Re: far ptr support forr Adam memory expansions?

Post by dom »

Implementing far pointers isn't that difficult, it's just a set of routines that you need to write: https://github.com/z88dk/z88dk/wiki/Mor ... far-memory - there's the z88 implementation here: https://github.com/z88dk/z88dk/tree/mas ... loc/farz88

The program itself runs within the regular 64k namespace and just calls out to these routines to read/write the memory as required. Usually the high 8 bits of the far pointer encode the bank number so to provide the illusion of a linear address space.

The other option is to look at named address spaces: https://github.com/z88dk/z88dk/wiki/Mor ... -and-zsdcc this one works slightly differently in that you'll need to have a non-paged area where your program is located. The helper banking functions for named address spaces should leave the switched to address space paged in.

Both approaches have their advantages and drawbacks:

+ Far pointers provide you with a much larger program space (since the banking is temporary)
- Far pointers are 24 bits long, so you can't pass them to library routines (eg for string.h routines)
- Far pointers will be slower (since the banking happens on every access)
- Far pointers are only supported by sccz80
+ Named address space code will be faster since it's easier to optimise
+ Named address spaces are in the embedded C standard and supported by both sdcc and sccz80
- Named address space programs will need to be < 32k of code (since you've got a 32k banking window)

Which one you use depends on what you're doing, whether you're data or code heavy. My gut feel is that with the 32k paging window on the ADAM far pointers would probably be more useful
Post Reply