home *** CD-ROM | disk | FTP | other *** search
/ Turbo Toolbox / Turbo_Toolbox.iso / tasm / ofilclos.asm < prev    next >
Assembly Source File  |  1988-08-28  |  1KB  |  65 lines

  1.  
  2. ;    FILENAME: OFILCLOS.ASM
  3. ;    Copyright (c) 1988 by Borland International, Inc.
  4. ;
  5. ;    Description: This module implements the routine FileClose. FileClose 
  6. ;    closes a file.
  7. ;    ASSEMBLY INSTRUCTIONS:  To assemble this module use the following  
  8. ;    TASM command line.     
  9. ;  
  10. ;        TASM ofilclos
  11.  
  12. include globals.inc
  13.  
  14. _TEXT   segment
  15.  
  16.     FileClose proc
  17.  
  18.     ;    Input 
  19.     ;        bx - file record offset
  20.     ;        cx - number of bytes
  21.     ;        si - location of bytes
  22.     ;    Output
  23.     ;        cf - set if error occurred
  24.     ;        ax - error code
  25.     ;        (cf set and ax = 0 if EOF)
  26.     ;            0 - if EOF and 0 bytes are read
  27.     ;    Registers modified
  28.     ;        None
  29.  
  30.     push    bx
  31.  
  32.     ;--- flush file buffer
  33.  
  34.     test    WORD PTR [bx], 1  ;test if open for writing
  35.     jz      filclo1
  36.     call    FileFlush         ;flush buffer
  37.     jc      filclo2
  38.  
  39.     ;--- close file
  40.  
  41. filclo1:
  42.     mov     ah, 3eh         ;function
  43.     mov     bx, [bx+8]      ;handle
  44.     int     21h             ;execute
  45.     pop     bx
  46.     ret
  47.  
  48.     ;--- close file, error on flush
  49.  
  50. filclo2:
  51.     push    ax
  52.     mov     ah, 3eh         ;function
  53.     mov     bx, [bx+8]      ;handle
  54.     int     21h             ;execute
  55.     pop     ax
  56.     pop     bx
  57.     stc
  58.     ret
  59.     FileClose endp
  60.  
  61. _TEXT    ends
  62.  
  63. end
  64.