Idiot codes a custom OS
Source: Idiot codes a custom OS, misterbob, 16:51, uploaded 2026-09-20.
misterbob builds BobOS from a boot sector into a system that can load a text editor and save files. The recurring test is printing “Bob”, but each repetition moves another responsibility away from firmware and into code he has written. The result is an educational prototype using legacy x86 BIOS boot, not a general account of how every modern operating system starts.
Getting beyond the boot sector
In the demonstrated setup, the BIOS loads a 512-byte boot sector at 0x7C00 and transfers control to it. Assembly initialises a stack, prints a string, and supplies the boot signature in the sector’s final two bytes. NASM produces the binary, a disk image holds it, and QEMU runs it.
The sector cannot contain everything that follows. The printing code moves into a separate kernel, while the bootloader uses a disk address packet and BIOS interrupt 0x13 to load more sectors. It then jumps to the kernel’s location. The visible output stays the same, but the initial sector now hands off to a larger program.
The next change enables a 32-bit C kernel. The machine begins in 16-bit real mode; misterbob chooses protected mode rather than a compiler targeting that older environment. His transition disables interrupts, loads a global descriptor table, sets the protected-mode control bit, performs a far jump, and establishes the segment registers and a larger stack.
BIOS text-output calls are no longer the chosen output mechanism. The kernel instead writes character and attribute values to VGA text memory beginning at 0xB8000. A linker script combines the assembly entry code and C kernel, while an explicit entry symbol removes the assumption that the first C function in the binary will happen to be the right one.
Rebuilding the services ordinary programs expect
Freestanding C makes the kernel easier to extend, but it does not supply a hosted standard library. BobOS adds its own integer types, character and string output, string length, memory copying and filling, comparison helpers, and boolean definitions. These small functions make later features possible without requiring every caller to manipulate display memory directly.
Keyboard input uses hardware ports through inline assembly. A polling loop waits for input, reads scan codes, and maps them to characters using material from the OSDev community. This is deliberately simple and inefficient. A shell then recognises commands to print a message, clear the screen, or shut down, while the creator’s Discord community develops a competing system for his earlier Bob-16 architecture.
Adding shell commands soon reaches a limit: BobOS has no persistent storage interface. Further port helpers read and write disk sectors, with 16-bit transfers used for the disk data. A test writes “Bob” into sector 64 and reads it back, establishing that the program can change the disk rather than just its working memory.
Turning sectors into files
BobFS links sectors to represent files and directories. A file header stores its name and metadata, while the final two bytes of a sector identify the next sector when the contents need more space. A directory contains addresses of file or directory headers. A bitmap in the filesystem’s first 16 sectors records whether sectors are free or allocated.
The filesystem enables directory creation and navigation, listing contents, reporting the working directory, and creating files. These operations supply the setting for the first separate application, Bob’s Useless Text Editor, abbreviated BEAUT.
Loading a program and saving its work
Most early shell commands are branches inside the kernel. BEAUT instead tests the ability to load another binary and call its entry point. BobOS places it at the fixed address 0x200000, uses a linker script to put the entry function first, casts the address to a function pointer, and calls it. Returning from that function returns to the shell. This is a minimal loading convention, without the process isolation or general executable loading expected from a mature system.
The editor searches the working directory for a filename and loads its contents into a buffer. Its deliberately rough saving strategy deletes an existing file after loading it, then recreates it when the editor exits; a new file stays in memory until that same exit. The design therefore leaves a clear failure case if execution stops before saving. Backspace and arrow-key handling are implemented for the editor even though the shell still lacks them, and Escape finishes the edit.
The final demonstration writes text in BEAUT, saves it through BobFS, and returns control to BobOS. The achievement is the chain connecting boot code, a C kernel, device access, storage, a filesystem, and a separately loaded program. The creator leaves moving the remaining shell commands and expanding the operating system to later work.
References
- OSDev Wiki, cited as a resource for operating-system development and keyboard input.
- Operating-system development tutorial playlist, linked in the description.