Microsoft (R) Macro Assembler Version 5.10                  5/16/24 23:40:13
CP/DOS  DosFindClose  mapper                                Page     1-1


				page 80,132
				
				title CP/DOS  DosFindClose  mapper
				
				        include find.inc
			     C	; find.inc
			     C	
			     C	
			     C	FileFindBuf     struc
 0000  0000                  C	Create_Date     dw      ?
 0002  0000                  C	Create_Time     dw      ?
 0004  0000                  C	Access_Date     dw      ?
 0006  0000                  C	Access_Time     dw      ?
 0008  0000                  C	Write_Date      dw      ?
 000A  0000                  C	Write_Time      dw      ?
 000C  00000000              C	File_Size       dd      ?
 0010  00000000              C	FAlloc_Size     dd      ?
 0014  0000                  C	Attributes      dw      ?
 0016  00                    C	String_Len      db      ?
 0017  000C[                 C	File_Name       db      12 dup (?)
	   ??                C	
			 ]   C	
			     C	
 0023                        C	FileFindBuf     ends
			     C	
			     C	;
			     C	; dta buffer structure
			     C	;
			     C	
			     C	dtastr  struc
 0000  0015[                 C	                db      21 dup (?)
	   ??                C	
			 ]   C	
			     C	
 0015  00                    C	DTAFileAttrib   db      ?
 0016  0000                  C	DTAFileTime     dw      ?
 0018  0000                  C	DTAFileDate     dw      ?
 001A  00000000              C	DTAFileSize     dd      ?
 001E  000D[                 C	DTAFileName     db      13 dup (?)
	   ??                C	
			 ]   C	
			     C	
 002B                        C	dtastr  ends
			     C	
 = 0008                      C	MaxFinds        equ     8
 = 8000                      C	OpenedHandle    equ     08000h
			     C	
			     C	
				
				
 0000				FindSegment     segment word public 'find'
				
				; We will use the offset into the segment 'FindSegment' as the handle that we
				;  return and use in subsequent FindNext and FindClose calls.  The data that is
				;  in the word is the offset into the 'FindSegment' to the DTA that we should
				;  use.
				                extrn   FindDTAs:word
				                extrn   FindHandles:word
				
 0000				FindSegment     ends
				
				
				; ************************************************************************* *
				; *
				; *      MODULE: DosFindClose
				; *
				; *      FUNCTION:  Close Find Handle
				; *
				; *      FUNCTION: This module closes the directory handle used by CP/DOS
				; *                in a find first/find next search.  Since PC/DOS does not
				; *                use directory handles it will simply return to the caller
				; *                removing the parameters passed on the stack.
				; *
				; *      CALLING SEQUENCE:
				; *
				; *                PUSH  WORD  DirHandle   ; Directory search handle
Microsoft (R) Macro Assembler Version 5.10                  5/16/24 23:40:13
CP/DOS  DosFindClose  mapper                                Page     1-2


				; *                CALL DosFindClose
				; *
				; *
				; *      RETURN SEQUENCE:
				; *
				; *                IF ERROR (AX not = 0)
				; *
				; *                   AX = Error Code:
				; *
				; *
				; *      MODULES CALLED:  None
				; *
				; *************************************************************************
				
				        public  DosFindClose
				        .sall
				        .list
				
				str     struc
 0000  0000			old_bp    dw      ?
 0002  00000000			return    dd      ?
 0006  0000			DirHandle dw      ?           ; dirctory search handle
 0008				str     ends
				
				
 0000				dosxxx  segment byte public 'dos'
				        assume  cs:dosxxx,ds:nothing,es:nothing,ss:nothing
				
 0000				DosFindClose  proc   far
				        Enter   DosFindClose               ; push registers
				
 000C  B8 ---- R		        mov     ax,seg FindSegment         ; get address to our data
 000F  8E D8			        mov     ds,ax
				        assume  ds:FindSegment
				
				; Close the handle
				
				; The 'DirHandle' that the mapper returns from FindFirst, is the offset into
				; 'FindSegment' of the pointer to the DTA for that Handle.  The 08000h bit
				; of the pointer is used to indicate that the handle is open.  Reset the bit.
				
				; Special Logic to handle DirHandle = 1
				
 0011  8B 76 06			        mov     si,[bp].DirHandle          ; get directory hanlde
 0014  83 FE 01			        cmp     si,1                       ; handle = 1??
 0017  75 03			        jne     CheckForClose              ; branch if not
				
 0019  BE 0000 E		        mov     si,offset FindSegment:FindHandles
				
 001C				CheckForClose:
 001C  F7 04 8000		        test    ds:[si],OpenedHandle       ; handle is open ??
 0020  75 06			        jnz     OkToClose                  ; go and close if it is open
				
 0022  B8 0006			        mov     ax,6                       ; else load error code
 0025  EB 07 90			        jmp     ErrorExit                  ; return
				
 0028				OkToClose:
 0028  81 24 7FFF		        and     ds:[si],not OpenedHandle   ; set close flag
 002C  33 C0			        xor     ax,ax                      ; set good return code
				
 002E				ErrorExit:
				        mexit                              ; pop registers
 003A  CA 0002			        ret     size str - 6               ; return
				
 003D				DosFindClose endp
				
 003D				dosxxx  ends
				
				        end

