streams.c

来自「Embedded magazine source code. this is t」· C语言 代码 · 共 50 行

C
50
字号
      case DOS_READ:
         p = (BYTE_PTR) MK_FP(ds, dx) ;
         i = 0 ;
         while (i < cx)   {
            ch = _getch() ;
            /* Check for and process backspace characters */
            if (ch == '\b')   {
               if (i > 0)   {
                  _putch(ch) ;
                  _putch(' ') ;
                  _putch(ch) ;
                  p-- ;
                  i-- ;
               }
               continue ;
            }
            /* Check for the end of the line */
            if (ch == '\r')   {
               _putch(*p++ = ch) ;
               _putch(*p = '\n') ;
               i += 2 ;
               break ;
            }
            /* Put the character in the buffer and echo */
            _putch(*p++ = ch) ;
            i++ ;
         }
         /* Return the number of characters read in AX */
         ax = i ;
         break ;

      case DOS_WRITE:
         p = (BYTE_PTR) MK_FP(ds, dx) ;
         for (i = 0; i < cx; i++)
            _putch(*p++) ;

         /* Return the number of characters written in AX */
         ax = i ;
         break ;

      case DOS_IOCTL:
         if (lowbyte(ax) == 0)   {
            dx = 0x80d3 ;
         }
         else   {
            psw |= 1 ;              /* Signal an error */
            ax = 6 ;                /* Invalid or not open handle */
         }
         break ;


⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?