2

I am trying to write a rudimentary OS, to understand the basics. The problem that I encountered is the read from floppy when the number of sectors is greater than 72.

The current working code:

KERNEL_SECTORS equ 72

mov    ax,    0x1000            ; to avoid DMA access across 64k boundary
mov    es,    ax
mov    ah,    02h               ; parameters for calling int13 (ReadSectors) - read the Kernel
mov    al,    KERNEL_SECTORS    ; read KERNEL_SECTORS sectors (hardcoded space for Kernel)
mov    ch,    00h     
mov    cl,    0Bh               ; starting from sector 11 - skip first 10 sectors (the MBR + SSL)
mov    dh,    00h     
mov    bx,    0                 ; memory from 0x7E00 - 0x9200 used by SLL;  0x9200 - 0x9FFFF is unused          
int    13h   

If the KERNEL_SECTORS is 73 the AH will be 1, which translates to bad command passed to driver. According to http://stanislavs.org/helppc/int_13-2.html I should be able to go to 128. Any idea what I do wrong?

Cody Gray - on strike
  • 239,200
  • 50
  • 490
  • 574
Tandura
  • 866
  • 2
  • 7
  • 19
  • 1
    Any chance you are running this on BOCHS. seem to recall that BOCHS (or maybe QEMU) have an artificial limit of 72 for floppy media. – Michael Petch Nov 14 '19 at 22:49
  • 1
    In general its a good idea not to read a number of sectors that would cause the BIOS and hardware to read across a cylinder boundary. On really old legacy hardware you couldn't read across a track boundary but anything that supports multitrack reads and writes (most modern equipment that still has legacy BIOS support) should work. – Michael Petch Nov 14 '19 at 22:51
  • @MichaelPetch yes I am indeed running from BOCHS – Tandura Nov 14 '19 at 23:34
  • OKay, thanks. I believe this is now a duplicate of the other question. I will mark it as such. If you want an example of some bootloader code that reads a number of sectors from disk 1 sector at a time that doesn't pose problems for either crossing a cylinder boundary, a track boundary, or a DMA boundary, you may wish to take a look at this: https://stackoverflow.com/a/54894586/3857942 – Michael Petch Nov 14 '19 at 23:44
  • @MichaelPetch Do real floppy drives support multi-track read on more modern BIOSs? – Martin Rosenau Nov 15 '19 at 07:17
  • @MartinRosenau: About the only real floppy drives you'll find these days are USB devices if you can find them but the ones I have encountered support multitrack reads and writes. As well on modern hardware USB drives in floppy disk emulation mode (USB FDD) support multitrack reads and writes through the BIOS. If you happen to have a PC with a real floppy drive controller in it, and it was made in the last 25 years, it likely supports multitrack reads. – Michael Petch Nov 15 '19 at 09:48
  • Generally the safest best is to not read/write across a track boundary. If you avoid crossing a track boundary with a read/write then you remain compatible with most of the ancient BIOSes that didn't support multitrack reads. – Michael Petch Nov 15 '19 at 11:33

0 Answers0