//----------------------------------------------------------------- // ourfirst.s // // This application merely displays a message that we can see // on the screen, to confirm that our boot-loader has worked. // // to assemble: $ as ourfirst.s -o ourfirst.o // and to link: $ ld ourfirst.o -T ldscript -o ourfirst.b // and install: $ dd if=ourfirst.b of=/dev/sda4 seek=1 // // NOTE: This program begins executing with CS:IP = 1000:0002 // // programmer: ALLAN CRUSE // written on: 09 SEP 2008 //----------------------------------------------------------------- .code16 # executes in 'real-mode' .section .text .word 0xABCD # application's signature begin: # preserve our bootstrap-loader's stack-address mov %sp, %cs:retptr+0 # preserve SP register mov %ss, %cs:retptr+2 # preserve SS register # switch to our own stack (for safely handling interrupts) mov %cs, %ax # address program data mov %ax, %ss # with SS register lea tos, %sp # setup a new stacktop # get current video page-number in BH mov $0x0F, %ah # get_display_mode int $0x10 # invoke BIOS service # get current cursor-location (row,col) in (DH,DL) mov $0x03, %ah # get_cursor function int $0x10 # invoke BIOS service # write message-string at current page's cursor-position mov %cs, %ax # address program data mov %ax, %ds # with DS register mov %ax, %es # also ES register lea msg, %bp # point ES:BP to string mov len, %cx # character-count in CX mov att, %bl # color-attribute in BL mov $0x1301, %ax # write_string function int $0x10 # invoke BIOS service # return control to our bootstrap loader lss %cs:retptr, %sp # restore loader's stack lret # give control to loader msg: .ascii "\r\n Hello from memory-arena at 0x10000 \n\n\r" len: .word . - msg # length of this message att: .byte 0x0B # bright cyan upon black retptr: .word 0, 0 # holds SS and SP values .align 16 # insures word alignment .space 512 # space for stack to use tos: # label for our stacktop .end # nothing more to assemble