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

  1.         ;************************************************************;
  2.         ;                                                            ;
  3.         ;   Function 44H, Subfunctions 04H,05H:                      ;
  4.         ;                 IOCTL Block Device Control                 ;
  5.         ;                                                            ;
  6.         ;   int ioctl_block_ctrl(recvflag,drive_ltr,pbuffer,nbytes)  ;
  7.         ;       int   recvflag;                                      ;
  8.         ;       int   drive_ltr;                                     ;
  9.         ;       char *pbuffer;                                       ;
  10.         ;       int   nbytes;                                        ;
  11.         ;                                                            ;
  12.         ;   Set recvflag = 0 to receive info, 1 to send.             ;
  13.         ;                                                            ;
  14.         ;   Returns -1 for error, otherwise returns number of        ;
  15.         ;   bytes sent or received.                                  ;
  16.         ;                                                            ;
  17.         ;************************************************************;
  18.  
  19. cProc   ioctl_block_ctrl,PUBLIC,<ds>
  20. parmB   recvflag
  21. parmB   drive_ltr
  22. parmDP  pbuffer
  23. parmW   nbytes
  24. cBegin
  25.         mov     al,recvflag     ; Get recvflag.
  26.         and     al,1            ; Keep only lsb.
  27.         add     al,5            ; AL = 04H for receive, 05H for send.
  28.         mov     bl,drive_ltr    ; Get drive letter.
  29.         or      bl,bl           ; Leave 0 alone.
  30.         jz      ibc
  31.         and     bl,not 20h      ; Convert letter to uppercase.
  32.         sub     bl,'A'-1        ; Convert to drive number: 'A' = 1,
  33.                                 ; 'B' = 2, etc.
  34. ibc:
  35.         mov     cx,nbytes       ; Get number of bytes to recv/send.
  36.         loadDP  ds,dx,pbuffer   ; Get pointer to buffer.
  37.         mov     ah,44h          ; Set function code.
  38.         int     21h             ; Call MS-DOS.
  39.         jnc     ibcx            ; Branch if no error.
  40.         mov     ax,-1           ; Return -1 for all errors.
  41. ibcx:
  42. cEnd
  43.