
void putbuf (char c)                             // Write a Character to SBUF

{
  if (!FLG_Sendfull)                             // Transmitt only if buffer not full
     {
       if (!FLG_Sendactive)                      //  and currently not transmitting.
	  {
	    FLG_Sendactive = 1 ; 
	    SBUF0 = c ;                          // Start direct transmission.
         }
       else
	  {
 	   IE = 0xA2 ;                           // Disable serial interrupt during buffer update.
	   outbuf [oend++ & (OLEN-1)] = c ;      // Put char to transmission buffer..
           if (((oend ^ ostart ) & (OLEN-1)) == 0)
              {
		FLG_Sendfull = 1;                // Buffer full
	      }
	   IE = 0xB2 ;                          // Enable Serial Interrupt again
	   }
       }
 }
/*===============================================//

// Replacement routine for standard "putchar" routine. 
The printf function uses this to output a character */

char putchar ( char c )

{
  if ( c == 'n')                                // Expand new line character..
     {
	     while (FLG_Sendfull);               // Wait for space in buffer
	     putbuf (0x0A) ;                     // Send CR before LF for <new line>
     }
  while (FLG_Sendfull);
  putbuf (c);                                    // Send chartacter.
  return (c);
}
