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

  1.         ;************************************************************;
  2.         ;                                                            ;
  3.         ;      Function 27H: Random File Block Read, FCB-based       ;
  4.         ;                                                            ;
  5.         ;      int FCB_rblock(oXFCB,nrequest,nactual,start)          ;
  6.         ;          char *oXFCB;                                      ;
  7.         ;          int   nrequest;                                   ;
  8.         ;          int  *nactual;                                    ;
  9.         ;          long  start;                                      ;
  10.         ;                                                            ;
  11.         ;      Returns read status 0, 1, 2, or 3 and sets            ;
  12.         ;      nactual to number of records actually read.           ;
  13.         ;                                                            ;
  14.         ;      If start is -1, the relative-record field is          ;
  15.         ;      not changed, causing the block to be read starting    ;
  16.         ;      at the current record.                                ;
  17.         ;                                                            ;
  18.         ;************************************************************;
  19.  
  20. cProc   FCB_rblock,PUBLIC,<ds,di>
  21. parmDP  poXFCB
  22. parmW   nrequest
  23. parmDP  pnactual
  24. parmD   start
  25. cBegin
  26.         loadDP  ds,dx,poXFCB    ; Pointer to opened extended FCB.
  27.         mov     di,dx           ; DI points at FCB, too.
  28.         mov     ax,word ptr (start) ; Get long value of start.
  29.         mov     bx,word ptr (start+2)
  30.         mov     cx,ax           ; Is start = -1?
  31.         and     cx,bx
  32.         inc     cx
  33.         jcxz    rb_skip         ; If so, don't change relative-record
  34.                                 ; field.
  35.         mov     [di+28h],ax     ; Otherwise, seek to start record.
  36.         mov     [di+2ah],bx
  37. rb_skip:
  38.         mov     cx,nrequest     ; CX = number of records to read.
  39.         mov     ah,27h          ; Get MS-DOS to read CX records,
  40.         int     21h             ; placing them at DTA.
  41.         loadDP  ds,bx,pnactual  ; DS:BX = address of nactual.
  42.         mov     [bx],cx         ; Return number of records read.
  43.         cbw                     ; Clear high byte.
  44. cEnd
  45.