home *** CD-ROM | disk | FTP | other *** search
/ Chip 1997 April / Chip_1997-04_cd.bin / prezent / cb / data.z / CLOSE.ASM < prev    next >
Assembly Source File  |  1997-01-16  |  979b  |  62 lines

  1.  
  2. ; *******************************************************
  3. ; *                            *
  4. ; *     Delphi Runtime Library                          *
  5. ; *                            *
  6. ; *    Copyright (c) 1996 Borland International    *
  7. ; *                            *
  8. ; *******************************************************
  9.  
  10.     INCLUDE    SE.ASM
  11.     INCLUDE    FILEIO.ASM
  12.  
  13.     .386
  14.     .MODEL    FLAT
  15.  
  16.     EXTRN    GetLastError:NEAR, Input:DWORD, SetInOutRes:NEAR
  17.  
  18.     PUBLIC    _Close
  19.  
  20.     .CODE
  21.  
  22. ;    PROCEDURE _Close( f: File or Text);
  23.  
  24. _Close    PROC
  25.  
  26. ; ->    EAX    Pointer to file variable
  27.  
  28.     PUSH    EBX
  29.     MOV    EBX,EAX
  30.  
  31.     MOV    EDX,[EAX].Mode        ; check whether file is open
  32.     SUB    EDX,fmInput
  33.     JE    @@isInput
  34.     CMP    EDX,fmInOut-fmInput
  35.     JA    @@fileNotOpen
  36.  
  37.     CALL    [EAX].InOutFunc
  38.     TEST    EAX,EAX
  39.     JNE    @@error
  40.     MOV    EAX,EBX
  41. @@isInput:
  42.     CALL    [EBX].CloseFunc
  43.     TEST    EAX,EAX
  44.     JNE    @@error
  45. @@exit:
  46.     POP    EBX
  47.     RET
  48.  
  49. @@error:
  50.     CALL    SetInOutRes
  51.     JMP    @@exit
  52.  
  53. @@fileNotOpen:
  54.     CMP    EAX,offset Input
  55.         JE    @@exit
  56.     MOV    EAX,103
  57.     JMP    @@error
  58.  
  59. _Close    ENDP
  60.  
  61.     END
  62.