Floppy Disk

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
noodles

Floppy Disk

Post by noodles »

Hi,

I have already posted this to alt.os.development but i thought I would post it here as well as I just joined the forum yesterday and wanted to say hi. I only recognise Tim Robinson from a.o.d so far, any others? Ok here goes...

I am trying to load my kernel into memory from my FAT12 formatted floppy. This shouldnt be a problem though. The problem is that when I try to read the disk it wont stop reading. The green light stays on and it keeps reading the sector. After running it through bochsdbg and checking the error code it show up as a controller failure. My code then attempts to read the disk again. I would appreciate it if someone could take a look at my disk reading code and see what they think.

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
resetFloppy:

xor ax, ax ; Puts the disk into a known state.
int 13h ;

readSectors:

mov ax, 020Eh ; ah = 02h, al = 0Eh (14 sectors to load).
mov cx, 0013h ; cl = sector_number, ch = cylinder_number.
mov dx, 0000h ; dh = head_number, dl = drive_number.
mov bx, 800h ; Setup buffer es:bx to 800:0000h.
mov es, bx ;
xor bx, bx ;
int 13h ; Start reading.

jc readSectors ; Whoops, didn't manage it this time. Lets try again.
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


Can anyone take a stab at it for me? Im compiling with nasm.

Thanks :)
Chris Hodgins
Ozguxxx

Re:Floppy Disk

Post by Ozguxxx »

< mistake >

Hi I think a problem like this had occured to somebody else and If I am not mistaken you have the same problem, you are basically overwriting your own bootloader code because:
8000h+(0200h*0eh)=09c00h > 07c00h which is 8096 bytes past your boot loader code start. Problem might be caused by this, change your buffer area, and try again. Good luck...

< / mistake >

Of course, this is correct only if the start of the loading address is under the start of the boot sector. It cannot apply here :)
Ozguxxx

Re:Floppy Disk

Post by Ozguxxx »

If I were you, I would not depend too much on results that I get from floppy stuff of bochs, I saw that it gave some inconsistent results from real hardware... (hey gurus, do you agree? :) )
Ozguxxx

Re:Floppy Disk

Post by Ozguxxx »

Hi, people, I realized that this is a terrible mistake, do not take care of my previous posts, I am soory, really sorry, very very big mistake.... MY concentration is out of order.... ???
noodles

Re:Floppy Disk

Post by noodles »

Its ok Ozguxxx I spotted it :)

I have worked out what I was doing wrong thanks to a very nice person in alt.os.development.

Code: Select all

mov cx, 0013h        ; cl = sector_number, ch = cylinder_number.
you can see in the line above I requested sector 13h. this is 19 in decimal and of course a floppy only has 18 sectors per track. Silly old me.

Anyway it is nice to see such a friendly forum where people are so willing to help. i ahve found that a lot with OS Development. The people here are genuine and friendly; almost the total opposite of comp.lang.c lol.

Thanks for all your help!
Chris :) :) :)

BTW Great forum! ;)
Post Reply