Author Topic: Operating System Development  (Read 3804 times)

Stryker

  • VIP
  • Member
  • ***
  • Posts: 1,258
  • Kudos: 41
Operating System Development
« on: 15 November 2002, 06:42 »
I'm working on making an operating system. I've gotten quite a bit done but I haven't actually gotten it to boot. I do not want to use anything written by anyone else, no grub, lilo, or kernel. But what I do need is a c++ compiler that will compile things in machine code, rather than a .com, .exe, or linux executable. When I compile it with linux it will only work in linux, when it's compiled in windoze it only runs in windoze. I've considered learning ASM but I am having trouble finding a good tutorial anywhere. Does anyone know of a c++ compiler that will compile for a x86 machine without any non-bios interrupts?

The Auditor

  • Member
  • **
  • Posts: 59
  • Kudos: 0
Operating System Development
« Reply #1 on: 15 November 2002, 07:43 »
To my knowledge, you will only be able to get it to run under one or the other.
its a thing about C++.

The HUO (Hackers Unlimited Organization, see profile) is working on an OS, BSD, or possibly Darwin based..
i woulod advise the learning of ASM, it will only benefit you.

The Auditor

[ November 14, 2002: Message edited by: The Auditor ]

"You can always die, it's living that takes courage."

Stryker

  • VIP
  • Member
  • ***
  • Posts: 1,258
  • Kudos: 41
Operating System Development
« Reply #2 on: 15 November 2002, 08:22 »
quote:
Originally posted by The Auditor:
To my knowledge, you will only be able to get it to run under one or the other.
its a thing about C++.

The HUO (Hackers Unlimited Organization, see profile) is working on an OS, BSD, or possibly Darwin based..
i woulod advise the learning of ASM, it will only benefit you.

The Auditor

[ November 14, 2002: Message edited by: The Auditor ]



Well i'm not really looking for it to run in both, but rather neither. I'm looking to have it compile into a standalone program, one that doesn't require an OS. I've gotten one to work but it was made with ASM all i know is enableing the mouse and changing screen modes. Is there any compiler that will compile and use bios interrupts instead of dos or any linux, bsd, or any other one? I don't care if it's C/C++ anymore, i would rather have something a bit easier than ASM, i can't find anything good for learning ASM.

The Auditor

  • Member
  • **
  • Posts: 59
  • Kudos: 0
Operating System Development
« Reply #3 on: 15 November 2002, 08:42 »
Ahh i see what you mean now.. I apologise.

Hmm, I don't know what to suggest..
I'll have a word with the programmers with HUO and my mate AIDeveloper..
see what they think..

It should, beyond all reasonable doubt, be possible... but im not certain how one would do it, soo.. Ill find out and post as soon as i know..

Sorry about the confusion.

The Auditor
"You can always die, it's living that takes courage."

Kintaro

  • Member
  • **
  • Posts: 6,545
  • Kudos: 255
  • I want to get the band back together!
    • JohnTate.org
Operating System Development
« Reply #4 on: 15 November 2002, 08:58 »
You will have to write your own libarys or modify the orignal ones to work, its hard work but can be done, its easy to work with the GeekOS Kernel. But if you want to make an Arrogance OS then do what your doing. Im also working on a simlar thing based around networking, its currently 37 flowcharts and things.

voidmain

  • VIP
  • Member
  • ***
  • Posts: 5,605
  • Kudos: 184
    • http://voidmain.is-a-geek.net/
Operating System Development
« Reply #5 on: 15 November 2002, 21:41 »
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 ]

Someone please remove this account. Thanks...

beltorak0

  • Member
  • **
  • Posts: 223
  • Kudos: 0
    • http://www.angelfire.com/realm/beltorak
Operating System Development
« Reply #6 on: 15 November 2002, 10:08 »
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 ]

from Attrition.Org
 
quote:
Like many times before, Microsoft is re-inventing the wheel and opting for something other than round.

-t.


voidmain

  • VIP
  • Member
  • ***
  • Posts: 5,605
  • Kudos: 184
    • http://voidmain.is-a-geek.net/
Operating System Development
« Reply #7 on: 15 November 2002, 10:27 »
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 ]

Someone please remove this account. Thanks...

voidmain

  • VIP
  • Member
  • ***
  • Posts: 5,605
  • Kudos: 184
    • http://voidmain.is-a-geek.net/
Operating System Development
« Reply #8 on: 15 November 2002, 11:49 »
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 ]

Someone please remove this account. Thanks...

