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

  1.         ;************************************************************;
  2.         ;                                                            ;
  3.         ;     Function 44H, Subfunctions 02H,03H:                    ;
  4.         ;                   IOCTL Character Device Control           ;
  5.         ;                                                            ;
  6.         ;     int ioctl_char_ctrl(recvflag,handle,pbuffer,nbytes)    ;
  7.         ;         int   recvflag;                                    ;
  8.         ;         int   handle;                                      ;
  9.         ;         char *pbuffer;                                     ;
  10.         ;         int   nbytes;                                      ;
  11.         ;                                                            ;
  12.         ;     Set recvflag = 0 to get flags, 1 to set flags.         ;
  13.         ;                                                            ;
  14.         ;     Returns -1 for error, otherwise returns number of      ;
  15.         ;     bytes sent or received.                                ;
  16.         ;                                                            ;
  17.         ;************************************************************;
  18.  
  19. cProc   ioctl_char_ctrl,PUBLIC,<ds>
  20. parmB   recvflag
  21. parmW   handle
  22. parmDP  pbuffer
  23. parmW   nbytes
  24. cBegin
  25.         mov     al,recvflag     ; Get recvflag.
  26.         and     al,1            ; Keep only lsb.
  27.         add     al,3            ; AL = 02H for receive, 03H for send.
  28.         mov     bx,handle       ; Get character-device handle.
  29.         mov     cx,nbytes       ; Get number of bytes to receive/send.
  30.         loadDP  ds,dx,pbuffer   ; Get pointer to buffer.
  31.         mov     ah,44h          ; Set function code.
  32.         int     21h             ; Call MS-DOS.
  33.         jnc     iccx            ; Branch if no error.
  34.         mov     ax,-1           ; Return -1 for all errors.
  35. iccx:
  36. cEnd
  37.