RST 30h

Page 7/7
1 | 2 | 3 | 4 | 5 | 6 |

By Eugeny_Brychkov

Paladin (1016)

Eugeny_Brychkov's picture

12-10-2018, 11:31

If you carefully read the MSX Technical data book chapter 5, section 7, you should get very strong feeling that when standard was developed, RAM was expected to be in slot 0-x in CPU bank 0 only under MSX-DOS.

Quote:

7.2.2 Inter-slot call use

There are several ways to execute inter-slot calls, as described below. They
are included in MAIN-ROM as BIOS calls. Some of them are offered in MSX-DOS,
so inter-slot calls can be executed under MSX-DOS.

It is not direct confirmation, but there're other statements in the subchapter leading me concluding that having RAM in slot 0-x in bank 0 without MSX-DOS running is unsupported configuration. You either run BASIC, DOS or cartridge. BASIC does not support upper 32K; cartridges may theoretically require RAM in this location, but I suspect it should be rarity in MSX1 development and production time.

When requirements have changed, issue was discovered, and manufacturers released new versions of the same models with RAM in slot 3. Should they have been updating the standard with precautions? Or release "errata" or amendment? Do we know that there is really no such document? If we do not have it does not mean it does not exist.

Note that releasing change to the standard may negatively affect image of the companies involved as well as standard image itself, thus things may have been made as privately as possible, with only selected developers developing complex software.

By DarkSchneider

Paladin (748)

DarkSchneider's picture

12-10-2018, 12:53

Ummm, looking at that chapter, we can see:

Quote:

7.2.1 Inter-slot call operation

When calling BIOS in MAIN-ROM from MSX-DOS, the state of slots changes as
described below.

(1) Since, in the initial MSX-DOS mode, RAM is selected all over 64K address
space, BASIC-ROM cannot be accessible in this state (see Figure 5.41-a).

(2) To call BIOS in ROM, switch page 0 to MAIN-ROM or BASIC to access. Then,
call BIOS (see Figure 5.41-b).

(3) Restore the original status after BIOS operations and return to the
initial address.

Figure 5.41 Inter-slot call

a) When using MSX-DOS

MSX-DOS BASIC-ROM MSX-DOS BASIC-ROM
------- ------- ------- -------
Page 0 | RAM | | ROM | Page 0 | RAM | | ROM | BIOS is
|-----| |-----| |-----| |-----| called
Page 1 | RAM | | ROM | Page 1 | RAM | | ROM |
|-----| |-----| <----------> |-----| |-----|
Page 2 | RAM | | ___ | Page 2 | RAM | | ___ |
|-----| |-----| |-----| |-----|
Page 3 | RAM | | ___ | Page 3 | RAM | | ___ |
------- ------- ------- -------
Slot 3 Slot 0 Slot 3 Slot 0

This is easily done when the program resides in other than page 0, but there
can be some problem when the calling program resides in page 0 which is the
same page as BIOS of the called program. Care is needed to prevent the
program from disappearing itself and generating unpredictable results when it
is switched to page 0. The inter-slot call settles this problem by jumping to
page 3 temporarily and then switching slots.

They put clearly the RAM at slot 3. So maybe they also made documentation for manufacturers with this fact, but as mentioned we have no access to that documentation. It could be accidental, but it is there.

Also, on points 1-3, they say switch page 0, but I had problems doing that even on MSX-DOS:
https://www.msx.org/forum/msx-talk/development/safe-set-bios-and-restore-ram-on-page-0-from-msx-dos?page=0
https://www.msx.org/forum/msx-talk/development/enaslt-for-page-0-in-msx-dos
What's wrong then?

Quote:

This is easily done when the program resides in other than page 0

So, it is supposed ENASLT to work for page 0. But as mentioned I had problems on machines with RAM at slot 0, it crashed when restoring the RAM.

By ARTRAG

Enlighted (6015)

ARTRAG's picture

12-10-2018, 19:50

Let me recollect some findings:

