Image Map Image Map
Results 1 to 4 of 4

Thread: Help using M4 memory map configurations

  1. #1

    Default Help using M4 memory map configurations


    So I'm finally figuring this M4 malarkey out!

    It seems that DOS (LDOS6 in this case) starts a M4 in configuration "B" (see diagram). Presumably this is what most systems regards as "M4 mode", whereas config A is "M3 mode"?

    I've been trying to run my stuff in config "C". This is so that i can sensibly hit the screen without paging it.

    This all works until i re-enable interrupts, then it all goes bad. Now i understand that, as soon as it interrupts back to the "system", it expects things to be as "B".

    So what i do now is leave interrupts off, but whenever i need to make a SVC trap, i;

    * switch to B
    * enable interrupts
    * perform the trap
    * disable interrupts
    * switch to C

    This works because, it appears, C & B share the same ram banks. For example, i have my stack up near $HIGH and it works both in "B" and "C".

    But, leaving interrupts off nearly all the time is a bit hacky.

    So my questions are:

    1. Is there a proper way to use config C and then trap to DOS?
    For example, is there a way to tell DOS, I'm in config C (eg by having DOS switch configs) and then DOS "automatically" switches back and forth during a trap?

    I can't find any way to switch to C using DOS. Only mapping various banks into high memory, but not actually reconfiguring the memory map.

    Maybe i missed it?

    2. If there's not a proper way to do (1), who ever uses config "C"? and if so, is there a better way than what i'm currently doing?

    Thanks for any help and info!

  2. #2
    Join Date
    Jun 2010
    Vancouver, BC, Canada


    TRSDOS 6 (or LS-DOS 6) runs primarily in mode D and flips into mode C when it wants to poll the keyboard or write to the screen. You notice this in that Model 4 BASIC programs have no way to POKE to the screen or PEEK the keyboard as they can only ever see the "full RAM" memory map.

    All this is controlled by the memory map register on I/O port $84. The LS-DOS programmer's manual says that port $84 is shadowed by OFLAG$ (see SYSCALL 101 @FLAG$ for how to find OFLAG$). To stay friendly with LS-DOS you should put any port $84 changes you make into OFLAG$.

    For most applications you'll be best off using LS-DOS routines for keyboard and screen I/O.

    I don't think LS-DOS cares too much but one thing to beware is that you don't have your stack overlapping where the screen and keyboard map into high memory.

    Incidentally, you can see what LS-DOS does with port $84 in trs80gp. Go into Debug -> Z-80 Debugger and select Z-80 Port Writes in the drop-down that has Z-80 Memory. That will show you the last value written to each I/O port. When LS-DOS is running at the DOS prompt I see it switching rapidly between $86 and $87.

  3. #3



    YES! that's it!!

    DOS _does_ continuously switch between config "C" and config "D" not "B".

    I tracked down the OFLAG, and sure enough all i need to to is:

    (from initial D)
    * disable interrupts
    * switch to "C" aka 0x86
    * set OFLAGS=0x86
    * enable interrupts.

    Once at the start, then interrupts can be left on _and_ i can call SVC traps, and it appears DOS "knows" to switch for me!

    Like this i can work like I'm running in config "C" = 0x86 and hit the video 2K ram directly whilst using DOS for everything else, like keyboard and file IO.

    I also enabled fast mode and that works too.


    Thanks again.

  4. #4


    Just to add.

    I already battled the stack earlier. I'm setting it to min(0xf400,$HIGH).


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts