Hi,
Msta wrote:o ya what do u mean hello world program?
A "hello world" program is a program that displays the words "Hello world" on the screen. It's one of the first things most people write when they learn a new programming language.
For example, for C, it'd be something like:
Code: Select all
#include "stdio.h"
void main(void) {
printf("Hello World\n");
}
The problem here is that the program is loaded into memory and run by an OS, and the compiler is typically designed (or configured) to create executables for the OS it's running on. For OS code there is no OS to do this, and the code needs to be designed to be started by the BIOS. This means you need to reconfigure your compiler to make it generate suitable code, but the BIOS expects to start 16-bit code and most modern compilers won't generate 16-bt code.
The next problem is that the "printf()" function just tells the compiler to send the string to "something else" (a terminal, a window, a video driver, etc). For an OS developer, "something else" doesn't exists until you write it.
Lastly, the C compiler uses standard libraries that talk to the OS (for things like memory management, timing, file I/O, etc). For an OS developer, these standard libraries aren't usually useful, and you either need to avoid using them or write your own.
If you add all this up, a "Hello World" program that takes 4 lines of simple code can easily become 100 lines of code, plus hassles with tools, linkers, etc.
The easiest way to write some "Hello World" boot code is to forget about the compiler completely, and hand code it in assembly language. For an example, I'd try something like this (for NASM):
Code: Select all
org 0x7C00
bits 16
jmp 0x0000:START
align 2
START:
xor ax,ax
mov bx,0xB800
mov ds,ax
mov es,bx
cli
mov ss,ax
mov sp,START
sti
mov ax,0x0003
int 0x10
mov si,helloString
xor di,di
mov ah,0x0F
lodsb
.l1:
stosw
lodsb
test al,al
jne .l1
jmp $
helloString: db 'Hello World',0
times ($$-$+0x1fe) db 0x00
dw 0xAA55
Of course after you've assembled it you'd need to find a way to install it somewhere. Floppy disks are a common choice (no-one likes messing up their hard drive). For this (on a Unix OS) I'd try something like "cat hello.bin > /dev/fd0". For Windows you'd need to download a utility like
Rawrite.
Now that you've seen the code, how much of it do you understand? I wrote this in 5 minutes (and didn't bother testing it), but how many hours of research would you have needed to write something similar and make sure it actually worked?
Msta wrote:my motivation is to beat bill gates is his world one OS i know it seens impossible but at am motivated enough.
This wouldn't be very hard if Bill Gates wrote Windows....
Unfortunately Bill Gates and thousands of programmers wrote Windows, and I'd guess Bill actually didn't write any of it himself. It took Microsoft around 5 years to write Vista, but half the code came from earlier versions of Windows and the device drivers were probably written by hardware manufacturers. This means 1000 programmers for 40 hours a week wrote about half of Vista in 5 years. Assuming each programmer worked for 50 weeks per year, this works out to 1000 * 40 * 50 * 5 hours to write half of Vista, or 20000000 hours to write all of it.
If you worked for 60 hours per week 52 weeks per year, then it'd take you about 6410 years. For a new OS there's no compatability hassles with old software (like getting applications designed for Windows XP to run under Vista), and you could probably cut a few corners and get it done in 5000 years. If your friends help you then it might take less time, but then you might waste a lot of time explaining what needs to happen and it might take longer...
Of course Microsoft has a variety of programmers with different knowledge - some know a lot about memory management, some know about file systems, schedulers, GUIs, etc. This means you'd need to become a specialist in every different area to get the same work done in the same number of hours. Also the time Microsoft took doesn't include learning any of it (almost all of the programmers had training and experience before they started working on Vista).
Also, Microsoft have facilities for testing the OS on a wide variety of hardware to make sure it all actually does work (and there's no annoying compatability problems). You'd need to do that yourself too...
Lastly, Microsoft has enough finances to do this sort of thing. If you're spending 60 hours a week every week, then you won't have time to work, won't be able to pay for internet access, electricity, food, rent, etc. At the moment you might be lucky enough to be living at home with your parents, but sometime in the next few thousand years they'll probably expect you to leave home and get a job. You won't be able to work on the OS for 60 hours every week for very long.
Linux is different, but not much. It's taken about 20 years to go from a half-baked Unix clone into what you see today, and most of it has been written by thousands of different volunteers and large companies (like IBM, Redhat, Intel, etc). A lot of the code is portable code that is recycled for several different Unix clones (Solaris, FreeBSD, OpenBSD, etc), and some of it probably even dates back to before Linux (the kernel) even existed.
Now I know I'm not being fair - there are people here who are hoping to eventually produce a commercial quality OS (including myself). The general idea is to produce enough of the kernel and framework to allow other programmers to easily write code for your OS (device drivers, applications, etc), and to make sure that the work you do is extremely impressive (and well documented) so that other programmers would actually want to write code for your OS. So far I've spent over ten years, and I'm expecting to spend another 10 years before anyone thinks it's impressive...
Msta wrote:so what programs do i need to make this OS?
for a 64 bit?
C++ programing language i think?
The most common combination is C with a little assembly language for the kernel and boot code. It's not the only combination of languages that could be used though - mostly it depends on what you're familiar with (although a little assembly language is required)...
Cheers,
Brendan