Reorder disk access and fix missing si setting

This commit is contained in:
Nero 2020-04-16 23:04:06 +02:00
parent 27e4dec580
commit 70a675442a

View File

@ -143,32 +143,16 @@ drvoff: dd 0 ; partition offset
drvpos: dd 0 ; absolute physical sector number drvpos: dd 0 ; absolute physical sector number
buffer: times 512 db 0 buffer: times 512 db 0
; Select active drive ; Convert between drive number and BIOS dl
; IN dl drive number A=0, B=1, C=2, ... ; Bidirectional mapping
select: mov [drvnum], dl ; 0 <-> 0, 1 <-> 1, 2 <-> 0x80, 3 <-> 0x81
push es dnconv: mov cx, 7
xor ax, ax ror dx, 1
push cs rol dl, 1
pop es dncl: rcl dl, 1
stosw rcr dh, 1
stosw loop dncl
stosw xchg dh, dl
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
@ -183,9 +167,9 @@ read: ; this uses the EBIOS extensions
xor ax, ax xor ax, ax
push ax push ax
push ax push ax
mov ax, [drvpos+2] mov ax, [cs:drvpos+2]
push ax push ax
mov ax, [drvpos] mov ax, [cs:drvpos]
push ax push ax
; dword target buffer ; dword target buffer
@ -203,25 +187,41 @@ read: ; this uses the EBIOS extensions
mov si, sp mov si, sp
mov ah, 0x42 mov ah, 0x42
mov dl, [drvnum] mov dl, [cs:drvnum]
call dnconv call dnconv
stc stc
int 0x13 int 0x13
add sp, di add sp, di
ret ret
; Convert between drive number and BIOS dl ; Select active drive
; Bidirectional mapping ; IN dl drive number A=0, B=1, C=2, ...
; 0 <-> 0, 1 <-> 1, 2 <-> 0x80, 3 <-> 0x81 select: mov [cs:drvnum], dl
dnconv: mov cx, 7 ret
ror dx, 1 push es
rol dl, 1 xor ax, ax
dncl: rcl dl, 1 push cs
rcr dh, 1 pop es
loop dncl mov si, drvoff
xchg dh, dl stosw
stosw
stosw
stosw
pop es
call read
; load bpb from buffer to bpb
ldbpb: push ds
push es
mov ax, cs
mov ds, ax
mov es, ax
mov si, buffer+0x0B
mov di, bpb
mov cx, bpb_len
rep movsb
pop es
pop ds
ret ret
init: cli init: cli
@ -232,7 +232,6 @@ init: cli
xor sp, sp xor sp, sp
call dnconv call dnconv
int 3
call select call select
int 3 int 3
mov ax, [cs:bpb+bpb_ss] mov ax, [cs:bpb+bpb_ss]