MBR « Hello »

Fichier assembleur source:

	mov ah, 0x0e  ; AH == 0Eh : Write Character in TTY Mode
	              ; See https://en.wikipedia.org/wiki/BIOS_interrupt_call
loop:
	mov al, 'H'
	int 0x10      ; 10h : Video services
	mov al, 'e'
	int 0x10
	mov al, 'l'
	int 0x10
	mov al, 'l'
	int 0x10
	mov al, 'o'
	int 0x10
	mov al, ' '
	int 0x10
	jmp loop
times 510-($-$$) db 0
dw 0xaa55

Fichier Makefile:

name=hellokernel
target=$(name).bin
all: $(target)
$(target): $(name).S
	nasm -o $@ -f bin $^
clean:
	rm -f  $(target)
run: $(target)
	qemu-system-x86_64 -drive format=raw,file=$(target)
# No graphics (qui: CTRL-A X)
# qemu-system-x86_64 -curses -drive format=raw,file=$(target)

Fichier Makefile (version Docker):

name=hellokernel
target=$(name).bin
all: $(target)
$(target): $(name).S
	docker build -t $(name) .
	docker run -v `pwd`:/mnt $(name) nasm -o /mnt/$(target) -f bin /mnt/$(name).S
clean:
	rm -f $(target)
run: $(target)
	qemu-system-x86_64 -drive format=raw,file=$(target)

Dockerfile:

FROM debian
LABEL author="gas@mines.paris"
RUN apt-get update 
RUN apt-get install -y nasm
#CMD ["ls", "-al", "/mnt"]

Écriture sur une clef USB du bootloader sous Linux:

lsblk
sudo dd if=hellokernel.bin of=/dev/sdb