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

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
gerenjo
Posts: 10
Joined: Tue Feb 03, 2009 12:16 pm

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

Post 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.
madeofstaples
Member
Member
Posts: 204
Joined: Thu Apr 12, 2007 8:15 am
Location: Michigan

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

Post by madeofstaples »

From where in memory is the code that you posted executing? You are probably overwriting it.
Some people are offended by the verifiable truth; such people tend to remain blissfully unencumbered by fact.
If you are one of these people, my posts may cause considerable discomfort. Read at your own risk.
User avatar
mintie
Posts: 6
Joined: Wed Jun 03, 2009 8:44 pm
Location: North Carolina, USA

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

Post by mintie »

And shouldn't ES:BX be 0xB00:0x0000 in the second one? 0x2000 + 0x9000 = 0xB000, not 0x11000...
gerenjo
Posts: 10
Joined: Tue Feb 03, 2009 12:16 pm

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

Post by gerenjo »

my code is at 0x1000, I'm not overwriting it :/

And yeah, it should be 0xB000, but it doesn't change anything :(
User avatar
Combuster
Member
Member
Posts: 9301
Joined: Wed Oct 18, 2006 3:45 am
Libera.chat IRC: [com]buster
Location: On the balcony, where I can actually keep 1½m distance
Contact:

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

Post 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.
"Certainly avoid yourself. He is a newbie and might not realize it. You'll hate his code deeply a few years down the road." - Sortie
[ My OS ] [ VDisk/SFS ]
Post Reply