Microsoft (R) Macro Assembler Version 5.10                  5/16/24 23:40:13
CP/DOS  DosFindClose  mapper                                Symbols-1


Macros:

		N a m e			Lines

ENTER  . . . . . . . . . . . . .  	   3
MEXIT  . . . . . . . . . . . . .  	   3
POPAL  . . . . . . . . . . . . .  	   9
PUSHAL . . . . . . . . . . . . .  	   9

Structures and Records:

                N a m e                 Width   # fields
                                        Shift   Width   Mask    Initial

DTASTR . . . . . . . . . . . . .  	002B	0006
  DTAFILEATTRIB  . . . . . . . .  	0015
  DTAFILETIME  . . . . . . . . .  	0016
  DTAFILEDATE  . . . . . . . . .  	0018
  DTAFILESIZE  . . . . . . . . .  	001A
  DTAFILENAME  . . . . . . . . .  	001E
FILEFINDBUF  . . . . . . . . . .  	0023	000B
  CREATE_DATE  . . . . . . . . .  	0000
  CREATE_TIME  . . . . . . . . .  	0002
  ACCESS_DATE  . . . . . . . . .  	0004
  ACCESS_TIME  . . . . . . . . .  	0006
  WRITE_DATE . . . . . . . . . .  	0008
  WRITE_TIME . . . . . . . . . .  	000A
  FILE_SIZE  . . . . . . . . . .  	000C
  FALLOC_SIZE  . . . . . . . . .  	0010
  ATTRIBUTES . . . . . . . . . .  	0014
  STRING_LEN . . . . . . . . . .  	0016
  FILE_NAME  . . . . . . . . . .  	0017
STR  . . . . . . . . . . . . . .  	0008	0003
  OLD_BP . . . . . . . . . . . .  	0000
  RETURN . . . . . . . . . . . .  	0002
  DIRHANDLE  . . . . . . . . . .  	0006

Segments and Groups:

                N a m e         	Length	 Align	Combine Class

DOSXXX . . . . . . . . . . . . .  	003D	BYTE	PUBLIC	'DOS'
FINDSEGMENT  . . . . . . . . . .  	0000	WORD	PUBLIC	'FIND'

Symbols:            

                N a m e         	Type	 Value	 Attr

CHECKFORCLOSE  . . . . . . . . .  	L NEAR	001C	DOSXXX

DosFindClose . . . . . . . . . .  	F PROC	0000	DOSXXX	Global	Length = 003D

ERROREXIT  . . . . . . . . . . .  	L NEAR	002E	DOSXXX

FindDTAs . . . . . . . . . . . .  	V WORD	0000	FINDSEGMENT	External
FindHandles  . . . . . . . . . .  	V WORD	0000	FINDSEGMENT	External

MAXFINDS . . . . . . . . . . . .  	NUMBER	0008	

OKTOCLOSE  . . . . . . . . . . .  	L NEAR	0028	DOSXXX
OPENEDHANDLE . . . . . . . . . .  	NUMBER	8000	

@CPU . . . . . . . . . . . . . .  	TEXT  0101h		
@FILENAME  . . . . . . . . . . .  	TEXT  f_close		
@VERSION . . . . . . . . . . . .  	TEXT  510		

Microsoft (R) Macro Assembler Version 5.10                  5/16/24 23:40:13

CP/DOS  DosFindClose  mapper                                Symbols-2






    187 Source  Lines
    211 Total   Lines
     43 Symbols

  47282 + 317195 Bytes symbol space free

      0 Warning Errors
      0 Severe  Errors
