Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
128K SPECTRUM COMPATIBILITY...
#13
It's more than time to revisit this. I find myself wanting to write programs that are bigger than 48K!

If they are modular, and register clean (and ZX Basic very nicely doesn't assume registers will stay put between SUB calls, so is register clean), we can bank swap all we need to. The compiler just needs to be willing to swap memory before jumping to routines in other banks.

As mentioned above, I propose:

Based on http://www.worldofspectrum.org/faq/refer...erence.htm

My proposal is this - compiler directives that lock memory address space. (Pretty much what I said above, yes)

e.g.:

#GLOBAL LOW
#GLOBAL CONTENDED
Lets you choose whether the compiler places global memory and heap into the low contended memory or bank 2


#BANK CONTENDED
This memory bank is basically bank 5 from the ORG address to 32767
Do we want alternate screen features in bank 7?
This memory is contended.

#BANK LOW
This is actually memory bank 2 from address 32768 to 49151
On a 128K/+2 This memory is uncontended.
On a +2A / +3 This memory is uncontended.

#BANK HIGH 0
This is memory bank 0 and is in address space 49152 to 65535
On a 128K/+2 This memory is uncontended.
On a +2A / +3 This memory is uncontended.

#BANK HIGH 1
This is memory bank 1 and is in address space 49152 to 65535
On a 128K/+2 This memory is contended.
On a +2A / +3 This memory is uncontended.

#BANK HIGH 3
This is memory bank 3 and is in address space 49152 to 65535
On a 128K/+2 This memory is contended.
On a +2A / +3 This memory is uncontended.

#BANK HIGH 4
This is memory bank 4 and is in address space 49152 to 65535
On a 128K/+2 This memory is uncontended.
On a +2A / +3 This memory is contended.

#BANK HIGH 6
This is memory bank 6 and is in address space 49152 to 65535
On a 128K/+2 This memory is uncontended.
On a +2A / +3 This memory is contended.


So I'd expect the compiler, given a command like:

#BANK HIGH 6

To>

1> Compile this block to a separate binary (or tzx block)
2> Not allow this compilation block to exceed 16K
3> Know to jump to code to swap it in before jumping to any code in this block.


Further, we need a library command to manually swap these in for things like data access.

Finally, we need a routine that bank switches.

An example of a typical bank switch on the 128 is:
Code:
    LD      A,(0x5b5c)      ;Previous value of port
    AND    0xf8
    OR      4              ;Select bank 4
    LD      BC,0x7ffd
    DI
    LD      (0x5b5c),A
    OUT    (C),A
    EI

The principle is the same for all bank switching: change only the bits you need to.

When the routine comes back, switch it back to bank 0 presumably?

This routine would have to be in memory space that stays put.


But on the whole, this isn't actually difficult or rocket science - it could be done manually; but would be a pain, since you'd have to manually bank switch, then manually call the routine addresses. This is something a compiler should do for you, so you can call subroutines by name!
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 2 Guest(s)