Programming an OS

toast0

2[H]4U
Joined
Jan 26, 2010
Messages
2,314
I think there's been some Pascal operating systems, but I don't think I've seen BASIC of any flavor... You might look around on osdev.org's forums and see if anyone has been playing with those ideas.

The well trodden path is C with a bit of assembly to do the important things that C can't really do: getting the processor into the right mode, setting up stacks, switching stacks when switching tasks, some stuff around interrupts and user/kernel boundaries, poking at cpu registers, etc. You can do the same assembly work to support Pascal or BASIC instead, but there may not be examples to follow.
 

philb2

[H]ard|Gawd
Joined
May 26, 2021
Messages
1,202
I think there's been some Pascal operating systems, but I don't think I've seen BASIC of any flavor... You might look around on osdev.org's forums and see if anyone has been playing with those ideas.

The well trodden path is C with a bit of assembly to do the important things that C can't really do: getting the processor into the right mode, setting up stacks, switching stacks when switching tasks, some stuff around interrupts and user/kernel boundaries, poking at cpu registers, etc. You can do the same assembly work to support Pascal or BASIC instead, but there may not be examples to follow.
I went to the OSDEV.ORG website and I was a bit surprised to see IBM's System/390, but no Linix/UNIX or any other old OSs like DEC or Burroughs

Comment 2. The page on floppy disk controllers has an error. It does not mention 8" floppy disks. https://www.amazon.com/floppy-diskette-5-WORKING-GIFTS-PROMOTIONS/dp/B01N1JRQ0E Back in the day, I worked for the OEM drive company that was the market leader in 8" floppy drives.
 

LukeTbk

2[H]4U
Joined
Sep 10, 2020
Messages
3,643
I do not see why not do you have a compiler for the processor you want to make an OS on, having to make your own would be a big hurdle.
 

Yoseff

n00b
Joined
Sep 2, 2022
Messages
9
I think there's been some Pascal operating systems, but I don't think I've seen BASIC of any flavor... You might look around on osdev.org's forums and see if anyone has been playing with those ideas.

The well trodden path is C with a bit of assembly to do the important things that C can't really do: getting the processor into the right mode, setting up stacks, switching stacks when switching tasks, some stuff around interrupts and user/kernel boundaries, poking at cpu registers, etc. You can do the same assembly work to support Pascal or BASIC instead, but there may not be examples to follow.
What did you mean by the words: "trodden path"?
 

scottypippin

Weaksauce
Joined
Feb 28, 2022
Messages
78
What did you mean by the words: "trodden path"?
It is a phrase that indicates a method that many people have already done (i.e. a path that has had many travellers on it). See definition 2 at this link:

https://dictionary.cambridge.org/us/dictionary/english/well-trodden

toast0 is recommending that you use C with Assembly Language to write an OS because many people have already accomplished the task you want to accomplish with that method, so there are more resources for getting it done online.
 

gamerk2

[H]ard|Gawd
Joined
Jul 9, 2012
Messages
2,037
I mean, you *can*; you would have to bend over backwards to force BASIC especially to do things it wasn't designed to do, but you can certainly make a basic non-GUI OS written in it.
 

philb2

[H]ard|Gawd
Joined
May 26, 2021
Messages
1,202
I'm just curious. NOT being a troll. Why is anyone interested in writing an OS? If you do, do you try to support Windows or Linux APIs?
 

LukeTbk

2[H]4U
Joined
Sep 10, 2020
Messages
3,643
I'm just curious. NOT being a troll. Why is anyone interested in writing an OS? If you do, do you try to support Windows or Linux APIs?
During my computer degree we had to do a cpu for a very simple 8 bits assembly language (3 bits for the command limited to only 8 of times, 5 for the value), for a simple calculator by drawing it on an FPGA, then we had to run it in the physical world on an actual FGPA on a board with a text lcd and buttons. After that we had to do a very simple compiler from scratch to code simple basic like code instead to write it in assembly that would run on it. That was probably the most fun and memorable part for me, with the most learning by minutes.

Will usually be a mix of curiosity and learning, those low level affair can be incredibly eye-opening and hard to beat in that regard, they're just basic way memory, transistor, logic gate, stack vs heap, register vs L1 cache, CPU, pipeline, code, compiler, clock, pointer work that for some people just get assimilated quicker and in a more deep way by doing it than in theory.

