flat assembler
Message board for the users of flat assembler.

Index > OS Construction > [idea]Boot code tutorial

Author
Thread Post new topic Reply to topic
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 23 Feb 2006, 19:13
As browsing thru the forum i found questions about boot-up code again and again. So someone experienced may put it together, what are rules (where is code loaded, what are register values, what you can/cannot use etc.) and post it here. I think, with writing this article, even it's author will save typing from answering same questions again and again.

thanks
Post 23 Feb 2006, 19:13
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
calpol2004



Joined: 16 Dec 2004
Posts: 110
calpol2004 23 Feb 2006, 19:20
definetly a good idea. there aren't a lot of tutorials out there for this kind of thing. And the the ones that do exist don't go that in-depth. unfortunatly im way to inexperienced myself to write one Confused. Maybe in a few months/years when i got the hang of this OS development ill write one Wink.
Post 23 Feb 2006, 19:20
View user's profile Send private message MSN Messenger Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 23 Feb 2006, 19:34
yes, i couldn't myself find such information together.
Post 23 Feb 2006, 19:34
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2139
Location: Estonia
Madis731 25 Feb 2006, 13:42
Hmm, I'm just starting, but I'll think about it when I get better...I just got the hang of 512-byte bootloader. Now the next step is to increase the codespace to include more code in the Very Happy ...runnin' outta space...
Post 25 Feb 2006, 13:42
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2465
Location: Bucharest, Romania
Borsuc 28 Feb 2006, 18:08
code is loaded at 0x7C00 flat address (segments and offsets may vary).. seriously, I think everybody with their own OS knows this

upon entry, dl=drive number (there are not many sites explaining this)

the last two bytes should be 55 AA Laughing (note, if you use dw 0xAA55 is still correct, 'cause of little endian thing, but I suggest you use db 0x55, 0xAA it's far clearer).

i'm not really experienced, but I wanted to share what I know 'bout booting rules.
Post 28 Feb 2006, 18:08
View user's profile Send private message Reply with quote
kake_zinger



Joined: 15 Jul 2004
Posts: 51
kake_zinger 01 Mar 2006, 07:39
I think writing a 512 byte multiboot program would make a nice asm programming contest. I mean pure boot sector loader no 2nd stage, but no space consuming limitations either like FAT filesystem, just pure boot loader on raw disk with data of which LBA has which OS boot sector and able to jmp there with keyboard number input. I'm thinking about a setup where first n sectors of the boot media are left unpartitioned raw space and actual OS partitions only come later. I'm not sure the Windows Wirus likes this approach though.

I don't think it can be done with all meaning of multiboot, including fdd hdd cdrom and usb.

Or something along these lines but also including a full pmode OS which drops the user to kind of text command line shell to do whatever he wants, with a program to "continue" booting to other OS later on. I've been working on something like this but recent hardware and time problems have forced me to abandon the project for the moment.

What I had in mind was kind of anti-OS which is made for programming and using the PC hardware directly, and only. A simple free flat space with no limitations (and no support either, because the more services are builtin, the more limitations there inherently are due to the design of the services).

My project used simple keyboard polling (not interrupt) for input because with interrupt come the questions of the data input model etc which lead much further than at first would be obvious. A bit like good C64 days.

(A "proper" input-output model brings forth concepts like pipes, interprocess communication and such and are way removed from the simple reality of a Personal Computer with display memory output and keyboard input.)
Post 01 Mar 2006, 07:39
View user's profile Send private message Reply with quote
MazeGen



Joined: 06 Oct 2003
Posts: 977
Location: Czechoslovakia
MazeGen 01 Mar 2006, 08:54
SpooK wrote some OS Dev Guide, but there seems to be some kind of error at the moment.

http://win.asmcommunity.net/board/index.php?topic=18162.0
Post 01 Mar 2006, 08:54
View user's profile Send private message Visit poster's website Reply with quote
smiddy



Joined: 31 Oct 2004
Posts: 557
smiddy 03 Mar 2006, 19:24
Hey vid (et al),

Well, in my time away I haven't had the opportunity to do any ASM coding at all. My plan is to be more involved again by the 20th of this month. Since I know a few things about booting from both a hardware and software perspective, something like a boot loading tutorial is something I could do that would get my juices flowing again and reaquaint me with ASM coding. I realize this doesn't help you now, but for future folks learning ASM and how the x86 systems work it may be helpful too.
Post 03 Mar 2006, 19:24
View user's profile Send private message Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 03 Mar 2006, 19:55
Great smiddy Cool, It would be much easier to point someone to a good "boot code tut", than keep answering the same ??.
Post 03 Mar 2006, 19:55
View user's profile Send private message Reply with quote
TDCNL



Joined: 25 Jan 2006
Posts: 56
TDCNL 15 Apr 2006, 18:15
smiddy wrote:
Hey vid (et al),

Well, in my time away I haven't had the opportunity to do any ASM coding at all. My plan is to be more involved again by the 20th of this month. Since I know a few things about booting from both a hardware and software perspective, something like a boot loading tutorial is something I could do that would get my juices flowing again and reaquaint me with ASM coding. I realize this doesn't help you now, but for future folks learning ASM and how the x86 systems work it may be helpful too.


Sounds absolutely great for us and for you too Very Happy

Can you guess (we won't turn you down if it's not exactly correct) a date for when you think you got some tutorial on it? Wink

_________________
:: The Dutch Cracker ::
Post 15 Apr 2006, 18:15
View user's profile Send private message Reply with quote
TDCNL



