home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 5 / ctrom5b.zip / ctrom5b / PROGRAM / ASM / ALIB30B / DISK2.ASM < prev    next >
Assembly Source File  |  1994-11-15  |  2KB  |  83 lines

  1.     page    66,132
  2. ;******************************** DISK2.ASM  *********************************
  3.  
  4. LIBSEG           segment byte public "LIB"
  5.         assume cs:LIBSEG , ds:nothing
  6.  
  7. ;----------------------------------------------------------------------------
  8. .xlist
  9.     include  mac.inc
  10.     include  common.inc
  11. .list
  12. ;----------------------------------------------------------------------------
  13.  
  14. comment 
  15. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -(  DISK   )
  16. FILE_SIZE1 - find an open file's size
  17. ;
  18. ; inputs:    BX = file handle
  19. ; output:    if CF = 0, DX:AX = file size (low word in AX)
  20. ;            if CF = 1, AX = DOS error code
  21. ;            
  22. ;* * * * * * * * * * * * * *
  23. 
  24.     public    FILE_SIZE1
  25. FILE_SIZE1    PROC    FAR
  26.    APUSH   BX,CX,SI,DI
  27.    MOV       AX,4201h        ;set ds:ax to file posn (save)
  28.    XOR     CX,CX
  29.    MOV     DX,CX
  30.    INT     21h
  31.    JB      FSIZE_1
  32.    MOV     DI,DX
  33.    MOV     SI,AX
  34.    MOV       AX,4202h        ;seek to end of file, size -> dx:ax
  35.    XOR     CX,CX
  36.    MOV     DX,CX
  37.    INT     21h
  38.    PUSH    DX
  39.    PUSH    AX
  40.    MOV       AX,4200h         ;restore orig. file posn
  41.    MOV     CX,DI
  42.    MOV     DX,SI
  43.    INT     21h
  44.    POP       AX            ;put file size in dx:ax
  45.    POP     DX
  46. FSIZE_1:
  47.    APOP    DI,SI,CX,BX
  48.    RETF
  49. FILE_SIZE1    ENDP
  50. comment 
  51. ;- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -(  DISK   )
  52. FILE_SIZE2 - find a closed file's size
  53. ;
  54. ; inputs:    DS:DX = pointer to file name asciiz string
  55. ; output:    if CF = 0, DX:AX = file size (low word in AX)
  56. ;            if CF = 1, AX = DOS error code
  57. ;            
  58. ;* * * * * * * * * * * * * *
  59. 
  60.     public    FILE_SIZE2
  61. FILE_SIZE2    PROC    FAR
  62.     apush    bx,cx,si,di
  63.     mov    ax,3d00h
  64.     int    21h            ;open file
  65.     jc    fs_err2            ;jmp if error
  66.     mov    bx,ax            ;get file handle
  67.     call    file_size1
  68.     pushf
  69.     push    ax
  70.     mov    ah,3eh
  71.     int    21h            ;close file
  72.     pop    ax
  73.     popf
  74. fs_err2:
  75.     apop    di,si,cx,bx    
  76.     ret    
  77. FILE_SIZE2    ENDP
  78.  
  79. LIBSEG    ENDS
  80.     end
  81.