Very simple booting code (http://blog.ghedini.me/post/6175473948/x86-booting-code)
; Very simple booting code | |
; | |
; Copyright (C) 2011 Alessandro Ghedini <alessandro@ghedini.me> | |
; -------------------------------------------------------------- | |
; "THE BEER-WARE LICENSE" (Revision 42): | |
; Alessandro Ghedini wrote this file. As long as you retain this | |
; notice you can do whatever you want with this stuff. If we | |
; meet some day, and you think this stuff is worth it, you can | |
; buy me a beer in return. | |
; -------------------------------------------------------------- | |
org 7C00h ; where BIOS wants me to be loaded | |
section .data | |
msg db "Fuck yeah!", 0 ; string to be printed | |
section .text | |
global start | |
start: | |
cli ; disable interrupts (not really needed) | |
mov SI, msg ; setup SI for our string (used by lodsb) | |
mov AH, 0Eh ; set BIOS int to print a char | |
print: | |
lodsb ; load the next byte to be printed | |
cmp AL, 0 ; if AL is 0 we are at the end of the string | |
je $ ; loop to infinity and beyond if AL is 0 | |
int 10h ; BIOS interrupt call (print byte) | |
jmp print ; re-do |
ASM=nasm | |
ISO=genisoimage -input-charset utf-8 -boot-load-size 4 -no-emul-boot -r | |
all: boot.iso | |
boot.bin: boot.asm | |
$(ASM) -o boot.bin boot.asm | |
boot.iso: boot.bin | |
mkdir iso/ | |
cp boot.bin iso/boot | |
$(ISO) -b boot -no-emul-boot -o boot.iso iso 2> /dev/null | |
run: boot.iso | |
qemu -boot once=d -cdrom boot.iso | |
clean: | |
rm -rf *.iso *.bin iso/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment