MTX BASIC / Assembly Interface

Everything about programming, including VDP and Sound programming.
Post Reply
User avatar
Posts: 623
Joined: 11 Aug 2012 18:16

MTX BASIC / Assembly Interface

Post by Dave » 18 Aug 2017 13:18

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?

User avatar
Posts: 116
Joined: 12 Aug 2012 16:08

Re: MTX BASIC / Assembly Interface

Post by thewiz » 18 Aug 2017 13:42

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 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.

Martin A
Posts: 328
Joined: 09 Nov 2013 21:03

Re: MTX BASIC / Assembly Interface

Post by Martin A » 19 Aug 2017 12:17

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
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.

Post Reply