Reposted from Timo Soilamaa's question on Facebook
Yesterday while releasing new version of MSX ROM loader I promised to bomb you with stupid questions, so here comes the first ones: smile emoticon:)
- When I exit from ML program back to BASIC, how do I know what is the correct IObyte to use?
- Is there a standard way to know how long file was loaded?
- MTX ROM seems to be pretty much driven by RST-commands... Are the "safe" BIOS routines documented somewhere?
- What address ranges are needed to keep intact in order to keep BASIC running without hickups?
MTX BASIC / Assembly Interface
Re: MTX BASIC / Assembly Interface
For development, Memu can be used to show what blocks of data are being loaded.
On a real MTX, if its loaded by Basic, then the sysvars will.
Basic starts at BASBOT ($FAA7), i.e. $4000 or $8000.
Basic ends at ARRTOP (includes memory for arrays) ($FACC)
Noddy ends at NBTOP. ($FAA4)
So size of data loaded by Basic only is NBTOP - BASBOT.
From a tape, there is another block for basic variables, which is from $c000 to CALCBOT ($FA7F)
More blocks of data can be read in from tape by called in $AAE which will only be known by the program just loaded.
The RSTs are documented somewhere, from memory:
RST 0 - Reset
RST 8 - LD DE, (HL) ; INC HL ; INC HL
RST 10 - Output characters. There is a scan of what it can do on Dave's site. Let me know if you can't find it.
RST 18 - ?
RST 20 - ?
RST 28 - Floating Point. Again see Dave's site as there is a scan of them. Failing that they are in the scans of Memopad on his site.
RST 30 - ?
RST 38 - IM Interrupt
The system variables are realistically from $F8F2 to $FFFF. Note only $F8F2 to $FB50 are loaded from tape.
E&OE
On a real MTX, if its loaded by Basic, then the sysvars will.
Basic starts at BASBOT ($FAA7), i.e. $4000 or $8000.
Basic ends at ARRTOP (includes memory for arrays) ($FACC)
Noddy ends at NBTOP. ($FAA4)
So size of data loaded by Basic only is NBTOP - BASBOT.
From a tape, there is another block for basic variables, which is from $c000 to CALCBOT ($FA7F)
More blocks of data can be read in from tape by called in $AAE which will only be known by the program just loaded.
The RSTs are documented somewhere, from memory:
RST 0 - Reset
RST 8 - LD DE, (HL) ; INC HL ; INC HL
RST 10 - Output characters. There is a scan of what it can do on Dave's site. Let me know if you can't find it.
RST 18 - ?
RST 20 - ?
RST 28 - Floating Point. Again see Dave's site as there is a scan of them. Failing that they are in the scans of Memopad on his site.
RST 30 - ?
RST 38 - IM Interrupt
The system variables are realistically from $F8F2 to $FFFF. Note only $F8F2 to $FB50 are loaded from tape.
E&OE

THIS is what Memotech is doing now.
Re: MTX BASIC / Assembly Interface
The MTX OS is somewhat lacking in defined entry points, some of the interesting ones are
CALL #001B sends line feed & carriage return to the screen
CALL #0079 is the main keyboard entry point
CALL #0AAE cassette interface block loader entry point.
RST 28 has some extra's in addition to the floating point, as it's also the main error reporting routine.
RST 28
DB #00
Would report error 0 = "params"
(if you need to quit without an error, JP #0250 will return you to the basic prompt)
One I use a lot is:
RST 28
DB #AC
That prints the character in A to the current screen, it destroys A in the process though.
Another useful one is
RST 28
DB #42
This one calls VDINIT to setup/reset the display.
RST 30 is part of the input like scanning, returns a "value" in BC
The "current" memory layout is stored in "page" at #FAD2, as port 0 which controls the memory mapping is write only.
CALL #001B sends line feed & carriage return to the screen
CALL #0079 is the main keyboard entry point
CALL #0AAE cassette interface block loader entry point.
RST 28 has some extra's in addition to the floating point, as it's also the main error reporting routine.
RST 28
DB #00
Would report error 0 = "params"
(if you need to quit without an error, JP #0250 will return you to the basic prompt)
One I use a lot is:
RST 28
DB #AC
That prints the character in A to the current screen, it destroys A in the process though.
Another useful one is
RST 28
DB #42
This one calls VDINIT to setup/reset the display.
RST 30 is part of the input like scanning, returns a "value" in BC
The "current" memory layout is stored in "page" at #FAD2, as port 0 which controls the memory mapping is write only.