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

  1.         ;************************************************************;
  2.         ;                                                            ;
  3.         ;       Function 28H: Random File Block Write, FCB-based     ;
  4.         ;                                                            ;
  5.         ;       int FCB_wblock(oXFCB,nrequest,nactual,start)         ;
  6.         ;           char *oXFCB;                                     ;
  7.         ;           int   nrequest;                                  ;
  8.         ;           int  *nactual;                                   ;
  9.         ;           long  start;                                     ;
  10.         ;                                                            ;
  11.         ;       Returns write status of 0, 1, or 2 and sets          ;
  12.         ;       nactual to number of records actually written.       ;
  13.         ;                                                            ;
  14.         ;       If start is -1, the relative-record field is         ;
  15.         ;       not changed, causing the block to be written         ;
  16.         ;       starting at the current record.                      ;
  17.         ;                                                            ;
  18.         ;************************************************************;
  19.  
  20. cProc   FCB_wblock,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    wb_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. wb_skip:
  38.         mov     cx,nrequest     ; CX = number of records to write.
  39.         mov     ah,28h          ; Get MS-DOS to write CX records
  40.         int     21h             ; from DTA to file.
  41.         loadDP  ds,bx,pnactual  ; DS:BX = address of nactual.
  42.         mov     ds:[bx],cx      ; Return number of records written.
  43.         cbw                     ; Clear high byte.
  44. cEnd
  45.