How to properly detect MSX-DOS version?

Page 2/2
1 |

By gdx

Prophet (3037)

gdx's picture

17-12-2018, 23:18

NYYRIKKI wrote:
	ld	c,06fh
	call	BDOS		; Get MSX-DOS version
	and	a
	ret	nz		; No MSX-DOS
	ld	a,b
	cp	2
	jp	c,DOS1
	jp	DOS2

This doesn't work properly because the function 6fh is not available on MSX-DOS1. If we call this fonction on DOS1, BC and DE do not change. It is for this reason that I put D to 1 before calling the function.
In addition it's useless to test A because if the routine is executed from a DOS command, the result will always be 0 even when the routine is called from DOS1.
My routine does not test BC nor E because I do not need more detail. I just wanted to explain how it is possible to know the current operating system is DOS1 or DOS2.

By NYYRIKKI

Enlighted (5384)

NYYRIKKI's picture

18-12-2018, 08:42

gdx wrote:
NYYRIKKI wrote:
	ld	c,06fh
	call	BDOS		; Get MSX-DOS version
	and	a
	ret	nz		; No MSX-DOS
	ld	a,b
	cp	2
	jp	c,DOS1
	jp	DOS2

This doesn't work properly because the function 6fh is not available on MSX-DOS1. If we call this fonction on DOS1, BC and DE do not change. It is for this reason that I put D to 1 before calling the function.

Can you tell how did you come up with this result? According to my tests it works exactly like documented (B=0)

Quote:

In addition it's useless to test A because if the routine is executed from a DOS command, the result will always be 0 even when the routine is called from DOS1.

Well, I guess this is a fair assumption... but it is anyway less than 6 months since I last time executed a COM-file under CP/M Smile

Quote:

My routine does not test BC nor E because I do not need more detail. I just wanted to explain how it is possible to know the current operating system is DOS1 or DOS2.

But your example does not work since it always jumps to "DOS1"-label under DOS2 and under DOS1 it just falls trough without jump.
Example:
DOS2 ROM is active, but MSX-DOS2 is not loaded -> D=0 -> Jump to DOS1.
DOS2 ROM is active and MSX-DOS2 has been loaded -> D=2 -> Jump to DOS1.

By gdx

Prophet (3037)

gdx's picture

18-12-2018, 10:33

Oups, I forgot to replace the NZ with Z when I copied / pasted the code.

	ld	d,1		; Because D register does not change on DOS1
	ld	c,06fh
	call	BDOS		; Get MSX-DOS version
	ld	a,d
	cp	1
	jp	z,DOS1
	cp	2
	jp	z,DOS2

By hit9918

Prophet (2867)

hit9918's picture

18-12-2018, 15:46

konamiman wrote:

Why is it fishy?

I think that the whole point with the A register is simply to detect cp/m.
and the word "error" made it into the DOS docs because the thing is built upon a "unimplemented function" error happening on CP/M.
while from a DOS programmers point of view, there IS NO error variable. it is NOT the case that one day the oh so abstract UFO error happens.
the other thing I wondered is whether one needs to LD A,255 before calling the function, to be sure on cp/m. but it is just a question, I dont know cp/m.

By NYYRIKKI

Enlighted (5384)

NYYRIKKI's picture

18-12-2018, 22:07

gdx wrote:

Oups, I forgot to replace the NZ with Z when I copied / pasted the code.

Ok... but although this kind of MSXDOS2.SYS version check works in practice after this fix, I see no real reason to do it differently than ASCII suggests to do it.

Page 2/2
1 |