how would you call the BASIC interpreter to execute a command from inline assembly ?
something like this ..
10 code
4007 LD HL, Command ; HL points to the BASIC command string
400A CALL #2400 ; Call BASIC interpreter to execute the command
400C RET ; Return to BASIC
400D Command: DB "PRINT "HELLO FROM ASM"", 0
I can't find the EXACT Rom subroutines call address , tried #2400, #2500 and others .. is there a detailed subroutines-documentation for ROM calls somewhere ?!
This is what I was able to find in general:
0x2100 - 0x21FF: Memory management routines, including setting up memory pages and handling memory access.
0x2200 - 0x22FF: Input/output routines, such as reading from the keyboard, writing to the display, and handling disk operations.
0x2300 - 0x23FF: System control routines, including resetting the system, handling interrupts, and managing system resources.
0x2400 - 0x24FF: BASIC interpreter routines, which handle the execution of BASIC programs and commands.
0x2500 - 0x25FF: Assembly language support routines, including machine code execution and interfacing with BASIC.
Calling BASIC from assembly..
Re: Calling BASIC from assembly..
There is no complete documentation of the MTX ROM.
The ReSource manual describes a few useful entry points.
You may also find some information in the various other books and magazines on Dave's site.
Otherwise you have to read the ROM source listings from Andy Key's site:
If you find anything interesting, you might contribute an addition to ReSource for the benefit of others.
The ReSource manual describes a few useful entry points.
You may also find some information in the various other books and magazines on Dave's site.
Otherwise you have to read the ROM source listings from Andy Key's site:
If you find anything interesting, you might contribute an addition to ReSource for the benefit of others.
Re: Calling BASIC from assembly..
Thanks Bill,
Yes, I looked at Resource2022 before, couldn't find entry points related to calling the basic interpreter..
the ROM sources are interesting .. I will search through it and hopefully find something
Yes, I looked at Resource2022 before, couldn't find entry points related to calling the basic interpreter..
the ROM sources are interesting .. I will search through it and hopefully find something
Re: Calling BASIC from assembly..
..The only related entry points I found in ROM sources were these:
basic -- #259
basics -- #205 -- new page/reset
basics1 -- #244
basics2 -- #250
basics4 -- #24A
..and dobasic .. #2116 , #2118
what I'm trying to do is .. read bytes from the SDX floppy in assembly .. or hybrid (assy/basic) method..
is there an assembly example OUT THERE on how to use the BASIC command "USER READ <file.dat>" from the assembler?
code snippet below, but it doesn't yield the desired results .. basic does not execute the next line after the interpreted call.. (PC) not preserved
basic -- #259
basics -- #205 -- new page/reset
basics1 -- #244
basics2 -- #250
basics4 -- #24A
..and dobasic .. #2116 , #2118
what I'm trying to do is .. read bytes from the SDX floppy in assembly .. or hybrid (assy/basic) method..
is there an assembly example OUT THERE on how to use the BASIC command "USER READ <file.dat>" from the assembler?
code snippet below, but it doesn't yield the desired results .. basic does not execute the next line after the interpreted call.. (PC) not preserved
- Attachments
-
- testing.zip
- (2.61 KiB) Downloaded 1491 times
-
- 0001.png (2.34 KiB) Viewed 100045 times
Re: Calling BASIC from assembly..
I would like to have a program that will ‘LLIST’ a MTX Basic program into an ASCII file.. Why? You might ask.. Well very simple.. The MTX offers a Centronics type interface to connect a parallel printer. After 41 years it’s next to impossible to get a cable (although this can be created) and a properly working printer.
Recently I bought the MFX add-on hardware. This allows files to be transfered to and from a modern PC. Since MTX Basic is stored tokenised in memory, it can’t be send over. I still would like to keep some Basic programs on paper (handy for quick reference). A direct command like ‘USER LPRINT’ would be nice, but I will settle with a conversion program just as well..
I am quite proficient in programming CP/M and Z80. With the proper info I could dabble something myself… All ideas/info is welcome
Recently I bought the MFX add-on hardware. This allows files to be transfered to and from a modern PC. Since MTX Basic is stored tokenised in memory, it can’t be send over. I still would like to keep some Basic programs on paper (handy for quick reference). A direct command like ‘USER LPRINT’ would be nice, but I will settle with a conversion program just as well..
I am quite proficient in programming CP/M and Z80. With the proper info I could dabble something myself… All ideas/info is welcome
Re: Calling BASIC from assembly..
You might want to take a look at Paul Daniel's mtx2bas program "- a program to convert .mtx, .sdx and .run files to text"
Available on this page http://primrosebank.net/computers/mtx/m ... m#software
It's written in C, but it might give you a few pointers (pun intended!)
This page (on variable storage), may be useful too http://primrosebank.net/computers/mtx/t ... c_vars.htm
regards
Dave
Available on this page http://primrosebank.net/computers/mtx/m ... m#software
It's written in C, but it might give you a few pointers (pun intended!)
This page (on variable storage), may be useful too http://primrosebank.net/computers/mtx/t ... c_vars.htm
regards
Dave
Re: Calling BASIC from assembly..
Thx Dave, I've seen those before .. long time ago
What I was looking for is an assembly code snippet , the equivalent of "user read" command .. but in assembly
USER READ "FILE.DAT",32768
I guess because of the lack of SDX-ROM routines documentation or some disk loading examples .. it is difficult to understand how those disk functions are called, and how the arguments are passed to them from the assembler.. the "Resource2022" PDF touches up on that .. but it isn't enough..
anyone has a working example in assembly .. for SDX ?!
What I was looking for is an assembly code snippet , the equivalent of "user read" command .. but in assembly
USER READ "FILE.DAT",32768
I guess because of the lack of SDX-ROM routines documentation or some disk loading examples .. it is difficult to understand how those disk functions are called, and how the arguments are passed to them from the assembler.. the "Resource2022" PDF touches up on that .. but it isn't enough..
anyone has a working example in assembly .. for SDX ?!
Last edited by gilmo on 21 Sep 2025 14:05, edited 1 time in total.
Re: Calling BASIC from assembly..
The SDX disc system IS CPM, CPM 2.2 BDOS calls from 13 upwards are available. The only difference is the SDX entry point, as CALL 0005 isn't feasable due to the ROM.
The SDX rom listings that Andy provides on his site has the alternate entry point "SDXBDOS" set to F5B0, that entry point has been retained in CFX snd MFX
No snippet available, however code the reading in of a file into memory as you would for CPM, but call SDXBDOS instead of BDOS.
NB MFX and CFX both have JP D706 as the instruction at F5B0 so CALL D706 will be fractionally quicker, and will probably work on a real SDX though I can't guarantee it.
Re: Calling BASIC from assembly..
Thx Martin,
yes, I''m using a clone SDX with orig rom (not for CFX or MFX)
LD HL,FCB ; HL points to FCB-file control block at #BFFA
LD DE,FILENAME ; copy "TEST BIN"
LD BC,11
LDIR ; fill filename/ext fields
LD (FCB+11),0 ; drive = default
LD HL,#5000 ; load address
LD (FCB+12),HL
XOR A
LD (FCB+14),A ; clear high bytes
CALL #F5B0 ; call SDX file load
JP NC,LOADED ; NC = success
JP C,ERROR ; C set = error
.. so something like this psuedo code could work ..
OR maybe ..
; -----------------------------------------------------------
; Start of loader
; -----------------------------------------------------------
START:
; Initialize DMA to 0x4100 (file load address)
LD HL,04100h
LD (DMAADDR),HL
LD DE,04100h
LD C,26h ; BDOS: Set DMA
CALL 0F5B0h
; Open file
LD DE,FCB
LD C,0Dh ; BDOS: Open file (13 decimal)
CALL 0F5B0h
OR A
JP NZ,NOFILE ; Jump if file not found
; -----------------------------------------------------------
; Read loop
; -----------------------------------------------------------
READLOOP:
LD DE,FCB
LD C,14h ; BDOS: Read sequential (20 decimal)
CALL 0F5B0h
OR A
JP NZ,DONE ; EOF or error
; Advance DMA by 128 bytes
LD HL,(DMAADDR)
LD DE,128
ADD HL,DE
LD (DMAADDR),HL
; Update BDOS DMA pointer
LD E,L
LD D,H
LD C,26h ; BDOS: Set DMA
CALL 0F5B0h
JP READLOOP
; -----------------------------------------------------------
; Close file and finish
; -----------------------------------------------------------
DONE:
LD DE,FCB
LD C,0Eh ; BDOS: Close file (14 decimal)
CALL 0F5B0h
JP EXIT
NOFILE:
JP $ ; File not found: infinite loop
EXIT:
JP $ ; Halt; file is loaded at 0x4100
END START
| Function | Decimal | Hex | Purpose |
| -------- | ------- | --- | --------------- |
| Open | 13 | 0D | Open FCB file |
| Close | 14 | 0E | Close FCB file |
| Read Seq | 20 | 14 | Read sequential |
LD C,0Dh ; Open file
LD C,0Eh ; Close file
LD C,14h ; Read sequential
LD C,26h ; Set DMA
yes, I''m using a clone SDX with orig rom (not for CFX or MFX)
LD HL,FCB ; HL points to FCB-file control block at #BFFA
LD DE,FILENAME ; copy "TEST BIN"
LD BC,11
LDIR ; fill filename/ext fields
LD (FCB+11),0 ; drive = default
LD HL,#5000 ; load address
LD (FCB+12),HL
XOR A
LD (FCB+14),A ; clear high bytes
CALL #F5B0 ; call SDX file load
JP NC,LOADED ; NC = success
JP C,ERROR ; C set = error
.. so something like this psuedo code could work ..
OR maybe ..
; -----------------------------------------------------------
; Start of loader
; -----------------------------------------------------------
START:
; Initialize DMA to 0x4100 (file load address)
LD HL,04100h
LD (DMAADDR),HL
LD DE,04100h
LD C,26h ; BDOS: Set DMA
CALL 0F5B0h
; Open file
LD DE,FCB
LD C,0Dh ; BDOS: Open file (13 decimal)
CALL 0F5B0h
OR A
JP NZ,NOFILE ; Jump if file not found
; -----------------------------------------------------------
; Read loop
; -----------------------------------------------------------
READLOOP:
LD DE,FCB
LD C,14h ; BDOS: Read sequential (20 decimal)
CALL 0F5B0h
OR A
JP NZ,DONE ; EOF or error
; Advance DMA by 128 bytes
LD HL,(DMAADDR)
LD DE,128
ADD HL,DE
LD (DMAADDR),HL
; Update BDOS DMA pointer
LD E,L
LD D,H
LD C,26h ; BDOS: Set DMA
CALL 0F5B0h
JP READLOOP
; -----------------------------------------------------------
; Close file and finish
; -----------------------------------------------------------
DONE:
LD DE,FCB
LD C,0Eh ; BDOS: Close file (14 decimal)
CALL 0F5B0h
JP EXIT
NOFILE:
JP $ ; File not found: infinite loop
EXIT:
JP $ ; Halt; file is loaded at 0x4100
END START
| Function | Decimal | Hex | Purpose |
| -------- | ------- | --- | --------------- |
| Open | 13 | 0D | Open FCB file |
| Close | 14 | 0E | Close FCB file |
| Read Seq | 20 | 14 | Read sequential |
LD C,0Dh ; Open file
LD C,0Eh ; Close file
LD C,14h ; Read sequential
LD C,26h ; Set DMA
Last edited by gilmo on 07 Nov 2025 17:26, edited 1 time in total.
Re: Calling BASIC from assembly..
You'll need to read up on how CPM works. But just replace where CPM calls the BDOS entry point at 0005 with the SDXBDOS entry point instead.
Dave has some info and pointers at http://primrosebank.net/computers/cpm/cpm_about.htm
It's going to be something like:
Set up buffers, FCB etc
Open the file with function 15
repeat:
Set the DMA address with function 26
Read in 128 bytes with function 20
until done
Close the file using function 16
NB if you do ROM 5 and USER DIR from Ready (or whatever your real SDX needs to setup the drive), then go to panel and LF5B0 if you see JP D706 as in the screenshot then you can use the shortcut address the same as CFX/MFX.
Dave has some info and pointers at http://primrosebank.net/computers/cpm/cpm_about.htm
It's going to be something like:
Set up buffers, FCB etc
Open the file with function 15
repeat:
Set the DMA address with function 26
Read in 128 bytes with function 20
until done
Close the file using function 16
NB if you do ROM 5 and USER DIR from Ready (or whatever your real SDX needs to setup the drive), then go to panel and LF5B0 if you see JP D706 as in the screenshot then you can use the shortcut address the same as CFX/MFX.