Page 1 of 1
How can I load the next file from bootloader ?? Please HELP
Posted: Tue Mar 22, 2005 12:41 pm
by KiBOrG
How can I load the next file from bootloader ?? Please HELP ME, I?m Newbie
I want write my bootloader to FDD and when i have a lot of lines in bootloader i wand load next file ??
Is it really ?
How Can I do ??
Help me, please
KiBOrG
Re:How can I load the next file from bootloader ?? Please HE
Posted: Tue Mar 22, 2005 2:44 pm
by Pype.Clicker
you need a second stage, most probably. Since you're only allowed to have 512 bytes in the bootsector, your first task is to load more things (for instance the next sectors, or some file from FAT12, depending on what's on your floppy) using the BIOS INT13h
Re:How can I load the next file from bootloader ?? Please HE
Posted: Tue Mar 22, 2005 2:53 pm
by Dex4u
This also may help, it let you load a bin or com or exe from the floppy disk, its call "bootprog" you can get it here come with wel commented code, so that may help too.
http://alexfru.chat.ru/epm.html#bootprog
Re:How can I load the next file from bootloader ?? Please HE
Posted: Wed Mar 23, 2005 7:39 am
by aladdin
I found a method to load two files from the bootsector without the need of a secod stage loader ...
i did it by storing both filenames in two variables and the respecting loading adresses in two other variables,
the i wrote some routines to load a file from a fat12 floppy, after calling this routine i test if i just loaded the first or the second file, if it is the first one, i load the second else i continue :
the folowing pseudo code can help you understand how i did it :
Code: Select all
var first_file = "setup.bin"
var second_file = "kernel.bin"
var first_addr = 0x9200
var second_addr = 0x1000
var current_file_to_load = @first_file
var current_addr = first_addr;
/*do something*/
...
.loading :
routine_to_load_file ( current_file_to_load, current_addr)
if (current_addr == first_addr) then
current_addr=second_addr;
current_file_to_load=@second_file;
goto .loading
/* do something else */
/* jump to start code ... if you want */
Note1: if you want to use fat12 filesystem, you have to write the fat header in your bootsector, doing this you will anly have 410byte to write all your code
Note2: this pseudo-code is very simple compared to what you should really do in asm but it gives you an idea about how you can do it ...
Note3: even if i consider my code very optimised, i have too few comments (some characters)
Note4: here is my bootsector code
http://xos.freezee.org/beta/boot.asm
but it is commented in french
Re:How can I load the next file from bootloader ?? Please HE
Posted: Wed Mar 23, 2005 8:55 am
by slash
Well here is a sample bootloader that boots and loads the file that is just after it:
Code: Select all
[ORG 0] ;starts here
jmp 07C0h:start ; Goto segment 07C0
start:
; Update the segment registers
mov ax, cs
mov ds, ax
mov es, ax
reset: ; Reset the floppy drive
mov ax, 0 ;
mov dl, 0 ; drive 0 means the A:\ drive, 1 = B:\
int 13h ;
jc reset ; if ther was error then try again
read:
mov ax, 1000h ; ES:BX = 1000:0000
mov es, ax ;
mov bx, 0 ;
mov ah, 2 ; Load disk data to ES:BX
mov al, 5 ; Load 5 sectors
mov ch, 0 ; Cylinder
mov cl, 2 ; Sector
mov dh, 0 ; Head
mov dl, 0 ; Drive 0=A:\ , 1 = B:\
int 13h ; start reading
jc read ; try again if there was error
jmp 1000h:0000 ; Jump to the program
times 510-($-$$) db 0
dw 0AA55h ;Ends here
To compile the bootstrap, use this command:
nasm boot.asm -o boot.bin
And write the resulting "boot.bin" to sector 0 on floppy disk.
Well if you understand asm then you can see that boot code lasts just 1 sector on the floppy after that you have your other file to load.Your other file must fit into 5 sectors [5 sectors = 5 KB] of floppy but you can change that by changing line 32 to "mov cl,[no# of sectors to read]".
Re:How can I load the next file from bootloader ?? Please HE
Posted: Thu Mar 24, 2005 11:02 am
by KiBOrG
Very thanks for all. ;D ;D ;D
Thank,
KiBOrG