Page 1 of 1

How much data can we load with the BIOS int0x13 (floppy) ?

Posted: Fri Jul 10, 2009 12:02 pm
by gerenjo
Hi,

After adding a large amount of code in my kernel, I was surprised to see that it wouldn't boot anymore. I made some tests, and saw that it would boot only when it takes less than 75 sectors or so, on my floppy disk.
I had this problem once, but managed to get around it by adding a second int 0x13.
Here is my code, what is wrong about it ?

Code: Select all

        ;; Load Kernel ;;                                                                                                                                                                              
        xor     ax, ax
        int     0x13
        push    es
        mov     ax, 0x200
        mov     es, ax
        mov     bx, 0
        mov     ah, 2
        mov     al, 72          ;sector num -- max = 72 (2 full cylinders)                                                                                                                
        mov     ch, 0
        mov     cl, 3
        mov     dh, 0
        mov     dl, 0
        int     0x13


        ;; Load Kernel  2 ;;                                                                                                                                                                           
        xor     ax, ax
        int     0x13
        push    es
        mov     ax, 0x1100
        mov     es, ax
        mov     bx, 0
        mov     ah, 2
        mov     al, 72          ;sectors number                                                                                                                
        mov     ch, 2           ;cylinder num                                                                                                                                                          
        mov     cl, 3           ;sector                                                                                                                                                                
        mov     dh, 0           ;head                                                                                                                                                                  
        mov     dl, 0
        int     0x13
Let me explain it a bit.
I want my kernel at 0x2000, that's why I have es:bx equal 0x200:0x0. I begin to read at sector 3, because the first ones are my bootloader and stage2. (this code is from my stage 2).

In my second read, I juste have to add 2 to the cylinder index, since 72 sectors = 2 cylinders. Also, the es:bx is now 0x1100:0, because 72 sectors is 0x9000 bytes (512 bytes per sector * 18 sectors per track * 2 heads per cylinder * 2 cylinder).

Any idea ? Thanks.

Re: How much data can we load with the BIOS int0x13 (floppy) ?

Posted: Fri Jul 10, 2009 12:24 pm
by madeofstaples
From where in memory is the code that you posted executing? You are probably overwriting it.

Re: How much data can we load with the BIOS int0x13 (floppy) ?

Posted: Fri Jul 10, 2009 12:27 pm
by mintie
And shouldn't ES:BX be 0xB00:0x0000 in the second one? 0x2000 + 0x9000 = 0xB000, not 0x11000...

Re: How much data can we load with the BIOS int0x13 (floppy) ?

Posted: Fri Jul 10, 2009 1:09 pm
by gerenjo
my code is at 0x1000, I'm not overwriting it :/

And yeah, it should be 0xB000, but it doesn't change anything :(

Re: How much data can we load with the BIOS int0x13 (floppy) ?

Posted: Fri Jul 10, 2009 1:25 pm
by Combuster
I suspect DMA transfers crossing 64k boundaries making it fail (DMA can't do that). In any case, reading more than a single track of 18 sectors can already cause trouble with some BIOSes, let alone if you do multiples of that.