flat assembler
Message board for the users of flat assembler.

Index > OS Construction > Bootloader...

Author
Thread Post new topic Reply to topic
tspier2
Guest




tspier2 18 Jul 2005, 07:26
I know that this has been asked over and over again, but I need an answer specifically to what I ask. I started writing a bootloader, although I can't figure out how to boot it up on a computer. If there is any information about where and how to place the bootloader at the first 512 bytes of the floppy disk, please tell me. Also if there are any examples of microkernels and/or monolithic operating systems, please post pictures here, so I can gather source code if needed. Thanks.Wink
Post 18 Jul 2005, 07:26
Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 18 Jul 2005, 07:49
how to place - look at interrupt 13h description
Post 18 Jul 2005, 07:49
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
smiddy



Joined: 31 Oct 2004
Posts: 557
smiddy 18 Jul 2005, 10:39
What operating system are you using to develop with?
Post 18 Jul 2005, 10:39
View user's profile Send private message Reply with quote
coconut



Joined: 02 Apr 2004
Posts: 326
Location: US
coconut 18 Jul 2005, 15:57
i may be off, but you need something like rawwrite to place your bootloader at sector 0 of a floppy to be bootable.

http://flatassembler.net/examples/phboot.zip - this is a nice bootloader example and includes source for a utility to write to sector 0 of a floppy too
Post 18 Jul 2005, 15:57
View user's profile Send private message Reply with quote
tspier2
Guest




tspier2 18 Jul 2005, 21:19
I was mainly using Windows for the coding, although I've decided that I'm switching entriely over the Linux, because I have experience with it.
Post 18 Jul 2005, 21:19
Reply with quote
Night Rider



Joined: 28 Jul 2005
Posts: 72
Night Rider 28 Jul 2005, 00:13
Quote:

or monolithic operating systems

The Linux Very Happy
Really, it is monolithic kernel system... with opened sources Wink
If other questions, you always can ask me mndos@yandex.ru i'll be glad to help You, because i have done all this way completely myself...
Post 28 Jul 2005, 00:13
View user's profile Send private message ICQ Number Reply with quote
tspier2
Guest




tspier2 28 Jul 2005, 00:17
I know that. I was asking more specifically for advice with writing a bootsector to the floppy diskette.
Post 28 Jul 2005, 00:17
Reply with quote
crc



Joined: 21 Jun 2003
Posts: 637
Location: Penndel, PA [USA]
crc 28 Jul 2005, 01:33
On Linux you can do "dd if=bootsector of=/dev/fd0" to write the boot sector to a floppy.
Post 28 Jul 2005, 01:33
View user's profile Send private message Visit poster's website Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 28 Jul 2005, 02:45
If you are using FASMW maybe you want to develop in this way:
Code:
org 100h

  mov     ax, 0301h
  mov     bx, bootCode
  mov     cx, 1
  xor     dx, dx

  int     13h
  jnc     @f

  mov     dx, msgErr
  mov     ah, 09
  int     21h

@@:
  int     20h

  msgErr db "Write error$"

bootCode:

org 7c00h

  push    cs
  pop     ds
  mov     si, msg
  jmp     loadChar

printChar:
  mov     ah, 0eh
  int     10h

loadChar:
  lodsb
  test    al, al
  jnz      printChar

  xor     ax, ax
  int     16h

  xor     ax, ax
  int     19h

msg db "Remove disk and press any key", 13, 10, 0



if $-7c00h > 512
  display 'WARNING: boot code is more than 512 bytes'
end if
    


In this way you just press F9 and the boot code will be compiled and written to floppy. Of course you can change the code below the bootCode label, it just an example.

[edit] WARNING: this method replaces the first 512 bytes of the floppy disk, if you have files in the diskette will be difficult to get them back (floppy disk will appear as unformatted)[/edit]
Post 28 Jul 2005, 02:45
View user's profile Send private message Reply with quote
Night Rider



Joined: 28 Jul 2005
Posts: 72
Night Rider 28 Jul 2005, 11:01
Use Disk Editor. I used it, it is very good utility! Specialy, to put sector. Just compile it, run DE and write to PHYSICAL floppy device.
Post 28 Jul 2005, 11:01
View user's profile Send private message ICQ Number Reply with quote
bogdanontanu



Joined: 07 Jan 2004
Posts: 403
Location: Sol. Earth. Europe. Romania. Bucuresti
bogdanontanu 28 Jul 2005, 14:11
OR you could use rawwrite or rawwritewin
Post 28 Jul 2005, 14:11
View user's profile Send private message Visit poster's website Reply with quote
THEWizardGenius



Joined: 14 Jan 2005
Posts: 382
Location: California, USA
THEWizardGenius 28 Jul 2005, 19:22
Well if the disk is FAT you'll want to include the BPB (Boot Parameter Block) - http://home.freeuk.net/foxy2k/disk/disk3.htm - But with FAT you need to be able to load a file.

The whole point of a bootloader is to load a kernel from the file system into memory and execute it. On a disk with no file-system you can put the kernel in whichever sector you want. Most disks, however, you want to copy your kernel to the disk and load it from the filesystem. If you have a FAT [12|16|32] on your disk, then you will need to learn about the FAT filesystem - see http://home.freeuk.net/foxy2k/disk/disk1.htm for that information. However, the easiest thing is to use a pre-made bootloader that loads a file from a FAT disk. In the Examples section on the main FASM website, there is one. You might convince the MenuetOS people to let you use theirs. Or you can use one written in a different language. I have used John S. Fine's FAT12 bootloader, written in NASM, in the past. I took the pre-compiled binary, hex-edited it to add a loading message and change the filename (that was HARD work Razz) and used that.

Use whatever works for you. Even if you aren't using any file system, you'll need to load the kernel from the disk. Most people would just store it in the sectors directly following the boot sector.

Wherever it is, you use BIOS INT 13h to read/write these. Here's a reference on how to use it:

http://www.xaff.org/GI/biosref.html

You should use rawwrite or rawwritewin in DOS or Windows, or the dd command in linux, to write to the bootsector. You may want to backup what's currently there first. You can also use the free partcopy to write to the disk; I found PartCopy (John S. Fine's program) helpful because it works in Windows, and you can write a batch file for it. For example, I wrote a batch file for (a)compiling my bootloader and (b)writing it to disk. You can write a shell script for "dd" in linux, and a batch file for rawwrite, but only in DOS.

Good luck! Wink
Post 28 Jul 2005, 19:22
View user's profile Send private message AIM Address 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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.