1: /
2: /
3:
4: / nroff4
5:
6: text:
7: inc nflush
8: cmp nl,$-1
9: bne 0f
10: jsr pc,newln1
11: rts pc
12: 0:
13: clr ulstate
14: jsr pc,setnel
15: tst ce
16: bne nofill
17: tst fi
18: beq nofill
19: tst pendw
20: bne 7f
21: tst pendt
22: bne 8f
23: inc pendt
24: tst x
25: bne 0f
26: 1:
27: jsr pc,getchar
28: bmi 1f
29: cmpb r0,$' /
30: beq 3f
31: cmpb r0,tabc
32: bne 1f
33: 3:
34: inc x
35: br 1b
36: 1:
37: tst nlflg
38: bne 6f
39: mov r0,ch
40: tst x
41: beq 2f
42: 0:
43: jsr pc,rbreak
44: tst nc
45: bne 5f
46: tst wch
47: bne 5f
48: add x,un
49: clr x
50: jsr pc,setnel
51: tst trap
52: bne 5f
53: 2:
54: tst x
55: bne 0b
56: tst nlflg
57: beq 2f
58: 6:
59: clr nflush
60: clr x
61: clr pendt
62: clr ch
63: mov $1,r0
64: jsr pc,casesp1
65: rts pc
66: 8:
67: tst x
68: bne 0b
69: 2:
70: tst spread
71: bne 1f
72: tst pendw
73: bne 0f
74: tst wch
75: bne 3f
76: 0:
77: 7:
78: jsr pc,getword
79: br 4f
80: 3:
81: jsr pc,movword
82: bne 2b
83: tst nlflg
84: beq 1f
85: clr pendt
86: 1:
87: jsr pc,adjust
88: tst trap
89: beq 2b
90: tst nlflg
91: beq 5f
92: 4:
93: clr pendt
94: tst pendw
95: bne 5f
96: dec ul
97: bge 5f
98: clr ul
99: 5:
100: clr nflush
101: rts pc
102:
103: nofill:
104: tst pendnf
105: bne 1f
106: clr over
107: jsr pc,rbreak
108: tst trap
109: bne 3f
110: tst nlflg
111: bne 6b
112: clr fac
113: clr fmq
114: mov $1000,nwd
115: 1:
116: jsr pc,gettchar
117: bmi 0f
118: cmpb r0,$'\n
119: beq 1f
120: cmpb r0,ohc
121: beq 1b
122: cmpb r0,$005
123: beq 4f
124: 0:
125: jsr pc,storeline
126: br 1b
127: 1:
128: tst ce
129: ble 2f
130: dec ce
131: mov nel,r0
132: asr r0
133: bpl 1f
134: clr r0
135: 1:
136: add r0,un
137: 2:
138: tst nc
139: bne 0f
140: mov $037,r0
141: jsr pc,storeline
142: 0:
143: jsr pc,rbreak
144: dec ul
145: bpl 3f
146: clr ul
147: 3:
148: clr nflush
149: clr pendnf
150: rts pc
151: 4:
152: inc pendnf
153: clr nflush
154: jsr pc,flushi
155: rts pc
156:
157: adjust:
158: mov r2,-(sp)
159: mov r3,-(sp)
160: clr r2
161: clr r3
162: tst ad
163: beq 1f
164: mov nwd,r0
165: dec r0
166: ble 1f
167: mov nel,r3
168: ble 1f
169: dvd r0,r2
170: 1:
171: mov r3,fac
172: mov r2,fmq
173: mov (sp)+,r3
174: mov (sp)+,r2
175: mov $-1,lastl
176: jsr pc,rbreak1
177: clr spread
178: rts pc
179:
180: fill:
181: mov fmq,r0
182: 1:
183: inc r0
184: dec nc
185: cmpb (r2)+,$'
186: beq 1b
187: dec r2
188: bit $1,totout
189: beq 2f
190: inc fac
191: cmp fac,nwd
192: blt 1f
193: inc r0
194: br 1f
195: 2:
196: dec fac
197: bmi 1f
198: inc r0
199: 1:
200: jsr pc,space
201: movb (r2),r0
202: rts pc
203:
204: movword:
205: mov wordp,r4
206: tst nwd
207: bne 2f
208: 1:
209: movb (r4)+,r0
210: cmp r0,$'
211: bne 1f
212: dec wch
213: jsr pc,width
214: sub r1,wne
215: br 1b
216: 1:
217: dec r4
218: 2:
219: cmp wne,nel
220: ble 1f
221: tst nwd
222: beq 2f
223: cmp nel,$4
224: blt 1f
225: cmp wch,$5 /don't do 4 char words
226: ble 1f
227: 2:
228: bit $2,hyf
229: beq 0f
230: tst op
231: bne 0f
232: clr r0
233: jsr pc,findt
234: dec r1
235: ble 1f
236: 0:
237: jsr pc,hyphen
238: 1:
239: clr nhyph
240: mov wch,-(sp)
241: 1:
242: movb (r4)+,r0
243: cmp r0,$'-
244: bne 2f
245: movb (r4),r2
246: jsr pc,alph2
247: bne 2f
248: bisb $200,(r4)
249: 2:
250: tst r0
251: bpl 2f
252: bic $!177,r0
253: mov r4,r3
254: sub $3,r3
255: cmp r3,$word
256: blo 2f
257: movb (r3),r2
258: bic $!177,r2
259: jsr pc,alph2
260: bne 2f
261: 3:
262: mov r0,-(sp)
263: clr r0
264: jsr pc,storeline
265: mov (sp)+,r0
266: inc nhyph
267: 2:
268: jsr pc,width
269: sub r1,wne
270: jsr pc,storeline
271: dec wch
272: bne 1b
273: tst nel
274: blt 1f
275: inc nwd
276: tst (sp)+
277: clz
278: rts pc
279: 1:
280: mov linep,r3
281: 1:
282: tst nhyph
283: bne 2f
284: tst nwd
285: beq 3f
286: cmp wch,(sp)
287: beq 4f
288: 2:
289: movb -(r3),r0
290: bne 2f
291: dec nhyph
292: bne 5f
293: tst nwd
294: beq 6f
295: 5:
296: tst nel
297: ble 2f
298: 6:
299: cmpb -1(r3),$'-
300: beq 3f
301: movb $'-,(r3)
302: dec nel
303: inc ne
304: br 3f
305: 2:
306: dec nc
307: tstb (r3)
308: beq 1b
309: jsr pc,width
310: sub r1,ne
311: add r1,nel
312: inc wch
313: dec r4
314: add r1,wne
315: br 1b
316: 3:
317: inc nwd
318: 4:
319: mov r4,wordp
320: bicb $!177,(r4)
321: tst (sp)+
322: sez
323: rts pc
324:
325:
326: width:
327: mov r0,-(sp)
328: cmpb r0,$014
329: bne 0f
330: mov $1,r1
331: br 3f
332: 0:
333: cmpb r0,$013
334: bne 0f
335: movb eschar,r0
336: 0:
337: bic $!177,r0
338: cmp r0,ohc
339: beq 2f
340: tst r0
341: beq 2f
342: cmp r0,$0177
343: beq 2f
344: cmp r0,$010
345: bne 1f
346: mov $-1,r1
347: br 3f
348: 1:
349: cmp $' ,r0
350: bgt 2f
351: mov $1,r1
352: br 3f
353: 2:
354: clr r1
355: 3:
356: mov (sp)+,r0
357: rts pc
358: setwd:
359: mov column,-(sp)
360: clr column
361: mov r2,-(sp)
362: clr -(sp)
363: jsr pc,*(r5)
364: mov r0,r2
365: 1:
366: jsr pc,*(r5)
367: bmi 0f
368: cmpb r0,r2
369: beq 2f
370: 0:
371: tst nlflg
372: bne 2f
373: jsr pc,width
374: add r1,(sp)
375: br 1b
376: 2:
377: mov (sp)+,r0
378: jsr pc,setn0
379: mov (sp)+,r2
380: mov (sp)+,column
381: tst (r5)+
382: rts r5
383:
384: :
385: /headin:
386: clr nls
387: jsr pc,skipcont
388: mov $'',r2
389: tst op
390: beq 1f
391: jsr pc,wbfl
392: 1:
393: jsr pc,alloc
394: bne 0f
395: rts pc
396: 0:
397: mov nextb,r1
398: 2:
399: mov r1,headp
400: jsr pc,getchar
401: bmi 3f
402: cmpb r0,$'\n
403: beq 2f
404: mov r0,r2
405: 1:
406: jsr pc,getchar
407: bmi 3f
408: cmpb r0,$'\n
409: beq 2f
410: 0:
411: cmpb r0,r2
412: bne 3f
413: mov $004,r0
414: 3:
415: jsr pc,wbf
416: br 1b
417: 2:
418: mov $004,r0
419: jsr pc,wbf
420: mov $004,r0
421: jsr pc,wbf
422: clr r0
423: jsr pc,wbt
424:
425: /headout:
426: clr -(sp)
427: mov headp,r2
428: jsr r5,headseg; width
429: mov r0,-(sp)
430: jsr r5,headseg; width
431: mov r0,-(sp)
432: jsr r5,headseg; width
433: mov r0,-(sp)
434: tst op
435: bne 1f
436: mov po,r0
437: jsr pc,space
438: 1:
439: mov headp,r2
440: jsr r5,headseg; putchar
441: mov llh,r0
442: add 6(sp),r0
443: sub 2(sp),r0
444: asr r0
445: sub 4(sp),r0
446: mov r0,-(sp)
447: tst 4(sp)
448: bne 1f
449: tst 2(sp)
450: beq 2f
451: 1:
452: jsr pc,space
453: 2:
454: jsr r5,headseg; putchar
455: mov llh,r0
456: sub (sp)+,r0
457: sub (sp)+,r0
458: sub (sp)+,r0
459: sub (sp)+,r0
460: add (sp)+,r0
461: tst -10(sp)
462: beq 1f
463: jsr pc,space
464: jsr r5,headseg; putchar
465: 1:
466: jsr pc,newline
467: cmp nl,hnl
468: ble 0f
469: mov nl,hnl
470: 0:
471: mov headp,r0
472: jsr pc,free
473: rts pc
474:
475: headseg:
476: clr -(sp)
477: 1:
478: mov r1,-(sp)
479: mov r2,r1
480: jsr pc,rbf0
481: jsr pc,incoff
482: mov r1,r2
483: mov (sp)+,r1
484: tst r0
485: beq 1f
486: bmi 0f
487: cmpb r0,$004
488: beq 1f
489: cmpb r0,$'%
490: beq 2f
491: 0:
492: jsr pc,*(r5)
493: add r1,(sp)
494: br 1b
495: 2:
496: mov $'%,r0
497: jsr pc,findr
498: mov [flist-vlist](r1),nform
499: mov pn,r0
500: clr r1
501: jsr pc,fnumb
502: add r1,(sp)
503: br 1b
504: 1:
505: mov (sp)+,r0
506: tst (r5)+
507: rts r5
508:
509: space:
510: jsr r5,nlines;putchar
511: rts pc
512:
513: nlines:
514: mov r0,-(sp)
515: 1:
516: dec (sp)
517: blt 1f
518: mov $' ,r0
519: jsr pc,*(r5)
520: br 1b
521: 1:
522: cmp (r5)+,(sp)+
523: rts r5
524:
525: decimal:
526: jsr pc,decml
527: tst (r5)+
528: rts r5
529:
530: decml:
531: mov r2,-(sp)
532: mov r3,-(sp)
533: jsr pc,decml1
534: mov (sp)+,r3
535: mov (sp)+,r2
536: rts pc
537:
538: decml1:
539: mov r1,-(sp)
540: clr r2
541: mov r0,r3
542: dvd $10.,r2
543: mov r3,-(sp)
544: mov r2,r0
545: beq 1f
546: jsr pc,decml1
547: mov r1,2(sp)
548: 1:
549: mov (sp)+,r0
550: add $'0,r0
551: jsr pc,*(r5)
552: add (sp)+,r1
553: rts pc
554:
555: roman0:
556: jsr pc,roman
557: tst (r5)+
558: rts r5
559: roman:
560: tst r0
561: beq decml
562: mov r2,-(sp)
563: mov r3,-(sp)
564: cmp ro,$2
565: bne 1f
566: mov $cones,onesp
567: mov $cfives,fivesp
568: br 2f
569: 1:
570: mov $ones,onesp
571: mov $fives,fivesp
572: 2:
573: jsr pc,roman1
574: mov (sp)+,r3
575: mov (sp)+,r2
576: rts pc
577: roman1:
578: clr r2
579: mov r0,r3
580: bne .+4
581: rts pc
582: mov r1,-(sp)
583: dvd $10.,r2
584: mov r3,-(sp)
585: mov r2,r0
586: inc onesp
587: inc fivesp
588: jsr pc,roman1
589: mov r1,2(sp)
590: dec onesp
591: dec fivesp
592: clr r2
593: mov (sp)+,r3
594: dvd $5.,r2
595: cmp r3,$4
596: bne 1f
597: movb *onesp,r0
598: jsr pc,*(r5)
599: add r1,(sp)
600: tst r2
601: beq 2f
602: inc onesp
603: movb *onesp,r0
604: dec onesp
605: br 3f
606: 2:
607: movb *fivesp,r0
608: 3:
609: jsr pc,*(r5)
610: add (sp)+,r1
611: rts pc
612: 1:
613: tst r2
614: beq 2f
615: movb *fivesp,r0
616: jsr pc,*(r5)
617: add r1,(sp)
618: 2:
619: dec r3
620: blt 1f
621: movb *onesp,r0
622: jsr pc,*(r5)
623: add r1,(sp)
624: br 2b
625: 1:
626: mov (sp)+,r1
627: rts pc
628:
629: abc0:
630: jsr pc,abc
631: tst (r5)+
632: rts r5
633: abc:
634: mov r2,-(sp)
635: mov r3,-(sp)
636: mov r0,r3
637: bne 0f
638: mov $'0,r0
639: jsr pc,*(r5)
640: br 1f
641: 0:
642: dec r3
643: jsr pc,abc1
644: 1:
645: mov (sp)+,r3
646: mov (sp)+,r2
647: rts pc
648: abc1:
649: clr r2
650: dvd $26.,r2
651: mov r3,-(sp)
652: mov r2,r3
653: beq 1f
654: dec r3
655: jsr pc,abc1
656: 1:
657: cmp ro,$2
658: beq 1f
659: add $'a,(sp)
660: br 2f
661: 1:
662: add $'A,(sp)
663: 2:
664: mov (sp)+,r0
665: jsr pc,*(r5)
666: rts pc
667:
668: fnumb0:
669: jsr pc,fnumb
670: tst (r5)+
671: rts r5
672: fnumb:
673: mov ro,-(sp)
674: mov nform,ro
675: bne 0f
676: mov (sp),ro
677: br 1f
678: 0:
679: dec ro
680: 1:
681: tst ro
682: bne 1f
683: jsr pc,decml
684: br 2f
685: 1:
686: cmp ro,$2
687: bgt 1f
688: jsr pc,roman
689: br 2f
690: 1:
691: sub $2,ro
692: jsr pc,abc
693: 2:
694: mov (sp)+,ro
695: rts pc
696:
697: /wordout:
698: / tst index
699: / beq 1f
700: / mov wch,0f
701: / beq 1f
702: / mov indid,r0
703: / sys write; word; 0:..
704: / mov indid,r0
705: / sys write; 8f; 1
706: / mov indid,r0
707: / jsr r5,numb; pn
708: / mov indid,r0
709: / sys write; 8f; 1
710: / mov nl,char
711: / inc char
712: / mov indid,r0
713: / jsr r5,numb; char
714: / mov indid,r0
715: / sys write; 9f; 1
716: /1:
717: / rts pc
718: /8: 011 /tab
719: /9: <\n\0>
720: / .even
721: /numb:
722: / mov r2,-(sp)
723: / mov r3,-(sp)
724: / mov *(r5)+,r3
725: / mov r0,r1
726: / jsr pc,numb1
727: / mov (sp)+,r3
728: / mov (sp)+,r2
729: / rts r5
730: /numb1:
731: / clr r2
732: / dvd $10.,r2
733: / mov r3,-(sp)
734: / mov r2,r3
735: / beq 1f
736: / jsr pc,numb1
737: /1:
738: / add $'0,(sp)
739: / mov (sp)+,char
740: / mov r1,r0
741: / sys write; char; 1
742: / rts pc
743:
744: setstr:
745: clr -(sp)
746: clr -(sp)
747: 0:
748: jsr pc,get1
749: bmi 3f
750: bic $!177,r0
751: cmpb r0,$'\\
752: bne 1f
753: 4:
754: jsr pc,get1
755: jsr r5,switch;esctab
756: cmpb r0,dolc
757: bne 2f
758: jsr pc,seta
759: br 0b
760: 2:
761: cmpb r0,numc
762: bne 1f
763: clr r1
764: jsr pc,setn
765: br 0b
766: 1:
767: tst 2(sp)
768: bne 5f
769: bic $!177,r0
770: cmpb r0,$'(
771: bne 1f
772: inc 2(sp)
773: jsr pc,get1
774: bic $!177,r0
775: cmpb r0,$'\\
776: beq 4b
777: 5:
778: mov r0,-(sp)
779: jsr pc,get1
780: bic $!177,r0
781: swab r0
782: bis (sp)+,r0
783: 1:
784: mov $contab,r1
785: 1:
786: mov (r1)+,(sp)
787: bic $100000,(sp)
788: cmp r0,(sp)
789: beq 2f
790: cmp (r1)+,$-1
791: bne 1b
792: br 3f
793: 2:
794: mov (r1),(sp)
795: tst -(r1)
796: bpl 3f
797: clr *nxf
798: jsr pc,pushi
799: mov (sp),ip
800: 3:
801: cmp (sp)+,(sp)+
802: rts pc
803:
804: copys:
805: inc copyf
806: jsr pc,skipcont
807: bne 2f
808: jsr pc,getchar
809: bmi 0f
810: cmpb r0,$'"
811: bne 0f
812: 1:
813: jsr pc,getchar
814: tst nlflg
815: bne 2f
816: 0:
817: jsr pc,wbf
818: br 1b
819: 2:
820: clr r0
821: jsr pc,wbt
822: clr copyf
823: rts pc
824:
825: setrpt:
826: inc copyf
827: inc raw1
828: jsr pc,get1
829: dec copyf
830: dec raw1
831: mov r0,r1
832: jsr pc,get1
833: cmpb r0,$006
834: beq 1f
835: 0:
836: movb r0,rchar
837: movb r1,nspace
838: cmpb r1,$377
839: bne 1f
840: clr nspace
841: 1:
842: rts pc
843:
844: setfield:
845: clr npad
846: mov r1,-(sp)
847: mov r2,-(sp)
848: mov r3,-(sp)
849: mov r4,-(sp)
850: clr r4
851: clr -(sp)
852: jsr pc,width
853: sub r1,column /start
854: mov column,-(sp)
855: mov $tabtab,r0
856: 1:
857: tst (r0)
858: beq 4f
859: cmp (sp),(r0)+
860: bge 1b
861: mov -(r0),2(sp)
862: sub (sp),2(sp) /h
863: mov $fbuf,r2
864: 1:
865: jsr pc,getch1
866: bmi 0f
867: cmpb r0,padc
868: bne 2f
869: jsr pc,width
870: sub r1,column
871: inc npad
872: mov r2,-(sp)
873: add $2,r2
874: 2:
875: cmpb r0,fc
876: beq 3f
877: cmpb r0,$'\n
878: bne 0f
879: mov $012,r4
880: clr nlflg
881: br 3f
882: 0:
883: movb r0,(r2)+
884: cmp r2,$efbuf-6
885: blo 1b
886: 3:
887: tst npad
888: bne 0f
889: inc npad
890: mov r2,-(sp)
891: add $3,r2
892: 0:
893: movb r4,(r2)+
894: clrb (r2)+
895: jsr pc,width
896: sub r1,column
897: mov npad,r1
898: asl r1
899: add sp,r1
900: mov (r1),-(sp)
901: sub column,(r1) /-s
902: mov (sp)+,column
903: add 2(r1),(r1) /h-s
904: mov (r1),r1
905: mov r1,r2
906: sxt r0
907: div npad,r0
908: mov $014,r3 /unpaddable sp
909: tst r2
910: bpl 1f
911: neg r0
912: neg r1
913: mov $010,r3
914: 1:
915: mov (sp)+,r2
916: movb $006,(r2)+
917: movb r0,(r2)+
918: movb r3,(r2)
919: tst r1
920: beq 0f
921: incb -1(r2)
922: dec r1
923: 0:
924: tstb -(r2)
925: bne 0f
926: movb $377,(r2)
927: 0:
928: dec npad
929: bgt 1b
930: mov $fbuf,cp
931: 4:
932: cmp (sp)+,(sp)+
933: mov (sp)+,r4
934: mov (sp)+,r3
935: mov (sp)+,r2
936: mov (sp)+,r1
937: rts pc