EXPERIMENT 003 · x86-os-experiment
boot sector
the assembly behind a BIOS hello world
Question
How does this boot sector get a message on screen using BIOS services? The actual assembly from an x86 learning experiment, alongside the behavior recorded in its learning notes. The Lab presents the source; it does not boot or emulate it.
Bench
src/main.asm · e9668891 / 5 · entry
org 0x7C00bits 16%define ENDL 0x0D, 0x0Astart: jmp mainNote
NASM is told to assemble 16-bit code with an origin of 0x7C00. The entry jumps to main; org describes the expected address rather than loading the code.
main: mov ax, 0 mov ds, ax mov es, ax mov ss, ax mov sp, 0x7C00 mov si, msg_hello call puts hlt.halt: jmp .haltNote
The source initializes DS, ES, and SS to zero, sets SP to 0x7C00, points SI at the message, and calls puts. After printing, it reaches hlt and a loop before the data.
puts: push si push ax.loop: lodsb or al, al jz .done mov ah, 0x0E mov bh, 0x00 int 0x10 jmp .loop.done: pop ax pop si retNote
The routine saves SI and AX, reads characters with lodsb, and stops at the zero terminator. BIOS interrupt 0x10 with AH = 0x0E prints each character. The saved registers are restored before returning.
msg_hello: db 'Hello, World!', ENDL, 0Note
The actual message is followed by ENDL (carriage return and line feed, defined in entry/) and a zero byte that terminates the string.
times 510 - ($ - $$) db 0dw 0xAA55Note
NASM pads the sector with zero bytes up to offset 510, then writes the word 0xAA55. Its little-endian byte order is 55 AA. This explains the source directive; it is not a compiled byte dump.
Hello, World!Important
The project’s learning notes record this output in QEMU. This page does not boot the source or reproduce that verification.
Sections group the source by purpose, not file order. Source comments are omitted.
Fidelity
sourcereal · revision e966889 · comments omitted
executionnone · not booted, not emulated
resultdocumented in project notes
Based on x86-os-experiment revision e966889. The Hello, World! result is documented in the project notes, not independently reproduced here.