Outside academic reason, you can have your own custom or rare simple hardware without an valid OS for a commercial workload you want to do or very ambitious people that think they could do better in some aspect (light, speed, security, not appeal-usefulness) for a specific scenario.
 
Last edited:

toast0

2[H]4U
Joined
Jan 26, 2010
Messages
2,314
Yeah, for fun mostly. If you have reasonable expectations, it's actually pretty easy to get started, make progress and learn a lot on the way. When you get tired of it, you can abandon it, no big deal; nobody's OS was going to make a huge splash anyway. (Exceptions exist, but not many)

Personally, my hobby OS does support a limited number of FreeBSD syscalls. My goal is to run a specific language environment on my own terms, and it was easier to run an existing binary compiled for FreeBSD than to put together enough stuff that I could compile the environment to run directly. My goal isn't to be a general purpose work-alike though. (And yes, you could probably do just about what I'm doing if you ran the language environment as init with an existing kernel, but that's not as much fun). There's some windows work alike projects out there too.
 

somebrains

[H]ard|Gawd
Joined
Nov 10, 2013
Messages
1,668
Start small.
Write something primitive for a terminal in a game.

Something simple like phaser3

Make it a behave like an OS.

That’ll start you on a path with goals you can attain with minimal resources and pain.
 

Eulogy

2[H]4U
Joined
Nov 9, 2005
Messages
2,955
I'm just curious. NOT being a troll. Why is anyone interested in writing an OS? If you do, do you try to support Windows or Linux APIs?
Why not? It doesn't even have to be writing a full fledged OS, but, could be jumping in and committing to the Linux kernel codebase. Or writing an abstraction layer. Or working on a new dev language and figuring out how it may interact directly with hardware. It's not as sexy work as other dev work, but, it's just as (or more) rewarding. Having an understanding of how things are working layers underneath you is always a good thing.
 

somebrains

[H]ard|Gawd
Joined
Nov 10, 2013
Messages
1,668
Create a joke OS for a device.
Think self aware salt shaker or toilet paper holder.

The 70s-80s era Radio Shack ethic is kinda cool.

Niche things like paintball gun control boards have applications that jumped to enhanced optics tied to sensors for hunting.

There’s an entire ecosystem of aftermarket car computing.

Any basic os that can export xml or json to a watch or phone has a hobbyist use case.

Pick a fun application and execute.
 

JoK

Weaksauce
Joined
Feb 24, 2017
Messages
86
People create OSs in Delphi and FreePascal all the time for professional or amateur reasons.

See this:

The most popular OS written in Pascal was Classic OS (not macOS) by Apple.

If you want to become a developer, learning to code an OS even as an exercise it is invaluable. You will learn so much about how computers operate and what sort of techniques are used to solve multithreading, multi-cores, networking, etc.
 

philb2

[H]ard|Gawd
Joined
May 26, 2021
Messages
1,202
People create OSs in Delphi and FreePascal all the time for professional or amateur reasons.

See this:

The most popular OS written in Pascal was Classic OS (not macOS) by Apple.

If you want to become a developer, learning to code an OS even as an exercise it is invaluable. You will learn so much about how computers operate and what sort of techniques are used to solve multithreading, multi-cores, networking, etc.

During my computer degree we had to do a cpu for a very simple 8 bits assembly language (3 bits for the command limited to only 8 of times, 5 for the value), for a simple calculator by drawing it on an FPGA, then we had to run it in the physical world on an actual FGPA on a board with a text lcd and buttons. After that we had to do a very simple compiler from scratch to code simple basic like code instead to write it in assembly that would run on it. That was probably the most fun and memorable part for me, with the most learning by minutes.

Will usually be a mix of curiosity and learning, those low level affair can be incredibly eye-opening and hard to beat in that regard, they're just basic way memory, transistor, logic gate, stack vs heap, register vs L1 cache, CPU, pipeline, code, compiler, clock, pointer work that for some people just get assimilated quicker and in a more deep way by doing it than in theory.

Outside academic reason, you can have your own custom or rare simple hardware without an valid OS for a commercial workload you want to do or very ambitious people that think they could do better in some aspect (light, speed, security, not appeal-usefulness) for a specific scenario.
My post was #13 in this thread. At this point, I (1) understand why developers code their own OS, and (2) given all the complexities of coding an OS, I have new-found respect for them.
 
Top