Show HN: MyraOS – My 32-bit operating system in C and ASM (Hack Club project)

github.com

225 points by dvirbt 21 hours ago

Hi HN, I’m Dvir, a young developer. Last year, I got rejected after a job interview because I lacked some CPU knowledge. After that, I decided to deepen my understanding in the low level world and learn how things work under the hood. I decided to try and create an OS in C and ASM as a way to broaden my knowledge in this area.

This took me on the most interesting ride, where I’ve learned about OS theory and low level programming on a whole new level. I’ve spent hours upon hours, blood and tears, reading different OS theory blogs, learning low level concepts, debugging, testing and working on this project.

I started by reading University books and online blogs, while also watching videos. Some sources that helped me out were OSDev Wiki (https://wiki.osdev.org/Expanded_Main_Page), OSTEP (https://pages.cs.wisc.edu/~remzi/OSTEP), open-source repositories like MellOS and LemonOS (more advanced), DoomGeneric, and some friends that have built an OS before.

This part was the longest, but also the easiest. I felt like I understood the theory, but still could not connect it into actual code. Sitting down and starting to code was difficult, but I knew that was the next step I needed to take! I began by working on the bootloader, which is optional since you can use a pre-made one (I switched to GRUB later), but implementing it was mainly for learning purposes and to warm up on ASM. These were my steps after that:

  1) I started implementing the VGA driver, which gave me the ability to display text.
  2) Interrupts - IDT, ISR, IRQ, which signal to the CPU that a certain event occurred and needs handling (such as faults, hardware connected device actions, etc).
  3) Keyboard driver, which enables me to display the same text I type on my keyboard.
  4) PMM (Physical memory management)
  5) Paging and virtual memory management
  6) RTC driver - clock addition (which was, in my opinion, optional)
  7) PIT driver - Ticks every certain amount of time, and also  
  8) FS (File System) and physical HDD drivers - for the HDD I chose PATA (HDD communication protocol) for simplicity (SATA is a newer but harder option as well).
     For the FS I chose EXT2 (The Second Extended FileSystem), which is a foundational linux FS structure introduced in 1993. This FS structure is not the simplest,
     but is very popular in hobby-OS, it is very supported, easy to set up and upgrade to newer EXT versions, it has a lot of materials online, compared to other
     options. This was probably the longest and largest feature I had worked on.
  9) Syscall support.
  10) Libc implementation.
  11) Processing and scheduling for multiprocessing.
  12) Here I also made a shell to test it all.
At this point, I had a working shell, but later decided to go further and add a GUI! I was working on the FS (stage 8), when I heard about Hack Club’s Summer of Making (SoM). This was my first time practicing in HackClub, and I want to express my gratitude and share my enjoyment of participating in it.

At first I just wanted to declare the OS as finished after completing the FS, and a bit of other drivers, but because of SoM my perspective was changed completely. Because of the competition, I started to think that I needed to ship a complete OS, with processing, GUI and the bare minimum ability to run Doom. I wanted to show the community in SoM how everything works.

Then I worked on it for another 2 months, after finishing the shell, just because of SoM!, totalling my project to almost 7 months of work. At this time I added full GUI support, with dirty rectangles and double buffering, I made a GUI mouse driver, and even made a full Doom port! things I would've never even thought about without participating in SoM.

This is my SoM project: https://summer.hackclub.com/projects/5191.

Every project has challenges, especially in such a low level project. I had to do a lot of debugging while working on this, and it is no easy task. I highly recommend using GDB which helped me debug so many of my problems, especially memory ones.

The first major challenge I encountered was during the coding of processes - I realized that a lot of my paging code was completely wrong, poorly tested, and had to be reworked. During this time I was already in the competition and it was difficult keeping up with devlogs and new features while fixing old problems in a code I wrote a few months ago.

Some more major problems occurred when trying to run Doom, and unlike the last problem, this was a disaster. I had random PFs and memory problems, one run could work while the next one wouldn’t, and the worst part is that it was only on the Doom, and not on processes I created myself. These issues took a lot of time to figure out. I began to question the Doom code itself, and even thought about giving up on the whole project.

After a lot of time spent debugging, I fixed the issues. It was a combination of scheduling issues, Libc issues and the Qemu not having enough (wrongfully assuming 128MB for the whole OS was enough).

Finally, I worked throughout all the difficulties, and shipped the project! In the end, the experience working on this project was amazing. I learned a lot, grew and improved as a developer, and I thank SoM for helping to increase my motivation and make the project memorable and unique like I never imagined it would be.

The repo is at https://github.com/dvir-biton/MyraOS. I’d love to discuss any aspect of this with you all in the comments!

MisterTea 20 minutes ago

> ... and the Qemu not having enough (wrongfully assuming 128MB for the whole OS was enough).

