1: .globl b1
   2: .globl hblk
   3: .globl headers
   4: .globl  initl
   5: .globl asmem
   6: .globl b1s
   7: .globl b1e
   8: .globl w1
   9: .globl stats
  10: .globl  lookchar
  11: .globl  flush
  12: .globl  fsfile
  13: .globl  seekchar
  14: .globl  backspace
  15: .globl  alterchar
  16: .globl  zero
  17: .globl  getchar
  18: .globl  putchar
  19: .globl  copy
  20: .globl  rewind
  21: .globl  create
  22: .globl  allocate
  23: .globl  release
  24: .globl  collect
  25: .globl  w,r,a,l
  26: .globl  getword
  27: .globl  putword
  28: .globl  backword
  29: .globl  alterword
  30: /
  31: /
  32: /	routine to read next character from string
  33: /	pointer to by r1; character returned in r0
  34: /	c-bit set if character not availiable (eof)
  35: /
  36: /	mov	...,r1
  37: /	jsr	pc,getchar
  38: /	movb	r0,...
  39: /
  40: getchar:
  41:         jsr     pc,lookchar
  42:         bes     1f
  43:         inc     r(r1)
  44:         tst     r0              /clears c-bit
  45: 1:      rts     pc
  46: /
  47: /
  48: /	routine to read a string backwards
  49: /	the read pointer is decremented before reading
  50: /
  51: /	mov	...,r1
  52: /	jsr	pc,backspace
  53: /	mov	r0,...
  54: /
  55: backspace:
  56:         cmp     a(r1),r(r1)
  57:         bhis    nochc
  58:         dec     r(r1)
  59:         jsr     pc,lookchar
  60:         rts     pc
  61: nochc:  clr     r0
  62:         sec
  63:         rts     pc
  64: /
  65: /
  66: /	routine to put a word onto the string
  67: /
  68: /	mov	...,r1
  69: /	mov	...,r0
  70: /	jsr	pc,putword
  71: /
  72: putword:
  73:         mov     r0,-(sp)
  74:         sub     $hblk,r0
  75:         jsr     pc,putchar
  76:         swab    r0
  77:         jsr     pc,putchar
  78:         mov     (sp)+,r0
  79:         rts     pc
  80: /
  81: /
  82: /	routine to get a word from the string
  83: /
  84: /	mov	...,r1
  85: /	jsr	pc,getword
  86: /	mov	r0,...
  87: /
  88: getword:
  89:         jsr     pc,lookchar
  90:         bes     1f
  91:         movb    r0,nchar
  92:         inc     r(r1)
  93:         jsr     pc,lookchar
  94:         bes     1f
  95:         movb    r0,nchar+1
  96:         inc     r(r1)
  97:         mov     nchar,r0
  98:         add     $hblk,r0
  99: 1:      rts     pc
 100: /
 101: /
 102: /	routine to alter the word pointed to by r(r1)
 103: /	by replacing the word there with r0
 104: /
 105: /	mov	wd,r0
 106: /	mov	...,r1
 107: /	jsr	pc,alterword
 108: /
 109: alterword:
 110:         mov     r0,-(sp)
 111:         sub     $hblk,r0
 112:         jsr     pc,alterchar
 113:         swab    r0
 114:         jsr     pc,alterchar
 115:         mov     (sp)+,r0
 116:         rts     pc
 117: /
 118: /
 119: /	routine to get words backwards from string
 120: /
 121: /	mov	...,r1
 122: /	jsr	pc,backword
 123: /	mov	r0,...
 124: /
 125: backword:
 126:         cmp     a(r1),r(r1)
 127:         bhis    nochw
 128:         dec     r(r1)
 129:         jsr     pc,lookchar
 130:         movb    r0,nchar+1
 131:         cmp     a(r1),r(r1)
 132:         bhis    nochw
 133:         dec     r(r1)
 134:         jsr     pc,lookchar
 135:         movb    r0,nchar
 136:         mov     nchar,r0
 137:         add     $hblk,r0
 138:         rts     pc
 139: /
 140: nochw:
 141:         clr     r0
 142:         sec
 143:         rts     pc
 144: /
 145: /
 146: /	routine to copy the contents of one string
 147: /	to another.
 148: /
 149: /	mov	source,r0
 150: /	mov	dest,r1
 151: /	jsr	pc,copy
 152: /	mov	r1,...
 153: /
 154: /	on return, r1 points to the new string and should
 155: /	be saved.  r0 is preserved.
 156: /
 157: copy:
 158:         inc     stats+12.
 159:         mov     r0,-(sp)
 160:         mov     r1,-(sp)
 161:         mov     r2,-(sp)
 162:         mov     r3,-(sp)
 163:         mov     w(r0),r2
 164:         sub     a(r0),r2        /W-A (old)
 165:         mov     l(r1),r3
 166:         sub     a(r1),r3        /L-A (new)
 167:         cmp     r2,r3
 168:         blos    1f
 169:         mov     r2,r0
 170:         jsr     pc,allocate
 171:         mov     4(sp),r0        /new
 172:         jsr     pc,swap
 173:         jsr     pc,release
 174:         mov     r0,r1
 175:         mov     0(sp),r0        /old
 176: 1:
 177:         mov     a(r1),w(r1)     /rewind w pointer
 178:         cmp     r2,$512.
 179:         blos    copy1           /is a short string
 180: /
 181:         jsr     pc,flush
 182:         jsr     pc,reset
 183: /
 184:         mov     a(r0),-(sp)
 185: 4:
 186:         mov     (sp),0f
 187:         mov     afi,r0
 188:         sys     seek;0:.. ;0    /set input pointer
 189:         cmp     r2,$512.
 190:         blos    2f
 191:         mov     $512.,r3        /# output this time
 192:         mov     r3,0f
 193:         mov     r3,3f
 194:         add     r3,(sp)
 195:         sub     r3,r2   /# left to output
 196:         br      1f
 197: 2:
 198:         mov     r2,0f
 199:         mov     r2,3f
 200:         mov     r2,r3
 201:         clr     r2
 202: 1:
 203:         mov     afi,r0
 204:         sys     read;b1;0:..
 205:         bes     bad
 206:         cmp     r0,r3
 207:         bne     bad
 208:         mov     afout,r0
 209:         mov     (r1),0f
 210:         add     r3,(r1)
 211:         sys     seek;0:.. ;0
 212:         sys     write;b1;3:..
 213:         bes     bad
 214:         tst     r2
 215:         bgt     4b
 216:         tst     (sp)+
 217: /
 218: /	fix up read ptr of new string
 219: /
 220: copy2:
 221:         mov     6(sp),r0        /restore r0
 222:         mov     r(r0),r2
 223:         sub     a(r0),r2
 224:         add     a(r1),r2
 225:         mov     r2,r(r1)
 226: /
 227: /	restore and return
 228: /
 229:         mov     (sp)+,r3
 230:         mov     (sp)+,r2
 231:         mov     (sp)+,r1
 232:         mov     (sp)+,r0
 233:         rts     pc
 234: /
 235: bad:    mov     $1,r0
 236:         sys write;1f;2f-1f
 237:         4
 238: 1:      <error on copy\n>
 239: 2:      .even
 240: /
 241: swap:
 242:         mov     w(r1),-(sp)
 243:         mov     w(r0),w(r1)
 244:         mov     (sp),w(r0)
 245:         mov     r(r1),(sp)
 246: 
 247:         mov     r(r0),r(r1)
 248:         mov     (sp),r(r0)
 249:         mov     a(r1),(sp)
 250:         mov     a(r0),a(r1)
 251:         mov     (sp),a(r0)
 252:         mov     l(r1),(sp)
 253:         mov     l(r0),l(r1)
 254:         mov     (sp)+,l(r0)
 255:         rts     pc
 256: /
 257: /	copy a short string
 258: /
 259: copy1:
 260:         mov     r(r0),-(sp)
 261:         mov     a(r0),r(r0)
 262:         mov     nchar,-(sp)
 263:         mov     r0,r2           /old
 264:         mov     r1,r3           /new
 265: 1:
 266:         mov     r2,r1
 267:         jsr     pc,getchar
 268:         bes     1f
 269:         mov     r3,r1
 270:         jsr     pc,putchar
 271:         br      1b
 272: 1:
 273:         mov     r2,r0
 274:         mov     (sp)+,nchar
 275:         mov     (sp)+,r(r0)
 276:         mov     r3,r1
 277:         br      copy2
 278: /
 279: /
 280: /
 281: /
 282: /
 283: /	routine to rewind read pointer of string
 284: /	pointed to by r1
 285: /
 286: /	mov	...,r1
 287: /	jsr	pc,rewind
 288: /
 289: rewind:
 290:         mov     a(r1),r(r1)
 291:         rts     pc
 292: /
 293: /
 294: /	routine to rewind write pointer of string
 295: /	pointed to by r1
 296: /
 297: /	mov	...,r1
 298: /	jsr	pc,create
 299: /
 300: create:
 301:         mov     a(r1),w(r1)
 302:         mov     a(r1),r(r1)
 303:         rts     pc
 304: /
 305: /
 306: /	routine to zero a string
 307: /
 308: /	mov	...,r1
 309: /	jsr	pc,zero
 310: /
 311: zero:
 312:         mov     r0,-(sp)
 313:         .if testing
 314:         jsr     pc,preposterous
 315:         .endif
 316:         mov     a(r1),w(r1)
 317:         clrb    r0
 318: 1:      cmp     w(r1),l(r1)
 319:         bhis    1f
 320:         jsr     pc,putchar
 321:         br      1b
 322: 1:      mov     a(r1),w(r1)
 323:         mov     (sp)+,r0
 324:         rts     pc
 325: /
 326: /
 327: /
 328: /	routine to move the read pointer of a string to the
 329: /	relative position indicated by r0.  the string is
 330: /	extended if necessary - there is no error return.
 331: /
 332: /	mov	position,r0
 333: /	mov	...,r1
 334: /	jsr	pc,seekchar
 335: /
 336: seekchar:
 337:         mov     r1,-(sp)
 338:         mov     r0,-(sp)
 339:         .if testing
 340:         jsr     pc,preposterous
 341:         .endif
 342:         inc     stats+10.
 343: 1:
 344:         mov     (sp),r0
 345:         add     a(r1),r0
 346:         cmp     r0,l(r1)
 347:         bhi     3f
 348:         mov     r0,r(r1)
 349:         cmp     r0,w(r1)
 350:         blo     1f
 351:         mov     r0,w(r1)
 352:         br      1f
 353: 3:
 354:         mov     (sp),r0
 355:         jsr     pc,allocate
 356:         mov     2(sp),r0
 357:         jsr     pc,copy
 358:         jsr     pc,swap
 359:         jsr     pc,release
 360:         mov     2(sp),r1
 361:         br      1b
 362: 1:
 363:         mov     (sp)+,r0
 364:         mov     (sp)+,r1
 365:         rts     pc
 366: /
 367: /
 368: /	routine to move read pointer of string to end of string
 369: /
 370: /	mov	...,r1
 371: /	jsr	pc,fsfile
 372: /
 373: fsfile:
 374:         mov     r0,-(sp)
 375:         .if testing
 376:         jsr     pc,preposterous
 377:         .endif
 378:         inc     stats+10.
 379:         mov     w(r1),r(r1)
 380:         mov     (sp)+,r0
 381:         rts     pc
 382: /
 383: /
 384: /	routine to place the character in r0 at the current
 385: /	position of the read pointer - the read pointer
 386: /	is not moved.
 387: /
 388: /	movb	ch,r0
 389: /	mov	...,r1
 390: /	jsr	pc,alterchar
 391: /	mov	r1,...
 392: /
 393: alterchar:
 394:         mov     r2,-(sp)
 395:         mov     r1,-(sp)
 396:         mov     r0,nchar
 397:         .if testing
 398:         jsr     pc,preposterous
 399:         .endif
 400:         inc     stats+8.
 401: 1:      cmp     r(r1),l(r1)     /W,L
 402:         blo     3f
 403:         mov     l(r1),r0
 404:         inc     r0
 405:         sub     a(r1),r0        /W-A+1
 406:         jsr     pc,allocate
 407:         mov     (sp),r0
 408:         jsr     pc,copy
 409:         jsr     pc,swap
 410:         jsr     pc,release
 411:         mov     (sp),r1
 412: 3:
 413:         mov     r(r1),r0
 414:         jsr     pc,bufchar
 415:         bec     2f
 416:         jsr     pc,getbuf
 417: 
 418: 2:      movb    nchar,(r0)
 419:         mov     $1,w1(r2)
 420:         mov     nchar,r0        /to preserve r0 for user
 421:         inc     r(r1)
 422:         cmp     r(r1),w(r1)
 423:         blos    3f
 424:         mov     r(r1),w(r1)
 425: 3:
 426:         mov     (sp)+,r1
 427:         mov     (sp)+,r2
 428:         rts     pc
 429: /
 430: /
 431: /	routine to look at next character from string
 432: /	pointed to by r1;  character returned in r0
 433: /	c-bit set if character not available (end of file)
 434: /	r1 is preserved
 435: /
 436: /	mov	...,r1
 437: /	jsr	pc,lookchar
 438: /	movb	r0,...
 439: /
 440: lookchar:
 441:         mov     r2,-(sp)
 442:         inc     stats+6.
 443:         .if testing
 444:         jsr     pc,preposterous
 445:         .endif
 446:         cmp     w(r1),r(r1)     /W,R
 447:         blos    noch
 448:         mov     r(r1),r0
 449:         jsr     pc,bufchar
 450:         bec     2f
 451:         jsr     pc,getbuf
 452: /
 453: 2:
 454:         inc     flag
 455:         bne     2f
 456:         jsr     pc,fixct
 457:         br      1f
 458: 2:
 459:         mov     flag,u1(r2)
 460: 1:
 461:         mov     (sp)+,r2
 462:         movb    (r0),r0
 463:         tst     r0      /clears c-bit
 464:         rts     pc
 465: /
 466: noch:
 467:         mov     (sp)+,r2
 468:         clr     r0
 469:         sec
 470:         rts     pc
 471: /
 472: /
 473: /	routine to put a character into the string
 474: /	pointed to by r1;  character in r0
 475: /	r0 is preserved; r1 points to the string
 476: /	after return and must be saved.
 477: /
 478: /	movb	ch,r0
 479: /	mov	...,r1
 480: /	jsr	pc,putchar
 481: /	mov	r1,...
 482: /
 483: putchar:
 484:         mov     r2,-(sp)
 485:         mov     r1,-(sp)
 486:         mov     r0,nchar
 487:         .if testing
 488:         jsr     pc,preposterous
 489:         .endif
 490:         inc     stats+8.
 491: 1:      cmp     w(r1),l(r1)     /W,L
 492:         blo     3f
 493:         mov     w(r1),r0
 494:         inc     r0
 495:         sub     a(r1),r0        /W-A+1
 496:         jsr     pc,allocate
 497:         mov     (sp),r0
 498:         jsr     pc,copy
 499:         jsr     pc,swap
 500:         jsr     pc,release
 501:         mov     (sp),r1
 502: 3:
 503:         mov     w(r1),r0
 504:         jsr     pc,bufchar
 505:         bec     2f
 506:         jsr     pc,getbuf
 507: 2:      movb    nchar,(r0)
 508:         mov     $1,w1(r2)
 509:         mov     nchar,r0        /to preserve r0 for user
 510:         inc     w(r1)
 511:         inc     flag
 512:         bne     2f
 513:         jsr     pc,fixct
 514:         br      1f
 515: 2:
 516:         mov     flag,u1(r2)
 517: 1:
 518:         mov     (sp)+,r1
 519:         mov     (sp)+,r2
 520:         rts     pc
 521: /
 522: /
 523: /	routine to flush contents of all buffers.
 524: /
 525: /	jsr	pc,flush
 526: /
 527: flush:
 528:         mov     r1,-(sp)
 529:         mov     r2,-(sp)
 530:         mov     r3,-(sp)
 531:         clr     r3
 532: 1:
 533:         cmp     r3,$numb
 534:         bhis    1f
 535:         mov     r3,r2
 536:         asl     r2
 537:         tst     w1(r2)
 538:         ble     2f
 539:         mov     r3,r1
 540:         ashc    $9.,r1
 541:         bic     $777,r1
 542:         add     $b1,r1
 543:         jsr     pc,clean
 544: 2:
 545:         inc     r3
 546:         br      1b
 547: 1:
 548:         mov     (sp)+,r3
 549:         mov     (sp)+,r2
 550:         mov     (sp)+,r1
 551:         rts     pc
 552: /
 553: /
 554: reset:
 555:         mov     r3,-(sp)
 556:         mov     r2,-(sp)
 557:         clr     r3
 558: 1:
 559:         cmp     r3,$numb
 560:         bge     1f
 561:         mov     r3,r2
 562:         asl     r2
 563:         mov     $-1.,w1(r2)
 564:         clr     b1s(r2)
 565:         clr     b1e(r2)
 566:         clr     u1(r2)
 567:         inc     r3
 568:         br      1b
 569: 1:
 570:         clr     flag
 571:         mov     (sp)+,r2
 572:         mov     (sp)+,r3
 573:         rts     pc
 574: /
 575: /
 576: /	routine to read from disc to a buffer
 577: /	wcing the buffer if necessary
 578: /
 579: /	mov	disc addr,r0
 580: /	mov	buffer addr,r2
 581: /	jsr	pc,getb
 582: /
 583: /	on return r0 = addr of byte in buffer
 584: /
 585: getb:
 586:         mov     r3,-(sp)
 587:         mov     r1,-(sp)
 588:         mov     r0,-(sp)
 589:         mov     r2,r3
 590:         asr     r3
 591:         mov     r3,r1
 592:         ashc    $9.,r1
 593:         bic     $777,r1
 594:         add     $b1,r1
 595:         tst     w1(r2)  / w
 596:         ble     1f
 597: 
 598:         jsr     pc,clean
 599: 
 600: 1:      mov     (sp),r0
 601:         bic     $777,r0         /get lowest multiple of 512.
 602:         mov     r0,0f
 603:         mov     r0,b1s(r2)      /set start
 604:         mov     afi,r0
 605:         sys     seek;0:..;0
 606:         mov     r1,0f
 607:         sys     read;0:..;512.
 608: 
 609:         mov     b1s(r2),b1e(r2)
 610:         add     $512.,b1e(r2)   / set end
 611:         clr     w1(r2)          /clear w
 612:         mov     (sp)+,r0
 613:         sub     b1s(r2),r0
 614:         add     r1,r0           / set r0=byte addr in buffer
 615:         mov     (sp)+,r1
 616:         mov     (sp)+,r3
 617:         rts     pc
 618: /
 619: /
 620: /	routine to wc a buffer
 621: /
 622: /	mov	buffer addr,r2
 623: /	mov	buffer addr+6,r1	beginning of buffer
 624: /	jsr	pc,clean
 625: /
 626: clean:
 627:         inc     stats+24.
 628:         mov     r0,-(sp)
 629:         mov     b1s(r2),0f
 630:         mov     afout,r0
 631:         sys     seek;0:..;0
 632:         mov     r1,0f
 633:         sys     write;0:..;512.
 634: 
 635:         clr     w1(r2)  /clear w
 636:         mov     (sp)+,r0
 637:         rts     pc
 638: /
 639: /
 640: /	routine to get buffer addr of byte whose disc
 641: /	addr is in r0 - also returns addr of write
 642: /	flag for buffer in r2
 643: /
 644: /	mov	disc addr,r0
 645: /	jsr	pc,bufchar
 646: /	mov	(r0),r0	for read
 647: /	inc	(r2)	for write must inc w
 648: /
 649: /	c-bit set if char not in either buffer
 650: /
 651: bufchar:
 652:         mov     r1,-(sp)
 653:         mov     r3,-(sp)
 654:         clr     r3
 655: 1:
 656:         mov     r3,r2
 657:         asl     r2
 658:         cmp     r0,b1s(r2)
 659:         blo     2f
 660:         cmp     r0,b1e(r2)
 661:         bhis    2f
 662:         sub     b1s(r2),r0
 663:         mov     r3,r1
 664:         ashc    $9.,r1
 665:         bic     $777,r1
 666:         add     r1,r0
 667:         add     $b1,r0
 668:         mov     (sp)+,r3
 669:         mov     (sp)+,r1
 670:         clc
 671:         rts     pc
 672: 2:
 673:         inc     r3
 674:         cmp     r3,$numb
 675:         blt     1b
 676:         mov     (sp)+,r3
 677:         mov     (sp)+,r1
 678:         sec
 679:         rts     pc
 680: /
 681: /
 682: /	routine to get a buffer
 683: /
 684: /	mov	disc addr,r0
 685: /	jsr	pc,getbuf
 686: /	mov	(r0),r0		(for read)
 687: /	inc	(r2)		must inc w for w
 688: /
 689: getbuf:
 690:         mov     r4,-(sp)
 691:         mov     r3,-(sp)
 692:         mov     $2,r3
 693:         clr     r2
 694:         mov     $1,r4
 695: 1:
 696:         cmp     r4,$numb
 697:         bge     1f
 698:         cmp     u1(r3),u1(r2)
 699:         bhis    2f
 700:         mov     r3,r2
 701: 2:
 702:         inc     r4
 703:         add     $2.,r3
 704:         br      1b
 705: 1:
 706:         mov     r2,r3
 707:         jsr     pc,getb
 708:         add     $stats+14.,r3
 709:         inc     (r3)
 710:         mov     (sp)+,r3
 711:         mov     (sp)+,r4
 712:         rts     pc
 713: /
 714: /
 715: /	this routine renumbers the time used cell u1(r2)
 716: /	of the buffers when the clock overflows
 717: /
 718: fixct:
 719:         mov     r1,-(sp)
 720:         mov     r3,-(sp)
 721:         mov     $numb,r1
 722:         mov     $numb,flag
 723: 2:
 724:         mov     r1,u1(r2)
 725:         dec     r1
 726:         bge     1f
 727:         mov     (sp)+,r3
 728:         mov     (sp)+,r1
 729:         rts     pc
 730: 1:
 731:         clr     r2
 732:         mov     $2,r3
 733: 1:
 734:         cmp     r3,$numb2
 735:         bge     2b
 736:         cmp     u1(r3),u1(r2)
 737:         blo     2f
 738:         mov     r3,r2
 739: 2:
 740:         add     $2,r3
 741:         br      1b

