1: /
   2: /	routine to read from disc to a buffer
   3: /	wcing the buffer if necessary
   4: /	mov	disc addr,r0
   5: /	mov	buffer addr,r2
   6: /	jsr	pc,getb
   7: /	on return r0 = addr of byte in buffer
   8: /
   9: getb:
  10:         mov     r3,-(sp)
  11:         mov     r1,-(sp)
  12:         mov     r0,-(sp)
  13:         mov     r2,r3
  14:         asr     r3
  15:         mov     r3,r1
  16:         ashc    $9.,r1
  17:         bic     $777,r1
  18:         add     $b1,r1
  19:         tst     w1(r2)  / w
  20:         ble     1f
  21: 
  22:         jsr     pc,clean
  23: 
  24: 1:      mov     (sp),r0
  25:         bic     $777,r0         /get lowest multiple of 512.
  26:         mov     r0,0f
  27:         mov     r0,b1s(r2)      /set start
  28:         mov     afi,r0
  29:         sys     seek;0:..;0
  30:         mov     r1,0f
  31:         sys     read;0:..;512.
  32: 
  33:         mov     b1s(r2),b1e(r2)
  34:         add     $512.,b1e(r2)   / set end
  35:         clr     w1(r2)  /clear w
  36:         mov     (sp)+,r0
  37:         sub     b1s(r2),r0
  38:         add     r1,r0   / set r0=byte addr in buffer
  39:         mov     (sp)+,r1
  40:         mov     (sp)+,r3
  41:         rts     pc
  42: /
  43: /
  44: /	routine to wc a buffer
  45: /	mov	buffer addr,r2
  46: /	mov	buffer addr+6,r1	beginning of buffer
  47: /	jsr	pc,clean
  48: /
  49: clean:
  50:         mov     r0,-(sp)
  51:         mov     b1s(r2),0f
  52:         mov     afout,r0
  53:         sys     seek;0:..;0
  54:         mov     r1,0f
  55:         sys     write;0:..;512.
  56: 
  57:         clr     w1(r2)  /clear w
  58:         mov     (sp)+,r0
  59:         rts     pc
  60: /
  61: /	routine to get buffer addr of byte whose disc
  62: /	addr is in r0 - also returns addr of write
  63: /	flag for buffer in r2
  64: /	mov	disc addr,r0
  65: /	jsr	pc,bufchar
  66: /	mov	(r0),r0	for read
  67: /	inc	(r2)	for write must inc w
  68: /	c-bit set if char not in either buffer
  69: /
  70: bufchar:
  71:         mov     r1,-(sp)
  72:         mov     r3,-(sp)
  73:         clr     r3
  74: 1:
  75:         mov     r3,r2
  76:         asl     r2
  77:         cmp     r0,b1s(r2)
  78:         blo     2f
  79:         cmp     r0,b1e(r2)
  80:         bhis    2f
  81:         sub     b1s(r2),r0
  82:         mov     r3,r1
  83:         ashc    $9.,r1
  84:         bic     $777,r1
  85:         add     r1,r0
  86:         add     $b1,r0
  87:         mov     (sp)+,r3
  88:         mov     (sp)+,r1
  89:         clc
  90:         rts     pc
  91: 2:
  92:         inc     r3
  93:         cmp     r3,nbuf
  94:         blt     1b
  95:         mov     (sp)+,r3
  96:         mov     (sp)+,r1
  97:         sec
  98:         rts     pc
  99: /
 100: /	routine to get a buffer
 101: /	mov	disc addr,r0
 102: /	jsr	pc,getbuf
 103: /	mov	(r0),r0	(for read)
 104: /	inc	(r2)	must inc w for w
 105: /
 106: getbuf:
 107:         mov     r4,-(sp)
 108:         mov     r3,-(sp)
 109:         mov     $2,r3
 110:         clr     r2
 111:         mov     $1,r4
 112: 1:
 113:         cmp     r4,nbuf
 114:         bge     1f
 115:         cmp     u1(r3),u1(r2)
 116:         bhis    2f
 117:         mov     r3,r2
 118: 2:
 119:         inc     r4
 120:         add     $2.,r3
 121:         br      1b
 122: 1:
 123:         mov     r2,r3
 124:         jsr     pc,getb
 125:         add     $stats+6.,r3
 126:         inc     (r3)
 127:         mov     (sp)+,r3
 128:         mov     (sp)+,r4
 129:         rts     pc
 130: /
 131: /	routine to look at next character from string
 132: /	pointed to by r1;  character returned in r0
 133: /	c-bit set if character not available (end of file)
 134: /	r1 is preserved
 135: /
 136: /	mov	...,r1
 137: /	jsr	pc,lookchar
 138: /	movb	r0,...
 139: /
 140: lookchar:
 141:         mov     r2,-(sp)
 142:         jsr     pc,plausible
 143:         cmp     w(r1),r(r1)     /W,R
 144:         blos    noch
 145:         mov     r(r1),r0
 146:         jsr     pc,bufchar
 147:         bec     2f
 148:         jsr     pc,getbuf
 149: /
 150: 2:
 151:         inc     flag
 152:         bne     2f
 153:         jsr     pc,fixct
 154:         br      1f
 155: 2:
 156:         mov     flag,u1(r2)
 157: 1:
 158:         mov     (sp)+,r2
 159:         movb    (r0),r0
 160:         tst     r0      /clears c-bit
 161:         rts     pc
 162: /
 163: noch:
 164:         mov     (sp)+,r2
 165:         clr     r0
 166:         sec
 167:         rts     pc
 168: /
 169: /
 170: /	routine to put a character into the string
 171: /	pointed to by r1;  character in r0
 172: /	r0 is preserved; r1 points to the string
 173: /	after return and must be saved.
 174: /
 175: /	movb	ch,r0
 176: /	mov	...,r1
 177: /	jsr	pc,putchar
 178: /	mov	r1,...
 179: /
 180: putchar:
 181:         mov     r2,-(sp)
 182:         mov     r1,-(sp)
 183:         mov     r0,nchar
 184:         jsr     pc,plausible
 185: 1:      cmp     w(r1),l(r1)     /W,L
 186:         blt     3f
 187:         mov     w(r1),r0
 188:         inc     r0
 189:         sub     a(r1),r0        /W-A+1
 190:         jsr     pc,allocate
 191:         mov     (sp),r0
 192:         jsr     pc,copy
 193:         jsr     pc,swap
 194:         jsr     pc,release
 195:         mov     (sp),r1
 196: /
 197: 3:      mov     w(r1),r0
 198:         jsr     pc,bufchar
 199:         bec     2f
 200:         jsr     pc,getbuf
 201: 2:      movb    nchar,(r0)
 202:         mov     $1,w1(r2)
 203: 
 204:         mov     nchar,r0        /to preserve r0 for user
 205:         inc     w(r1)
 206:         inc     flag
 207:         bne     2f
 208:         jsr     pc,fixct
 209:         br      1f
 210: 2:
 211:         mov     flag,u1(r2)
 212: 1:
 213:         mov     (sp)+,r1
 214:         mov     (sp)+,r2
 215:         rts     pc
 216: 
 217: /
 218: /
 219: fixct:
 220:         mov     r1,-(sp)
 221:         mov     r3,-(sp)
 222:         mov     nbuf,r1
 223:         mov     nbuf,flag
 224: 2:
 225:         mov     r1,u1(r2)
 226:         dec     r1
 227:         bge     1f
 228:         mov     (sp)+,r3
 229:         mov     (sp)+,r1
 230:         rts     pc
 231: 1:
 232:         clr     r2
 233:         mov     $2,r3
 234: 1:
 235:         cmp     r3,nbuf2
 236:         bge     2b
 237:         cmp     u1(r3),u1(r2)
 238:         blo     2f
 239:         mov     r3,r2
 240: 2:
 241:         add     $2,r3
 242:         br      1b

Defined functions

bufchar defined in line 70; used 2 times
clean defined in line 49; used 1 times
  • in line 22
fixct defined in line 219; used 2 times
getb defined in line 9; used 1 times
getbuf defined in line 106; used 2 times
lookchar defined in line 140; never used
noch defined in line 163; used 1 times
putchar defined in line 180; never used
Last modified: 1975-05-14
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 471
Valid CSS Valid XHTML 1.0 Strict