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