Implement loading BPB from media

This commit is contained in:
Nero 2020-04-15 23:51:07 +02:00
parent 23ddd6b41a
commit 27e4dec580

View File

@ -139,12 +139,36 @@ setint: push es
bpb: times bpb_len db 0 bpb: times bpb_len db 0
drvnum: db 0 drvnum: db 0
align 4 align 4
drvpos: dd 0 drvoff: dd 0 ; partition offset
drvpos: dd 0 ; absolute physical sector number
buffer: times 512 db 0 buffer: times 512 db 0
; Select active drive ; Select active drive
; IN dl drive number A=0, B=1, C=2, ... ; IN dl drive number A=0, B=1, C=2, ...
select: mov [drvnum], dl select: mov [drvnum], dl
push es
xor ax, ax
push cs
pop es
stosw
stosw
stosw
stosw
pop es
call read
call ldbpb
ret
; load bpb from buffer to bpb
ldbpb: push ds
push es
mov ax, cs
mov si, buffer+0x0B
mov di, bpb
mov cx, bpb_len
rep movsb
pop es
pop ds
ret ret
; Set sector number ; Set sector number
@ -207,17 +231,11 @@ init: cli
mov ss, ax mov ss, ax
xor sp, sp xor sp, sp
xor dh, dh
call dnconv call dnconv
int 3
call select call select
int 3
xor ax, ax mov ax, [cs:bpb+bpb_ss]
xor dx, dx
call seek
call read
mov ax, [buffer+0x1FE]
int 3 int 3
main: push cs main: push cs