Interesting that 128 MB was not enough. What did you do to find this issue and how are you measuring memory usage?

  • zeusk 4 minutes ago

    Double buffering a 4K 4bpp framebuffer itself is 64mb

Imustaskforhelp 20 hours ago

Hey, what an amazing project, bravo!

i would suggest to providing an iso or co-operating / looking into copy.sh which provides a large number of iso files which you can boot/play around with in the browser itself!

I was just today tinkering around with the ibm iso (exploring ibm) and others too, its always fun seeing new operating system!

I would love if you could, as I said, co-operate with copy.sh/v86 team to also include your iso and also provide iso files in github releases if possible

Source: https://copy.sh/v86/ Their github page : https://github.com/copy/v86

  • dvirbt 13 hours ago

    Thanks! I’ll look into it

whitehexagon 9 hours ago

Well done to you both. I'm only a 1/4 way down your useful TODO list after 12 months. I got bogged down in setting up IRQ vector tables on armv8 and took a huge detour to refresh my assembly skills. So I feel some of the journey you have been on. It takes a lot of patience, but can be very rewarding. Congrats!

  • dvirbt 9 hours ago

    Thank you and good luck!

noduerme 12 hours ago

This is quite amazing. I'm not anything like a serious C coder and haven't tried ASM. I've written "filesystems" in higher level languages (stuff that imposed a directory structure and metadata on what were just bins of data), so I was just looking at parts of your code at random. I think that triple pointer dir_entry_t*** is where my head exploded. Pretty amazing code, you should be very proud.

  • dvirbt 11 hours ago

    Thank you so much! I also made a few years ago an high level filesystem, which helped me during I made this one. I think the main difference is just that you need to work with drivers here for every disk operation.

scuff3d 18 hours ago

Damn man, this is awesome. This should land you a job damn near anywhere.

  • dvirbt 13 hours ago

    I really hope so! :)

LarsDu88 2 hours ago

Why VGA? I thought that protocol was particularly complicated

iezepov 12 hours ago

This feels like a fresh breath of air after all "I vibe coded this in 4 hours with Claude". Don't get me wrong, vibe coding had its own place, but it feels that projects like this one have become a rarity.

  • dvirbt 11 hours ago

    Thank you so much! That’s great to hear :) I feel like vibe coding projects like this, where the whole idea is to learn, vibe coding only makes it harder

Levitating 3 hours ago

How did you handle the graphics stack? Is DOOM playable on just software rendering?

  • dvirbt 3 hours ago

    Yes it is playable, I made an API for window graphics which gives every window the ability to render stuff on it’s surface. Then I used DoomGeneric to port my graphics API to Doom.

joexbayer 9 hours ago

Wow! Looks great! Id suggest checking out https://oshub.org/ it has a lot of hobby operating systems similar to this one.

maxpert 16 hours ago

Would recommend making a good youtube video with demo.

  • dvirbt 13 hours ago

    Yes, you are right. Do you think I should make the video technical or just a showcase?

    • iezepov 12 hours ago

      I'd go for something more technical, it feels like your target audience are hackers and not people shopping for an OS.

      But as always, it's your project done for yourself, so whatever feels like more fun recording.

      • saretup 12 hours ago

        On the other hand, for future employers you might wanna simply showcase the creation. They don’t have all the knowledge to appreciate the technicals or even the time to sit through it.

liqilin1567 15 hours ago

One of the biggest headaches for me is memory bugs when codebase grows large. So I 'm very interested: is this a headache for you too and how do you deal with this?

  • dvirbt 13 hours ago

    Yes, I think most of the time working on the project was working ob fixing memory bugs. GDB did a great job for me, have you tried to use it?

    • liqilin1567 10 hours ago

      Yeah, it's kind of annoying to fix these bugs for me, even though GDB is a great debugging tool.

      I always wonder if there are any techniques to avoid these kind of bugs in huge projects like OSes and browsers, otherwise it can be a nightmare

      • dvirbt 10 hours ago

        You can read about how NASA writes their code, I remember reading an article about it, which includes some great tips with how to avoid these kind of bugs. And I think also as other commenter said, new languages like Rust really help with avoiding bugs like that.

danielberdit 7 hours ago

What an amazing project! They don’t know what they missed.

userbinator 19 hours ago

wrongfully assuming 128MB for the whole OS was enough

