/* Copyright 2009 Charles Lohr under the MIT/X11 License. */ .code16 .global loader //Code runs from 0x7c00 .align 4 .org 0x00 //First, preserve drive letter. push %dx //Print out the letter 1, so we know it's working. mov $0x0e31, %ax mov $0x00, %bx int $0x10 //Copy over first few sectors of hard disk into ram. mov %al, %dl mov $0x0202, %ax //Read first sector. mov $0x0002, %cx //Track = 0, sector = 1 pop %dx mov $0x00, %dh //Head = 0, Drive = (whatever drive we started with) mov $0x0000, %bx mov %bx, %es //Segment of output mov $0x8200, %bx //Pointer of output int $0x13 // mov 0x130, %al //Print if was successful, if 0: success! mov %ah, %al mov $0x0e, %ah add $0x30, %al mov $0x00, %bx int $0x10 jmpl $0, $0x8200 //$main //Disk Signature .org 0x180 .long 0xefcdab89 .short 0x0000 //Disk entry 1. .byte 0x80 //Active partition 1 (and bootable) .byte 0x00 .byte 0x02 //CHS address .byte 0x00 .byte 0x56 //Partition type .byte 0x03 .byte 0x0b //CHS adderss of last sector .byte 0x00 .long 0x01 .long 0xc7 //Number of sectors in partition. //MBR Signature .org 0x1fe .byte 0x55 .byte 0xaa .section ".endprog", "ax" .extern end_of_kernel end_of_kernel: leave ret