int 13h loading more than 18 sectors how to

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.
mr. xsism

int 13h loading more than 18 sectors how to

Post by mr. xsism »

how do u laod more than 18 sectors into memory at a time? This is kinda a continuation of my gateway booting problem post. some simple code would be greatly appreciated :) thx

regards,
mr. xsism :-\

here is what i have so far:
|---------------Start Code segment-----------------------|
ResetFloppy:
mov ax,0x00 ; Floppy Reset BIOS Function
mov dl,[drive] ; Select floppy that was booted from
int 0x13 ; Reset the floppy drive
jc ResetFloppy ; If there was a error, try again.


mov byte [gs:0],'2'
mov byte [gs:1],0x04

LoadFloppy:
mov bx,0x1000 ; Data buffer for file = 0x00001000
mov es,bx
mov bx,0x00
mov ch,0 ; Track
mov cl,2 ; Sector 2 of floppy
mov al,22 ; to sector 24
mov ah,2 ; Function to read disk
mov dh,0 ; Head
mov dl,[drive] ; Drive #
int 0x13 ; Call BIOS read disk sectors function
jc LoadFloppy ; motor error, try again

mov edx,0x3F2 ; stop the floppy motor
mov al,0x0C
out dx,al
|-------------------------End Code segment-----------------|
jrfritz

Re:int 13h loading more than 18 sectors how to

Post by jrfritz »

Ok...sorry but I have to tell you this ... i'd show some code but right now my linux x server is messing up...

in fritzos's boot.asm in the source\boot directory...you should see a function called ReadFloppy2.

Use that to load the next cylinder ... to load a total of 18 * 2 sectors...and just keep c/p that function renaming it to readfloppy3 and so on when you need to.
mr. xsism

Re:int 13h loading more than 18 sectors how to

Post by mr. xsism »

np tom, thx, ur real kool :) I was thinking the same thing but i thought that someone might know a quicker kill 2 birds with 1 stone deal. Thx though, i'll try that and hopefully it'll work :) thx :]

regards,
mr. xsism
jrfritz

Re:int 13h loading more than 18 sectors how to

Post by jrfritz »

