https://akshatjoshi.com/i-wrote-a-pong-game-in-a-512-byte-boot-sector/ aksst | Akshat Joshi 512-Byte Boot Sector Pong Game 1 - Tech 512-Byte Boot Sector Pong Game Nov 14, 2025 2 min read written by - Akshat Joshi Sometime back, I set myself a crazy constraint: Load only one thing at boot - A Pong game that fits in one floppy disk sector -- 512 bytes. Why would I build this? I have played with Operating Systems and their workings by customizing them and tweaking their behavior. But this was about pushing constraints to the extreme. Can I have an OS which just loads one PONG GAME ? The challenge * No operating system. * No drivers. * No libraries. * Just raw x86 assembly, BIOS interrupts, and the video memory at 0xB800. The boot sector is the first 512 bytes a computer loads from disk. It has to end with the magic bytes 0x55 0xAA -- leaving only 510 bytes for actual code. I wanted to see if I could fit: * Player paddle (W/S keys) * CPU opponent * Ball with velocity * Scoring * Color toggle (C key) * Full reset (R key) After learning about Operating systems and the bootup flow, I finally managed to get a pong game running How it works! The game runs in 80x25 text mode (VGA mode 03h) using BIOS interrupt 10h. Everything is drawn directly into video memory (0xB800) with stosw -- of course no graphics libraries here. Controls W / S -- Move your paddle C -- Cycle paddle and midline colors R -- Reset game (reboots the sector) It's a deterministic ball-tracking logic. It checks the ball's Y position every frame: * If ball is above paddle - move up * If below - move down * Never goes off-screen Simple. Fast. Fits in 510 bytes. 0:00 /0:20 [0 ] 1x [100 ] Demo run Key Technical Highlights * Video Memory Direct Access Used ES:DI = 0xB800:0000 and rep stosw to clear screen in one instruction. * Efficient Positioning - imul di, [playerY], 160 - converts row to video offset (80 cols x 2 bytes per char). * Real-Time Input - BIOS int 0x16 with ah=1 (peek) - non-blocking keyboard check. * Physics & Collision - Ball velocity stored in single bytes ( ballVeloX, ballVeloY). Reversed on wall/paddle hit using neg byte . * Delay Loop - Used BIOS timer at 0x46C for frame pacing -- no hlt, no busy-wait burn. * Color Cycling - C key increments drawColour by 0x10 - rotates through 16 background colors. The Full Code The entire game is in one file: pong.asm Publicly available on GitHub: https://github.com/akshat666/-bootponggame Run It Yourself 1. Clone the repo 2. Assemble with NASM 3. Run in QEMU (or burn to USB and boot on old hardware) Akshat Joshi Senior Technical Specialist Washington DC Writing Performant Software Is More Critical Today Oct 1, 2025 2 min read Writing Performant Software Is More Critical Today Not long ago, most developers could get away with saying "hardware will catch up." If code wasn't perfectly optimized, faster processors, more memory, and better infrastructure usually masked inefficiencies. But today, things Read More Fortify Kubernetes with gVisor - Unleashing Deeper Security Mar 24, 2024 3 min read Fortify Kubernetes with gVisor - Unleashing Deeper Security Fortify Kubernetes with gVisor - Unleashing Deeper Security Read More aksst | Akshat Joshi (c) 2025 * Sign up Powered by Curiosity * Home * About * Profile Recent posts 512-Byte Boot Sector Pong Game Nov 14, 2025 Writing Performant Software Is More Critical Today Oct 1, 2025 Scribble objects u see Sep 25, 2025 More links * Sign up