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

  1.         ;************************************************************;
  2.         ;                                                            ;
  3.         ;        Function 0AH: Buffered Keyboard Input               ;
  4.         ;                                                            ;
  5.         ;        int read_str(pbuf,len)                              ;
  6.         ;            char *pbuf;                                     ;
  7.         ;            int len;                                        ;
  8.         ;                                                            ;
  9.         ;        Returns number of bytes read into buffer.           ;
  10.         ;                                                            ;
  11.         ;        Note: pbuf must be at least len+3 bytes long.       ;
  12.         ;                                                            ;
  13.         ;************************************************************;
  14.  
  15. cProc   read_str,PUBLIC,<ds,di>
  16. parmDP  pbuf
  17. parmB   len
  18. cBegin
  19.         loadDP  ds,dx,pbuf      ; DS:DX = pointer to buffer.
  20.         mov     al,len          ; AL = len.
  21.         inc     al              ; Add 1 to allow for CR in buf.
  22.         mov     di,dx
  23.         mov     [di],al         ; Store max length into buffer.
  24.         mov     ah,0ah          ; Set function code.
  25.         int     21h             ; Ask MS-DOS to read string.
  26.         mov     al,[di+1]       ; Return number of characters read.
  27.         mov     ah,0
  28.         mov     bx,ax
  29.         mov     [bx+di+2],ah    ; Store 0 at end of buffer.
  30. cEnd
  31.