/* set to 16 bit mode (80x86 begin in real mode) text section to 0 original code at http://www.netspace.net.au/~gok/resources/ Modified by Stellios Keskinidis April 2001 this is a boot loader that displays hello world at bootup and loops until the user presses 'q' Makefile ---------------------------------------------------------- install: bootsect dd if=./bootsect of=/dev/fd0 bs=512 count=1 bootsect: boot.o objcopy -O binary boot.o bootsect boot.o: boot.s as -o boot.o boot.s clean: rm bootsect boot.o ---------------------------------------------------------- */ .code16 .text .org 0x00 .global _start _start: mov $0x07C0,%ax mov %ax,%ds call booting xor %dx,%dx /* test if dx == 0 */ call working call idleloop ret /* display booting message */ booting: mov $boot,%si call message ret /* display message in %si */ message: cld /* set direction to increment */ lodsb or %al,%al jz done mov $0xE,%ah mov $7,%bx int $0x10 jmp message done: ret /* display hello world message */ working: mov $hellow,%si call message call waitenter jmp working ret /* TODO: gracefully exit it just disables interrupts and halt the cpu, ctrl-alt-del won't even work, you'll have to hit the reset button */ exit: mov $bye,%si call message int $0x20 cli hlt ret /* get keypress from user, if a 'q' (113) then halt */ waitenter: movw $cont,%si call message xor %ax,%ax /* Sets AH=0 and AL=0 */ int $0x16 /* Wait for keypress */ cmp $113,%al je exit cmp $13,%al mov %ax,%si call message jnz working ret /* wait for an interrupt to occur */ idleloop: hlt jmp idleloop /* all our messages that get displayed */ boot: .ascii "Loading ....." .byte 10, 13, 10, 13, 0 hellow: .ascii "Hello World " .byte 33, 10, 13, 0 cont: .ascii "press 'q' to quit or any other key to continue" .byte 10, 13, 0 bye: .ascii "bye." .byte 10, 13, 0 /* Fill with zero until boottag */ padlen: .byte boottag - . .fill 10,1,0 /* times 510-($-$$) db 0 */ /* the boot loader */ .org 410 boottag: .word 0xAA55