If I were you I'd investigate why it needs so much. Keep in mind how much functionality older OSs had, and how much computing power they needed. Always good to see more OS projects nonetheless, but always remember that efficiency is important.

  • qingcharles 13 hours ago

    I had to just go find the details for the original 386 Unix server [1] I was running ~1995 because I thought it was running just fine on 8MB RAM, running an EFnet IRC node, FTP, MUDs and some early web apps. And... yep, 2 x 4MB SIMMs. Wild times. A single photo from my phone is three times that size.

    (I later took that PC home and used it as the test machine for my own hobby OS, which had to run from a 1.44MB floppy because there was no other sane way to transfer the dev images from my desktop)

    [1] One of these: https://www.computinghistory.org.uk/userdata/images/large/75...

    • dvirbt 13 hours ago

      Wow 8MB of ram… that’s really amazing! Which hobbyOS did you made?

      • qingcharles 35 minutes ago

        I named it Tinkerbell for some reason. It was kinda neat, it would boot directly into a windowed GUI. It lived at tinkerbell.org back in the 90s, but it seems it got missed by archive.org :(

  • dvirbt 13 hours ago

    Hey, it was enough for most basic stuff, but only running Doom or more advanced things would need above that.

    • userbinator 12 hours ago

      Doom was released in 1993. 128MB of RAM wouldn't even fit in the typical mobo of the time.

      http://www.dosdays.co.uk/topics/1993.php

      • sedatk 11 hours ago

        It only supported 320x200 as resolution at the time though.

      • dvirbt 11 hours ago

        Yes you are right, could be a memory leak somewhere, I’ll need to take a look at it

  • ethin 17 hours ago

    Eh, I tend to do the same (significantly over-estimate RAM requirements) since it's hard to know just how much RAM you'll need to begin with. Though usually for something like the stack I start with 256-512K.

tomjacobs 10 hours ago

wow, just wow

i did something similar when i was 18. got to the point of filesystem and mouse driver.

noone_youknow 10 hours ago

This is really great work! Always impressed to see hobby OS projects that get this far, well done.

That said, I’m once again reminded that we sorely need some updated resources for aspiring OS developers in 2025. Targeting 32-bit x86 and legacy devices that haven’t been “the norm” for decades suggests to me a heavy influence from resources like the osdev wiki which, while occasionally useful, are increasingly outdated in the modern world and lead to many questionable choices early on.

I have come to believe (through multiple iterations of my own OS projects) that there’s more value in largely ignoring resources such as osdev and focusing instead on first-principles design, correct layering, and building based on modern platforms (be that x86_64 or something else) and ignoring legacy devices like the PIT and PS2 etc.

I just wish we had good introductory documentation resources to reflect that, and that outdated resources weren’t overwhelmingly surfaced by search engines and now AI “summaries”.

None of the above is intended to take away from OPs achievement, which is fantastic, or from the work done over the years by the osdev community, who I’m sure largely do the best they can with what they have.

  • trollbridge 5 hours ago

    Yes. This stuff needs to be retargeted at x86_64 (on EFI, too) and ARM.

    Of course, also supporting i386 with legacy BIOS is OK, but it doesn't really get into the meat of what computers are doing now when you power them on.

    • sim7c00 3 hours ago

      trying to write about x86_64 (uefi, aslr, message signaled interrupts, lapic, acpi, iommu etc. etc.) and how to do platform init etc. to get ready for OS to execute. its a mess. its also hard to find someone who can proof read it and give meaningful feedback. (not many ppl enjoy this stuff i suppose :()

ktimespi 19 hours ago

This is beautiful.

  • dvirbt 13 hours ago

    Thank you!

ethin 17 hours ago

I did this (worked on an OS) from 2019-2022 or so, during college. Didn't get to user mode sadly. Did it in Rust because back then Rust was what I was really into. It was really fun! :) OS dev has always been fun/interesting :)

  • dvirbt 13 hours ago

    Absolutely, I learned so much from this project! Do you think I should make a new version in Rust?

    • vlovich123 11 hours ago

      That’s your call to make but I think it’ll be easier to write tests for the trickier parts and avoid the memory safety issues you flagged as being your biggest annoyance by isolating into unsafe that’s better unit tested (+ maybe cover with Miri to double check the unsafe code is still sound)

      • dvirbt 11 hours ago

        That’s a great idea, could’ve really improved the overall project structure

        • vlovich123 10 hours ago

          I’ll flag one thing which is that the page table stuff mentioned is unlikely something rust can protect you against - if you set up the wrong memory mapping that’s a higher level logic bug that would make rust unsound and result in weird failures. Rust can only protect you within the bounds of the memory model it defines for its abstract machine.

          • drougge 3 hours ago

            There's probably a lot of other memory bugs though. The first thing I looked at was the shell, and almost immediately I spotted an out of bounds write (input[n] = '\0' where n could be sizeof(input)).

            • vlovich123 31 minutes ago

              For sure. I’m highlighting the nastier parts of the system that Rust can’t help with. I love Rust but it’s important to understand its limitations, particularly for something like OS development. There’s a similar way to make Rust unsafe using 100% safe Rust where you poke /proc/self/mem to violate memory safety using safe IO :).

kbbgl87 19 hours ago

מגניב ממש אחי, תמשיך ככה

MarcelOlsz 19 hours ago

Awesome. Should take a look at TempleOS as well.

  • dvirbt 13 hours ago

    Thank, I’ll do!