Get MBR ready, add hdimage target

This commit is contained in:
Nero 2019-09-17 22:41:39 +00:00
parent 7c4a618385
commit c70f388548
3 changed files with 79 additions and 7 deletions

View file

@ -151,6 +151,10 @@ load_sectors:
push cx
push dx
; add partition offset (required for HDD)
add ax, [fdc.po]
adc dx, [fdc.po+2]
; calculate CHS data
div word [cs:fdc.spt] ; ax:temp = (lba / spt)
inc dx ; dx:sector = (lba % spt) + 1

View file

@ -2,6 +2,11 @@
%define self 0x00600 ; 1 sector
%define prog 0x07C00 ; 1 sector
; FDC fields in VBR
%define spt (prog + 0x18)
%define nos (prog + 0x1A)
%define po (prog + 0x1C)
org self
cpu 8086
@ -26,15 +31,69 @@ init:
jmp 0:main
main:
mov bp, 0x0035
mov WORD [dap.blocknum], 1
mov bp, 0x3335
mov si, part1
mov cx, 4
.loop:
test BYTE [si], 0x80
jnz loadpart
add si, 0x10
loop .loop
jmp error
loadpart:
; transfer starting address into DAP
push si
add si, 0x08
mov di, dap.blocknum
movsw
movsw
pop si
; load sector
push si
mov si, dap
mov bp, 0x3336
mov ah, 0x42
stc
int 0x13
jc error
mov cx, [dap.blocknum]
int3
pop si
cmp BYTE [si+4], 0x01
jne jump
adjust:
push dx
mov bp, 0x3337
mov ah, 0x08
stc
int 0x13
jc error
; update sectors per track
xor ax, ax
mov al, cl
mov [spt], ax
; update number of sides
xor ax, ax
mov al, dh
mov [nos], ax
; update partition offset
push si
add si, 0x08
mov di, po
movsw
movsw
pop si
pop dx
jump:
jmp 0:prog
error:
mov ax, bp