X86osdev
x86 OS development using Bochs emulator. MIT xv6, JamesM's kernel development tutorials (with some changes) & more
Install / Use
/learn @therealdreg/X86osdevREADME
x86 OS development using Bochs emulator (x86osdev)
Prerequisites: You need to know x86 assembly, C, GCC inline ASM, basic Linux and Windows cmd usage.
Index
- x86 OS development using Bochs emulator (x86osdev)
- Index
- Install Bochs
- Usage and Debug
- Bochs Software Magic Breakpoint
- Bochs Input and Output debugger macros - BochsConsolePrintChar and BochsBreak
- Advanced Bochs debugging
- How to modify a project - optional step
- boot code - bochs/x86osdev/boot_code/floppy.img
- Screen - bochs/x86osdev/screen/floppy.img
- GDT and IDT - bochs/x86osdev/gdt_idt/floppy.img
- IRQs and PIT - bochs/x86osdev/irqs_and_the_pit/floppy.img
- Paging - bochs/x86osdev/paging/floppy.img
- Heap - bochs/x86osdev/heap/floppy.img
- VFS and initrd - bochs/x86osdev/vfs_and_initrd/floppy.img
- Multitasking - bochs/x86osdev/multitasking/floppy.img
- User Mode (and syscalls) - bochs/x86osdev/user_mode/floppy.img
- Multi core startup - bochs/x86osdev/multi_core_startup/floppy.img
- xv6 - bochs/x86osdev/xv6_dregmod/
- Changelog
- More info
Install Bochs
For Windows all are included, just download this repo:
- https://github.com/therealdreg/x86osdev/archive/refs/heads/main.zip
For Linux you must install Bochs with debugger gui support + smp (--enable-smp, --enable-debugger and --enable-debugger-gui):
- https://bochs.sourceforge.io/doc/docbook/user/compiling.html
Usage and Debug
WARNING: wait and be patient, Bochs is slow
- Copy bochs/x86osdev/Project/floppy.img to bochs/
- Go to bochs/
- run bochsdbg.bat (For Linux ./bochsdbg.sh)
- Click Start
- Click Continue (First Breakpoint):

- When "Magic Breakpoint" text appears click Continue again (Second Magic Breakpoint):

IMPORTANT: When you read "Run" or "Run Bochs" it means Run bochs from bochsdbg.bat (For Linux ./bochsdbg.sh) script.
With first breakpoint its possible debug bootloader code from start.
With second magic breakpoint its possible debug kernel code from start.
Debug commands: https://bochs.sourceforge.io/doc/docbook/user/internal-debugger.html
Bochs Software Magic Breakpoint
From our OS Code:
GCC:
asm volatile ("xchgw %bx, %bx");
NASM:
xchg bx, bx
Bochs Input and Output debugger macros - BochsConsolePrintChar and BochsBreak
From our OS Code:
//outputs a character to the debug console
#define BochsConsolePrintChar(c) outportb(0xe9, c)
//stops simulation and breaks into the debug console
#define BochsBreak() outportw(0x8A00,0x8A00); outportw(0x8A00,0x08AE0);
Advanced Bochs debugging
Commands supported by port 0x8A00
- 0x8A00: Used to enable the device. Any I/O to the debug module before this command is sent is sent will simply be ignored.
- 0x8A01: Selects register 0: Memory monitoring range start address (inclusive)
- 0x8A02: Selects register 1: Memory monitoring range end address (exclusive)
- 0x8A80: Enable address range memory monitoring as indicated by register 0 and 1 and clears both registers
- 0x8AE0: Return to Debugger Prompt. If the debugger is enabled (via --enable-debugger), sending 0x8AE0 to port 0x8A00 after the device has been enabled will return the Bochs to the debugger prompt. Basically the same as doing CTRL+C.
- 0x8AE2: Instruction Trace Disable. If the debugger is enabled (via --enable-debugger), sending 0x8AE2 to port 0x8A00 after the device has been enabled will disable instruction tracing
- 0x8AE3: Instruction Trace Enable. If the debugger is enabled (via --enable-debugger), sending 0x8AE3 to port 0x8A00 after the device has been enabled will enable instruction tracing
- 0x8AE4: Register Trace Disable. If the debugger is enabled (via --enable-debugger), sending 0x8AE4 to port 0x8A00 after the device has been enabled will disable register tracing.
- 0x8AE5: Register Trace Enable. If the debugger is enabled (via --enable-debugger), sending 0x8AE5 to port 0x8A00 after the device has been enabled will enable register tracing. This currently output the value of all the registers for each instruction traced. Note: instruction tracing must
Related Skills
node-connect
341.2kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
84.5kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
341.2kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
commit-push-pr
84.5kCommit, push, and open a PR