Kintaro

  • Member
  • **
  • Posts: 6,545
  • Kudos: 255
  • I want to get the band back together!
    • JohnTate.org
Operating System Development
« Reply #9 on: 15 November 2002, 13:50 »
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...

Stryker

  • VIP
  • Member
  • ***
  • Posts: 1,258
  • Kudos: 41
Operating System Development
« Reply #10 on: 16 November 2002, 02:41 »
Well what I was thinking of doing was something like...

Make a .com file that doesn't use dos interrupts.

Make a small assembly program that will go to a certain byte on a disk and start executing there.

use debug to put it on the floppy disk

add the signature with e 2fe aa 55

write the assembly goodie to the disk, use debug to move the .com file to the place i specified in the assembly program.

But the thing is I don't know how to compile a .com file that doesn't use dos interrupts. I'll be back in a while, going to check out those links.

voidmain

  • VIP
  • Member
  • ***
  • Posts: 5,605
  • Kudos: 184
    • http://voidmain.is-a-geek.net/
Operating System Development
« Reply #11 on: 16 November 2002, 04:54 »
Believe it or not, it's not as hard as you are making it. If you make the right kind of COM file in assembly all you have to do is write it to the floppy starting at the first sector (the hardware automatically loads and executes the first sector on disk). You can write your program to raw floppy using debug, but it's easier to use "dd" or "rawrite".

Now since it only automatically loads and executes the first sector of the floppy (512 bytes) if your program is bigger than that you may have to call a BIOS interrupt to load the 2nd through ?? sectors into memory and jump to that memory location to continue execution. But I can't remember if the programs I used to write were small enough to fit entirely on the first sector. The helloworld.asm example on that linuxassembly site I linked to you was only around 400 bytes when assembled.

And by the way, you don't "compile" a *.com file. You compile source into object code using a compiler (could be C, C++, Pascal, etc). You "assemble" assembly code into object code. And in both cases you use the linker to create the executable file from the object code (weather it be *.COM, *.EXE, a.out, elf, etc). But you probably already know this....
Someone please remove this account. Thanks...

Stryker

  • VIP
  • Member
  • ***
  • Posts: 1,258
  • Kudos: 41
Operating System Development
« Reply #12 on: 16 November 2002, 05:04 »
quote:
Originally posted by void main:
Believe it or not, it's not as hard as you are making it. If you make the right kind of COM file in assembly all you have to do is write it to the floppy starting at the first sector (the hardware automatically loads and executes the first sector on disk). You can write your program to raw floppy using debug, but it's easier to use "dd" or "rawrite".

Now since it only automatically loads and executes the first sector of the floppy (512 bytes) if your program is bigger than that you may have to call a BIOS interrupt to load the 2nd through ?? sectors into memory and jump to that memory location to continue execution. But I can't remember if the programs I used to write were small enough to fit entirely on the first sector. The helloworld.asm example on that linuxassembly site I linked to you was only around 400 bytes when assembled.

And by the way, you don't "compile" a *.com file. You compile source into object code using a compiler (could be C, C++, Pascal, etc). You "assemble" assembly code into object code. And in both cases you use the linker to create the executable file from the object code (weather it be *.COM, *.EXE, a.out, elf, etc). But you probably already know this....



Well I wasn't going for vocabulary, i just try to get my point across. i used to make programs with quickbasic (is it the good old days, or is it the undeducated days?) to make those .com files, anyone know if it uses dos interrupts? i made some pretty cool graphics programs, there would be an interesting operating system. i'll give it a shot.

Kintaro

  • Member
  • **
  • Posts: 6,545
  • Kudos: 255
  • I want to get the band back together!
    • JohnTate.org
Operating System Development
« Reply #13 on: 16 November 2002, 05:26 »
You could just make a bootable MS-DOS and have your program start in autoexec and use a Hex editor so it says "Starting StrykerOS" instead of "Starting Windows 95" or whatever it used to say!

Stryker

  • VIP
  • Member
  • ***
  • Posts: 1,258
  • Kudos: 41
Operating System Development
« Reply #14 on: 16 November 2002, 05:49 »
quote:
Originally posted by Ex Eleven / b0b 2.1:
You could just make a bootable MS-DOS and have your program start in autoexec and use a Hex editor so it says "Starting StrykerOS" instead of "Starting Windows 95" or whatever it used to say!


What? and live with the guilt of using microsoft products? i suppose i could, i've done it before, it's just that... isn't that basicly what microsoft did. bought dos from some guys and changed the banner?