Skip to content

Instantly share code, notes, and snippets.

@rain-1
Created September 30, 2018 10:16
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rain-1/52a0be541364d0212a8b526396503c7a to your computer and use it in GitHub Desktop.
Save rain-1/52a0be541364d0212a8b526396503c7a to your computer and use it in GitHub Desktop.
GNU assembly bootloader
.code16
.global _start
_start:
cli
xor %ax, %ax
mov %ax, %ds
mov $msg, %si
cld
loop:
lodsb
or %al, %al
jz hang
mov $0x0E, %ah
mov $0x00, %bh
int $0x10
jmp loop
hang:
jmp hang
msg:
.string "BOOTLOADER"
.byte 0x0D, 0x0A, 0x00
.org 510
.byte 0x55
.byte 0xAA
#!/bin/bash
set -ex
rm -f boot.o boot.elf boot.bin
i686-elf-as -o boot.o boot.S
i686-elf-ld -Ttext 0x7C00 -o boot.elf boot.o
objcopy -O binary boot.elf boot.bin
@vineethrp
Copy link

we do cli, should we be enabling interrupts later using sti

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