ENASLT for page 0 in MSX-DOS

By DarkSchneider

Paladin (860)

DarkSchneider's picture

08-06-2017, 14:05

Reading the manual, we have this for MSX-DOS:

Quote:

(2) Inter-slot call in MSX-DOS

In MSX-DOS, five kinds of inter-slot calls are offered and their entry
addresses are defined at jump vectors of MSX-DOS. These are the same as ones
in BIOS, so refer to BIOS above for their functions or use. Note that these
routines should not be used when calling routines in SUB-ROM from MSX-DOS.

* RDSLT (000CH) ....... read value at specified address of specified slot
* WRSLT (0014H) ....... write value at specified address of specified slot
* CALSLT (001CH) ...... call specified address of specified slot
* ENASLT (0024H) ...... make specified slot available
* CALLF (0030H) ....... call specified address of specified slot

The addresses are the same. They are supposed to jump to a routine on page 3.
I have this code:

public enabio@
enabio@:
	ld a, (EXPTBL)
	ld hl, 0
	call ENASLT
	ei
	ret
	
public disbio@
disbio@:
	ld a, (RAMAD0)
	ld hl, 0
	ld iy,(RAMAD0-1)
	ld ix, ENASLT
	call CALSLT
	ei
	ret

It makes the computer to reset, don't know exactly why. If I change the 1st one to:

public enabio@
enabio@:
	ld a, (EXPTBL)
	ld hl, 0
	ld iy,(RAMAD0-1)
	ld ix, ENASLT
	call CALSLT
	ei
	ret

Then it works, but is a bit redundant an inter-slot call to the already slot set in page 0.
Why the 1st version fails? Both functions themselves and the calling one are placed into page 1. For setting other pages (i.e. page 2) it works perfectly with direct call.

All I can think about is something like it CALL instead JP to the routine in page 3, and when returning it fails. But then the inter-slot one should not work too, as the slot is already changed, or maybe inter-slot makes some "magic" and can execute code from the proper slot (the RAMAD0) until the RET of the jump at ENASLT address? Don't know.
But not doing a JP would be very strange.

Login or register to post comments

By DarkSchneider

Paladin (860)

DarkSchneider's picture

08-06-2017, 20:55

OK finally solved (think so) copying the MSX-DOS ENASLT routine (the jump vector) into our space (out of page 0) and calling it. This is:

; Initializes the BIOS functions usage from library. Call it once before using any other.
public inibio@
inibio@:
	; copy the ENASLT MSX-DOS routine to our page (another than 0)
	ld hl, ENASLT
	ld de, @enaslt
	ld bc, 4
	ldir
        ret

; copy of the MSX-DOS ENASLT page 0 routine	
@enaslt:
	ret
	ret
	ret
	ret

; Enables the BIOS at page 0
; Registers: same than ENASLT
; Remarks: enables interrupts after setting the BIOS
public enabio@
enabio@:
	ld a, (EXPTBL)
	ld hl, 0
	call @enaslt
	ei
	ret

; Disables the BIOS at page 0, restoring RAM
; Registers: same than ENASLT
; Remarks: enables interrupts after setting the RAM
public disbio@
disbio@:
	ld a, (RAMAD0)
	ld hl, 0
	call @enaslt
	ei
	ret

Tested even in a machine with RAM in the same main slot than BIOS (slot 0-0 for BIOS and 0-3 for RAM) and works.

By NYYRIKKI

Enlighted (5358)

NYYRIKKI's picture

08-06-2017, 22:11

By DarkSchneider

Paladin (860)

DarkSchneider's picture

09-06-2017, 08:12

Sure, thanks.

By Grauw

Ascended (8377)

Grauw's picture

09-06-2017, 18:14

Nicely found!