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     $1,-(sp)
 131:         mov     $_unit2,-(sp)
 132:         mov     $2,-(sp)
 133:         jsr     pc,_write
 134:         add     $6,sp
 135:         tst     r0
 136:         bmi     9b
 137:         cmp     r0,$1
 138:         bne     9b
 139:         rts     pc
 140: unit:
 141:         mov     r0,buf
 142:         beq     1f
 143:         tst     FUNIT(r0)
 144:         bmi     1f
 145:         mov     PFNAME(r0),_file
 146:         rts     pc
 147: 1:
 148:         mov     $EREFINAF,_perrno
 149:         error   EREFINAF
 150: /
 151: / standard files
 152: /
 153: .data
 154: /
 155: / unit 0 for "input"
 156: /
 157: u0buf:  .=.+518.
 158:         .-518.          / buffer pointer
 159:         0
 160:         0
 161:         stdin
 162:         0               / file name
 163:         FTEXT+FREAD+SYNC+0              / flags & unit number
 164:         1               / size of items
 165: _unit0:
 166:         0               / window
 167: /
 168: / unit 1 for "output"
 169: /
 170: u1buf:  1               / file descriptor for putc
 171: _draino:
 172: u1cnt:  .=.+516.
 173:         u1buf           / putc buffer pointer
 174:         0
 175:         0
 176:         stdout
 177:         0
 178:         FTEXT+FWRITE+1+EOF
 179:         1
 180: _unit1:
 181:         0
 182: /
 183: / unit2 for <message>
 184: /
 185:         0
 186:         0
 187:         0
 188:         mesgf
 189:         0
 190:         FTEXT+FWRITE+2
 191:         1
 192: _unit2:
 193:         0
 194: /
 195: FBUF = -14.
 196: FCHAIN = -12.
 197: FLEV = -10.
 198: PFNAME = -8.
 199: FNAME = -6
 200: FUNIT = -4
 201: FSIZE = -2
 202: nextu:  '0              / next temp file
 203: tnam:   <tmp.x\0>
 204: .even
 205: .bss
 206: buf:    .=.+2
 207: fchain: .=.+2
 208: .data
 209: bufopt: 1
 210: stdin:  <standard input\0>
 211: stdout: <standard output\0>
 212: mesgf:  <message file\0>
 213: .text
 214: EOF = 400
 215: EOLN = 1000
 216: SYNC = 2000
 217: TEMP = 4000
 218: FREAD = 10000
 219: FWRITE = 20000
 220: FTEXT = 40000

Defined functions

EOF defined in line 214; used 3 times
EOLN defined in line 215; used 2 times
FREAD defined in line 218; used 2 times
FTEXT defined in line 220; used 4 times
FWRITE defined in line 219; used 4 times
SYNC defined in line 216; used 4 times
TEMP defined in line 217; 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 140; used 1 times
  • in line 9

Defined variables

FBUF defined in line 195; used 4 times
FCHAIN defined in line 196; used 1 times
  • in line 21
FLEV defined in line 197; never used
FNAME defined in line 199; never used
FSIZE defined in line 201; used 2 times
FUNIT defined in line 200; used 12 times
PFNAME defined in line 198; used 1 times
_draino defined in line 171; never used
_unit0 defined in line 165; never used
_unit1 defined in line 180; used 1 times
  • in line 24
_unit2 defined in line 192; used 3 times
buf defined in line 206; used 12 times
bufopt defined in line 209; never used
fchain defined in line 207; used 1 times
  • in line 11
mesgf defined in line 212; used 1 times
nextu defined in line 202; never used
stdin defined in line 210; used 1 times
stdout defined in line 211; used 1 times
tnam defined in line 203; never used
u0buf defined in line 157; never used
u1buf defined in line 170; used 1 times
u1cnt defined in line 172; never used
Last modified: 1987-03-13
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 2793
Valid CSS Valid XHTML 1.0 Strict