X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?p=ld45_start_nothing;a=blobdiff_plain;f=src%2Fboot%2Fboot.asm;h=693bba3f7a60472aaa4d7c2827caed8552fff5e4;hp=80a92a9df4a14227b529299a04ba5702be888903;hb=2cef53ae69622dc995fa0f4ac7a6d793684b4403;hpb=6a16a1c526937ee551f968901cb949d55e35ecda diff --git a/src/boot/boot.asm b/src/boot/boot.asm index 80a92a9..693bba3 100644 --- a/src/boot/boot.asm +++ b/src/boot/boot.asm @@ -1,10 +1,13 @@ ; vi:filetype=nasm ts=8 sts=8 sw=8: bits 16 - org 7c00h + section .boot -STACKTOP equ 7c00h +STACKTOP equ 7b00h +DRIVENO_ADDR equ 7bf0h LOADADDR equ 7e00h + extern _boot2_size + start: cli ; setup stack and the rest of the segment registers @@ -17,15 +20,15 @@ start: mov gs, ax ; dl: drive number, save it - mov [driveno], dl + mov [DRIVENO_ADDR], dl call get_drive_chs mov si, newline_str call putstr - ; load main program + ; load the second stage boot loader and jump there mov bx, LOADADDR ; es:bx <- destination - mov cx, BINSIZE + mov cx, _boot2_size add cx, 511 shr cx, 9 ; cx <- binsize in sectors mov [binsize_sect], cx @@ -56,7 +59,7 @@ start: get_drive_chs: push es mov ah, 8 - mov dl, [driveno] + mov dl, [DRIVENO_ADDR] xor di, di int 13h pop es @@ -115,7 +118,7 @@ read_sector: ; ah = 2 (read), al = 1 sectors mov ax, 0201h - mov byte dl, [driveno] + mov byte dl, [DRIVENO_ADDR] int 13h jnc .success @@ -159,14 +162,17 @@ putchar: ret + global sect_per_track sect_per_track: dw 18 + global num_cylinders num_cylinders: dw 80 + global num_heads num_heads: dw 2 + global heads_mask heads_mask: db 1 read_retries: db 0 -driveno: db 0 binsize_sect: dw 0 rderr_str: db 'read error',13,10,0