2 ; FCB management routines for MSDOS
11 CODE SEGMENT BYTE PUBLIC 'CODE'
12 ASSUME
SS:DOSGROUP
,CS:DOSGROUP
28 i_need Current_Country
,WORD
30 procedure MakeFcb
,NEAR
34 MOV BYTE PTR [SpaceFlag
],0
35 XOR DL,DL ; Flag--not ambiguous file name
36 TEST AL,DRVBIT
; Use current drive field if default?
38 MOV BYTE PTR ES:[DI],0 ; No - use default drive
42 TEST AL,NAMBIT
; Use current name fields as defualt?
43 XCHG AX,BX ; Save bits in BX
45 JZ FILLB
; If not, go fill with blanks
47 XOR CX,CX ; Don't fill any
51 TEST BL,EXTBIT
; Use current extension as default
57 XCHG AX,CX ; Put zero in AX
59 STOSW ; Initialize two words after to zero
60 SUB DI,16 ; Point back at start
61 TEST BL,1 ; Scan off separators if not zero
63 CALL SCANB
; Peel off blanks and tabs
64 CALL DELIM
; Is it a one-time-only delimiter?
66 INC SI ; Skip over the delimiter
68 CALL SCANB
; Always kill preceding blanks and tabs
71 JBE NODRV
; Quit if termination character
72 CMP BYTE PTR[SI],":" ; Check for potential drive specifier
74 INC SI ; Skip over colon
75 SUB AL,"@" ; Convert drive letter to binary drive number
76 JBE BADDRV
; Valid drive numbers are <= NUMIO
77 CMP AL,BYTE PTR [NUMIO
]
82 STOSB ; Put drive specifier in first byte
84 DEC DI ; Counteract next two instructions
87 INC DI ; Skip drive byte
90 CALL GETWORD
; Get 8-letter file name
93 INC SI ; Skip over dot if present
94 MOV CX,3 ; Get 3-letter extension
107 JBE NONAM
; Exit if invalid character
110 ; UGH!!! Horrible bug here that should be fixed at some point:
111 ; If the name we are scanning is longer than CX, we keep on reading!
116 ; If spaceFlag is set then we allow spaces in a pathname
120 TEST BYTE PTR [SpaceFlag
],0FFh
128 CMP AL,"*" ; Check for ambiguous file specifier
138 JCXZ BNDERR
; Attempt to straddle boundry
139 MOVSB ; Transfer second byte
143 MOV BYTE PTR ES:[DI-1]," " ; patch up that space
144 JMP MustGetWord
; go back and scan until delim
151 OR DL,1 ; Flag ambiguous file name
168 ; NameTrans is used by FindPath to scan off an element
169 ; of a path. We must allow spaces in pathnames
170 ; Inputs: SS - DOSGROUP
172 ; Outputs: DS:SI advanced over spot
173 ; ES:DI point to after Name1
174 ; registers modified: AX, BX, CX, DX
175 procedure NameTrans
,near
176 MOV BYTE PTR [SpaceFlag
],1
179 MOV DI,OFFSET DOSGROUP
:NAME1
188 CMP BYTE PTR [SI],'.'
225 SUBTTL BUILDFCB
-- MAKE A BLANK FCB FOR A DEVICE
227 procedure BuildFCB
,near
228 ASSUME
DS:DOSGROUP
,ES:DOSGROUP
231 ; Build a blank FCB for I/O to a device
236 MOV DI,OFFSET DOSGROUP
:DEVFCB
+8 ; Point to extent field
238 STOSB ; Blank out extent field
241 REP STOSW ; Fill FCB with zeros
244 MOV DI,OFFSET DOSGROUP
:DEVFCB
+22
249 XCHG AX,BX ; But device number in AH
250 MOV BX,OFFSET DOSGROUP
:DEVFCB
252 XOR AL,AL ; Set zero, clear carry
256 SUBTTL MOVENAME
, LODNAME
-- EXAMINE FCB
AND SETUP
258 procedure FCB_move
,NEAR
265 ASSUME
DS:NOTHING
,ES:NOTHING
268 ; DS, DX point to FCB or extended FCB
270 ; DS:DX point to normal FCB
271 ; DS:SI point after end of NAME/EXT in FCB
274 ; [NAME1] has name in upper case
275 ; All registers destroyed
276 ; Carry set if bad file name or drive
280 MOV WORD PTR [CREATING
],0E500H ; Not creating, not DEL *.*
283 MOV [EXTFCB
],AL ; Set flag if extended FCB in use
284 XOR AH,AH ; Set default attributes
285 CMP AL,-1 ; Is it an extended FCB?
287 ADD DX,7 ; Adjust to point to normal FCB
289 MOV AH,[SI-1] ; Attribute byte
290 LODSB ; Get drive select byte
299 ; DS:DX is pointer to good FCB
302 ; Move the file into Name1 and UCASE it
306 MOV DI,OFFSET DOSGROUP
:NAME1
312 ; are we setting current dir info?
315 JNZ DrvNoSet
; do not set dir info
318 ; check for device name first, eliminating drive hits on devices
322 JNC DrvNoSet
; we have a device
325 ; make sure that everything is current
328 ASSUME
DS:NOTHING
,ES:NOTHING
329 MOV BYTE PTR [ATTRIB
],attr_directory
+attr_hidden
+attr_system
333 MOV BYTE PTR [ATTRIB
],AH
339 MOV DI,OFFSET DOSGROUP
:NAME1
342 ; Inputs: DS:SI point to an FCB
343 ; ES:DI point to an FCB
344 ; Outputs: DS:SI point to after FCB
345 ; ES:DI point to after FCB
346 ; FCB from DS:SI copied and ucased to ES:DI
347 ; Carry set if there was an error.
349 CMP BYTE PTR [SI]," " ; Don't allow blank as first letter
350 STC ; In case of error
355 CMP BYTE PTR [SI],0E5H
365 JNZ STOLET
; Is it a delimiter?
366 CMP AL," " ; This is the only delimiter allowed
367 STC ; In case of error
373 LODSB ;Get second byte
375 JZ BOUNDERR
;Attempt to cross boundry
383 JNZ STOLET2
; Is it a delimiter?
384 CMP AL," " ; This is the only delimiter allowed
385 STC ; In case of error
391 LODSB ;Get second byte
394 BOUNDERR: ;Attempt to cross boundry
407 JNZ STOLET
; Is it a delimiter?
408 CMP AL," " ; This is the only delimiter allowed
409 STC ; In case of error
416 CLC ; Got through whole name - no error
420 SUBTTL GETLET
, DELIM
-- CHECK CHARACTERS
AND CONVERT
422 procedure GetLet
,NEAR
423 ; Get a byte from [SI], convert it to upper case, and compare for delimiter.
424 ; ZF set if a delimiter, CY set if a control character (other than TAB).
431 SUB AL,20H
; Convert to upper case
434 MOV SI,[Current_Country
]
436 PUSH CS ; CS for long return
437 CALL WORD PTR CS:[SI]
452 CMP AL,":" ; Allow ":" as separator in IBM version
471 CMP AL,9 ; Filter out tabs too
473 ; WARNING! " " MUST be the last compare
478 procedure PATHCHRCMP
,NEAR
486 procedure TESTKANJ,NEAR