How to write a simple operating system in Assembler?
ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
If you find that interesting, look into KolibriOS. This is a project with the OS and all applications totally coded in assembler. Nothing I have seen is faster. I believe the source IS available, along with coding advice and standards for the project.
(Because, why try to reinvent the horse.)
If you find that interesting, look into KolibriOS. This is a project with the OS and all applications totally coded in assembler. Nothing I have seen is faster. I believe the source IS available, along with coding advice and standards for the project.
(Because, why try to reinvent the horse.)
I usually prefer the small, learning, programming, for education. I would be keen to find the thompson first universe made operating system, which was in assembler on first pc.
In the early mainframe days, everything was coded in assembler. In fact, the Unix® operating system was the first system to be coded in a (purpose-built) high-level language which they called "C."
The architecture of Linux is typical now: the optimizing compiler is left to do what it does best, except for certain specific fragments which are coded in architecture-specific assembly code sections. (A very few routines such as the "trampoline" are coded as .a files.)
Fortunately, thanks to virtual machines, it is very easy to dabble in operating systems – including pure-assembly ones.
In the early mainframe days, everything was coded in assembler. In fact, the Unix® operating system was the first system to be coded in a (purpose-built) high-level language which they called "C."
The architecture of Linux is typical now: the optimizing compiler is left to do what it does best, except for certain specific fragments which are coded in architecture-specific assembly code sections. (A very few routines such as the "trampoline" are coded as .a files.)
Fortunately, thanks to virtual machines, it is very easy to dabble in operating systems – including pure-assembly ones.
First Assembler, then, BCPL then A, after came B, and came C. The problem was that the system was taking too much resource.
First Assembler, then, BCPL then A, after came B, and came C. The problem was that the system was taking too much resource.
Those were in the days when memory was either magnetic cores (which is where "core memory" was originally coined) or little 1bit x 1K or less chips. A 5Meg hard drive took a spindle with multiple 21" disk/platters.
We came a LONG way VERY fast!
I remember when the IBM 1130 was our powerhouse machine. 16K core, with disk, tape, AND card readers!
Those were in the days when memory was either magnetic cores (which is where "core memory" was originally coined) or little 1bit x 1K or less chips. A 5Meg hard drive took a spindle with multiple 21" disk/platters.
We came a LONG way VERY fast!
I remember when the IBM 1130 was our powerhouse machine. 16K core, with disk, tape, AND card readers!
Not so much, since this is still today compatible:
Code:
#include <stdio.h>
#include <stdlib.h>
int main(){
printf( "HELLO WORLD \n" );
return 0;
}
Actually, it would be interesting to try to compile it on PDP-7 and linux and check how long it takes to compile.
Not so much, since this is still today compatible:
Code:
#include <stdio.h>
#include <stdlib.h>
int main(){
printf( "HELLO WORLD \n" );
return 0;
}
Actually, it would be interesting to try to compile it on PDP-7 and linux and check how long it takes to compile.
I agree, but even better would be to port the assembler for one of those operating systems to a more modern machine, tweak the I/O to make it more usable, and watch how it would FLY on modern hardware. I wonder how long the assemble times would be! The OS source was a LOT smaller. OK, now I want to go back and look at my KolibriOS stuff and pull new code to play with!
I agree, but even better would be to port the assembler for one of those operating systems to a more modern machine, tweak the I/O to make it more usable, and watch how it would FLY on modern hardware. I wonder how long the assemble times would be! The OS source was a LOT smaller. OK, now I want to go back and look at my KolibriOS stuff and pull new code to play with!
First Assembler, then, BCPL then A, after came B, and came C. The problem was that the system was taking too much resource.
Too much human time!
Remember the "80/20 rule." 80% of the time is spent in 20% of the code. 80% of the code is routine, 20% isn't. And, so on.
An optimizing compiler today can produce better code than people can, because microprocessors are designed to be programmed by compiled code, and chip manufacturers work closely with compiler writers – and write compilers of their own – in order that those compilers will produce "optimally optimized" instruction sequences.
Only a tiny fraction of the source-code in Linux is architecture-specific, therefore written using asm {...} code-blocks or outright assembly-files for any given architecture. Most of the code "is boring, but needs to run as efficiently as possible." The use of assembler is actually contra-indicated in those cases, because a compiler will generate better code than you would write.
By writing the software in "C" or in some other purpose-built high-level language, the authors are able to produce better object code, much faster. Furthermore, most of the time, their work can be cross-compiled to any desired target platform without any changes whatsoever.
Nevertheless: I encourage you to pursue your "old-school way" project. Many large and very-important operating systems were built entirely in assembler, and Your Author worked on one of them. But, in due time, IBM switched to writing in a compiler which, so far as I know, they never released to the public.
Last edited by sundialsvcs; 04-20-2017 at 08:23 AM.
I know I'm dating myself when I say this, but I got to see a core-memory transistor-based machine in service the University of Tennessee at Knoxville. They were running the machine because it could run an Autocoder emulator, for an IBM 1401. This is how they did their accounting, at the time.
I still have my "card saw," and I'm a card-carrying member of the "dropped a box of punched cards all over the floor and had to [mechanically ...] sort them back in order" club.
Those were interesting times. Everything was new, everything was changing right before your eyes, and you were there. No matter how ubiquitous and powerful computers have since become, I believe that there is no substitute for that life-experience.
We haven't had anything that interesting since a Scandinavian college kid spent one winter writing an operating system in his dorm room . . . and named it after himself.
Last edited by sundialsvcs; 04-20-2017 at 08:32 AM.
Those were interesting times. Everything was new, everything was changing right before your eyes, and you were there. No matter how ubiquitous and powerful computers have since become, I believe that there is no substitute for that life-experience.
We haven't had anything that interesting since a Scandinavian college kid spent one winter writing an operating system in his dorm room . . . and named it after himself.
Impressive. Do you have free access possibilities or can see/visit early machines? (e.g. PDP-7 or PDP-11 in your lab)
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.