putchar.c

来自「上课老师给的8086仿真器」· C语言 代码 · 共 55 行

C
55
字号
/*
 *  This file is part of the C-51 Compiler package
 *  Copyright (c) KEIL ELEKTRONIK GmbH and Franklin Software Inc. 1993
 *
 *  PUTCHAR.C:  This routine is the general character output of C-51.
 *
 *  To compile this file use C51 with the following invocation:
 *
 *     C51 PUTCHAR.C
 *
 *  To link the modified PUTCHAR.OBJ file to your application use the
 *  following L51 invocation:
 *
 *     L51 <your object file list>, PUTCHAR.OBJ <controls>
 *
*/

#include <reg51.h>

#define XON  0x11
#define XOFF 0x13

char putchar (char c)  {
  if (c == '\n')  {
    if (RI)  {
      if (SBUF == XOFF)  {
        do  {
          RI = 0;
          while (!RI);
        }
        while (SBUF != XON);
        RI = 0; 
      }
    }
    while (!TI);
    TI = 0;
    SBUF = 0x0d;                         /* output CR  */
  }

  if (RI)  {
    if (SBUF == XOFF)  {
      do  {
        RI = 0;
        while (!RI);
      }
      while (SBUF != XON);
      RI = 0; 
    }
  }

  while (!TI);
  TI = 0;
  return (SBUF = c);
}

⌨️ 快捷键说明

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