Created
December 10, 2014 10:56
-
-
Save yackx/a52010a05a430496ae11 to your computer and use it in GitHub Desktop.
Hello World bootloader in assembly language
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;----------------------------------------------; | |
; | |
; 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 |
You have compilation instructions in the first comment:
nasm -f bin hello-boot.asm -o hello-boot.bin
hello, are there any special characters to erase the screen ?
what is the difference between
- loop:
and - .loop
?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Could you give compilation and run instructions?