X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=boot%2Fboot.asm;fp=boot%2Fboot.asm;h=2b74db8265dd34740ed1795d4ada85145d570aeb;hb=be7535b3af9d7ecc5581a7b3d325f5caec87b24f;hp=5b82c2d37d43d858d6e37cffd2dd3779aa8a1f36;hpb=06692d6c927aae4e6f06efd1e401d005839c1e5f;p=eightysix diff --git a/boot/boot.asm b/boot/boot.asm index 5b82c2d..2b74db8 100644 --- a/boot/boot.asm +++ b/boot/boot.asm @@ -3,10 +3,9 @@ bits 16 section .bootsect -extern _stage2_start -extern _stage2_end +extern _stage2_start_seg +extern _stage2_size -stacktop equ 7b00h boot_driveno equ 7b00h num_read_tries equ 7b06h ; 2 bytes sect_pending equ 7b08h ; 2 bytes @@ -58,12 +57,12 @@ start: xor ax, ax mov ds, ax mov es, ax - mov ss, ax - mov gs, ax - mov fs, ax jmp 00:.setcs .setcs: - mov sp, stacktop + ; put the stack high + mov ax, 0x7f00 + mov ss, ax + xor sp, sp mov [boot_driveno], dl ; query sectors per track @@ -84,20 +83,15 @@ start: mov word [num_heads], 2 .querydone: -; load the rest of the code at 7e00h - mov ax, _stage2_end - sub ax, _stage2_start + ; load the rest of the code high + mov ax, _stage2_size add ax, 511 mov cl, 9 shr ax, cl inc ax mov [sect_pending], ax - mov ax, _stage2_start - shr ax, 1 - shr ax, 1 - shr ax, 1 - shr ax, 1 - mov es, ax ; destination segment 7e0h to allow loading up to 64k + mov ax, _stage2_start_seg + mov es, ax ; destination segment mov word [destptr], 0 mov word [start_sect], 1 ; start from sector 1 to skip boot sector mov word [cur_cyl], 0 @@ -170,10 +164,15 @@ start: add [destptr], ax jnz .rdloop - ; loaded sucessfully, reset es back to 0 and jump -.done: xor ax, ax + ; loaded sucessfully, load segment registers and jump +.done: mov ax, _stage2_start_seg + mov ds, ax mov es, ax - jmp _stage2_start + push ax + xor ax, ax + push ax + retf + .fail: add sp, 2 ; clear num_sect off the stack dec word [num_read_tries]