File: building.md | Updated: 11/18/2025
Learn how to build bootOS from the assembly source code.
The simplest way to build bootOS:
nasm -f bin os.asm -l os.lst -o os.img
Parameters:
-f bin - Output raw binary format-l os.lst - Generate listing file-o os.img - Output filenameThis produces:
os.img - Bootable disk image (512 bytes)os.lst - Assembly listing with addressesThe included Makefile provides convenient targets:
# Build os.img
make
# Build and run in QEMU
make runqemu
# Clean build artifacts
make clean
After building, you'll have:
| File | Description | Size |
|------|-------------|------|
| os.img | Bootable OS image | 512 bytes |
| os.lst | Assembly listing | Variable |
The .lst file shows the assembled code with addresses:
00000000 31C0 xor ax,ax
00000002 8ED8 mov ds,ax
00000004 8EC0 mov es,ax
This is useful for:
The code specifies cpu 8086 for compatibility with the original IBM PC:
cpu 8086
This ensures no instructions newer than 8086 are used.
Key addresses defined in the source:
stack: equ 0x7700 ; Stack pointer
line: equ 0x7780 ; Buffer for line input
sector: equ 0x7800 ; Sector data for directory
osbase: equ 0x7a00 ; bootOS location
boot: equ 0x7c00 ; Boot sector location
bootOS must fit in exactly 512 bytes:
times 510-($-$$) db 0x4f
db 0x55,0xaa ; Boot sector signature
The last two bytes (0x55, 0xAA) are the boot sector signature required by the BIOS.
ls -l os.img
Should show exactly 512 bytes.
hexdump -C os.img | tail -1
Should end with 55 aa.
objdump -D -b binary -m i8086 os.img | head -20
Shows the disassembled machine code.
The repository includes counter.asm:
nasm -f bin counter.asm -l counter.lst -o counter.img
This is an example program that can run under bootOS.
To change where bootOS loads:
osbase constantTo add new commands:
commands tableTips for keeping code small:
Error: instruction not supported
cpu 8086 directive is presentError: phase error
Check image size:
stat -f%z os.img # macOS
stat -c%s os.img # Linux
Check boot signature:
tail -c 2 os.img | xxd
Should show: 55 aa