1: /
   2: / IO SUBROUTINES
   3: /
   4:         .globl  _getc,_putc
   5: _pmessage:
   6:         mov     r3,-(sp)
   7:         mov     _file,r3
   8:         mov     $_unit2,r0
   9:         jsr     pc,unit
  10:         mov     r3,_file
  11:         mov     fchain,r3       / flush all files
  12: 1:
  13:         tst     r3
  14:         beq     2f
  15:         bit     $FWRITE,FUNIT(r3)
  16:         beq     3f
  17:         mov     FBUF(r3),-(sp)
  18:         jsr     pc,_fflush
  19:         tst     (sp)+
  20: 3:
  21:         mov     FCHAIN(r3),r3
  22:         br      1b
  23: 2:
  24:         mov     $_unit1,r3
  25:         mov     FBUF(r3),-(sp)
  26:         jsr     pc,_fflush
  27:         tst     (sp)+
  28:         mov     (sp)+,r3
  29:         rts     pc
  30: _pputch:
  31:         mov     2(sp),*buf
  32:         jsr     pc,put
  33:         rts     pc
  34: /
  35: / iosync insures that
  36: / a useable image is in
  37: / the buffer window.
  38: /
  39: 2:
  40:         mov     (sp)+,r3
  41:         mov     (sp)+,r2
  42:         mov     (sp)+,r1
  43:         rts     pc
  44: iosync:
  45:         mov     buf,r0
  46:         bit     $SYNC,FUNIT(r0)         / dirty bit
  47:         bne     1f
  48:         rts     pc
  49: 1:
  50:         mov     r1,-(sp)
  51:         mov     r2,-(sp)
  52:         mov     r3,-(sp)
  53:         mov     r0,r2
  54:         bic     $SYNC,FUNIT(r2)
  55:         bit     $EOF,FUNIT(r2)
  56:         bne     pasteof
  57:         mov     FSIZE(r2),r3
  58: 1:
  59:         mov     buf,r0
  60:         mov     FBUF(r0),-(sp)
  61:         jsr     pc,_getc
  62:         tst     (sp)+
  63:         tst     r0
  64:         bmi     eof
  65:         movb    r0,(r2)+
  66:         sob     r3,1b
  67:         mov     buf,r0
  68:         bic     $EOLN,FUNIT(r0)
  69:         bit     $FTEXT,FUNIT(r0)
  70:         beq     2b
  71:         cmpb    *buf,$'\n
  72:         bne     2b
  73:         bis     $EOLN,FUNIT(r0)
  74:         movb    $' ,*buf
  75:         br      2b
  76: eof:
  77:         mov     buf,r0
  78:         bis     $EOF,FUNIT(r0)
  79:         br      2b
  80: pasteof:
  81:         mov     $EPASTEOF,_perrno
  82:         error   EPASTEOF
  83: /
  84: / get insures that
  85: / something is in the window
  86: / and then sets the dirty
  87: / bit effectively throwing the
  88: / windowed data away
  89: /
  90: get:
  91:         mov     r1,-(sp)
  92:         mov     buf,r1
  93:         bit     $FREAD,FUNIT(r1)
  94:         bne     1f
  95:         mov     $EREADIT,_perrno
  96:         error   EREADIT
  97: 1:
  98:         jsr     pc,iosync
  99:         bis     $SYNC,FUNIT(r1)
 100:         mov     (sp)+,r1
 101:         rts     pc
 102: put:
 103:         cmp     buf,$_unit2
 104:         beq     6f
 105:         mov     r2,-(sp)
 106:         mov     r3,-(sp)
 107:         mov     buf,r2
 108:         bit     $FWRITE,FUNIT(r2)
 109:         bne     1f
 110:         mov     $EWRITEIT,_perrno
 111:         error   EWRITEIT
 112: 1:
 113:         mov     FSIZE(r2),r3
 114: 1:
 115:         mov     buf,r0
 116:         mov     FBUF(r0),-(sp)  / the hidden buffer
 117:         movb    (r2)+,-(sp)     / the character to write
 118:         jsr     pc,_putc
 119:         cmp     (sp)+,(sp)+
 120:         tst     _errno          / error occurred?
 121:         bne     9f
 122:         sob     r3,1b
 123:         mov     (sp)+,r3
 124:         mov     (sp)+,r2
 125:         rts     pc
 126: 9:
 127:         mov     $EWRITE,_perrno
 128:         error   EWRITE
 129: 6:
 130:         mov     $2,r0
 131:         sys     write; _unit2; 1
 132:         bes     9b
 133:         cmp     r0,$1
 134:         bne     9b
 135:         rts     pc
 136: unit:
 137:         mov     r0,buf
 138:         beq     1f
 139:         tst     FUNIT(r0)
 140:         bmi     1f
 141:         mov     PFNAME(r0),_file
 142:         rts     pc
 143: 1:
 144:         mov     $EREFINAF,_perrno
 145:         error   EREFINAF
 146: /
 147: / standard files
 148: /
 149: .data
 150: /
 151: / unit 0 for "input"
 152: /
 153: u0buf:  .=.+518.
 154:         .-518.          / buffer pointer
 155:         0
 156:         0
 157:         stdin
 158:         0               / file name
 159:         FTEXT+FREAD+SYNC+0              / flags & unit number
 160:         1               / size of items
 161: _unit0:
 162:         0               / window
 163: /
 164: / unit 1 for "output"
 165: /
 166: u1buf:  1               / file descriptor for putc
 167: _draino:
 168: u1cnt:  .=.+516.
 169:         u1buf           / putc buffer pointer
 170:         0
 171:         0
 172:         stdout
 173:         0
 174:         FTEXT+FWRITE+1+EOF
 175:         1
 176: _unit1:
 177:         0
 178: /
 179: / unit2 for <message>
 180: /
 181:         0
 182:         0
 183:         0
 184:         mesgf
 185:         0
 186:         FTEXT+FWRITE+2
 187:         1
 188: _unit2:
 189:         0
 190: /
 191: FBUF = -14.
 192: FCHAIN = -12.
 193: FLEV = -10.
 194: PFNAME = -8.
 195: FNAME = -6
 196: FUNIT = -4
 197: FSIZE = -2
 198: nextu:  '0              / next temp file
 199: tnam:   <tmp.x\0>
 200: .even
 201: .bss
 202: buf:    .=.+2
 203: fchain: .=.+2
 204: .data
 205: bufopt: 1
 206: stdin:  <standard input\0>
 207: stdout: <standard output\0>
 208: mesgf:  <message file\0>
 209: .text
 210: EOF = 400
 211: EOLN = 1000
 212: SYNC = 2000
 213: TEMP = 4000
 214: FREAD = 10000
 215: FWRITE = 20000
 216: FTEXT = 40000

