Skip to content

Instantly share code, notes, and snippets.

@yackx
Created December 10, 2014 10:56
Show Gist options
  • Star 13 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save yackx/a52010a05a430496ae11 to your computer and use it in GitHub Desktop.
Save yackx/a52010a05a430496ae11 to your computer and use it in GitHub Desktop.
Hello World bootloader in assembly language
;----------------------------------------------;
;
; A minimal bootloader that prints a hello world
; then halts.
;
; nasm -f bin hello-boot.asm -o hello-boot.bin
;
; @YouriAckx
;
;----------------------------------------------;
org 0x7c00 ; BIOS loads at this address
bits 16 ; 16 bits real mode
; Print a welcome message.
; We have no DOS nor Linux kernel here.
; Therefore, we will use bios int 0x10.
start:
cli ; disable interrupts
mov si, msg ; SI points to message
mov ah, 0x0e ; print char service
.loop lodsb ; AL <- [DS:SI] && SI++
or al, al ; end of string?
jz halt
int 0x10 ; print char
jmp .loop ; next char
halt: hlt ; halt
msg: db "Hello, World!", 0
;----------------------------------------------;
; Bootloader signature must be located
; at bytes #511 and #512.
; Fill with 0 in between.
; $ = address of the current line
; $$ = address of the 1st instruction
;----------------------------------------------;
times 510 - ($-$$) db 0
dw 0xaa55
@sarnobat
Copy link

Could you give compilation and run instructions?

@dluengo-rti
Copy link

You have compilation instructions in the first comment:
nasm -f bin hello-boot.asm -o hello-boot.bin

@patatetom
Copy link

hello, are there any special characters to erase the screen ?

@irodionzaytsev
Copy link

what is the difference between

  1. loop:
    and
  2. .loop
    ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment