Page 1 of 1

...typical beginner questions...

Posted: Fri Mar 12, 2004 12:00 am
by Neptune
Hello, all. So far I have a very rudimentary OS that simply prints a message, waits for a keypress, then reboots. All of this is done using BIOS service routines. Now I would like to read the very next sector of the floppy (I wrote the kernel directly to this sector using debug.exe, so I don't need to worry about searching for it as a FAT12 entry, for now) into memory exactly 1024 bytes ahead of the currently loaded image (which is of course at 0x7c00 at this point) and then turn over control from there. I am a little unsure how to work this BIOS service (int 13:02) and would like someone to verify that I have things set up properly before proceeding. Here is the code:

; load kernel 1024 bytes ahead of here
mov bx, 0x0000
mov ax, 0x8000
mov es, ax

; read second sector from floppy
  ; first reset the disk
mov ah, 0x00
int 13
; now try to read
mov ah, 0x02 ; read service
mov al, 0x01 ; #sectors
mov ch, 0x00 ; cyl#
mov cl, 0x02 ; sector#
mov dh, 0x00 ; head
mov dl, 0x00 ; drive# (floppy)
int 13
jc egress

At this point I am just trying the read once (though I heard 3 tries are generally used for floppies). Does everything look kosher?

My next question relates to something experimental I was trying. I wanted to 'generically' set all of the segments to whatever position BIOS loaded the bootsector. I know that this will probably always be 0x7c00, but just for fun, I wanted to code it so that some future BIOS could load it anywhere else and everything worked. So I removed the 'org 0x7c00' from the code, then took the label for the base of the code, and tried to load it into the segment registers, and then proceed normally. Unfortunately, this didn't work, and my print message never appeared. Why not?

Finally, what is the best resource for writing non-BIOS-dependant code? I would ultimately like to do everything 'by hand' (ie: reading from disks, keyboard, etc). Are there any recommended reference materials for doing that?

I apologize for being so long-winded! Any comments/suggestions would be appreciated. Thanks!

- Sebastian

RE:...typical beginner questions...

Posted: Fri Mar 12, 2004 12:00 am
by ASHLEY4
Try these links:
http://www.free2code.net/tutorials/othe ... =1&print=1

This will tell you how to load sector with out bios:
  http://debs.future.easyspace.com/Progra ... loppy.html

ASHLEY4.

RE:...typical beginner questions...

Posted: Fri Mar 12, 2004 12:00 am
by Neptune
Ok, thank you for those links, Ashley - I'll give them a thorough read...