7

Has there been boot sector code (either as binary or assembly source) released, which can boot MS-DOS and PC DOS, by autodetecting the files found in the root directory of the FAT12 or FAT16 filesystem? (It loads io.sys and msdos.sys, or ibmbio.com and ibmdos.com, whichever it finds. If it finds both pairs, then I don't care which one it loads.)

I know that I can install GRUB4DOS to the MBR (+ ~1 MiB), and configure it for such autodetection, but I'd prefer something more lightweight (i.e. less than 512 bytes of machine code).

3
  • 1
    My only question is, how similar the IO.SYS and IBMBIO.COM are to load? Do they load to same address or different address, how many sectors are loaded, and are they assumed to be contiguous? IIRC, three sectors of IO.SYS is simply loaded to 0:700h and jumped to.
    – Justme
    Commented 12 hours ago
  • The bootable lDebug allows running commands like boot protocol msdos6 then if (! rc) then q to try booting a certain protocol. However, like grub this requires installing the entire debugger (> 80 KiB in a file). Unlike grub it runs in 8086 Mode throughout. @Justme I documented the MS-DOS v6 protocol in the lDOS boot manual, basically you read msload (first 1.5 KiB of io.sys) to 00700h, enter it at 70h:0, pass the two directory entries at 00500h and 00520h, dl = unit, +BPB, DPT.
    – ecm
    Commented 11 hours ago
  • 1
    @Justme The IBM-DOS load protocol (around v6/v7) is the same as MS-DOS v6 except the names, and it can boot off FAT32 for PC-DOS v7.10. Unfortunately in the free software release of MS-DOS v4 of 2024 April, msboot requires the bio file to start in the first data cluster of the file system so that would have to be fixed first to allow adapting the original code.
    – ecm
    Commented 10 hours ago

1 Answer 1

11

I don't know that one has been written, but it looks like it should be pretty easy to write one. If we look at the code for DOS 4.0 on GitHub, the boot sector has code like this:

    MOV DI,BX
    MOV CX,11
    MOV SI,OFFSET BIO       ; point to "ibmbio  com"
    REPZ    CMPSB           ; see if the same
    JNZ CKERR           ; if not there advise the user
;
; Found the BIOS.  Check the second directory entry.
;
    LEA DI,[BX+20h]
    MOV SI,OFFSET DOS       ; point to "ibmdos  com"
    MOV CX,11
    REPZ    CMPSB
    JZ  DoLoad

To make it work for either, we'd basically duplicate this code, but in the duplicate modify the data to search for "IO SYS" and "MSDOS SYS" (which are already present in the code, and the PC-DOS/MS-DOS version selected with an ifdef). At the jnz CKERR, you'd jump to the second set of code to search for the second set of entries. And if either pair matches, do the jz DoLoad. That adds around 30 bytes of code and 22 bytes of data for the directory entries. I haven't assembled the existing boot sector to see whether there's ~55 bytes free to do this the easy way, or whether you'd have to get tricky to make it fit. There is a comment further down in the code saying there's not room for a full 32-bit division though, so fitting this change in could be non-trivial.

Reference

https://github.com/microsoft/MS-DOS/blob/main/v4.0/src/BOOT/MSBOOT.ASM

[lines 256-268]

7
  • 1
    Better link: github.com/microsoft/MS-DOS/blob/… Problem with the v4.00 msboot is it expects the msbio file to start in the first cluster aka cluster 2 (and for msload / 1536 bytes to be consecutive in the file system). MS-DOS v5 or v6 may have fixed that problem.
    – ecm
    Commented 10 hours ago
  • Given that for DOS 3.30+ the boot sector only needs to load (three sectors of) the DOS-BIOS, one can just skip checking if the name of the BDOS file matches, and instead probe for the other name of the DOS-BIOS file. So this can be made essentially free in terms of code size. Commented 10 hours ago
  • 1
    @user3840170 You still have to load the DOS module's directory entry to 00520h though.
    – ecm
    Commented 9 hours ago
  • I think I can write all this to fit to 512 bytes, based on the answer and the comments. I just wanted to see what I can reuse.
    – pts
    Commented 9 hours ago
  • 1
    @ecm Yes, that is a disadvantage. Though one would only hit it in the case of the DOS-BIOS file being properly installed, but the BDOS file not. For private use it just might be acceptable. Commented 7 hours ago

You must log in to answer this question.

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