ENASLT from basic will fail when setting ram in page 0 under any configuration (tested and documented)
CALLF and CALSLT from basic will fail in case the ram and the bios are in the same primary slot (tested but not documented)
RDSLT and WRSLT work under any condition (I've tested them as part of the tests on CALLF)

By DarkSchneider

Paladin (748)

DarkSchneider's picture

13-10-2018, 10:34

BASIC relies much on BIOS, probably many BASIC functions are only wrappers of the BIOS ones. And even character related stuff probably use the corresponding BIOS calls. Maybe adding some of own stuff after.

By gdx

Prophet (2268)

gdx's picture

13-10-2018, 10:57

I modified explanation about CALLF and CALSLT in the wiki.
ARTRAG, can you detail the problem with ENASLT?

By ARTRAG

Enlighted (6015)

ARTRAG's picture

13-10-2018, 11:46

gdx wrote:

I modified explanation about CALLF and CALSLT in the wiki.
ARTRAG, can you detail the problem with ENASLT?

Thanks!
About ENASLT, the code that changes the primary slots is in page 0 of the bios, so when you try to set ram in page 0 (or anything else than bios) the code commit suicide.
The aspect is documented, at least in the msx red book, and does not depend on the machine configuration.

"Standard routine to switch in a page permanently from any slot. Unlike the RDSLT, WRSLT and CALSLT standard routines the Primary Slot switching is performed directly and not by a Workspace Area routine. Consequently addresses in page 0 (0000H to 3FFFH) will cause an immediate system crash."

By DarkSchneider

Paladin (748)

DarkSchneider's picture

13-10-2018, 12:41

The MSX-DOS functions are on a workspace. That's why when concerning MSX-DOS they say:

Quote:

When calling BIOS in MAIN-ROM from MSX-DOS, the state of slots changes as
described below.

(1) Since, in the initial MSX-DOS mode, RAM is selected all over 64K address
space, BASIC-ROM cannot be accessible in this state (see Figure 5.41-a).

(2) To call BIOS in ROM, switch page 0 to MAIN-ROM or BASIC to access. Then,
call BIOS (see Figure 5.41-b).

(3) Restore the original status after BIOS operations and return to the
initial address.

I think it was the original idea, but they failed when created the BIOS version, which never was revised, and delegated the fix to the OS version. It is really weird how there is so much space of the working area wasted in BASIC and they didn't put something for this.

By DarkSchneider

Paladin (748)

DarkSchneider's picture

13-10-2018, 14:49

Well I start to think that is a hardware problem, consecuence of a mistake on any or multiple of specification/implementation/documentation. As we know, in the own MSX Handbook we have that on MSX-DOS is supposed to work to set page 0 to BIOS and then set to RAM.

Well, with RAM at slot 3, it works with no need of anything special. With RAM at slot 0 (same than BIOS), it crash when restoring the RAM. An easy test:
Note: we link in all cases the code to begin at address 4000h (page 1).

bios1_.mac

.z80

; define
ENASLT equ 00024h
RAMAD0 equ 0f341h
EXPTBL equ 0FCC1h
CHPUT equ 00A2H

; 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

; CHPUT wrapper
public chput@
chput@:
	call CHPUT
	ret
END

bios1.c

VOID enabio();
VOID disbio();
VOID chput();

VOID main(argc, argv)
int argc;
char *argv[];
{
	enabio();
	chput((char)90);
	disbio();
}

It simply writes a 'Z' (char 90) using BIOS CHPUT from MSX-DOS, as said in the MSX Handbook.
On machines with RAM at slot 3 it works, writes the 'Z' and exits to DOS. On machines with RAM at slot 0, it writes the 'Z' and then hangs, even when reset, it does not boot.

If we change to this, notice the addition of inibio function and the change of ENASLT to @enaslt:
bios2_.mac

.z80

; define
ENASLT equ 00024h
RAMAD0 equ 0f341h
EXPTBL equ 0FCC1h
CHPUT equ 00A2H


; 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

; CHPUT wrapper
public chput@
chput@:
	call CHPUT
	ret
END

bios2.c

VOID inibio();
VOID enabio();
VOID disbio();
VOID chput();

VOID main(argc, argv)
int argc;
char *argv[];
{
	inibio();
	enabio();
	chput((char)90);
	disbio();
}

It works on any machine. But those inibio and @enaslt uses are not supposed to be required by documentation to change page 0.

By ARTRAG

Enlighted (6015)

ARTRAG's picture

13-10-2018, 17:24

I haven't done tests on msx dos but from what you report I'd say that ENASLT cannot deal with page 0 in basic while in dos, it fails only if rom and ram are in the same slot

By ARTRAG

Enlighted (6015)

ARTRAG's picture

14-10-2018, 17:48

I've edited 0024H (ENASLT) in the WIKI

Page 7/7
1 | 2 | 3 | 4 | 5 | 6 |
My MSX profile