1: /
   2: /
   3: 
   4: / roff1 -- text formatter
   5: 
   6:         .globl ttyn
   7:         nop = 000240
   8:         signal = 48.
   9: 
  10: ibuf: /init code in ibuf+obuf
  11:         cmp     sp,$end
  12:         bhi     1f
  13:         jsr     r5,string; emes1
  14:         sys     exit
  15: 1:
  16:         clr     r0
  17:         jsr     pc,mesg
  18:         sys     signal; 1; place
  19:         sys     signal; 2; place
  20:         jsr     pc,makebf
  21:         sys     open; suffil; 0
  22:         bes     1f
  23:         mov     r0,suff
  24:         sys     seek; 20; 0
  25:         bes     1f
  26:         mov     suff,r0
  27:         sys     read; suftab; 2*26.
  28: 1:
  29:         clr     r0
  30:         mov     (sp)+,argc
  31:         dec     argc
  32:         bne     1f
  33:         jmp     place
  34: 1:
  35:         tst     (sp)+
  36:         mov     (sp),r4
  37:         cmpb    (r4)+,$'+
  38:         bne     2f
  39:         jsr     r5,pnum; pfrom
  40:         br      3f
  41: 2:
  42:         cmpb    -1(r4),$'-
  43:         bne     2f
  44:         cmpb    (r4),$'s
  45:         bne     0f
  46:         inc     stop
  47:         br      3f
  48: 0:
  49:         cmpb    (r4),$'h
  50:         bne     0f
  51:         clr     slow
  52:         br      3f
  53: 0:
  54:         jsr     r5,pnum; pto
  55: 3:
  56:         dec     argc
  57:         bgt     1b
  58: 2:
  59:         mov     $nop,get1a
  60:         mov     $ibuf,ibufp
  61:         mov     $ibuf,eibuf
  62:         mov     sp,argp
  63:         jsr     pc,topbot
  64:         clr     r0
  65: 1:
  66:         movb    r0,trtab(r0)
  67:         inc     r0
  68:         cmp     r0,$128.
  69:         bne     1b
  70:         jsr     pc,rbreak
  71:         jsr     pc,istop
  72:         jmp     loop
  73: makebf:
  74:         sys     stat; bfn; stbuf
  75:         bec     2f
  76:         sys     creat; bfn; 400
  77:         bec     1f
  78: 2:
  79:         incb    bfn+8
  80:         cmpb    bfn+8,$'z
  81:         blos    makebf
  82:         jmp     place
  83: 1:
  84:         mov     r0,ibf
  85:         sys     write; sufbuf;128.
  86:         sys     open; bfn;0
  87:         mov     r0,ibf1
  88:         rts     pc
  89: 
  90: string:
  91:         mov     (r5)+,r1
  92:         mov     r1,r2
  93:         mov     r1,0f
  94: 1:
  95:         tstb    (r1)+
  96:         bne     1b
  97:         sub     r2,r1
  98:         mov     r1,1f
  99:         mov     $1,r0
 100:         sys     write; 0:..; 1:..
 101:         rts     r5
 102: 
 103: emes1: <Too many files.\n\0>
 104: xxx:
 105: .even
 106: obuf=ibuf+512.
 107: .=ibuf+1024.
 108: loop:
 109:         clr     nlflg
 110:         jsr     pc,getchar
 111:         cmpb    r0,cc
 112:         beq     2f
 113:         movb    r0,ch
 114:         jsr     pc,text
 115:         br      loop
 116: 2:
 117:         jsr     pc,control
 118:         jsr     pc,flushi
 119:         br      loop
 120: 
 121: mesg:
 122:         tst     r0
 123:         bne     setsame
 124:         jsr     pc,ttyn
 125:         movb    r0,ttyx+8.
 126:         sys     stat; ttyx; stbuf
 127:         mov     stbuf+4,0f
 128:         mov     0f,1f
 129:         bic     $22,0f
 130:         sys     chmod; ttyx; 0:..
 131:         rts     pc
 132: setsame:
 133:         sys     chmod; ttyx; 1:..
 134:         rts     pc
 135: 
 136: pnum:
 137:         mov     r4,ibufp
 138:         mov     $37777,eibuf
 139:         jsr     r5,number1; 0
 140:         mov     r0,*(r5)+
 141:         clr     ch
 142:         rts     r5
 143: 
 144: flushi:
 145:         clr     ch
 146:         tst     nlflg
 147:         bne     1f
 148:         jsr     pc,getchar
 149:         br      flushi
 150: 1:
 151:         rts     pc
 152: 
 153: gettchar:
 154:         tst     ul
 155:         ble     getchar
 156:         tst     ulstate
 157:         beq     3f
 158:         tst     bsc
 159:         bgt     1f
 160:         tst     ulc
 161:         bgt     2f
 162:         clr     ulstate
 163:         br      3f
 164: 1:
 165:         dec     bsc
 166:         mov     $010,r0
 167:         rts     pc
 168: 2:
 169:         dec     ulc
 170:         mov     $'_,r0
 171:         rts     pc
 172: 3:
 173:         jsr     pc,getchar
 174:         cmp     r0,$'0
 175:         blt     1f
 176:         cmp     r0,$'9
 177:         ble     2f
 178:         cmp     r0,$'A
 179:         blt     1f
 180:         cmp     r0,$'Z
 181:         ble     2f
 182:         cmp     r0,$'a
 183:         blt     1f
 184:         cmp     r0,$'z
 185:         ble     2f
 186: 1:
 187:         tst     ulc
 188:         bgt     3f
 189:         rts     pc
 190: 3:
 191:         mov     $1,ulstate
 192:         mov     r0,ch
 193:         br      gettchar
 194: 2:
 195:         inc     bsc
 196:         inc     ulc
 197:         rts     pc
 198: 
 199: getchar:
 200:         mov     ch,r0
 201:         beq     1f
 202:         clr     ch
 203:         rts     pc
 204: 1:
 205:         tst     nlflg
 206:         beq     1f
 207:         mov     $'\n,r0
 208:         rts     pc
 209: 1:
 210:         jsr     pc,get1
 211:         cmp     r0,$'\\
 212:         bne     2f
 213:         jsr     pc,get1
 214:         jsr     r5,switch; esctab
 215:         br      3f
 216: 2:
 217:         cmp     r0,$033  /prefix
 218:         bne     3f
 219:         jsr     pc,get1
 220:         jsr     r5,switch; pfxtab
 221: 3:
 222:         cmp     r0,$'\n
 223:         bne     3f
 224:         inc     nlflg
 225:         clr     column
 226: 3:
 227:         mov     r1,-(sp)
 228:         jsr     pc,width
 229:         add     r1,column
 230:         mov     (sp)+,r1
 231:         rts     pc
 232: 
 233: esctab:
 234:    .byte 'd, 032  /hlf (down)
 235:    .byte 'u, 035  /hlr (up)
 236:    .byte 'r, 036  /flr (reverse)
 237:    .byte 'x, 016  /SO (extra chars)
 238:    .byte 'y, 017  /SI (normal characters)
 239:    .byte 'l, 0177 /delete
 240:    .byte 't, 011  /hor tab
 241:    .byte 'a, 0100 /at sign
 242:    .byte 'n, 043  /number sign
 243:    .byte '\\, 134 /backslash
 244:    .byte 0, 0
 245: 
 246: pfxtab:
 247:    .byte '7, 036  /flr
 248:    .byte '8, 035  /hlr
 249:    .byte '9, 032  /hlf
 250:    .byte '4, 030  /brs
 251:    .byte '3, 031  /rrs
 252:    .byte '1, 026  /set hor tabs
 253:    .byte '2, 027  /clr hor tabs
 254:    .byte 0,0
 255: pfxtab1:
 256: 
 257: switch:
 258:         mov     r1,-(sp)
 259:         mov     (r5)+,r1
 260: 1:
 261:         cmpb    (r1)+,r0
 262:         beq     1f
 263:         tstb    (r1)+
 264:         bne     1b
 265:         cmp     r1,$pfxtab
 266:         ble     0f
 267:         cmp     r1,$pfxtab1
 268:         bgt     0f
 269:         mov     $037,r0
 270: 0:
 271:         mov     (sp)+,r1
 272:         rts     r5
 273: 1:
 274:         movb    (r1)+,r0
 275:         mov     (sp)+,r1
 276:         rts     r5
 277: 
 278: get1:
 279:         tst     nspace
 280:         ble     1f
 281:         dec     nspace
 282:         mov     tabc,r0
 283:         rts     pc
 284: 1:
 285:         mov     r1,-(sp)
 286: 4:
 287:         tst     ip
 288:         beq     5f
 289:         jsr     pc,rbf
 290:         br      6f
 291: 5:
 292:         tst     nx
 293:         bne     0f
 294:         mov     ibufp,r1
 295:         cmp     r1,eibuf
 296:         bne     3f
 297: 0:
 298:         mov     ifile,r0
 299:         bne     2f
 300: 1:
 301:         jsr     pc,nextfile
 302: 2:
 303:         clr     nx
 304:         sys     read; ibuf; 512.
 305:         bes     done
 306:         tst     r0
 307:         beq     1b
 308:         mov     $ibuf,r1
 309:         add     r1,r0
 310:         mov     r0,eibuf
 311: 3:
 312:         movb    (r1)+,r0
 313:         mov     r1,ibufp
 314: 1:
 315:         cmp     r0,$011 /tab
 316:         bne     6f
 317:         mov     (sp)+,r1
 318:         mov     $tabtab,r0
 319:         inc     nspace
 320: 1:
 321:         tstb    (r0)
 322:         beq     get1
 323:         cmpb    column,(r0)+
 324:         bge     1b
 325:         movb    -(r0),nspace
 326:         sub     column,nspace
 327:         br      get1
 328: 6:
 329: get1a:  br      7f
 330:         tst     r0
 331:         beq     4b
 332: 7:
 333:         mov     (sp)+,r1
 334:         rts     pc
 335: 
 336: nextfile:
 337:         mov     ifile,r0
 338:         beq     1f
 339:         sys     close
 340: 1:
 341:         tst     nx
 342:         beq     2f
 343:         mov     $nextf,0f
 344:         br      3f
 345: 2:
 346:         dec     argc
 347:         blt     done
 348:         mov     *argp,0f
 349:         add     $2,argp
 350: 3:
 351:         sys     open; 0:..; 0
 352:         bes     done
 353:         mov     r0,ifile
 354:         rts     pc
 355: 
 356: done:
 357:         jsr     pc,rbreak
 358:         jsr     pc,eject
 359:         jsr     pc,flush
 360: place:
 361:         sys     signal; 2; 1
 362:         mov     $1,r0
 363:         jsr     pc,mesg
 364:         sys     unlink; bfn
 365:         sys     exit
 366: 
 367:         rts     pc
 368: 
 369: putchar:
 370:         cmp     pn,pfrom
 371:         blt     2f
 372:         clr     pfrom
 373:         bic     $!177,r0
 374:         beq     2f
 375:         movb    trtab(r0),r0
 376:         cmp     r0,$'
 377:         bne     1f
 378:         inc     nsp
 379: 2:
 380:         rts     pc
 381: 1:
 382:         cmp     r0,$'\n
 383:         bne     1f
 384:         clr     nsp
 385:         clr     ocol
 386:         br      2f
 387: 1:
 388:         tst     nsp
 389:         beq     2f
 390:         tst     slow
 391:         bne     4f
 392:         jsr     pc,dsp
 393:         cmp     nsp,r1
 394:         blt     4f
 395:         mov     $011,3f+2
 396:         cmp     r1,$1
 397:         bgt     8f
 398:         mov     $040,3f+2
 399:         dec     nsp
 400:         br      9f
 401: 8:
 402:         sub     r1,nsp
 403: 9:
 404:         mov     r0,-(sp)
 405: 3:
 406:         mov     $011,r0
 407:         jsr     pc,pchar1
 408:         mov     (sp)+,r0
 409:         br      1b
 410: 4:
 411:         mov     r0,-(sp)
 412:         mov     $' ,r0
 413:         jsr     pc,pchar1
 414:         mov     (sp)+,r0
 415:         dec     nsp
 416:         bne     4b
 417: 2:
 418:         cmp     r0,$026
 419:         blt     2f
 420:         cmp     r0,$037
 421:         beq     3f
 422:         bgt     2f
 423:         mov     r0,-(sp)
 424:         jsr     r5, switch; unpfx
 425:         cmp     (sp)+,r0
 426:         beq     2f
 427:         mov     r0,-(sp)
 428:         mov     $033,r0  /prefix
 429:         jsr     pc,pchar1
 430:         dec     ocol
 431:         mov     (sp)+,r0
 432: 2:
 433: pchar1:
 434:         cmp     r0,$011
 435:         bne     1f
 436:         jsr     pc,dsp
 437:         br      2f
 438: 1:
 439:         jsr     pc,width
 440: 2:
 441:         add     r1,ocol
 442:         movb    r0,*obufp
 443:         inc     obufp
 444:         cmp     obufp,$obuf+128.
 445:         beq     flush
 446: 3:
 447:         rts     pc
 448: 
 449: dsp:
 450:         clr     r1
 451: 1:
 452:         add     $8.,r1
 453:         cmp     ocol,r1
 454:         bgt     1b
 455:         sub     ocol,r1
 456:         bne     2f
 457:         mov     $8.,r1
 458: 2:
 459:         rts     pc
 460: 
 461: 
 462: unpfx:
 463:    .byte 032, '9
 464:    .byte 035, '8
 465:    .byte 036, '7
 466:    .byte 031, '3
 467:    .byte 030, '4
 468:    .byte 026, '1
 469:    .byte 027, '2
 470:    .byte 0,0
 471: 
 472: flush:
 473:         mov     obufp,r0
 474:         sub     $obuf,r0
 475:         mov     r0,0f
 476:         mov     $1,r0
 477:         sys     write; obuf; 0:0
 478:         mov     $obuf,obufp
 479:         rts     pc
 480: 
 481: control:
 482:         jsr     pc,getchar
 483:         mov     r0,-(sp)
 484:         jsr     pc,getchar
 485:         swab    r0
 486:         bis     (sp),r0
 487:         mov     $contab,r1
 488: 1:
 489:         mov     (r1)+,(sp)
 490:         bic     $100000,(sp)
 491:         cmp     r0,(sp)
 492:         bne     4f
 493:         mov     (r1),(sp)
 494:         tst     -(r1)
 495:         bpl     3f
 496:         jsr     pc,flushi
 497:         cmp     ilistp,$iliste
 498:         bgt     5f
 499:         mov     ip,*ilistp
 500:         add     $2,ilistp
 501:         mov     (sp),ip
 502:         br      5f
 503: 3:
 504:         jmp     *(sp)+
 505: 4:
 506:         cmp     (r1)+,$-1
 507:         bne     1b
 508: 5:
 509:         tst     (sp)+
 510:         rts     pc
 511: 
 512: contab:
 513:    <ad>; casead
 514:    <bp>; casebp
 515:    <br>; casebr
 516:    <cc>; casecc
 517:    <ce>; casece
 518:    <ds>; caseds
 519:    <fi>; casefi
 520:    <in>; casein
 521:    <ix>; caseix
 522:    <li>; caseli
 523:    <ll>; casell
 524:    <ls>; casels
 525:    <na>; casena
 526:    <ne>; casene
 527:    <nf>; casenf
 528:    <pa>; casepa
 529:    <bl>; casebl
 530:    <pl>; casepl
 531:    <sk>; casesk
 532:    <sp>; casesp
 533:    <ss>; casess
 534:    <ta>; caseta
 535:    <ti>; caseti
 536:    <tr>; casetr
 537:    <ul>; caseul
 538:    <un>; caseun
 539:    <he>; casehe
 540:    <hx>; casehx
 541:    <fo>; casefo
 542:    <eh>; caseeh
 543:    <oh>; caseoh
 544:    <ef>; caseef
 545:    <of>; caseof
 546:    <m1>; casem1
 547:    <m2>; casem2
 548:    <m3>; casem3
 549:    <m4>; casem4
 550:    <hc>; casehc
 551:    <hy>; casehy
 552:    <n1>; casen1
 553:    <n2>; casen2
 554:    <nn>; casenn
 555:    <ni>; caseni
 556:    <jo>; casejo
 557:    <ar>; casear
 558:    <ro>; casero
 559:    <nx>; casenx
 560:    <po>; casepo
 561:    <de>; casede
 562:    <ig>; caseig
 563:    <tc>; casetc
 564:    <mk>; casemk
 565: bnames: .=.+100.
 566:     -1; -1