Defined functions

alterchar declared in line 15; defined in line 393; used 20 times
alterword declared in line 29; defined in line 109; used 4 times
backspace declared in line 14; defined in line 55; used 64 times
backword declared in line 28; defined in line 125; used 4 times
bad defined in line 235; used 3 times
bufchar defined in line 651; used 3 times
clean defined in line 626; used 2 times
copy declared in line 19; defined in line 157; used 4 times
copy1 defined in line 259; used 1 times
copy2 defined in line 220; used 1 times
create declared in line 21; defined in line 300; used 10 times
fixct defined in line 718; used 2 times
flush declared in line 11; defined in line 527; used 10 times
fsfile declared in line 12; defined in line 373; used 48 times
getb defined in line 585; used 1 times
getbuf defined in line 689; used 3 times
getchar declared in line 17; defined in line 40; used 46 times
getword declared in line 26; defined in line 88; used 21 times
lookchar declared in line 10; defined in line 440; used 14 times
noch defined in line 466; used 1 times
nochc defined in line 61; used 1 times
  • in line 57
nochw defined in line 140; used 2 times
putchar declared in line 18; defined in line 483; used 78 times
putword declared in line 27; defined in line 72; used 14 times
rewind declared in line 20; defined in line 289; used 52 times
seekchar declared in line 13; defined in line 336; used 8 times
swap defined in line 241; used 4 times
zero declared in line 16; defined in line 311; used 9 times
Last modified: 1975-05-14
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 624
Valid CSS Valid XHTML 1.0 Strict