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

  1.         ;************************************************************;
  2.         ;                                                            ;
  3.         ;          Function 40H: Write File or Device                ;
  4.         ;                                                            ;
  5.         ;          int write(handle,pbuffer,nbytes)                  ;
  6.         ;              int handle,nbytes;                            ;
  7.         ;              char *pbuffer;                                ;
  8.         ;                                                            ;
  9.         ;          Returns -1 if there was a write error,            ;
  10.         ;          otherwise returns number of bytes written.        ;
  11.         ;                                                            ;
  12.         ;************************************************************;
  13.  
  14. cProc   write,PUBLIC,ds
  15. parmW   handle
  16. parmDP  pbuffer
  17. parmW   nbytes
  18. cBegin
  19.         mov     bx,handle       ; Get handle.
  20.         loadDP  ds,dx,pbuffer   ; Get pointer to buffer.
  21.         mov     cx,nbytes       ; Get number of bytes to write.
  22.         mov     ah,40h          ; Set function code.
  23.         int     21h             ; Ask MS-DOS to write CX bytes.
  24.         jnb     wr_ok           ; Branch if write successful.
  25.         mov     ax,-1           ; Else return -1.
  26. wr_ok:
  27. cEnd
  28.