; boot05.asm -- bootstrap example with floppy access via BIOS ; Copyright (C) 2004 Steffen Solyga ; asmsyntax=nasm ; compile (on linux) with: nasm boot05.asm ; prepare floppy with: dd if=boot05 of=/dev/fd0 ; This program is free software; you can redistribute it and/or modify ; it under the terms of the GNU General Public License as published by ; the Free Software Foundation; either version 2 of the License, or ; (at your option) any later version. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; GNU General Public License for more details. ; ; You should have received a copy of the GNU General Public License ; along with this program; if not, write to the Free Software ; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. ; $Id: boot05.asm,v 1.2 2007-03-29 00:52:51 solyga Exp $ jmp 0x07c0:start ; set cs to 0x07c0, see boot00.asm start: ; set ds and es mov ax, cs mov ds, ax mov es, ax ; read 2nd floppy sector into ram at es:bx mov ah, 0x02 ; function: read sectors to es:bx mov al, 0x01 ; one sector mov dl, 0x00 ; drive number mov dh, 0x00 ; side number mov cl, 0x02 ; sector number mov ch, 0x00 ; track number mov bx, buffer ; buffer offset (bx=0x0200) int 0x13 ; BIOS: drive command ; print buffer ds:si (should be ascii code) mov si, buffer call print_string hang: jmp hang ; ----------------------------------------------------------------------------- print_string: cld mov di, 0xb800 ; video segment address mov es, di ; see boot04.asm xor di, di mov ah, 0x07 ; white on black print_loop: lodsb ; al= [ds:si], si+= 1 or al, al ; al= 0 ? jz print_done stosw ; [es:di]= ax, di+= 2 jmp print_loop print_done: ret ; ----------------------------------------------------------------------------- times 510-($-$$) db 0 ; fill the file with 0's dw 0xaa55 ; end the file with 55 aa ; remember: BIOS only reads 512 = 0x200 bytes for 1st stage ; i.e. until 0xaa55 buffer db 'This is floppy sector 2!', 0