Writing an OS

IS SNK COOL?

  • YES

    Votes: 0 0.0%
  • NO

    Votes: 0 0.0%
  • ???

    Votes: 0 0.0%

  • Total voters
    0
Status
Not open for further replies.
Assembly code doesn't refer to a specific language. Its just a class of languages that are a human readable version of the underlying binary opcodes.

Different processor architectures have different assembly codes.

X86 assembly is different than PowerPC assembly is different than MIPS assembly etc etc.
 
This is a response I wrote recently to a thread about programming:
TheHeadFL said:
To really write an OS you are going to need to know your processors assembly inside and out.

You're also going to have to be very very good at C.

The true beginning of an OS is basically building a binary image that you can write to a floppy disk (or other bootable media). This binary image basically contains a few lines of assembly that direct the computer to begin loading the rest of the OS (specifically the interrupt handler) from the floppy disk or the hard drive.

Once the interrupt handler is in place in memory, the fence register in the CPU must be set so that user programs cannot overwrite the interrupt handler.

Next, the System Vector Call table (syscall) must be loaded. This would be generally your lowest level functions like console input and output. This would also be basic functions that handle basic disk access. These syscalls are generally written in C with built-in assembly routines. In these cases, the C files must not rely on any standard libraries. All syscalls can only consist of the most basic C language statements, no libraries.

The next step is to pass control over the machine over to whatever higher level layer exists. In most cases, there are many layers between the SVC table, interrupt handler, and the end shell/interface.

If you were writing an OS at this point, you would want to implement your own implementation of the C standard libraries (or download a working source) and get those running on your system.

At this point, you are ready to execute binaries compiled using a high-level language like C and the standard libraries. Generally you only want the OS kernel to run at this level. The kernel then, combined with the interrupt handler, sets up a multi-programming environment. This just means you enable the 'OS' to manage processes and threads, and if neccesary handle multiple processes and context switching.

Once you are this far you would also want to write drivers to wrap the assembly calls (or low level syscalls) that are required to interface with the rest of the system hardware. This includes, but is in no way limited to sound cards, high-resolution video adapters, mouse or keyboard input, and any other essential hardware.

Finally, once this is completely done, you could write a shell or some other interface. This could be as simple as a command line, or you could use your driver layer to render high resolution graphical video. Either way, you are writing the main process by which the user interacts with the OS, including input/output, and launching and managing other processes.

At this level, you've basically got a complete OS. Theoretically you could compile and run user programs at this point.

Of course, what I've described easily encompasses months if not years of work. An OS that implements what I've described could easily be thousands and thousands of lines of code.
 
anyway. . . . I am not intending to make this OS to be just like windows. . . . . . I need a basic OS that can run on at least my calulator for now. I have a TI83 plus calculator. That has the X86 processor I do believe. as soon as I get the basic OS written I was going to have a driver that runs the extention port, then put some cool devices the run off the port.
 
The TI83 does not run any kind of x86 processor.

It would be a custom Texas Instruments processor that is probably a special purpose mathematics processor. It would not be a general purpose processor like the x86.

I don't think you could really call anything that ran on a TI83 calculator an "OS" in any sense of the term. Its more like a shell.
 
when you list java as one of your potential choice for writing OS, offically you have no idea what your talking about.. try linux, it might do what you want, if not, start hacking away..
 
"We should be ToUcHiiiiiiiN....."

TheHeadFL said:
Assembly code doesn't refer to a specific language. Its just a class of languages that are a human readable version of the underlying binary opcodes.

Different processor architectures have different assembly codes.

X86 assembly is different than PowerPC assembly is different than MIPS assembly etc etc.
That's true, (I know this already) and like i said before, i wouldn't put native windows upcodes in there if i were making my own OS, just like i wouldn't have native Mac upcodes with a PowerPC. It's a common mistake.

Programming an OS is not nearly as easy as programming a simple program. You have to specify every signal of every pixel on the screen (If you're making GUI) program how to integrate within the video board, Chipset, CPU, Math Coprocessor, keyboard, (As well as any device and port connected to the computer. :() and and most importantly, Recorce fork.

I bet most of you never even heard of that before, but that's just the Mac term for it. (I forgot what it's called with PC :eek:)It's how CPU's separate files from folders. This is why it takes alot more than just one person to make any OS.
;)

when you list java as one of your potential choice for writing OS, offically you have no idea what your talking about.. try linux, it might do what you want, if not, start hacking away..
Like i said....
Java is programming language for Sun Microsystems servers with SPARC Architexture and Sun OS. If he wants to build a SUN computer, there ya go. (Though that's more than likely not going to happen.)
Linux was a good suggestion. Most distrebutions are FREE! :D


Please let me know when you wan't to start building handheald! ;) :cool:
 
All x86 processors would use the same assembly, regardless of whether they are Windows, Linux, BSD, or anything else.

The opcodes are the functions that the processor exposes for end user usage.... ADD, SUB, MUL, DIV, MOV, STO, LD, INT, etc.
 
Well to "build" a handheld of your own, you have to make some decisions with regards to the microprocessors, RAM, ROM, etc. you want to use. If you want to 'build" those from scratch, then you have to look into FPGA and learn a HDL like VHDL.

Once you have the h/w, then you can use C/C++ and assembly to code the OS.

Things for you to look up on Wikipedia:
FPGA
VHDL
Microprocessor
Microcontroller
C++
Assembly
RTOS (well you don't need a "real time" OS, but the topic RTOS will talk about the needed elements - e.g. scheduler)

I am sure the other guys will list more stuff :)
 
Status
Not open for further replies.
Back
Top Bottom