📄 rxdossft.asm
字号:
sti
Return
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Find SFT by Handle ;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
; ;
; Input: ;
; ax handle id # ;
; ;
; Output: ;
; es:di pointer to matching SFT entry ;
;...............................................................;
FindSFTbyHandle:
push ax
push es
les di, dword ptr ss:[ _RxDOS_pFT ]
cmp ax, 00FFh ; if not assigned
jnc FindSFTbyHandle_12 ; if greater than or equal -->
FindSFTbyHandle_08:
cmp ax, word ptr es:[ numberSFTEntries ][ di ]
jc FindSFTbyHandle_16 ; if within this block -->
sub ax, word ptr es:[ numberSFTEntries ][ di ]
cmp word ptr es:[ nextFTPointer. _pointer ][ di ], -1
jz FindSFTbyHandle_12
les di, dword ptr es:[ nextFTPointer ][ di ]
jmp FindSFTbyHandle_08
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; if error
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FindSFTbyHandle_12:
mov ax, offset pexterrInvalidHandle ; set illegal handle error
pop es ; restore es:
pop ax ; restore ax
stc
ret
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; if located handle space
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
FindSFTbyHandle_16:
push cx
mov cx, sizeSFT
mul cl ; find offset
add di, sizeFT ; point past header
add di, ax ; plus offset
pop cx ; restore cx
pop ax ; throw away es:
pop ax ; restore ax (handle)
clc
ret
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Release SFT ;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
; ;
; Input: ;
; es:di pointer to SFT entry ;
; ;
; Output: ;
; es:di pointer to matching SFT entry ;
;...............................................................;
releaseSFT:
cmp word ptr es:[ sftRefCount ][ di ], 0000
jz releaseSFT_08 ; already released -->
dec word ptr es:[ sftRefCount ][ di ] ; clear entry count
releaseSFT_08:
ret
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Find Matching FCB SFT ;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
; ;
; Input: ;
; es:di FCB address ;
; ;
; Output: ;
; es:di pointer to matching SFT entry ;
;...............................................................;
findmatchingFCBSFT:
Entry
ddef _fcbaddress, es, di ; fcb pointer
ddef _sftPointer ; sft pointer
def _sftHandle ; sft handle
xor ax, ax
mov dx, word ptr es:[ fcbBegClusterNo ][ di ]
mov al, byte ptr es:[ fcbSFN ][ di ]
call FindSFTbyHandle ; locate matching SFT
jc findmatchingFCBSFT_08 ; if cannot locate SFT -->
cmp dx, word ptr es:[ sftBegCluster ][ di ]
ifz findmatchingFCBSFT_26 ; if entry matches -->
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; if not found, try to allocate new SFT
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
findmatchingFCBSFT_08:
call FindAvailableSFTHandle
ifc findmatchingFCBSFT_26 ; if can find an entry -->
storarg _sftHandle, ax ; sft handle
stordarg _sftPointer, es, bx ; sft pointer
push ds
; clear SFT
xor ax, ax
mov di, bx ; pointer to SFT
add di, 2 ; skip Count entry
mov cx, (sizeSFT - sftRefCount - 2)/ 2 ; effective count
rep stosw ; must have pointer at es: di
getdarg ds, si, _fcbAddress ; fcb address
getdarg es, di, _sftPointer ; sft pointer
or word ptr es:[ sftMode ][ di ], sftENTRY_ISFCB
; set owner PSP
mov ax, word ptr ss:[ _RxDOS_CurrentPSP ] ; get owner PSP
mov word ptr es:[ sftOwnerPSP ][ di ], ax
; set drive
mov cl, byte ptr [ fcbDrive ][ si ] ; get drive
and cx, sftDrivemask
mov word ptr es:[ sftDevInfo ][ di ], cx ; include drive
push word ptr [ fcbTime ][ si ] ; time last updated
push word ptr [ fcbDate ][ si ] ; date last updated
push word ptr [ fcbBegClusterNo ][ si ] ; beginning cluster
push word ptr [ fcbFileSize. _low ][ si ] ; file size
push word ptr [ fcbFileSize. _high ][ si ] ; file size
push word ptr [ fcbDHD. _pointer ][ si ] ; device header
push word ptr [ fcbDHD. _segment ][ si ] ;
pop word ptr es:[ sftDCB. _segment ][ di ]
pop word ptr es:[ sftDCB. _pointer ][ di ]
pop word ptr es:[ sftFileSize. _high ][ di ]
pop word ptr es:[ sftFileSize. _low ][ di ]
pop word ptr es:[ sftBegCluster ][ di ]
pop word ptr es:[ sftDate ][ di ]
pop word ptr es:[ sftTime ][ di ]
lea di, offset sftFileName [ di ] ; offset to filename
lea si, offset fcbName [ si ] ; offset to filename
mov cx, sizeFILENAME ; length of name/ ext
rep movsb ; copy name
pop ds
getdarg es, di, _fcbAddress ; fcb address
getarg ax, _sftHandle ; sft handle
mov byte ptr es:[ fcbSFN ][ di ], al
getdarg es, di, _sftPointer ; sft pointer
clc
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; return
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
findmatchingFCBSFT_26:
Return
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Invalidate SFTs belonging to changed drive ;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
; ;
; Input: ;
; ax drive ;
; cx:dx Old Serial Number ;
; ;
; Output: ;
; nz if open sfts exist ;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
; NO LONGER USED ;
;...............................................................;
invalidateOpenSFTs:
Entry
ddef _currentFT
ddef _PrevSerialNumber, cx, dx
def _drive, ax
push es
push bx
les bx, dword ptr ss:[ _RxDOS_pFT ]
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; look for available handle
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
invOpenSFT_08:
stordarg _currentFT, es, bx
mov cx, word ptr es:[ numberSFTEntries ][ bx ] ; get # files at this sft
lea bx, offset sizeFT [ bx ]
or cx, cx ; none ?
jle invOpenSFT_16 ; go to next -->
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; is SFT available ?
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
invOpenSFT_12:
cmp word ptr es:[ sftRefCount ][ bx ], 0 ; entry in use ?
jz invOpenSFT_14 ; no, skip to next -->
mov dx, word ptr es:[ sftDevInfo ][ bx ]
test dx, sftIsDevice ; is device ?
jnz invOpenSFT_14 ; no, skip to next -->
and dx, sftDrivemask
cmp dx, ax ; same as changed drive ?
jnz invOpenSFT_14 ; no -->
cmp ax, -1 ; not zero flag
jmp short invOpenSFT_26 ; we have a problem -->
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; goto next sft
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
invOpenSFT_14:
add bx, sizeSFT ; next SFT entry
loop invOpenSFT_12 ; if more -->
invOpenSFT_16:
les bx, dword ptr [ _currentFT ][ bp ]
cmp word ptr es:[ nextFTPointer. _pointer ][ bx ], -1
jz invOpenSFT_26
les bx, dword ptr es:[ nextFTPointer ][ bx ]
jmp invOpenSFT_08 ; go to next FT -->
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; return
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
invOpenSFT_26:
Return
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Init Clear SFT Entry ;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
; ;
; es:bx pointer to available SFT entry ;
;...............................................................;
InitSFTEntry:
push di
push cx
push ax
xor ax, ax
push word ptr es:[ sftRefCount ][ bx ]
mov di, bx
mov cx, sizeSFT / 2
rep stosw ; must have pointer at es: di
mov ax, word ptr ss:[ _RxDOS_CurrentPSP ] ; get owner PSP
mov word ptr es:[ sftOwnerPSP ][ bx ], ax
pop word ptr es:[ sftRefCount ][ bx ]
pop ax
pop cx
pop di
ret
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -