flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Creating a bootloader.

Author
Thread Post new topic Reply to topic
calpol2004



Joined: 16 Dec 2004
Posts: 110
calpol2004
so far i've made a rather pathetic bootloader, it quite generally can write text...ugh. i've messed around with entering protected mode and even tryed to load a dummy kernel from a FAT12 file system. But im just doing this by looking at other peoples bootloaders and generally messing about Rolling Eyes. is there some kind of resource that will teach me how to create my own bootloader properly. all the tutorials i've seen only go as far to teach you how to write text. any suggestions people?
Post 21 Feb 2006, 17:14
View user's profile Send private message MSN Messenger Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u
Yes you should get bootprog.zip from here: http://alexfru.chat.ru/epm.html#bootprog
Not only is it a great bootloader (eg: will load any bin, com, exe file, from anywere on a floppy, by a certain name), but it comes with welcommented asm code.
Post 21 Feb 2006, 18:22
View user's profile Send private message Reply with quote
calpol2004



Joined: 16 Dec 2004
Posts: 110
calpol2004
not really what im looking for. Reason i wanted to get into OS construction so all the code would be mine. no dependencies on anything (except of course the BIOS). i'll take a look at it's source maybe find out how i need to load the kernel properly. btw when i try to switch to protected mode, is it possible to not switch to pmode in the bootloader and wait until the kernel is loaded then do it then in the kernel? i want to do this because when i switch to protected mode in the bootloader all the text i had written in real mode never appears on the screen, this may be because i put "use32" after i've switched to protected, doesn't seem to like me declaring this half way through the code Rolling Eyes (works if i take this line out, though not sure if it properly enters protected mode). Though i think i have to put "use32" for the 32bit registers to become available (correct me if i'm wrong). any idea to what im doing wrong?
Post 21 Feb 2006, 19:38
View user's profile Send private message MSN Messenger Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u
Your bootloader can load a pmode kernel or a kernel that starts in realmode and then goes to pmode, thats up to you, but if you want to load your kernel over 1mb you will need to use unrealmode or pmode.
My kernel starts in realmode and then goes to pmode.

Enter pmode simple example.
Code:
;************************************; \\|//; (@ @); Dex4u;; Assemble with fasm; c:\fasm Testboot.asm Testboot.bin;;************************************org 0x7C00use16;****************************; Realmode startup code.;****************************start:        xor   ax,ax        mov   ds,ax        mov   es,ax        mov   ss,ax        mov   sp,0x7C00;*****************************; Setting up, to enter pmode.;*****************************        cli        lgdt  [gdtr]        mov   eax, cr0        or    al,0x1        mov   cr0,eax        jmp   0x10: protected;*****************************; We are entering Pmode. ;*****************************use32protected:        mov   ax,0x8        mov   ds,ax        mov   es,ax        mov   ss,ax        mov   esp,0x7C00;*****************************; Turn floppy off (if space).;*****************************        mov   dx,3F2h        mov   al,0        out   dx,al;*****************************; Print a P if we enter Pmode. Wink;*****************************        mov byte [es:0xB8000], 'P'        jmp   $;*************************************; GDT.;*************************************gdt:        dw    0x0000, 0x0000, 0x0000, 0x0000sys_data:   dw    0xFFFF, 0x0000, 0x9200, 0x00CFsys_code:   dw    0xFFFF, 0x0000, 0x9800, 0x00CFgdt_end:gdtr:       dw gdt_end - gdt - 1            dd gdt;*************************************; Make program 510 byte's + 0xaa55;*************************************times 510- ($-start)  db 0dw 0xaa55    
Post 22 Feb 2006, 00:44
View user's profile Send private message Reply with quote
calpol2004



Joined: 16 Dec 2004
Posts: 110
calpol2004
exactly the kind of thing i was lookin for.. ill let you know how i get on with implementing it.
Post 22 Feb 2006, 13:12
View user's profile Send private message MSN Messenger Reply with quote
calpol2004



Joined: 16 Dec 2004
Posts: 110
calpol2004
your pmode example worked great, now i've just about got my head around loading a kernel from a FAT12 file system though im having trouble with virtual pc 2004. so far i've just been using a simple tool (someone on this forum made it, don't remember who Rolling Eyes) that copies my .bin bootsector to the floppy image (can't add files if i tried id overwrite my bootsector Sad). However because my kernel will be loaded from a file on a floppy, i need to be able to copy my kernel file and my bootsector to the virtual floppy disk. I'm unable to find a utility that is able to do this. WinImage can copy files to images but has poor functionality for adding my bootloader to the bootsector. Anyone know any tools which can do this?
Post 23 Feb 2006, 19:00
View user's profile Send private message MSN Messenger Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u
If you go here: http://bos.asmhackers.net/downloads.php
and get "BOS version 0.04, with source" and read the bach file, which shows the commands to get round that problem, using "partcopy.exe".
Post 23 Feb 2006, 19:42
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.