Implement current drive for user programs

This commit is contained in:
Nero 2021-01-04 23:29:50 +00:00
parent 7e2e91b2b7
commit 34023678a4
3 changed files with 25 additions and 26 deletions

View File

@ -24,17 +24,15 @@ init: cli
call dinit
pop dx
cmp dl, 0x80
jc .k
sub dl, (0x80-2)
.k: mov [defdrv], dl
call logdrv
mov word [0x21*4], int21
mov word [0x21*4+2], cs
mov word [curpsp], 0x1000
cmp dl, 0x80
jc .k
sub dl, (0x80-2)
.k: call setdd
mov dl, 0x37
mov ah, 2
int 0x21

View File

@ -1,22 +1,20 @@
section .bss
; default drive if field in FCB = 0
defdrv: resb 1
section .text
; Helper function: read the drive number from FCB,
; apply default if necessary,
; and make it current I/O drive
_setdrv: mov dl, [es:bx] ; A=1
test dl, dl
jnz .nofix
mov dl, [defdrv] ; A=0
inc dl
mov [es:bx], dl ; A=1
; now set as current i/o drive
.nofix: dec dl ; A=0 for dsksel
jmp logdrv
; set default drive for current process
; IN dl drive number
setdd: push ds
mov ds, [ss:curpsp]
mov [PSPDD], dl
pop ds
ret
; get default drive for current process
; OUT al drive number
getdd: push ds
mov ds, [ss:curpsp]
mov al, [PSPDD]
pop ds
ret
; Load root directory entry
; IN ax number of directory entry

View File

@ -31,8 +31,8 @@ stab: ; syscall table
dw err, sret ; console status
dw err, sret ; return version num
dw err, sret ; reset disks
dw err, sret ; select disk
dw err, sret ; open file
dw setdd, sret ; select disk
dw err, sretb ; open file
.end:
section .text
@ -56,6 +56,9 @@ PSPDS: resw 1
PSPBX: resw 1
PSPES: resw 1
; default drive
PSPDD: resb 1
section .text
; Load current PSP segment into DS