Hi,
If I want to read say 100KB off a disk, do I have to manually swap cyliner, track, head and so on?
Currently I use
_LoadSystemSetup:
mov cx, word [LoadCount] ; Get the Count
cmp cx, 25 ; Try 25 Times
je SystemNotFound
inc cx ; Increment the Attempt Count
mov word [LoadCount], cx ; Save the Load Count
xor ax, ax ; Disk Reset Function 0x00
int 0x13 ; Reset the Disk
jc _LoadSystemSetup
cld ; Clear the Direction Flag
mov ax, 0x020a ; Function 0x02, Read 0x0a (10) Sectors
mov bx, 0x7e00 ; Read to ES:BX (0000:7e00)
mov cx, 0x0002 ; Disk Cylinder = 0, First Sector = 2
mov dl, byte [BootDrv] ; Set the Boot Drive Number
xor dh, dh ; Head Number = 0
int 0x13 ; Reads the Sectors
jc _LoadSystemSetup
to read 10 sectors from the disk. Can I just do this except say 200 sectors instead of 10? If i can then how would you specify more than 255 sectors? because there is only a byte for the sector count.
int 13h
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:int 13h
the largest block BIOS can read in one call is 64Kb (because of buffer limitations in realmode). So you're likely to need at least 2 separated calls ...
Re:int 13h
So I guess it is possible to read a block of 64kb in one with adjusting settings.
Thanks
Thanks
Re:int 13h
Actually, no. Using Int 0x13, the BIOS is only able to read on track(cylinder) from your drive per call. This is currently how I read in my kernel:
That code reads the first track of a floppy starting at sector 2(sector 1 is bootsector, there is NO sector 0 ), then reads all 18 sectors from the next cylinder. For the next cylinder, you make BX = 0x4600 and so on... It shouldn't be too hard to make a function to do this in a loop for you...
Code: Select all
mov bx, 1000h
mov es, bx
read:
xor bx, bx
mov ah, 0x02 ; Load disk data to ES:BX
mov al, 17 ; Load 17 sectors
mov ch, 0 ; Cylinder=0
mov cl, 2 ; Sector=2
mov dh, 0 ; Head=0
mov dl, [drive] ; Drive=0
int 13h ; Read!
jc read ; Error, try again
read2:
mov bx, 0x2200
mov ah, 0x02 ; Load disk data to ES:BX
mov al, 18 ; Load 18 sectors
mov ch, 1 ; Cylinder=0
mov cl, 1 ; Sector=2
mov dh, 0 ; Head=0
mov dl, [drive] ; Drive=0
int 13h ; Read!
jc read2 ; Error, try again
...etc...
Re:int 13h
Just a question how many cylinders are there per head? Also is a cylinder the same as a track?
Re:int 13h
On a 1.44MByte floppy diskette:
- There are 18 Sectors per track/cylinder
- There are 80 Cylinders (Tracks)
- There are 2 Heads
Yes, a track is the same thing as a cylinder. For floppies, you usually call them tracks, and for hard disks they are cylinders... Although when you say cylinders for a floppy, tracks are understood(Tracks is sort of a "computer slang" if you know what I mean).
Cylinders per head? You don't usually go by this, but on a floppy, there are 80 cylinders per head. The heads are aligned along the cylinders. Sector is basically a seek along the disk surface without moving the head, cylinder is moving the heads along the surface to access another... Heads are basically selectors of which side of which disk you want to read a sector...
To calc the size of a disk: (S * C * H * 512) / 1024 gives the size in KBytes, that / 1024 gives MBytes...
Now, I bet I gave you more than you asked for (sometimes good ) and you most likely have more questions
- There are 18 Sectors per track/cylinder
- There are 80 Cylinders (Tracks)
- There are 2 Heads
Yes, a track is the same thing as a cylinder. For floppies, you usually call them tracks, and for hard disks they are cylinders... Although when you say cylinders for a floppy, tracks are understood(Tracks is sort of a "computer slang" if you know what I mean).
Cylinders per head? You don't usually go by this, but on a floppy, there are 80 cylinders per head. The heads are aligned along the cylinders. Sector is basically a seek along the disk surface without moving the head, cylinder is moving the heads along the surface to access another... Heads are basically selectors of which side of which disk you want to read a sector...
To calc the size of a disk: (S * C * H * 512) / 1024 gives the size in KBytes, that / 1024 gives MBytes...
Now, I bet I gave you more than you asked for (sometimes good ) and you most likely have more questions
Re:int 13h
Actually you did give more than I asked, this extra info answered the other questions that I had, thanks heaps. ;D
Re:int 13h
Actually there is one more question that I have, and that is how is information written to the disk. If I fill a disk does the information fill one side and then start on the other side? Or is it written by alternating sides, track by track.
- Pype.Clicker
- Member
- Posts: 5964
- Joined: Wed Oct 18, 2006 2:31 am
- Location: In a galaxy, far, far away
- Contact:
Re:int 13h
the order is track 0 side 0 - track 0 side 1 - track 1 side 0 - track 1 side 1 - etc.PlayOS wrote: Actually there is one more question that I have, and that is how is information written to the disk. If I fill a disk does the information fill one side and then start on the other side? Or is it written by alternating sides, track by track.
this reduces the amount of head moves when sweeping the disk.