12

The early Amstrad IBM compatible PC the PC1512 initially included DR-DOS, according to its page at Old-Computers.com:

It was sold with MS-DOS 3.2, DR-DOS plus 1.2 (an operating system from Digital Research)

In a recent article in PC Pro Magazine about the early Amstrad PCs, Roland Perry is quoted as saying

Whatever the opinion of the market at the time, DR-DOS was technically superior because it had a certain amount of multitasking and, at a lower level, I think it preserved more registers when doing system calls.

Was this true, and what would have been any advantage of doing this?

13
  • 3
    The mention of multitasking suggests that he's referring to DOS Plus, which has a multitasking CP/M kernel that can run up to four processes, one of which can be a DOS emulator implenting the MS-DOS 2.11 API.
    – john_e
    Commented Apr 10, 2022 at 14:52
  • 6
    I used DR- DOS 5 - it had more features than MS-DOS 5. That was OK for a year or so until MS-DOS 6 came out. It had almost all the DR-DOS features plus a bit more. As for multitasking, it depends on the speaker's definition. In the 80s and 90s, to some people, multi-tasking meant being able to open 2 or more applications, even though all but one were completely static.
    – cup
    Commented Apr 10, 2022 at 16:44
  • 3
    It’s not “DR DOS Plus”, it’s just “DOS Plus”. Digital Research also produced other DOS clones with multitasking between DOS tasks (Concurrent DOS etc.); in their mainstream DOS clones, DR DOS 6.0 included TASKMAX, a task switcher, and Novell DOS 7 included pre-emptive multitasking with TASKMGR. Commented Apr 10, 2022 at 19:09
  • 2
    @Mark ah right, sorry. DR always referred to their DOS as “DR DOS” (no hyphen), which doesn’t help in this case! Commented Apr 11, 2022 at 4:20
  • 3
    I don’t like editing questions for accuracy, especially since the source material gets this wrong too. “DR DOS” is the purposefully MS-DOS-compatible operating system developed by Digital Research UK, based on Concurrent DOS 5. “DOS Plus” is a stripped-down version of Concurrent DOS 4, with limited DOS compatibility. DR DOS isn’t a (direct) descendant of DOS Plus, although one could consider DOS Plus to be an early version of DR DOS. The PC-1512 shipped with DOS Plus. I don’t think Amstrad ever shipped DR DOS with any of their PCs, even though they stuck with Digital Research’s GEM. Commented Apr 11, 2022 at 16:10

2 Answers 2

14

TL;DR:

MS_DOS preserved all registers, thus DR-DOS can not have preserved more.

It sounds much like memory blurred by time.


Was this true,

Seems hard to believe. Hard to answer as well, as no further data about what versions of DOS (and DR-DOS) this is about. Different versions may have behaved quite differently.

But while early MS-DOS was quite minimalist, it did save all registers. Easy to spot when looking at the MS-DOS 2.0 function scheduler (*1), located in the file MSCODE.ASM:

  • After entering via entry point COMMAND (line 96)
  • a check for max function number (MAXCOM) is done (line 105)
  • if below, label SAVREGS (line 123) is jumped to
  • which as very first action calls a procedure named save_world (line 124)
  • save_world (line 237) which stores all registers as
    • ES, DS ,BP, DI, SI, DX, CX, BX, AX

The subroutine is used for all other entry points, like CALL CS:5 or some of the other ints. Some use their own method (*2)

and what would have been any advantage of doing this?

Doing what? Saving all registers?

I have a hard time to come up with any reasoning why it should not preserve everything. At least for any system past trivial, which a DOS certainly is.

  • It's the very foundation of multitasking (*3)
  • It minimizes OS use of user side resources (*4)
  • It simplifies function design by having all input registers in a defined structure (*5)
  • The same structure can be used for output/return values (*6)

*1 - I selected MS-DOS 2.0 here, as it (or even 3.x) would have been contemporary to the mentioned DR DOS Plus 1.2 mentioned in a comment. MS-DOS 1.25 did work exactly the same, at least as far as it's about register saving. See MSDOS.ASM line 228 after the SAVEREGS label

*2 - INT 25h, Direct Disk Read, for example splits this in two parts. The entry point is at ABSDRD (MSDOS.ASM line 508), short after followed by saving all segment registers and then calling DSKREAD, located in DISK.ASM at line 623. This function uses DI, CX and AX as return value, all other registers are preserved. This is different from DOS 1.25 where all registers are saved and restored (except for AX which is modified as return code).

*3 - Which DOS 2.0 was prepared for, see comment at line 140/141

*4 - When for example doing a loop around WriteChar (21h/02h), it's quite handy if the OS would not destroy a string pointer in DI or a character count in CX, wouldn't it?

