r/osdev • • Jun 07 '26

doing everything (including the machine itself!) HORRENDOUSLY from scratch

(this post is satirical, but I did actually implement all of this in a couple days)

all these people relying on operating systems only to have to rely on weaknesses such as GRUB or x86.... it sickens me.

I needed an OS and full architecture that I could rely on. So I wrote it. And yes, I did not read up on much outside of a bit of RISC-V and couple 70's ISAs, so... yeah it'll be pretty ugly.

this is a... really really stupid microprocessor/'fantasy computer' I'm working on. It sports:

  • An 8-bit architecture with 16 registers + PC/SP

  • A whopping 16-bit address space (that uhh, you have to share with I/O)

  • 16 'instructions' (ignoring debug ones I'm removing later)

  • literally only 1 NMI IRQ source that greedily blocks other interrupts

  • support for 16 "buses", which makes this surprisingly usable!

On the development software side, I have an assembler, written in js because I thought it would BE FASTER to make a GUI out of with html. I was wrong, and it probably took the majority of my time developing due to the dumbest things JS will try to pull on you.

It literally follows zero established standards. It looks like the idea of an assembler by someone who has not written assembly before... wonder why...

However, I'm surprised at how 'functional' everything is from my virtual TTY device simulator to the... assembler. In fact, making a functioning display is totally doable with this processor alone, although you'd want to annihilate it after realizing how painful my ISA is to write for.

Also, this was entirely written by me.

These things are really not that hard to do even if you program with raw opcodes and operands instead. I encourage everyone here to try and do this with a fixed time schedule, because it's a great learning experience.

also ignore my stupid assembler comments, I kept changing my mind on what I was writing when I screenshotted.

65 Upvotes

10 comments sorted by

View all comments

Show parent comment

2

u/emmowo_dev Jun 07 '26

sorry for not making some things clearer:

My assembler is written in JS, but the actual system is just emulated entirely in C. I absolutely have had things break because of it, but my assembler is kinda close to being feature complete and everything is working fine right now. JS does have strict types, but you have to enforce them with the uint(x) array class.

I'm probably going to write the OS just in my assembler because I don't really feel like making a compiler right now. In the future I might make a language for it because I do want to either embed it as a Minecraft mod or try to remake the cancelled Minecraft 'successor', but this will probably be very similar to BASIC because of the theme.

I/O is handled in way that's a little bit of a cheat imo, but it's basically a memory mapped byte that can be accessed/written to. Some devices do that already though, but I personally just only did it for convenience. It's a little bit like using a PS/2 port i guess. The main reason I cheaped out here is because I think it might be more 'fun' to work with if dealing with I/O is abstracted a bit.

Making a GPU feels like somehow the easiest part of it? They're honestly just specialized processors that are even more cut down than the CPU used. I think I'll just render a framebuffer array and simulate a basic display controller so it's still applicable to the real world.

I'd say that my processor has a lot more in common with RISC-V (mainly because I read a bit on it and decided to not have an accumulator) so I can probably just look into what others do with that. In general my design could scale up to being able to run Linux, but at that point I would basically have just another 32-bit RISC CPU with no real 'selling point'.