Defined functions

bnames defined in line 565; never used
contab defined in line 512; used 1 times
control defined in line 481; used 1 times
done defined in line 356; used 3 times
dsp defined in line 449; used 2 times
emes1 defined in line 103; used 1 times
  • in line 13
esctab defined in line 233; used 1 times
flush defined in line 472; used 2 times
flushi defined in line 144; used 3 times
get1 defined in line 278; used 5 times
get1a defined in line 329; used 1 times
  • in line 59
getchar defined in line 199; used 6 times
gettchar defined in line 153; used 1 times
ibuf defined in line 10; used 6 times
loop defined in line 108; used 3 times
makebf defined in line 73; used 2 times
mesg defined in line 121; used 2 times
nextfile defined in line 336; used 1 times
obuf defined in line 106; used 4 times
pchar1 defined in line 433; used 3 times
pfxtab defined in line 246; used 2 times
pfxtab1 defined in line 255; used 1 times
place defined in line 360; used 4 times
pnum defined in line 136; used 2 times
putchar defined in line 369; never used
setsame defined in line 132; used 1 times
signal defined in line 8; used 3 times
string defined in line 90; used 1 times
  • in line 13
switch defined in line 257; used 3 times
unpfx defined in line 462; used 1 times
xxx defined in line 104; never used
Last modified: 1975-07-17
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1424
Valid CSS Valid XHTML 1.0 Strict