1: /*
   2:  * Copyright (c) 1987 Regents of the University of California.
   3:  * All rights reserved.  The Berkeley software License Agreement
   4:  * specifies the terms and conditions for redistribution.
   5:  */
   6: 
   7: #ifdef LIBC_SCCS
   8:         <@(#)fputc.s	1.1 (Berkeley) 2/4/87\0>
   9:         .even
  10: #endif LIBC_SCCS
  11: 
  12: #include "DEFS.h"
  13: #include "STDIO.h"
  14: 
  15: .globl  __flsbuf
  16: 
  17: /*
  18:  * fputc(c, iop)
  19:  *	char	c;
  20:  *	FILE	*iop;
  21:  *
  22:  * Output c to stream iop and return c.  For unbuffered streams iop->cnt is
  23:  * always zero.  For normally buffered streams iop->cnt is the amount of space
  24:  * left in the buffer.  For line buffered streams, -(iop->cnt) is the number
  25:  * of characters in the buffer.
  26:  */
  27: ENTRY(fputc)
  28:         mov     4(sp),r1                / grab iop
  29:         dec     _CNT(r1)                / less room in buffer
  30:         blt     2f
  31:         mov     2(sp),r0                / grab the character (for return)
  32: 1:
  33:         movb    r0,*_PTR(r1)            / push character into the buffer,
  34:         inc     _PTR(r1)                /   increment the pointer,
  35:         bic     $!0377,r0               /   cast to u_char - just in case ...
  36:         rts     pc                      /   and return
  37: 2:
  38:         bit     $_IOLBF,_FLAG(r1)       / iop-cnt < 0: are we line buffered?
  39:         beq     3f                      / (nope, flush output)
  40:         mov     _CNT(r1),r0             / -(iop->cnt) < iop->bufsiz?
  41:         add     _BUFSIZ(r1),r0          / (same as 0 < iop->bufsiz + iop->cnt)
  42:         ble     3f                      / (nope, flush output)
  43:         mov     2(sp),r0                / grab the character
  44:         cmpb    r0,$NL                  / a newline?
  45:         bne     1b                      / no, just put it into the buffer
  46: 3:
  47:         jmp     __flsbuf

Defined functions

_fputc defined in line 27; used 152 times
Last modified: 1987-02-11
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 361
Valid CSS Valid XHTML 1.0 Strict