
Show HN: OSle – A 510 bytes OS in x86 assembly by shikaan
A tiny and mighty boot sector OS.
osle-demo.mov
OSle is a real-mode OS that fits in a boot
sector.
It’s written in x86 assembly and, despite its tiny size (only 510 bytes), it
packs essential features like:
- Shell: Run commands and builtins.
- File System: Read, write, and find files on the system.
- Process Management: Cooperatively spawn child processes.
- Userland Software: Comes with pre-built software and an
SDK to write your own.
Check out the online demo to see it in action!
OSle includes a tiny Software Development Kit (SDK) that includes
definitions and a toolchain to create your own OSle programs.
Follow the step-by-step tutorial to write your first program!
To develop OSle and OSle programs you will need the following tools:
Installation instructions
Install dependencies using Homebrew:
brew install nasm brew install bochs
Install dependencies using your local package manager, e.g., on Debian:
These recipes will compile OSle and use the SDK to compile and bundle
all the pre-built programs. Using start
will also run bochs right away.
# build and run osle on bochs make start # or # build osle make osle # use QEMU to run it qemu-system-i386 -fda osle.img
# ensure you have a working OSle image at osle.img make osle # compile your source to generate my_file.bin sdk/build my_file.s # bundle my_file.bin into the osle.img image sdk/pack my_file.bin # run it! qemu-system-i386 -fda osle.img
Write the built image to a device using dd
:
Warning
The following action can damage your hardware. We take no responsibility for
any damage OSle might cause.
# generate an OSle image at osle.img make osle # write it on a device sudo dd if=osle.img of=/dev/YOUR_DEVICE bs=512 count=1
Feel free to explore the issues and
pull requests to contribute or request
features.
7 Comments
yjftsjthsd-h
Well that's cool. Does the name stand for something?
sim7c00
cool stuff, like you still fit quite a bit in there too, 510 bytes can be tricky.
if you want an ahci controller to 'see' it, it will need partition table too, which will make it even less bytes (or maybe cleverly encoded)
fuzzfactor
On projects like this, where the IMG is small enough, I would think it was ideal to include osle.img with the zip.
mycatisblack
Very cool!
I have to ask: what would the total size be if the package included the bios functions?
Also: what could be done if the size limit were 8kbyte like the mask-rom bios days?
Thanks for pointing me towards the bosh emulator.
revskill
All professors should be doing this decades ago right ?
nathell
Some related stuff:
In 2004, Gavin Barraclough’s mini-OS [0] won the IOCCC, packing a 32-bit multitasking operating system for x86 computers, with GUI and filesystem, support for loading and executing user applications in ELF binary format, with PS/2 mouse and keyboard drivers, VESA graphics, a command shell, and an application into 3.5 KB of highly obfuscated C code.
In 2021, Justine Tunney wrote SectorLISP [1], a Lisp implementation that fits into a bootsector and is able to run McCarthy’s metacircular evaluator.
[0]: https://www.ioccc.org/2004/gavin/index.html
[1]: https://github.com/jart/sectorlisp
90s_dev
Two questions:
1. I just saw how str_print is implemented. It's so short even though it's asm. Is this why nul-terminated strings were so popular and became the default in C? Would pascal strings be much longer/uglier/harder in asm?
2. Why is str_print repeated in multiple files? How would you do code sharing in asm? I assume str_print is currently not "static" and you'd have to make it so via linking or something, and then be able to get its address using an asm macro or something?