home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / dos_ency / section5 / fxn23h.asm < prev    next >
Encoding:
Assembly Source File  |  1988-08-11  |  2.1 KB  |  41 lines

  1.         ;************************************************************;
  2.         ;                                                            ;
  3.         ;      Function 23H: Get File Size, FCB-based                ;
  4.         ;                                                            ;
  5.         ;      long FCB_nrecs(uXFCB,recsize)                         ;
  6.         ;           char *uXFCB;                                     ;
  7.         ;           int recsize;                                     ;
  8.         ;                                                            ;
  9.         ;      Returns a long -1 if file not found, otherwise        ;
  10.         ;      returns the number of records of size recsize.        ;
  11.         ;                                                            ;
  12.         ;      Note: uXFCB must have the drive and                   ;
  13.         ;      filename fields (bytes 07H through 12H) and           ;
  14.         ;      the extension flag (byte 00H) set before              ;
  15.         ;      the call to FCB_nrecs (see Function 29H).             ;
  16.         ;                                                            ;
  17.         ;************************************************************;
  18.  
  19. cProc   FCB_nrecs,PUBLIC,ds
  20. parmDP  puXFCB
  21. parmW   recsize
  22. cBegin
  23.         loadDP  ds,dx,puXFCB    ; Pointer to unopened extended FCB.
  24.         mov     bx,dx           ; Copy FCB pointer into BX.
  25.         mov     ax,recsize      ; Get record size
  26.         mov     [bx+15h],ax     ; and store it in FCB.
  27.         mov     ah,23h          ; Ask MS-DOS for file size (in
  28.                                 ; records).
  29.         int     21h
  30.         cbw                     ; If AL = 0FFH, set AX to -1.
  31.         cwd                     ; Extend to long.
  32.         or      dx,dx           ; Is DX negative?
  33.         js      nr_exit         ; If so, exit with error flag.
  34.         mov     [bx+2bh],al     ; Only low 24 bits of the relative-
  35.                                 ; record field are used, so clear the
  36.                                 ; top 8 bits.
  37.         mov     ax,[bx+28h]     ; Return file length in DX:AX.
  38.         mov     dx,[bx+2ah]
  39. nr_exit:
  40. cEnd
  41.