*5 - After pushing them to the user stack, SS:SP can be saved as a pointer to this structure. Even better, doing so is close to being the most performant way to do so.

*6 - DOS functions can write whatever they return to this structure without any need to care about how it finally gets returned, avoiding complicated register juggling.

15
  • 1
    I meant what would be the advantage of saving anything more than MS-DOS did. Maybe it means saving some sort of multi-tasking context? Commented Apr 10, 2022 at 15:40
  • 1
    The original source doesn't specify the version, but elsewhere I found indications that it shipped with Dos plus 1.2. Commented Apr 10, 2022 at 15:46
  • 1
    @MarkWilliams Since DOS already saved ALL register, there isnt anything DR DOS-Plus can save more than that.
    – Raffzahn
    Commented Apr 10, 2022 at 16:40
  • 1
    @RichF: AX = clobber, BX is required to dispatch, almost everything is going to need DS, ES. If you need any BIOS call (which is almost everything) you're going to need to save CX and DX. BP is required for stack frame for any internal calls. That leaves maybe SI and DI. Code's smaller to just to preserve everything.
    – Joshua
    Commented Apr 11, 2022 at 2:16
  • 2
    @RichF in addition to Joshuas list, note that there are 50+ DOS functions, if each would have their own save/restore code, ist ends up in several hundred bytes of additional code bloat, without saving more than a few cycles in total. Not really a useful trade off. Also, tehy do need to save and restore at least DS, SS and SP as well - plus ES for most memory operations (CS is implied saved when doing an INT) . So
    – Raffzahn
    Commented Apr 11, 2022 at 2:35
7

For comparison with @Raffzahn's description above, here's how the INT 21h entry point works in DOS Plus.

In the INT 21h handler, the function number is compared with 2Fh. Functions up to 2Fh are handled by a 'DOS 1' handler, functions above by a 'DOS 2' handler.

The 'DOS 1' handler

  • If AH is zero, control is passed to the INT 20h handler.
  • In all other cases, DS is pushed to the stack. DS, SS and SP are saved to memory; then DS is switched to the DOS emulator data segment, and SP to an internal stack.
  • If the system is in an INT 24h handler invoked by DOS Plus: Functions 1-0Ch (console I/O) switch to the stack as it was when INT 24h was invoked. Functions 0Dh and higher call a function to reverse various temporary changes made to the DTA and the mapping of drive P:.
  • Interrupts are disabled.
  • Registers are pushed to the stack in the order AX,BX,CX,DX,SI,ES,DI,BP.
  • A near call is made to the appropriate function handler.
  • Registers are retrieved from the stack.
  • SS and SP are retrieved from memory. DS is retrieved from the caller's stack.
  • Control is returned to the calling program with an IRET.

The 'DOS 2' handler

This handler has only one code path:

  • DS, SS and SP are saved to memory.
  • SS and SP are set to an internal stack (a different one from those used by the 'DOS 1' handler)
  • The registers are saved in the order DX,ES,DI,SI,BP,CX,BX,AX.
  • If the system is in an INT 24h handler invoked by DOS Plus, the same function mentioned above is called to unwind temporary DTA / drive P: changes.
  • An internal flag is set to say that a 'DOS 2' call is being handled. This allows the Ctrl-Break handler to cope with the different stack layouts of 'DOS 1' and 'DOS 2' calls.
  • A near call is made to the appropriate function handler.
  • The internal 'DOS 2 call' flag is cleared.
  • The registers are retrieved from the stack.
  • SS, SP and DS are retrieved from memory.
  • Control is returned to the calling program with an IRET.

Therefore it's clear that both DOS Plus 1.2 and MS-DOS 2 preserve all possible registers across system calls. One obvious difference is that MS-DOS 2 saves them on the caller's stack, while DOS Plus saves them to one of its internal stacks. This may be what the Roland Perry quote is referring to; it would require less stack space in the calling program.

3
  • The use of a system stack is rather interesting or an OS that is supposed to allow (limited) multitasking. Basic MT support does require that process stack is used to store process information, quite the way MS-DOS does it (That is unless there's a call (and thus process) specific structure to save the state independent from stack)
    – Raffzahn
    Commented Apr 11, 2022 at 0:56
  • 2
    @Raffzahn: While the underlying CP/M kernel in DOS Plus allows multiple processes to run, only one of them at most can be a DOS program. So the DOS emulator is not multitasking or re-entrant.
    – john_e
    Commented Apr 11, 2022 at 7:29
  • Note the stored register values on the stack are accessible and may be modified to be what the function is supposed to return in that register before the return code is executed. In some corner cases like errors more register values may be modified by DOS than DR DOS.
    – Brian
    Commented Apr 11, 2022 at 12:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .