Page 1 of 1

Loading a file form the bootloader

Posted: Fri Feb 13, 2004 12:00 am
by john25
can some one tell me how to load a file from the floppy disk through the bootloader (Possibly a kernel)here is the code I have so far:

  one more thing I use the Nasm compiler so it must be compatible... thx in advance
----------------------Bootloader.asm------------------------
[BITS 16] ; Tells the compiler to create 16 bit code generation
[ORG 0x7C00] ; tell  the BIOS where to load the Boot loader into memory

main ; Main Program

mov ah,0x0e ; Puts the code into teletype mode
mov bh,0x00 ; The active page number
mov bl,0x09 ; Sets the Text Attributes

mov al, 65 ; Dislpay an ASCII Character - A

int 0x10 ; Calls the BIOS video interrupt

jmp $

times 510-($-$$) db 0 ; Fills the rest of the Program with 0's
dw 0xAA55 ; Valid Boot Signature

RE:Loading a file form the bootloader

Posted: Sat Feb 14, 2004 12:00 am
by graphics in pmode
search for fdos. a simple realmode os completely written in asm (nasm)

RE:Loading a file form the bootloader

Posted: Sat Feb 14, 2004 12:00 am
by Karig
If you want to load a file from a FAT12 (DOS- or Windows-formatted) floppy, you'd need to have code that reads in the sectors that make up the root directory, search them for the entry for the file you want, get the ID of the first sector of the file, then follow the FAT to get the IDs of the rest of the sectors of the file in order. Then you can just read in those sectors, and your file will be in memory. Setting this up is relatively complicated, as you can see, but the code isn't so complex that it won't fit into a boot sector, and you can just copy the file onto the floppy from within Windows or Linux or whatever OS you normally use.

A simpler way to read a "file" from a floppy, if you don't mind having to use a special tool (such as RawWrite) to write the file onto the floppy first, is just to load a number of sectors from the floppy in order, such as the first track (cylinder 0, head 0, sectors 1 through 18) -- which would contain your boot sector at sector 1 and up to 8.5KB of extra code beyond the end of the boot sector. You can of course load multiple tracks in order if your "file" is larger.

RE:Loading a file form the bootloader

Posted: Sun Feb 15, 2004 12:00 am
by ASHLEY4
All so if you go here:                http://alexfru.chat.ru/epm.html

And get "bootprog.zip", in it is the code to load a file from the disk,it is writen in nasm.
Once you put it to the boot scetor,you can boot any bin/com, exe,file put on the disk (no dos int's).this is grat for testing.

ASHLEY4.

RE:Loading a file form the bootloader

Posted: Mon Feb 23, 2004 12:00 am
by neil
Instructions to load your kernel throught the GNU GRUB bootloader (http://www.gnu.org/software/grub) using a floppy disk. I will use '/' as repertory separator.

1. Format your floppy
2. Create a /boot/grub directory on your floppy
3. Put the content of the grub tarball in this repertory
4. Create a new repertory for your kernel, for example /os and put your kernel there
5. Edit the /boot/grub/menu.lst for example:
# Begin /boot/grub/menu.lst
# GNU GRUB boot menu


# By default boot the first entry
default 0

# Timeout: 30 seconds
timeout 30

# Orange/Green Theme
color light-green/brown blink-red/blue

# Boot your Kernel
title My Operating System
root (fd0)
kernel /os/my-kernel


# End /boot/grub/menu.lst

6. Install GNU GRUB on this floppy

Of course, you can use GNU GRUB with the Bochs Emulator (http://bochs.sourceforge.net), you can use a file as a floppy, you can install GNU GRUB with GNU GRUB and Bochs, and many other things (man, info, or ask ;)

/ Neil Dökkalfar <[email protected]>