batari, on Thu Feb 28, 2008 2:15 AM, said:
I've been thinking about this. The problem is that bB relies on the state of the upper 3 address bits (which aren't connected to the 6507) to determine what bank it's currently in and to determine what bank to return to when it encounters a return. It works well because it doesn't use any unnecessary RAM, and the bits are set automatically. If the banks match, bB skips the bankswitch access. But with 3 bits, you can only support 8 banks.
So in order to seamlessly support 64k, bB would need to push another byte on the stack for each subroutine so it knew what bank it's in and where to return to. Cross-bank subroutines already push several bytes on the stack, but I can't think of any reasonable alternative.
The upside of pushing another byte is that the new limit goes up to 512k

In my initial includes for 4A50, I used RORG addresses that were just $F000, $F800, $FE00, or $FF00, because I figured there weren't enough 16-bit addresses to assign unique RORG addresses to each bank. But last week I realized that you can have RORG addresses larger than 16 bits, and DASM will still use just 2 bytes (16 bits) when referring to the addresses in the actual code!

So now I'm assigning unique RORG addresses to all banks:
$001000 through $03F000 for the lower-region banks (numbered 0 through 31)
$001800 through $01F800 for the middle-region banks (numbered 0 through 15)
$001E00 through $1FFE00 for the upper-region banks (numbered 0 through 255)
I've currently got a "4a50_macro.h" include file with macros for declaring the start of a given bank-- one macro for starting a new lower-region bank, a second macro for starting a new middle-region bank, and a third macro for starting a new upper-region bank-- and each macro also displays the number of bytes free in the previous bank. I use the "." in the macros to get the current 3-byte address (for determining the number of bytes free in the previous bank), and then I calculate the ORG and RORG addresses for the new bank based on the bank number. I'm now working on macros for other things, such as switching to a particular bank, or doing a goto or gosub to a different bank, etc.
The problem is that, to call a macro within the bB program, the programmer will need to use "asm," which will be kind of messy. But when (or if) you officially add 4A50 support to bB, the macros would be taken care of by the compiler-- i.e., the macros would be replaced by new bB commands, and when the compiler sees a particular command, it would insert the appropriate assembly code for that command.
Michael