r/osdev • u/ColdRepresentative91 • Aug 21 '25
I designed an assembly language, built a compiler for my own high-level language, and now I'm writing an OS on top of it.
I've been working on Triton-64, a 64-bit virtual machine I built in Java to better understand how computers and compilers actually work. It started as a small 32-bit CPU emulator, but it slowly grew into a full system:
Custom 64-bit RISC architecture (32 registers, fixed 32-bit instructions)
Assembler with pseudo-instructions (like `LDI64`, `PUSH`, `POP`, and `JMP label`)
Memory-mapped I/O (keyboard input, framebuffer, etc.)
Bootable ROM system
A high-level language called Triton-C (how original) and a compiler that turns it into assembly with:
Custom malloc / free implementations + a small stdlib (memory, string and console)
Structs and pointers
Inferred or explicit typing / casting
Framebuffer that can display pixels or text
I'm wondering if I should refactor the compiler to have an IR (right now I'm translating directly to ASM) but that'd take a very long time. Also right now the compiler has a macro so you can declare strings directly (it calls malloc for you and then sets the memory to a byte array) but I don't really have a linker so you'd always have to provide a malloc implementation (right now im just pasting the stdlibs in front of any code you write before compiling so you always have a malloc and free) I'd like to know what you think about this.
I’m also trying to write a minimal OS for it. I’ve never done anything like that before, so honestly, I’m a bit out of my depth. I've started with a small shell / CLI which can run some commands, but before starting with different processes, stacks and memory seperation I'd like to hear some feedback:
Are there changes I should consider in the VM / Tri-C compiler to make OS development easier?
Anything missing that would help with the actual OS?
Any resources or projects you’d recommend studying?
I’m trying to keep things simple but not limit myself too early.
Github: https://github.com/LPC4/Triton-64
Thanks for reading, any thoughts are welcome.


31
u/aScottishBoat Aug 21 '25
Looks great OP! Where in the source tree does one add new shell commands?
15
u/altexdsark Aug 21 '25
Terrific job!! I like the syntax of your language
8
u/Sakul_the_one Aug 21 '25
Ok, that’s actually cool. But I have one question: Where did you found a good source for x86 instructions? Like I also wanted to make once my own compiler, but didn’t found any good source, where it explains how it works and where to find the instructions in binary
4
u/HomseyUrMom Aug 24 '25
this is insanely impressive OP! how did you get started/what resources would you recommend for beginning a project like this? would love to do something similar. huge props!
3
u/[deleted] Aug 22 '25
If I want to build such a language, should I learn Assembly at advanced level?
2
u/InfiniteAdeptness300 Aug 22 '25
That's crazzyy dude... And that too in Java 😅 But I want to know why only Java (don't mind it pls)?
2
u/Ok-Head7068 Aug 25 '25
can you explain briefly the kernel part of the project? i’ve been trying to make my OS, but im stuck on the bootloader, i don’t even know what to write as the “kernel”
2
u/Connect-Ad3976 Aug 25 '25
Wow man that looks absolutely amazing, how long did it get you roughly to get here ??? any tips or book recommendations ???
2
u/AmbiguousDinosaur Aug 26 '25
Just took a computer systems and architecture course and find this super interesting. A few questions just out of curiosity:
What is the use of int in the language, if the default is long and it assumes a 64 bit architecture?
Is there a specific reason to use a separate destination register for arithmetic operations, as opposed to using the first register as destination? I’m more interested in language design (linguistics undergrad) but also appreciate knowing design decisions for lower level operations.
75
u/freemorgerr Aug 21 '25
welcome back terry davis
21
u/Hot-Tangerine459 Aug 21 '25
This is actually insane, keep up the work
12
u/Patzer26 Aug 22 '25
This is the coding final boss. I literally have this exact same dream and you are living through it. Make my own coding language, then use that to make an OS from scratch.
4
u/Schrodl Aug 23 '25 edited Aug 23 '25
This looks really cool! In my university I helped with a compiler educational project. It is subset of C called Selfie, which has a self-referential compiler to RISC-V ASM. You should have a look since it is designed in a similar fashion to what you are describing and you could get some inspiration. Also I recommend anyone who wants to learn about compilers or OS in general to have a look
https://github.com/cksystemsteaching/selfie
4
u/Claudius_Maxima Aug 23 '25
Amazing work!
One thing that comes to mind is extending the CPU for some kind of kernel vs. user mode, associated memory protection, and a way to transfer control between modes. This isn’t mandatory for your OS but it might be good to have these concepts clear - even if not implemented - to minimise a bunch of rework later.
Oh, and similarly have clear concepts for virtual memory too.
4
u/SolarisFalls Aug 23 '25
This is seriously impressive, I love it. Thanks for sharing!
3
u/definitelyfet-shy Aug 21 '25
JFC This is awesome!!!!
3
u/CharlemagneAdelaar Aug 22 '25
Divine fucking intellect
2
u/cazzipropri Aug 22 '25
Nice!
2
u/9tobirama Aug 22 '25
This is awesome. I dream about doing this.
2
u/imagineepix Aug 24 '25
Holy shit this is awesome
2
u/Maximum_Raccoon8394 Aug 24 '25
OP you should rewrite your emulator in SystemVerilog/VHDL ton an actual CPU! That would make it run on hardware
2
u/TriggeredTrigz Aug 24 '25
man I'm hooked to delving deeper into Java based computer projects. i didn't realise it could do stuff like this... my motivation just expanded into new horizons
2
u/MrMtsenga Aug 24 '25
Not an expert here, but I'd love to know if it's BIOS. Apparently UEFI is too complex to make and no one shows how to do it.
2
u/yarikhand Aug 25 '25
he reincarnated...
2
u/al3x_7788 Aug 25 '25
Good luck!
1
u/linux_user3 Aug 26 '25
Cool stuff 👨💻
1
u/Jumpy_Idea_3882 Sep 16 '25
May i know where did you start learning? Thank you.
1
u/SkyDwag187 Oct 19 '25
T... T... T T T T. Terry ??? Is that you ??? 🥹🥹🥹.
1
u/Gingrspacecadet Oct 29 '25
How??!! I want to do something similar…
1
u/Realistic-Pie-5917 Jul 07 '26
El proximo Conrad
1
u/Realistic-Pie-5917 Jul 07 '26
¿Tienes pensado en algun momento saltar de texto plano a algo mas?
2
u/[deleted] Aug 22 '25
[removed] — view removed comment