LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-17-2017, 04:11 AM   #1
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,657

Rep: Reputation: 255Reputation: 255Reputation: 255
How to write a simple operating system in Assembler?


Hello,

There is a very nice website on how to learn to create your own, simple, operating system in Assembler:
http://mikeos.sourceforge.net/write-your-own-os.html

A fantastic website.
 
Old 04-17-2017, 06:26 AM   #2
NevemTeve
Senior Member
 
Registered: Oct 2011
Location: Budapest
Distribution: Debian/GNU/Linux, AIX
Posts: 4,864
Blog Entries: 1

Rep: Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869Reputation: 1869
Cool!
 
Old 04-17-2017, 06:40 AM   #3
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,631

Rep: Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696
Quote:
Originally Posted by Xeratul View Post
Hello,

There is a very nice website on how to learn to create your own, simple, operating system in Assembler:
http://mikeos.sourceforge.net/write-your-own-os.html

A fantastic website.
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.)
 
Old 04-17-2017, 08:05 AM   #4
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,657

Original Poster
Rep: Reputation: 255Reputation: 255Reputation: 255
Quote:
Originally Posted by wpeckham View Post
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.
 
Old 04-17-2017, 09:07 AM   #5
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
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.
 
Old 04-17-2017, 09:12 AM   #6
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,657

Original Poster
Rep: Reputation: 255Reputation: 255Reputation: 255
Quote:
Originally Posted by sundialsvcs View Post
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.
 
Old 04-17-2017, 10:09 AM   #7
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,631

Rep: Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696
Quote:
Originally Posted by Xeratul View Post
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!
 
Old 04-17-2017, 10:12 AM   #8
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,657

Original Poster
Rep: Reputation: 255Reputation: 255Reputation: 255
Quote:
Originally Posted by wpeckham View Post
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.
 
Old 04-17-2017, 10:16 AM   #9
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,631

Rep: Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696Reputation: 2696
Quote:
Originally Posted by Xeratul View Post
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!
 
Old 04-17-2017, 01:04 PM   #10
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,657

Original Poster
Rep: Reputation: 255Reputation: 255Reputation: 255
Quote:
Originally Posted by wpeckham View Post
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 prefer this one which is more minimalist ... http://mikeos.sourceforge.net/shot-5.png
 
Old 04-17-2017, 03:18 PM   #11
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
Quote:
Originally Posted by Xeratul View Post
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.
 
Old 04-20-2017, 07:32 AM   #12
serafean
Member
 
Registered: Mar 2006
Location: Czech Republic
Distribution: Gentoo, Chakra
Posts: 997
Blog Entries: 15

Rep: Reputation: 136Reputation: 136
For information on generic OS/hw concepts, I go to osdev.org for reference.
 
Old 04-20-2017, 08:26 AM   #13
sundialsvcs
LQ Guru
 
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 10,659
Blog Entries: 4

Rep: Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941Reputation: 3941
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.
 
Old 04-20-2017, 04:09 PM   #14
Xeratul
Senior Member
 
Registered: Jun 2006
Location: UNIX
Distribution: FreeBSD
Posts: 2,657

Original Poster
Rep: Reputation: 255Reputation: 255Reputation: 255
Quote:
Originally Posted by sundialsvcs View Post

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)


herewith you can find an interesting presentation on the board on how to make own OS
https://www.youtube.com/watch?v=1rnA6wpF0o4

Last edited by Xeratul; 04-21-2017 at 11:01 PM.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I write my own operating system someday? Phillyguy Programming 17 08-24-2016 09:29 AM
Is that possible that operating system user i able to write in different directories? lauralinux Linux - Newbie 6 07-03-2015 11:49 PM
LXer: dd Utility - Write and Backup Operating System IMG files on Memory Card with Mac OS X LXer Syndicated Linux News 0 02-26-2015 02:33 AM
im trying to write a operating system TOOOOOOOOOOOOOL Linux - Newbie 10 07-23-2013 10:12 PM
How Do You Make A Simple Linux Operating System Jamie Kugelmann Linux - Newbie 19 10-05-2008 08:38 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:25 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration