;							>>B/S<<
;	LOGICAL DEVICE FUNCTIONS
;
; 02.10 06/22/80 krs
; 02.11 06/25/80 KRS
; 02.14 07/??/80 atrib byte
; 02.20 07/??/80 krs cp/2 et al
; 02.32 11/14/80 RLR SMALL SYS ERA ERR/big: free dir on 17
; 02.33 12/22/80 KRS fix X-Disk Rename
; 02.35 10/14/81 DEW macros added
; 02.37 02/??/82 KRS CLEANUP
; 02.39 06/??/82 SBW Handle ? in disk byte (DOS 17 call)
;			   also defeat new block logic in NEWIDX
; 02.42 12/08/82 sbw 8MB bug, break into FL and FL1
;       01/28/83 sbw edit
;
	icl	pdef		;02.39
	icl	df		;02.39
	df.dos			;02.39
	df.cpu			;02.39
	df.sys			;02.39
;
	NAM	FL242
;
C3VER	EQU	0	; 0 = NOT C3
;
	ENT	NAMFB,MULX,DIVX,ATBFL
	ENT	NMTCH,FCBDK,DRSCH
	ENT	NXDIR,DELFL,RENFL			;02.20
	ENT	XMTCH,GETDK,ATRIX		;02.20		;02.42
;
	ext	xgetat				;02.20		;02.42
	EXT	SDT,DIRSIZ,ASDTE
	EXT	DIV16,MUL16,SETLOG
	EXT	DIRRD,DIRWR			;02.35		;02.42
	EXT	SAVAF,MOVE,FREBK				;02.42
	EXT	DIRCLR					;02.00
	EXT	NEGHL				;02.07		;02.42
	ext	trans						;02.42
;
SPC	EQU	20H
DRLEN	EQU	32	; LEN OF DIR. ENTRY
;
    ifc SYSUCB=SINGLE					;02.35
	EXT	?UDEV,?USFB,?UDRB,?UBF1,?UDBF,?UBC	;02.35
	EXT	?UHL,?UDE,?UFCB,?ufcb33				;02.42
    elsec						;02.35
	EXT	ADUCB,SVCRG,RDUCB			;02.35
    endc						;02.35
;
FREEL	EQU	FCBEX	; FILE REEL (EXTENT)
FNXREC	EQU	FCBNR	; NEXT RECORD
	EJECT
;
; FORMAT FCB FROM STRING
;	@DE=FCB,@HL=NAME
;	=,/ ARE TERM. AS IS 0..20H
;
NAMFB:	PUSH	D	; SAVE FOR USER
;
	XCHG		; BLANK NAME INITIALLY
	PUSH	H
	MVI	M,0
	INX	H	; DISK:=0
	LXI	B,200BH	; B=SPC,C=11 CHARS
NAM1:	MOV	M,B
	INX	H
	DCR	C
	BRNZ	NAM1					;02.35
	POP	H
	XCHG
;
	MVI	B,8	; NAME HAS 8 CHARS
	MOV	A,M	; (**1.02**) IF NUL 
	ORA	A
	BRZ	NAM3	;THEN NONAME (DONE)		;02.35
	INX	H
	MOV	A,M
	CALL	TRANS	;* TRANSLATE TO UPPER CASE
	DCX	H
	CPI	':'
	BRNZ	NAM2	; IF NAME(2)=":"		;02.35
	MOV	A,M	; THEN PROCESS DISK NAME
	CALL	TRANS	;* TRANSLATE TO UPPER CASE
	SUI	'A'-1	; A=1,B=2..
	STAX	D
	INX	H
	INX	H
NAM2:	INX	D	; SKIP DISK NAME
	MVI	B,8	; 8 CHAR IN FILE NAME
NAM2A:	MOV	A,M
	CALL	TRANS	;* TRANSLATE TI UPPER CASE
	CPI	SPC+1
	JM	NAM3	; DONE IF <=SPC
	CPI	'/'
	BRZ	NAM3	; OR IF OPTION			;02.35
	CPI	'='
	BRZ	NAM3	; OR IF COMMAND			;02.35
	CPI	','
	BRZ	NAM3	; OR IF DELIMTER		;02.35
	CPI	'.'
	BRZ	NAM4	; HANDLE FILE TYPE		;02.35
	CPI	'*'
	BRZ	NAM5	; EXPAND ABIGIOUS REFERENCE	;02.35
;
	STAX	D	; JUST A LITTLE OLE CHAR
	INX	H
	INX	D
	DCR	B
	JP	NAM2A
;		NAME TOO LONG
	STC		; CY=1					;02.42
	BR	NAM3A	; BUT DONE			;02.35
;
;	'.'=START OF FILE TYPE
NAM4:	INX	H	; SKIP '.'
	LXI	B,9	; MOVE PAST NAME
	XCHG
	POP	H
	PUSH	H	; GET & SAVE FCB
	DAD	B
	XCHG		; DE=FCB.FILE TYPE
	MVI	B,3	; TYPE IS 3 CHAR MAX
	BR	NAM2A					;02.35
;
;	*=ABIGIOUS REFERENCE
;
NAM5:	INX	H	; SKIP *
	MVI	A,'?'	; ACTUAL CHAR
	INR	B	; IN CASE=0
NAM5A:	DCR	B
	BRZ	NAM2A					;02.35
	STAX	D
	INX	D	; FILL REST OF NAME IN
	BR	NAM5A					;02.35
;
;	DONE
;
NAM3:	ORA	A	; CY=0 , OK
NAM3A:	POP	D
	PUSH	H
	LXI	H,FREEL
	DAD	D
	MVI	M,0	; EXTENT ZERO (PROBABLY)
	INX	H	;   2 BYTES
	MVI	M,0
	INX	H
	MVI	M,0	; DIR NUMBER TOO.
;
	LXI	H,FNXREC
	DAD	D
	MVI	M,0	; RECORD 0 (PROBABLY)
	POP	H
	SHLUCB	HL				;02.37
	RET					;02.37
;
;	USEFULL MATH MULT,DIV
;
DIVX:	CALL	DIV16
	SHLUCB	HL				;02.37
	SHLUCB	BC	; WHY??			;02.37
	SDEUCB	DE				;02.37
	RET					;02.37
;
MULX:	CALL	MUL16
	SDEUCB	DE				;02.37
	RET					;02.37
;
	EJECT
;
DERA	EQU	0E5H	; ERASED DISK VALUE
;
; NAME MATCH
;  ENTRY: @DE=FCB, A=0 START OF DIRECTORY
;		,A=N, BUFFER PRE-FILLED BLOCK(N-1)MOD 4
;         ( NMTCX WILL DO A:=A+1 BEFORE ACCESS)
;	USER BUFFER USED
;  EXIT: @HL=DIR ENTRY, A=BLOCK FND (-1=EOD)
;	@DE=FCB(UNCHANGED)
; ENTRY POINTS:
;	 XMTCH -* MATCH FOR EXISTING, EXTENT
;	 NMTCHN-* MATCH FOR EXISTING, NON PERMANENT
;	 NMTCH -* MATCH FOR EXISTING , NAME ONLY
;	 NMTCX - MATCH FOR NAME ONLY (ERASED OR NOT)
;
;  * = ONLY MATCHS ON FILES (ATRIB BYTE AND 7)=0
;
XMTCH:	CALL	NMTCH
	CPI	-1
	RZ		; NOT FOUND
;	TEST FOR PROPER EXTENT
; @DE=FCB / @HL=DIR ENTRY
	PUSH	D
	PUSH	H
	PUSH	PSW	; AF
	LXI	B,FCBEX
	DAD	B
	XCHG
	DAD	B
	LDAX	D	; IF FCB.EXTENT
	CMP	M	;  = DIR.EXTENT
XMTCH1:	POP	H
	MOV	A,H	; RESTORE A W/O FLAGS
	POP	H
	POP	D
	RZ		; THEN FOUND MATCH
	BR	XMTCH	; ELSE SEARCH ON, MACBETH	;02.35
;
NMTCHN:	CALL	NMTCX	; NON-PERMANENT FILES ONLY
	CPI	-1
	RZ
	PUSH	PSW
	MOV	A,M
	RLC
	BRNC	NMTH1	; EXIT IF NON-PERMAMENT		;02.35
	POP	PSW
	BR	NMTCHN					;02.35
;
NMTCH:	CALL	NMTCX	; FILES ONLY
	CPI	-1
	RZ		; NOT FOUND AT ALL/GIVE UP
	PUSH	PSW
	MOV	A,M
	ANI	1
	BRZ	NMTH1					;02.35
	POP	PSW	; IF NOT FILE
	BR	NMTCH	; THEN KEEP SEARCHING		;02.35
;
NMTH1:	POP	PSW	; ELSE GOOD
	RET
;
NMTCX:	INR	A
	MOV	B,A	;##00.31
	CALL	DIRSIZ	; NUMBER OF DIR ENTRIES
	CMP	B
	MVI	A,-1	;A:=-1, NOT FOUND
	rlt							;02.42
;   NEXT ENTRY
	MOV	A,B						;02.42
	PUSH	PSW	;SAVE ENTRY NO.
	PUSH	D	;AND BLOCK
	CALL	FCBDK	; REAL READ (B:= DISK FROM FCB)	 02.01
	CALL	DIRRD					;02.01
;
;  RETURNS @HL= DIRECTORY ENTRY
;	ACCEPT ANY ERASED ENTRIES
;
	POP	D
NMT2:		; NEXT ENTRY/SAME BLOCK
	PUSH	D
	PUSH	H
	INX	H	;SKIP 1ST BYTES
	INX	D
; DE=@FCB; HL=@DIR ENTRY
	MVI	B,11	;11 CHARS
NMT3:	LDAX	D
	ANI	7FH	; FCB LSB'S ONLY		 02.01
	CPI	'?'
	BRZ	NMT3A	;AMBIGUOUS REFERENCE		;02.35
	MOV	C,A	; DIR LSB'S ONLY		 02.01
	MOV	A,M					;02.01
	ANI	7FH					;02.01
	CMP	C					;02.01
	BRNZ	NMT3B	;NO MATCH			;02.35
NMT3A:	INX	H
	INX	D
	dbrnz	nmt3						;02.42
;
;  FALL THRU ONLY ON MATCH
;
	POP	H	;HL:= DIR. ENTRY
	POP	D	;DE:=FCB
	POP	PSW	;A:=DIR ENTRY NUMBER
	RET
;
NMT3B:	POP	H
	POP	D
	POP	PSW	;DO NEXT ENTRY
	MOV	B,A	; IF (NEXT ENTRY-1)MOD 4=0
	MVI	C,3
NMT3C:	ANA	C
	MOV	A,B
	BRZ	NMTCX	; THEN READ NEXT NEW BLOCK	;02.35
; SAME DIRECTORY BLOCK
	INR	A
	PUSH	PSW
	LXI	B,DRLEN	; @ HL:=
	DAD	B	;   NEXT ENTRY
	BR	NMT2					;02.35
; GET DISK FROM A TO 'B'
; INPUT - A CONTAINS DISK NUMBER
; OUTPUT - B CONTAINS DISK NUMBER
;
GETDK:	PUSH	PSW	;SAVE PSW
	BR	FCD3					;02.35
;
;  GET DISK FROM FCB (@DE) TO 'B'
;
FCBDK:	PUSH	PSW
	LDAX	D
	CPI	'?'	; Question mark for 17 call?	;02.39
	BRNZ	..1					;02.39
	XRA	A	; Yes: use current.		;02.39
..1:							;02.39
;
FCD3:	ANI	0FH	;#.32 CLEAR PROTECT FLAGS
	MOV	B,A
	LDA	SDT	; (@SDT=# OF DRIVES)
	CMP	B	; ##00.31
	BRLT	FCD2	; AND < # OF DSKS		;02.35
;
	MOV	A,B
	DCR	B	;1=A, 2=B SHIFT TO 0=A...
	ORA	A
	BRNZ	FCD1	;EXPLICIT DISK REQ		;02.35
FCD2:	PUSH	H
	PUSH	B
	LHLUCB	DEV	;ELSE GET CURRENT DISK			;02.35
	POP	B
	MOV	B,L
	POP	H
FCD1:	POP	PSW
	RET
	EJECT	
;
;  DIRECTORY SEARCH FOR NAME (17) FROM BEGINNING
;  ENTRY: @DE=FCB
;  EXIT:  A= DIR ENTRY OR 255, @HL=ENTRY
;   (17)/(18) WILL FIND DELETED ENTRIES
;	SYSTEM USES -1,1..64 BUT RETURNS
;  -1..63 FOR CPM COMPATABILITY
;  IF BYTE 0='?' THEN MATCH DELETED
;  IF BYTE 12='?' THEN MATCH ANY EXTENT
;
DRSCH:	CALL	SETLOG	;(*01.01*) SETUP DISK & A:=0
	SDEUCB	SFB	;SAVE FCB FOR 'SEARCH NEXT'
	adrucb	fcb33	; for comparison on big dir searches	;02.42
	mvi	m,0ffh	;null out chain fcb entry #	;02.15
;
; SET UP CSDTE POINTER FOR SEARCH
;	(REV 1.01)
; A:=NEXT ENTRY TO SEARCH AT
;
DRSC0:	CALL	FCBDK	; B:=DISK SPECIFIED
	CALL	ASDTE	; CSDTE:=SDT[DISK]
;
DRSC1:	CALL	NMTCX
	PUSH	H
	ADRUCB	DRB						;02.35
	MOV	M,A	;UCB.DRB:=CURRENT DIRECTORY ENTRY
	POP	H
	CPI	-1	; EXIT IF -1 (EO DIR)
	jeq	savaf	;02.32    if no more entries
	PUSH	PSW
;
; IF @FCB='?' OR Directory entry "Not a file" bit is clear	;02.42
;
	LDAX	D
	CPI	'?'	; Wild card disk specifier?		;02.42
	BREQ	DRSC2	; Yes: accept "not a file"s too.	;02.42
	MOV	A,M
	ANI	1	; else check "not a file" bit		;02.42
	BRZ	DRSC2					;02.35
	POP	PSW	; NEXT
	BR	DRSC1					;02.35
; IF EXTENT(12) MATCH OR FCB.EXT='?'
DRSC2:	PUSH	H
	PUSH	D
;	code moved down several lines			 02.15
	LXI	B,FCBEX	
	XCHG
	DAD	B
	MOV	A,M
	CPI	'?'
	BREQ	DRSC4					;02.35
	XCHG
	DAD	B
	CMP	M
	BREQ	DRSC4					;02.35
	POP	D
	POP	H	; ELSE NEXT
	POP	PSW
	BR	DRSC1					;02.35
;
;
; THEN MATCH
DRSC4:
	POP	D
	POP	H
	SHLUCB		HL				;02.37
	pop	psw	;rel to zero			 02.15
	dcr	a	; and 0-3 only			;02.15
	ani	3	;now all regs ready		;02.15
	SAFUCB						;02.37
;
; Move the block containing the directory entry into the user's
; DMA address.
;
	LHLUCB	BF1	; System buffer 1 contains dir entry	;02.35
	XCHG
	LHLUCB	DBF	; Pointer to user's DMA address		;02.35
	PUSH	H						;02.07
	PUSH	D						;02.07
	LXI	B,128
	CALL	MOVE
	LHLUCB	HL	; Get dir entry pointer back		;02.37
	XCHG							;02.37
	POP	H	; Get addr of buff containing dir entry	;02.07
	CALL	NEGHL						 02.07
	DAD	D	; Calculate offset in buffer of entry	 02.07
	POP	D	;					 02.07
	DAD	D	; Add to user's DMA address to get	 02.07
	XCHG		;	dir entry in user's DMA area	;02.37
;
	LDAX	D	; If file is "Not a file"		;02.37
	MOV	H,A						;02.37
	ANI	1						;02.37
	BRNZ	NOXGT	; Then don't get atributes (they are	;02.37
	MVI	L,0	;	meaningless)			;02.37
	CALL	XGETAT	; Else break out atributes into high	;02.37
	XRA	A	; bits of directory entry, a la CP/M.	;02.37
	STAX	D	; Zero first byte of directory entry.	;02.37
NOXGT:	JSDEUCB	HL	; Return pointer to directory entry.	;02.37
	EJECT
;
;  NEXT DIRECTORY ENTRY (18)
;  PARAMETERS AS PER 'DRSCH'
;   USE PREV FCB (FOR CPM COMPAT.)
;	SAVE IN UCB.SFB BY SEARCH
;
NXDIR:	LHLUCB	SFB	; READ PREVIOUS ENTRY RETURNED		;02.35
	XCHG		; DE:=UCB.LAST SERACH FCBFCB
	LHLUCB	DRB
	MOV	A,L	; A:=UCB.DIR BLK LAST FND
	JMP	DRSC0
;
;  UPDATE DIRECTORY ENTRY (80H+7)
;	@DE=DISK(AS PER FCB)
;
;	ROUTINE REMOVED AND CALL MADE ILLEGAL		 02.20
;
	EJECT
;
;  DELETE FILE (19)
;  ENTRY:  @DE=FCB
;  EXIT: A = NUMBER OF DIRECTORY ENTRIES DELETED
DELFL:	CALL	SETLOG	; (*01.02*) SET DISK & A:=0
	PUSH	PSW	; INIT COUNT
DELF1:	CALL	NMTCHN
	CPI	-1
	BRNZ	DELFA	; NOT THRU YET			;02.35
; RECOVER COUNTER
RCVCNT:	CALL	FCBDK	;GET DISK			 02.07	
	CALL	DIRCLR	; CLEAR DIR FUNCTIONS		 02.00
	POP	PSW	; GET last one found or 0	 02.20
; a is 0 or dir rec entry number
	dcr	a	;from 0 to -1, or to entry #	 02.20
	cpi	0ffh	;return if failure		 02.20
	jz	savaf					;02.20
	ani	3	;else return 0,1,2,3		 02.20
	JMP	SAVAF	; WHICH WILL RETURN TO CALLER	 02.20
;
DELFA:	PUSH	D	;SAVE FCB
	PUSH	PSW	;SAVE ENTRY NO.
	MOV	A,M	;GET DIR FLAGS
	MVI	M,DERA	;MARK BLOCK DELETED
	LXI	B,16
	DAD	B	;TO DM
	CALL	FCBDK	;B=DISK
	MVI	C,16	;NO. ENTRIES TO DEALLOCATE
DELF1A:	MOV	E,M	;GET LOW CLUSTER BYTE
	XRA	A	:02.32 CLEAR A FOR TEST AND
	MOV	D,A	;CLEAR HIGH
	ORA	E	;ALLOCATED?
	BRNZ	DELF2	;YES...				;02.35
	BR	DELF2A	;NO...				;02.35
DELF2:	PUSH	H	; SAVE DM
	CALL	FREBK	; FREE THE CLUSTER
	POP	H
DELF2A:	INX	H	; NEXT DM
	DCR	C
	BRNZ	DELF1A					;02.35
	POP	PSW
	POP	D
	PUSH	D
	PUSH	PSW
	CALL	DIRWR	; UPDATE DIR			 02.00
	POP	PSW
	POP	D
	POP	B	; last one found
	PUSH	psw	; SAVE dir entry number		 02.20
	BR	DELF1	; FIND NEXT EXTENT		;02.35
	EJECT
;
;  RENAME FILE (23)
;  ENTRY: @DE=FCB WHERE:0..15 = OLD NAME
;		16..32= NEW NAME
; EXIT: A = NUMBER OF DIRECTORY ENTRIES RENAMMED
;
; ALLOWS AMBIGIOUS RENAME BY NOT MOVING '?'
;   IN NEW NAME TO OLD NAME (BUT SEARCHS ON OLD NAME!)
; TESTS FOR GLOBAL NEW NAME EXISTANCE
;
;
RENFL:	CALL	SETLOG	; (*01.02*) SET DISK & A:=0
	PUSH	PSW	; INIT COUNTER
; TEST FOR EXISTING NEW NAME (##00.32)
	PUSH	D
	LDAX  	D	; 02.33
	LXI	H,16
	DAD	D
	XCHG
	STAX	D	; 02.33
   	XRA	A	; 02.33
	CALL	NMTCH
	POP	D
	CPI	-1	; IF FOUND
	BRNZ	RCVCNT	; THEN NO RENAME		;02.35
	XRA	A
;
RENF1:	CALL	NMTCHN
	CPI	-1	; IF END OF DIR
	BREQ	RCVCNT	; THEN RECOVER CNTR & FINISH	;02.35
;
	PUSH	D						;02.42
	PUSH	PSW
	LXI	B,17
	XCHG
	DAD	B
	XCHG		; @DE=NEW NAME
	INX	H	; @HL=OLD DIR ENTRY
	MVI	B,11
; @DE->@HL , BUT DON'T MOVE '?' (FOR AMBIGIOUS REF)
RENF2:	LDAX	D	; REPEAT
	CPI	'?'
	BRZ	RENF3	; IF @DE<>'?'			;02.35
	MOV	M,A	; THEN @HL:=@DE
RENF3:	INX	H
	INX	D	; HL+1,DE+1
	DCR	B
	BRNZ	RENF2	; UNTIL B=0			;02.35
;
	POP	PSW	;  ONLY NAME.TYP [1..11]
	POP	D
	PUSH	D	; RESTORE FCB/TO SET DISK
	PUSH	PSW
	CALL	DIRWR	;02.00: UPDATE ENTRY
; TRY FOR NEXT EXTENT
	POP	PSW
	POP	D
	POP	B	; get previous one		 02.20
	PUSH	psw	; save dir pointer		 02.20
	BR	RENF1					;02.35
	EJECT
;
; SET ATRIBUTES - CP/M-TYPE 30 CALL -NAME HIGH BITS	 02.20
;
; System call 30 (1EH) is handled by translating it to a system
; call 94H.  Only three of the CP/M atribute bits are handled:
; Write protect, System, and Archive.  They are set according
; to their values in the FCB passed to system call 30.  The rest
; of the I/OS attribute bits are cleared by system call 30.
;
; Note that this system call allows an extension to the standard CP/M
; system call 30, in that an ambiguous filename FCB is allowed.
;
ATRIX:	LXI	H,9	; ADDRESS T1			 02.20
	DAD	D	; IN FCB			 02.20
	MOV	A,M					;02.20
	RRC		; W BIT TO POSITION		 02.20
	ANI	40H	; CLEAR REST			 02.20
	MOV	C,A	; SAVE IT			 02.20
;
	INX	H					;02.20
	MOV	A,M					;02.20
	RRC						;02.20
	RRC						;02.20
	RRC						;02.20
	RRC		; S BIT TO POSITION		 02.20
	ANI	08H	; CLEAR REST			 02.20
	ORA	C	; ADD W BIT			 02.20
;
	mov	c,a						;02.42
	inx	h	; Point to archive attribute		;02.42
	mov	a,m						;02.42
	rlc		; Roll into bit 2 (I/OS position)	;02.42
	rlc							;02.42
	rlc							;02.42
	ani	4	; Isolate the archive bit		;02.42
	ora	c	; Combine with Write protect & System	;02.42
	ori	3	; Indicate no effect on I/OS attributes	;02.42
	MOV	B,A
	br	atbfl0
;
; SET ATTRIBUTE (##00.32) System call 94H
;
; ENTRY: @DE=FCB, B=NEW ATRIB
; ATRIB ARE [PWRU/SA-+]						;02.42
;
; Change the attributes of all files matching the ambiguous FCB.
; If neither the "-" or "+" bit is set, the attributes are set
; exactly as specified in register B.  If the "+" bit is set, the
; attributes indicated by a 1 in register B are set, and the others
; are not affected.  If the "-" bit is set, the attributes indicated
; by a 1 in register B are cleared, and the others are not affected.
;
; The "+" and "-" bits are mutually exclusive.  If both are set, the
; result is undefined at the system call level.  This setting of bits
; is used by system call 30 (1EH) above to indicate that only the
; CP/M-compatible attributes (W, S, an A) are to be affected.
;
; In any case, files marked "Not a file" are not affected, and the
; BIG attribute is unaffected.
;
ATBFL:
	mov	a,b						;02.42
	ani	3	; Check the + and - bits		;02.42
	cpi	3	; Has the user specified an undefined	;02.42
	mvi	a,-1	;	combination off bits?		;02.42
	jz	savaf	; Yes: return an error.			;02.42
atbfl0:								;02.42
	CALL	SETLOG	; (*01.02*) SET DISK & A:=0
	MOV	C,B	; C:=NEW ATRIB
	MOV	B,A	; B=COUNT(0)
	PUSH	B	; INIT CNT
;
ATBFL1:	CALL	NMTCH	; GET A FILE
	CPI	-1	; IF END OF DIR
	JZ	RCVCNT	; THEN RECV CNT & FINISH
;
	POP	B
	push	b					;02.21
	PUSH	AF	; SAVE DIR PTR
;
;*************** Rewritten for 02.42 *****************************;
;
	mov	a,c	; Check the + and - bits
	ani	3
	brz	..1	; Jump if neither + or -: just set attributes
	cpi	2
	brlt	..2	; Jump if +: add attributes
	breq	..3	; Jump if -: subtract attributes
;
; Both + and - bits: set only the CP/M-compatible attributes.
;
	mov	a,m	; Clear the CP/M attributes
..6:	equ	atra!atrw!atrs
	ani	^..6
	br	..4
..3:			; Subtract attributes:
	mov	a,c
	ani	0fch	; Strip off the + and - bits
	cma
	ana	m	; Clear the indicated attributes
	br	..5
..1:			; Set attributes:
	mov	a,m
	ani	BIGFIL	; Clear all but the big file flag
..4:
	mov	m,a
..2:			; Add attributes:
	mov	a,c
	ani	0fch	; Strip the + and - bits
	ora	m	; Set the indicated attributes
..5:
	mov	m,a
;
;************ End of rewrite for 02.42 ***************************;
;
	POP	PSW	; A - DIR PTR
	pop	b					;02.21
	mov	b,a	; put in b as needed		 02.20
	PUSH	B	; SAVE CNT / ATRIB
	PUSH	PSW
	PUSH	D	; DIR PTR ANS FCB
	CALL	DIRWR	; UPDATE DIR			 02.00
	POP	D
	POP	PSW
	BR	ATBFL1					;02.35
;
	end
