assemblyvirtualboxinterruptx86-16bios

What is the use of Int 13H AH=00h


I don't understand the use of Int 13H AH=00h on my virtual floppy img.

I created an img virtual diskette from the command line:

copy amorce.com/B+programme.com/B disk.img /Y

The floppy disk is called "disk.img". It is made up of a boot sector which was in "amorce.com" and the boot sector is contained in the first sector of the diskette of 512 bytes. The floppy disk also contains a program which takes up 6 sectors, so from 2 to 7.

I then put my floppy disk on a virtual machine without an operating system with virtual box. The machine launches the boot sector program directly.

In the boot sector code I get these lines of code:

initialise_disque: 
    mov dl, 0
    xor ax, ax 
    int 0x13 
    jc initialise_disque

No errors detected in this code, except that the problem is that I don't understand its usefulness.
The documentation tells me that it resets the floppy disk system, but what does that mean in this context?

When I remove these lines of code it doesn't change anything in the rest of the code.

To try to understand the usefulness of this function I checked if, after performing it, it deleted the programs contained in the floppy disk, but this is not the case.

I also added code in my boot sector to write on sectors 2 to 7 in order to overwrite the other program contained in the floppy disk. Then I called this reset function to check if it was okay put back the crashed program, but no results.

This is the entire boot sector code.

What is the use of Int 13H AH=00h and what does reset mean in this context?


Solution

  • What is the use of Int 13H AH=00h and what does reset mean in this context?

    The BIOS.ResetDiskSystem function 00h will reset the controller for the drive selected through the DL register. In this context, 'reset' means forcing the drive to pull its head to track 0 so the next I/O operation can start from track 0. It is this recalibration that sometimes causes a grinding sound after a disk error occured. You won't hear that while on your virtual machine!

    Whenever a disk function like BIOS.ReadDiskSectors function 02h or BIOS.WriteDiskSectors function 03h reports an error, it is best to retry the failed operation a few times before giving up after consistent failure. In between tries you use this function so the disk operation can then start from a well-defined and safe starting point, in casu track 0.

    To try to understand the usefulness of this function I checked if after performing it it deleted the programs contained in the floppy disk, but this is not the case.

    Rest assured, using this function does not delete any files on the disk, nor does it overwrite any sectors.


    initialise_disque: ; Initialise le lecteur de disque
     xor ax, ax
     int 0x13
     jc initialise_disque; En cas d'erreur on recommence (sinon, de toute façon, on ne peut rien faire)
    
    lire:
     mov ax, 0x1000 ; ES:BX = 1000:0000
     xor bx, bx
     mov es, ax
     mov ah, 2 ; Fonction 0x02 : chargement mémoire
     mov al, 6 ; On s'arrête au secteur n° 6
     xor ch, ch ; Premier cylindre (n° 0)
     mov cl, 2 ; Premier secteur (porte le n° 2, le n° 1, on est dedans, et le n° 0 n'existe pas)
     ; Ca fait donc 5 secteurs
     xor dh, dh ; Tête de lecture n° 0
     ; Toujours pas d'identifiant de disque, c'est toujours le même.
     int 0x13 ; Lit !
     jc lire ; En cas d'erreur, on recommence
    

    There's little sense in repeating the reset function on its own. Use it in the same loop that tries to read the disk sectors. Preferrably using a count (like 5 times) so you don't keep trying indefinitely and can inform the user about the catastrophical fail.

     mov al, 6 ; On s'arrête au secteur n° 6
     ; Ca fait donc 5 secteurs
    

    This is wrong. The argument in AL specifies the number of sectors that you want to read. Starting from sector 2 (CL=2), you would read sectors 2, 3, 4, 5, 6, and 7. That's 6 in total.

    Your VESA code overwrites the disk id that BIOS gave you in the DL register on boot. Better preserve that value so you can use it in this part of the program.
    I see that the mov dl,0 instruction in the question's code snippet is nowhere to be found in the full code that you have provided a link for!