That's strange...last night I got my x server back up and running...and posted the code to help....but it didn't post!:(
mr. xsism

Re:int 13h loading more than 18 sectors how to

Post by mr. xsism »

tom, ur code doesn't work in bochs and my code that iwrote works but only loads half of it which leads me to believe that i have a problem with the 2nd head load :/ I know that it is int 13h because i ran my other early stage kernel yesterday that is less than 18 sectors and it runs fine.

\----------------Code Snippet-----------------/
LoadFloppy:
mov bx,0x1000 ; Data buffer for file = 0x00090000
mov ch,0 ; Track
mov cl,2 ; start at sector 2
mov al,18 ; for 18 sectors
mov ah,2 ; Function to read disk
mov dh,0 ; Head
mov dl,[drive] ; Drive #
int 0x13 ; Call BIOS read disk sectors function
jc LoadFloppy ; motor error, try again


LoadFloppy2:
mov dh,1 ; next head
mov cl,0 ; sector 0
mov al,18 ; for 18 more sectors
mov bx,0x1000 ; continuation address from kernel memory spot
int 0x13
jc LoadFloppy2
\---------------End Code Snippet---------------/

any suggestions? I know why urs doesn't work tom, u load only 17 sectors and not 18. And one more thing, why, if we start loading at sector 2, do we have to load 18 sectors instead of 16? i tried 16 and it triples! thx

regards,
mr. xsism
jrfritz

Re:int 13h loading more than 18 sectors how to

Post by jrfritz »

Why do you start at sector two? Aren't you suppose to start after...the bootsector at sector 1?
mr. xsism

Re:int 13h loading more than 18 sectors how to

Post by mr. xsism »

i knw that is wqeird huh!? But that is the only way that works and i can't figure it out. I burn it(image) to the 0 sector but i think 0=1 in int 0x13(must be non-zero)

I still can't figure out how to load the second half, am i supposed to load it to a different memory spot? (0x2400=18*512) I load the kernel to 0x1000 and i'm trying to load the second half to 0x3400 but it doesn't seem to work! HELP ME PLZ!!!!!!!!!!!!!!!!!!!!!!!

regards,
mr. xsism
jrfritz

Re:int 13h loading more than 18 sectors how to

Post by jrfritz »

Sigh...

0 = sector 0.
1 = where your kernel is...
so your not LOADING YOUR KERNEL!
mr. xsism

Re:int 13h loading more than 18 sectors how to

Post by mr. xsism »

ehm, tom, i'm sorry but u must be a lil less than u sau u r...
look in the manuals, sector must be a non-zero value. Thus, 1=0 2=1 etc.it is strange i agree. I also have to start at sector 2 for the 2nd half of the kernel loader, i thought i had to start at sector 0 or maybe 1 but i was wrong. Plus,in FritzOS u use sector 2 for both also so what in the world r u even talking about? I have ur code too, so ican show u(how could u forget this?? R u even Tom Fritz?? Did u steal that code? At least don't act like u know all.

|--------FritzOS boot.asm snippet----------|
; Read the floppy drive for loading the FritzOS C+ Kernel
ReadFloppy:
mov bx,   9000h      ; Load FritzOS at 9000h.
mov ah,   0x02      ; Load disk data to ES:BX
mov al,   17      ; Load two floppy head full's worth of data.

mov ch,   0      ; First Cylinder
mov cl,   2      ; Start at the 2nd Sector, so you don't load the bootsector, you load
               ; the C++ Kernel/Second Stage Loader ( they are linked together ).
mov dh,   0      ; Use first floppy head
mov dl,   [ drive ]   ; Load from the drive FritzOS booted from.

int 13h         ; Read the floppy disk.

    jc ReadFloppy         ; Error, try again.

; Now, since FritzOS is over 17 sectors ( one floppy head has 17 sectors ( 18, sector 0 is included in the
; number ), we load another floppy head.
ReadFloppy2:
   mov al,      17   ; The Second Head Full
   inc dh         ; Set it to the second head

   int 13h         ; Read the floppy disk.
|-----------End snippet------------------|

That was from Pre-kernel 0.7


sigh, don't try to act above the rest of us, i don't appreciate it and i'm sure others don't either.

friendly regards,
mr. xsism

ps:bth mine and ur reset floppy code won't work on real PCs. I'm trying to figure it out, but till then, it's a problem :) it lops (CF flag)
jrfritz

Re:int 13h loading more than 18 sectors how to

Post by jrfritz »

Oh...sorry...why won't the whole computer just use 1 = 1 and so on? Drives me to error with all the change...

Well...my code works on my computer ( real pc )...maybe it's my BIOS.

I think we both should ask for well tested BIOS reading code....and here it is:

Anyone have some well tested code to read raw ( on FS ) data off the floppy?
mr. xsism

Re:int 13h loading more than 18 sectors how to

Post by mr. xsism »

i hate bios floppy code!!!!!!! This sux, now my real pc isn't loading the rest of my kernel, maybe it's my code? I gotta fihure some stuff out. Ya, anyone have some BIOS manuals n what not?? Those would help alot :/

regards,
mr. xsism
User avatar
Pype.Clicker
Member
Member
Posts: 5964
Joined: Wed Oct 18, 2006 2:31 am
Location: In a galaxy, far, far away
Contact:

Re:int 13h loading more than 18 sectors how to

Post by Pype.Clicker »

what don't you try to get sector loading work within a DOS program first ? this will for sure be easier to do and to debug than on a bootsector ...
eL JeDi

Re:int 13h loading more than 18 sectors how to

Post by eL JeDi »

[attachment deleted by admin]
pini

Re:int 13h loading more than 18 sectors how to

Post by pini »

You can load more than 18 sectors in on stage, using the int 13h (with the amount of sectors in al), but I have found out that this doesn't work with American Trends (AMIBIOS) BIOS.
AMIBIOS can only load one track at a time.
Award BIOS (at least ;)) can load more than 18 sectors in one int 13h call
Curufir

Re:int 13h loading more than 18 sectors how to

Post by Curufir »

Nope. What happens with some BIOS is if the sectors requested exceed the number of sectors per track it will switch heads at the end of the track and continue to read. It will not switch cylinders for you. So if you go beyond the limits of the track on the next head it will switch heads again and continue to read at the start of the track. Ie you loop around the same cylinder. Now this is all well and good if all your data lies on the same cylinder, if not you'll end up with garbage trying to read it all in one go.

It's bad practice to rely on anything other than the basic BIOS behaviour, so it's far better to switch heads/tracks yourself. I'd almost go so far as to say forget the BIOS completely and use the ports instead, the fdc on x86 computers uses a very standardised format and set of ports.
Post Reply