Skip to content

Instantly share code, notes, and snippets.

@bejado
Created August 7, 2017 20:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save bejado/ee2feb20819f0ad5eeb2e0da5c3f8beb to your computer and use it in GitHub Desktop.
Save bejado/ee2feb20819f0ad5eeb2e0da5c3f8beb to your computer and use it in GitHub Desktop.
;
; A minimal boot sector that prints a 'Hello, world' message
;
; Initialize the stack pointer to the address 0x8000
mov bp, 0x8000
mov sp, bp
; Our boot sector has been loaded into memory at 0x7c00
; Set our es segment register to 0x07c0
; the address to print is calculated (segment * 16 + offset)
mov ax, 0x07c0
mov es, ax
; Call BIOS service to print a string
mov bp, hello
mov ah, 0x13 ; BIOS function 13 - print a string to the screen
mov al, 0x01 ; argument, update cursor after printing
mov bl, 0x0b ; argument, text color - magenta
mov cx, 12 ; argument, length of string (including the null terminator)
mov dh, 2 ; argument, row to put string
mov dl, 0 ; argument, column to put string
int 10h ; call BIOS service
; Loop until the end of time
jmp $
hello db 'Hello World'
; Padding and magic BIOS number
times 510-($-$$) db 0
dw 0xaa55
; So far we've filled 512 bytes. Fill more until we have an entire floppy-size worth's.
times (163840-512) db 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment