Miscellaneous > Programming & Networking

Operating System Development

<< < (2/5) > >>

voidmain:
Well, the easiest way if you want to do it in C++ is to first compile your program statically (g++ -static -o file file.cpp). Then strip it (strip file). Then make sure it's small enough to fit on a floppy. Then look over this:

http://www.groovyweb.uklinux.net/index.php?page_name=os%20newbie%20tutorial

Or similar links. You will find boot loader souce code in GRUB, you can rewrite it if you want but you are probably going to have to do that part in assembly.

Obviously if you write your entire program in assembly you don't need a boot loader. Just dd it to disk like you can with the Linux kernel (actually there is only a small amount of assembly in Linux kernel, most of it is C):

# dd if=program of=/dev/fd0

Yer not workin' on a virus are ya? The last time I did such a task was using Borland TASM about 12 or 14 years ago so I don't think I'll be much more help (if I've been any at all here). But please share your code and instructions when you get it sorted. I could use an updated refresher.

[ November 15, 2002: Message edited by: void main ]

beltorak0:
I used to do a heavy amount of assembly programming.  If you want to start from scratch, i suggest going there.  Of course assembly is terse; remember that it is only half a step removed from machine code: one instruction line equals one machine code instruction (unless you write some macros).  If you decide to go with assembly, get ralph brown's interrupt list .txt.

a ".com" is pure machine code.  Dos prefizes it with a "program segment prefix" which holds (the pointers to) important data; like the emegency failure routine, command line arguments, up to 2 supplied files, current environment, etc etc etc.  it is 100 bytes long (.RADIX 16).  In any event, the CS:IP (code segment & instruction pointer) points to byte 0 of the file.  There is no imposed header, like in ELF or .exe files.  They are a bit more complex in the setup, but machine code is machine code; and all memory is laid out linearly -- otherwise there would be no such thing as a buffer overflow attack.  I can't think of any online tutorials that would do better than printed resources; check out your local barnes and noble.

Creating your own OS is extreemly ... involved.  Most likely it will not run stand alone for a few incarnations -- remember that even linux required minix in order to work when it was being created.  

[never mind, thanks void main];

I am probably telling you what you already know, so i will just shut up now.  happy hacking   ;)  

-t.

[ November 15, 2002: Message edited by: beltorak0 ]

voidmain:
beltorak. I also started a big long message about OS design, writing your own compiler, kernel, device drivers etc, then I realized he just wants to be able to boot a simple program from a floppy without an OS or boot loader (for now anyway). You put him on the right track. And it prompted me to pull out a few old books from my wall. I know I learned how to do it long ago from one of them.

Let's see what I got here... Mastering Turbo Assembler by Tom Swan, 1989, Peter Norton's Assembly Language Book for the IBM PC 1989. I also have several DOS/BIOS interrupt books. Oh and a couple of my personal favorites "Tricks of the MS-DOS Masters" circa 1988 and if you want to learn how to manually repair a FAT table and fix those cross linked clusters using DEBUG there's Peter Norton's Hard Disk companion 1988. Should be good bathroom readin'!

[edit]
Just got back from the bathroom. Couldn't find the  COM examples for loading directly off of disk that I was looking for. Maybe I picked that up in a Byte magazine or something. Damn mind is going!!
[/edit]

[ November 15, 2002: Message edited by: void main ]

voidmain:
Ahh, this looks like just what you need:
http://linux.oreillynet.com/pub/a/linux/excerpts/linux_kernel/how_computer_boots.html

It would be best to understand how an existing OS boots in order to write your own (if you don't already know). The nice thing about Linux is all of the source is there for you to learn from.

And some Linux assembly tutorials and information:
http://linuxassembly.org/

[ November 15, 2002: Message edited by: void main ]

Kintaro:
Yeah, even i could do that stuff, i've read on general computer science. 86 based cpu's are really shitty to machine code. m68k's are easy though...

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version