Joined: 25 Jan 2006
Posts: 56
TDCNL 15 Apr 2006, 18:17
The_Grey_Beast wrote:
code is loaded at 0x7C00 flat address (segments and offsets may vary).. seriously, I think everybody with their own OS knows this

upon entry, dl=drive number (there are not many sites explaining this)

the last two bytes should be 55 AA Laughing (note, if you use dw 0xAA55 is still correct, 'cause of little endian thing, but I suggest you use db 0x55, 0xAA it's far clearer).

i'm not really experienced, but I wanted to share what I know 'bout booting rules.


Who exactly has put the drive number in DL ? The BIOS stub that is copied into RAM at bootup?

Anyway, why do you need bytes 0x55, 0xAA at the end?

I'm very curious at bootloaders Smile

_________________
:: The Dutch Cracker ::
Post 15 Apr 2006, 18:17
View user's profile Send private message Reply with quote
tom tobias



Joined: 09 Sep 2003
Posts: 1320
Location: usa
tom tobias 16 Apr 2006, 10:49
Quote:

Anyway, why do you need bytes 0x55, 0xAA at the end?

http://support.microsoft.com/kb/q149877/
and please search for Kake_Zinger on the forum, he recently provided a good explanation....
Post 16 Apr 2006, 10:49
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 16 Apr 2006, 15:34
Did you see a BIOS that really doesn't boot up without that signature? All my computers boots a floppy without that mark. I'm not so sure about HDD but at least one of my computers boots without signature.
Post 16 Apr 2006, 15:34
View user's profile Send private message Reply with quote
bogdanontanu



Joined: 07 Jan 2004
Posts: 403
Location: Sol. Earth. Europe. Romania. Bucuresti
bogdanontanu 16 Apr 2006, 18:25
I have seen a LOT of computers that do NOT boot without that signature.

In fact i have never seen one that boots without a 55AA signature at the end of the floppy boot sector... it is just a simple test after all... why will a BIOS not do it?
Post 16 Apr 2006, 18:25
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 16 Apr 2006, 22:33
Never? my three computers (one with AMI BIOS and the others with AWARD BIOS) boots a floppy regardless of the presence of the signature. Well, now I know the signature is not for OSes but for BIOSes too. Thanks for the data!!
Post 16 Apr 2006, 22:33
View user's profile Send private message Reply with quote
bogdanontanu



Joined: 07 Jan 2004
Posts: 403
Location: Sol. Earth. Europe. Romania. Bucuresti
bogdanontanu 17 Apr 2006, 01:22
Yes, never ... but doh i must believe you... how did you tested?

Are you sure that the signature was not there on the floppy?
Who produced the computers?

Anyway it does not matter much as long as your computer DOES boot a disk with a good signature. Razz

Since the target of an OS is to run on ALL computers... any OS writter must obey the rules and place the signature OR else his OS will not run on SOME computers Wink For example it will not run on my computers!

BIOS is the program that startups the computer and it is the task of the BIOS to load the first sector from floppy (or HDD or other devices) and to launch it into execution. But if you did not know that already.... hmmm

This signature test is done for this first sector as a check for not launching into execution random foloppy's that are in fact not bootable. IF the BIOS does not check for this minimal 55AA signature you could insert any floppy into the computer containing no OS or no code whatsoever, even a blank formated floppy and the BIOS will try to launch THAT? Such actions are funny and stupid to say at least.

If what you say is true... then your BIOS is faulty.

OR maybe you do not have a BIOS, maybe it is an EFI computer or maybe you boot from HDD or Floppy or another device and you ar not aware of it... besides new computers and laptops do not have a floppy anymore...

...maybe...
Post 17 Apr 2006, 01:22
View user's profile Send private message Visit poster's website Reply with quote
Dex4u



Joined: 08 Feb 2005
Posts: 1601
Location: web
Dex4u 17 Apr 2006, 10:49
bogdanontanu wrote:
besides new computers and laptops do not have a floppy anymore...

...maybe...

In the UK most PC, but not many laptops, still have floppy drives, just got a 64bit PC with floppy and card reader combind Wink .

PS: The thing that a lot of PC do not have anymore, is the cable from the CD drive to the sound card, this means that you waste CPU time, just to play a CD, we all know who's idea this is.
Post 17 Apr 2006, 10:49
View user's profile Send private message Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 18 Apr 2006, 14:24
bogdanontanu, please note that no one of my computers is branded, I bought the components and made it by my own, so I don't have a Compaq nor HP no DELL...

About if I'm sure well, check the attached example of my abandoned project, I'd modified the include file to write 00 00 instead of 55 aa.

My motherboard is a K8N SLI Platinum, the BIOS is a "Phoenix - AwardBIOS v6.00PG". At this moment I have flashed version "W7100NMS V3.7 090905".

If you need more data ask

Regards

PS: Please take care, boot.com will replace the data at first sector of drive A: without prompting you anything.


Description:
Download
Filename: Boot.zip
Filesize: 1.68 KB
Downloaded: 202 Time(s)

Post 18 Apr 2006, 14:24
View user's profile Send private message Reply with quote
TDCNL



Joined: 25 Jan 2006
Posts: 56
TDCNL 19 Apr 2006, 19:40
I think it's a good idea to include those bytes to be 100% sure your CD/Floppy is bootable,

but regardless, the BIOS will boot anyway if it finds the bootable sector for the type of media (sector 1 for floppy/hdd etc) Wink

_________________
:: The Dutch Cracker ::
Post 19 Apr 2006, 19:40
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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.