"Bare-metal development at the highest privilege level."
x86-RealShell is a minimalist bare-metal interactive shell developed in x86 Assembly (Real Mode). The project operates at the Ring 0 privilege level (DPL 00), where the code interacts directly with the silicon without the abstractions of a modern operating system. This project was built to explore fundamental concepts of computer architecture, hardware interrupts, and memory management.
- Two-Stage Bootloader: Overcomes the 512-byte MBR limit by loading the second stage from Sector 2 of the disk into RAM address
0x8000. - VGA Video Driver: Direct manipulation of video memory at
0xB8000for screen clearing and color control. - Keyboard Driver (PS/2): Interception of Scan Codes via I/O Port
0x60with ASCII translation using a lookup table. - Interface Security: Implementation of a logic lock on the Backspace key to prevent visual interface corruption using interrupt
0x10, AH=0x03. - Modularization: Code organized into reusable modules (
.asm) using the%includedirective.
.
├── src/
│ ├── boot/
│ │ └── boot.asm # Stage 1: Boot sector loader
│ └── kernel/
│ ├── kernel.asm # Stage 2: Entry point and main loop (Shell)
│ ├── keyboard.asm # Input driver (Keyboard)
│ └── screen.asm # Text output functions
├── bin/ # Compiled binaries (.bin)
└── run.bat # Automation script to compile/run in QEMU.
- NASM (Netwide Assembler)
- QEMU (Hardware Emulator)
Simply run the automation script to compile the stages, merge the binaries, and start the emulation:
./run.bat- The BIOS loads the first 512 bytes (
boot.asm) at physical address0x7C00. boot.asmuses BIOS interruptint 0x13to read the second stage (the Shell) from the disk and move it to0x8000.- Control is transferred via
jmp 0x8000, starting the interactive environment in real mode.
The shell operates in polling mode, monitoring the status register of the 8042 keyboard controller (Port 0x64). When bit 0 is active, indicating data is ready, the code reads the Scan Code from port 0x60 and uses a mapping table to convert the electrical signal into a human-friendly ASCII character for screen output.
This project was developed as part of independent Low-level studies, focusing on:
- Reverse Engineering and Binary Analysis.
- Low-level Driver Development and I/O Port manipulation.
- Register and Stack management in x86 Assembly.
Developed by 0xRobert de Souza Lages.
Interested in high-performance systems, hardware, and what happens under the hood.