simpleOS is a complete operating system written entirely in x86 assembly language, designed to run on legacy PC hardware in real mode. This document details the technical architecture and implementation decisions behind the system.
The system begins execution at physical address 0x7C00, following the standard PC boot convention. The boot sector:
- Sets up segment registers (DS, ES, SS) to 0
- Initializes stack pointer to 0x7C00
- Loads the kernel from disk sectors into memory at 0x7E00
- Transfers control to the kernel entry point
At 0x7E00, the kernel performs:
- Video mode setup (80x25 text mode via BIOS INT 10h)
- Professional UI rendering with border graphics
- System timer initialization
- Interrupt vector configuration
0x0000-0x03FF: Interrupt Vector Table
0x0400-0x04FF: BIOS Data Area
0x0500-0x7BFF: Free Conventional Memory
0x7C00-0x7DFF: Boot Sector (512 bytes)
0x7E00-0x9FFF: Kernel Code & Data
0xA000-0xFFFF: Video Memory & System Use
Text Mode Graphics:
- Utilizes BIOS INT 10h for all video operations
- Implements custom border drawing using box-drawing characters (0xC4, 0xB3, etc.)
- Maintains cursor position tracking for proper text wrapping
- Supports centered text rendering for headers
Input System:
- Keyboard input via BIOS INT 16h
- Real-time key processing without blocking
- Support for special keys (arrows, function keys)
- Input buffer management with backspace handling
The shell implements:
- Command parsing and dispatch system
- String comparison for command recognition
- Dynamic command registration
- Built-in help system with command documentation
All applications follow a consistent pattern:
application_entry:
call clear_content_area
; Display instructions
; Initialize application state
; Main application loop
; Clean exit back to shellWhile simpleOS doesn't implement a full file system, it provides:
- Disk sector reading via BIOS INT 13h
- Memory-based file buffers for applications
- Simple data persistence within session
- Static memory allocation for system structures
- Application-specific buffers (snake positions, notepad content, etc.)
- Careful segment:offset addressing throughout
Common Game Components:
- Game state structures (position, score, lives)
- Main game loops with timed updates
- Collision detection systems
- Input handling for game controls
- Rendering systems for game objects
Implementation Details:
- Linked list structure for snake segments
- Food generation with position validation
- Collision detection with walls and self
- Direction-based movement logic
- Growing mechanism when food is consumed
Technical Features:
- Adjustable game speed based on direction
- Border-constrained play area
- Random number generation via system timer
Physics System:
- Ball movement with simple vector mathematics
- Paddle collision detection and angle calculation
- AI opponent with imperfect tracking
- Score tracking and win conditions
Rendering:
- ASCII art paddles and ball
- Real-time position updates
- Score display during gameplay
Alien Management:
- Grid-based alien positioning
- Wave movement patterns
- Progressive difficulty increases
- Alien shooting AI with random timing
Combat System:
- Player bullet management
- Alien destruction scoring
- Collision detection for hits
- Game over conditions
Word System:
- Pre-defined word dictionary
- Random word selection
- Input validation and scoring
- Lives management system
User Interface:
- Real-time typing feedback
- Score and lives display
- Word presentation system
Arithmetic Engine:
- Integer arithmetic operations
- Multiplication and division support
- Error handling for division by zero
- Number parsing from string input
Interface:
- Interactive prompt system
- Result formatting and display
- Continuous calculation mode
Text Editing:
- Character buffer management
- Cursor position tracking
- Line wrapping and newline handling
- Backspace and delete functionality
Display System:
- Text rendering with scroll boundaries
- Cursor positioning feedback
- Edit mode indicators
- INT 10h: Video services (text mode, cursor control)
- INT 16h: Keyboard input services
- INT 1Ah: Time and date services
- INT 13h: Disk services
- INT 15h: System services (memory detection)
- print_string: Basic string output
- print_string_wrapped: Word-wrapped text output
- read_string: Buffered keyboard input
- clear_content_area: Screen management
- compare_string: String comparison utility
- Careful management of 640KB conventional memory
- Efficient data structure design
- In-place algorithm implementations
- 16-bit addressing limitations
- Segment:offset arithmetic throughout
- No memory protection features
- Minimal use of expensive operations (division, multiplication)
- Efficient screen updates to reduce flicker
- Optimized game loops for smooth gameplay
- Clear, readable assembly code
- Consistent coding patterns
- Minimal abstraction layers
- Responsive input handling
- Clear visual feedback
- Intuitive command structure
- Demonstrates fundamental computer architecture concepts
- Shows direct hardware interaction
- Illustrates low-level programming techniques
- Protected mode operation
- Simple file system implementation
- Basic multi-tasking support
- Hardware interrupt handling
- Text editor with file save/load
- Simple BASIC interpreter
- Network connectivity
- Sound support via PC speaker
simpleOS represents a complete, functional operating system built from first principles using x86 assembly language. It demonstrates that even with the constraints of real mode and limited resources, a rich computing environment with games, utilities, and a professional interface is achievable through careful design and efficient coding practices.
The system serves as both a practical demonstration of low-level programming concepts and a foundation for further exploration in operating system development. Its modular architecture allows for continuous expansion while maintaining the simplicity and performance characteristics that make assembly programming uniquely powerful.
simpleOS - A testament to understanding computers at their most fundamental level.