Defined functions

EOF defined in line 210; used 3 times
EOLN defined in line 211; used 2 times
FREAD defined in line 214; used 2 times
FTEXT defined in line 216; used 4 times
FWRITE defined in line 215; used 4 times
SYNC defined in line 212; used 4 times
TEMP defined in line 213; never used
_pmessage defined in line 5; never used
_pputch defined in line 30; never used
eof defined in line 76; used 1 times
  • in line 64
get defined in line 90; never used
iosync defined in line 44; used 1 times
  • in line 98
pasteof defined in line 80; used 1 times
  • in line 56
put defined in line 102; used 1 times
  • in line 32
unit defined in line 136; used 1 times
  • in line 9

Defined variables

FBUF defined in line 191; used 4 times
FCHAIN defined in line 192; used 1 times
  • in line 21
FLEV defined in line 193; never used
FNAME defined in line 195; never used
FSIZE defined in line 197; used 2 times
FUNIT defined in line 196; used 12 times
PFNAME defined in line 194; used 1 times
_draino defined in line 167; never used
_unit0 defined in line 161; never used
_unit1 defined in line 176; used 1 times
  • in line 24
_unit2 defined in line 188; used 3 times
buf defined in line 202; used 12 times
bufopt defined in line 205; never used
fchain defined in line 203; used 1 times
  • in line 11
mesgf defined in line 208; used 1 times
nextu defined in line 198; never used
stdin defined in line 206; used 1 times
stdout defined in line 207; used 1 times
tnam defined in line 199; never used
u0buf defined in line 153; never used
u1buf defined in line 166; used 1 times
u1cnt defined in line 168; never used
Last modified: 1981-07-10
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1005
Valid CSS Valid XHTML 1.0 Strict