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 call dinit
pop dx 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], int21
mov word [0x21*4+2], cs mov word [0x21*4+2], cs
mov word [curpsp], 0x1000 mov word [curpsp], 0x1000
cmp dl, 0x80
jc .k
sub dl, (0x80-2)
.k: call setdd
mov dl, 0x37 mov dl, 0x37
mov ah, 2 mov ah, 2
int 0x21 int 0x21

View File

@ -1,22 +1,20 @@
section .bss
; default drive if field in FCB = 0
defdrv: resb 1
section .text section .text
; Helper function: read the drive number from FCB, ; set default drive for current process
; apply default if necessary, ; IN dl drive number
; and make it current I/O drive setdd: push ds
_setdrv: mov dl, [es:bx] ; A=1 mov ds, [ss:curpsp]
test dl, dl mov [PSPDD], dl
jnz .nofix pop ds
mov dl, [defdrv] ; A=0 ret
inc dl
mov [es:bx], dl ; A=1 ; get default drive for current process
; now set as current i/o drive ; OUT al drive number
.nofix: dec dl ; A=0 for dsksel getdd: push ds
jmp logdrv mov ds, [ss:curpsp]
mov al, [PSPDD]
pop ds
ret
; Load root directory entry ; Load root directory entry
; IN ax number of 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 ; console status
dw err, sret ; return version num dw err, sret ; return version num
dw err, sret ; reset disks dw err, sret ; reset disks
dw err, sret ; select disk dw setdd, sret ; select disk
dw err, sret ; open file dw err, sretb ; open file
.end: .end:
section .text section .text
@ -56,6 +56,9 @@ PSPDS: resw 1
PSPBX: resw 1 PSPBX: resw 1
PSPES: resw 1 PSPES: resw 1
; default drive
PSPDD: resb 1
section .text section .text
; Load current PSP segment into DS ; Load current PSP segment into DS