📄 rxdossft.asm
字号:
TITLE 'SFT - Support SFT Management'
PAGE 59, 132
.LALL
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Support SFT Management ;
;...............................................................;
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Real Time Dos ;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
; ;
; This material was created as a published version of a DOS ;
; equivalent product. This program logically functions in ;
; the same way as MSDOS functions and it is internal data ;
; structure compliant with MSDOS 6.0 ;
; ;
; This product is distributed AS IS and contains no warranty ;
; whatsoever, including warranty of merchantability or ;
; fitness for a particular purpose. ;
; ;
; ;
; (c) Copyright 1990, 1997. Api Software and Mike Podanoffsky ;
; All Rights Reserved Worldwide. ;
; ;
; This product is protected under copyright laws and may not ;
; be reproduced in whole or in part, in any form or media, ;
; included but not limited to source listing, facsimile, data ;
; transmission, cd-rom, or floppy disk without the expressed ;
; written consent of the author. ;
; ;
; License for distribution for commercial use or resale ;
; required from: ;
; ;
; Api Software ;
; 12 South Walker Street ;
; Lowell, MA 01851 ;
; ;
; internet: mikep@world.std.com ;
; ;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
; Compile with MASM 5.1 ;
;...............................................................;
include rxdosmac.asm
include rxdosdef.asm
RxDOS SEGMENT PARA PUBLIC 'CODE'
assume cs:RxDOS, ds:RxDOS, es:RxDOS, ss:RxDOS
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Handle/ SFT File System Functions ;
;...............................................................;
public createSFTEntry
public FindAvailableSFTHandle
public findmatchingFCBSFT
public FindSFTbyHandle
public InitSFTEntry
public initSFTfromDirEntry
public MapApptoSFTHandle
public MapSFTtoAppHandle
public releaseSFT
public VerifyAvailableHandle
public TestIfMoveHandleTable
public _SFTCloseAllFiles
public _SFTCloseFile
public _SFTCommitFile
public _SFTCreateFile
public _SFTOpenFile
public _SFTReadFile
public _SFTWriteFile
public _SFTReadLine
public invalidateOpenSFTs
extrn AllocateInitCluster : near
extrn CCBChanged : near
extrn convFilenametoFCBString : near
extrn devCharRead : near
extrn devCharWrite : near
extrn devCharReadLine : near
extrn devCharWriteLine : near
extrn fillLogicalBuffer : near
extrn getDPB : near
extrn getAddrDPB : near
extrn getNextCluster : near
extrn getSysDateinDirFormat : near
extrn initdiskAccess : near
extrn locateCCBPHeader : near
extrn LocateFile : near
extrn LocateFreeDirSlot : near
extrn readBuffer : near
extrn readLine : near
extrn readLogicalBuffer : near
extrn ReleaseClusterChain : near
extrn AllocateCluster : near
extrn incorrectDiskMedia : near
extrn updateChangedCCB : near
extrn updateAllChangedCCBBuffers : near
extrn writeLogicalBuffer : near
extrn _div32 : near
extrn _RxDOS_CurrentPSP : word
extrn _RxDOS_TabPosition : word
extrn _RxDOS_pFT : dword
extrn pexterrInvalidFunction : near
extrn pexterrFileNotFound : near
extrn pexterrPathNotFound : near
extrn pexterrIllegalName : near
extrn pexterrNoHandlesAvailable : near
extrn pexterrAccessDenied : near
extrn pexterrInvalidHandle : near
extrn pexterrArenaTrashed : near
extrn pexterrNotEnoughMemory : near
extrn pexterrInvalidBlock : near
extrn pexterrInvalidAccess : near
extrn pexterrInvalidDrive : near
extrn pexterrCurrentDirectory : near
extrn pexterrNoMoreFiles : near
extrn pexterrFileExists : near
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Map handle found to App handle ;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
; ;
; Returns: ;
; ax handle id # ;
;...............................................................;
MapSFTToAppHandle:
cmp word ptr ss:[ _RxDOS_CurrentPSP ], 0000
jz MapSFTToAppHandle_16 ; if no app -->
push es
push si
push cx
mov es, word ptr ss:[ _RxDOS_CurrentPSP ] ; get PSP
mov cx, word ptr es:[ pspFileHandleCount ] ; get max count
les si, dword ptr es:[ pspFileHandlePtr ] ; get JHT pointer
MapSFTToAppHandle_04:
cmp byte ptr es:[ si ], -1 ; empty slot ?
jz MapSFTToAppHandle_08 ; yes, allocate -->
inc si ; next
loop MapSFTToAppHandle_04 ; continue looping
stc
mov ax, offset pexterrNoHandlesAvailable ; problem, no app handles left
jmp short MapSFTToAppHandle_12 ; exit -->
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; allocate App Handle
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MapSFTToAppHandle_08:
mov byte ptr es:[ si ], al ; replace sys handle into app
mov ax, si ; app handle offset
mov es, word ptr ss:[ _RxDOS_CurrentPSP ] ; restore PSP address
sub ax, word ptr es:[ pspFileHandlePtr. _pointer ]
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; return
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
MapSFTToAppHandle_12:
pop cx
pop si
pop es
MapSFTToAppHandle_16:
ret
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Map App Handle to SFT Handle ;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
; ;
; Returns: ;
; ax SFT handle id # ;
;...............................................................;
MapAppToSFTHandle:
push es
push si
cmp word ptr ss:[ _RxDOS_CurrentPSP ], 0000
jz MapAppToSFTHandle_08 ; if no app -->
mov si, ax
mov ax, 00FFh ; assume can't be found
mov es, word ptr ss:[ _RxDOS_CurrentPSP ] ; get PSP
cmp si, word ptr es:[ pspFileHandleCount ] ; beyond max handles
jnc MapAppToSFTHandle_08 ; yes, con't convert -->
les ax, dword ptr es:[ pspFileHandlePtr ] ; get JHT address
add si, ax ; use file handle as offset
mov al, byte ptr es:[ si ] ; get SFT handle
mov ah, 0
MapAppToSFTHandle_08:
pop si
pop es
cmp ax, 00FFh ; see if its unused
ret
;''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''';
; Find Available File Handle ;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
; ;
; File handles are stored in a dynamic file handles area created;
; on initialization by the FILES = < arg > command. ;
; ;
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -;
; ;
; Returns: ;
; ax handle id # ;
; es:bx pointer to available SFT entry ;
; ;
; SFT entry is automatically reserved and must be cleared ;
; if it wont be used. ;
;...............................................................;
FindAvailableSFTHandle:
Entry
ddef _currentFT
def _entries
def _handle, 0000
les bx, dword ptr ss:[ _RxDOS_pFT ]
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; look for available handle
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
findSFTHandle_08:
stordarg _currentFT, es, bx
mov cx, word ptr es:[ numberSFTEntries ][ bx ] ; get # files at this sft
mov word ptr [ _entries ][ bp ], cx
lea bx, offset sizeFT [ bx ]
or cx, cx
jle findSFTHandle_22
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; is handle available ?
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
findSFTHandle_12:
cli
cmp word ptr es:[ sftRefCount ][ bx ], 0 ; entry available ?
jnz findSFTHandle_14 ; no -->
inc word ptr es:[ sftRefCount ][ bx ] ; RESERVE ENTRY
mov ax, word ptr [ _handle ][ bp ] ; count handles
jmp short findSFTHandle_30 ; exit -->
findSFTHandle_14:
sti
inc word ptr [ _handle ][ bp ]
add bx, sizeSFT ; next SFT entry
loop findSFTHandle_12 ; if more -->
les bx, dword ptr [ _currentFT ][ bp ]
cmp word ptr es:[ nextFTPointer. _pointer ][ bx ], -1
jz findSFTHandle_22
les bx, dword ptr es:[ nextFTPointer ][ bx ]
jmp findSFTHandle_08 ; go to next FT -->
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; if out of handles system wide
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
findSFTHandle_22:
stc
mov ax, offset pexterrNoHandlesAvailable
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
; return
;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
findSFTHandle_30:
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -