003 / boot sector
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.
src/main.asm · e966889
Select a section to inspect its source and notes. Source comments are omitted.
entry/
org 0x7C00
bits 16
%define ENDL 0x0D, 0x0A
start:
jmp mainNASM 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.
initialization/
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 .haltThe 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.
print loop/
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
retThe 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.
message/
msg_hello: db 'Hello, World!', ENDL, 0The actual message is followed by ENDL (carriage return and line feed, defined in entry/) and a zero byte that terminates the string.
sector ending/
times 510 - ($ - $$) db 0
dw 0xAA55NASM 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!The project’s boot-sector learning notes record this output in QEMU. This page does not boot the source or reproduce that verification.
Based on x86-os-experiment revision e966889. The Hello, World! result is documented in the project notes, not independently reproduced here.