Research V5 development
authorRobert Morris <rhm@research.uucp>
Tue, 26 Nov 1974 23:13:21 +0000 (18:13 -0500)
committerRobert Morris <rhm@research.uucp>
Tue, 26 Nov 1974 23:13:21 +0000 (18:13 -0500)
Work on file usr/source/s1/form2.s

Co-Authored-By: Ken Thompson <ken@research.uucp>
Synthesized-from: v5

usr/source/s1/form2.s [new file with mode: 0644]

diff --git a/usr/source/s1/form2.s b/usr/source/s1/form2.s
new file mode 100644 (file)
index 0000000..d9c9674
--- /dev/null
@@ -0,0 +1,92 @@
+/      scan
+/      r1 = pointer to input header
+/      r0 = pointer to output header
+/      switch = 0 real output
+/              not 0  output to r0
+scan:
+       mov     r0,-(sp)
+       mov     r1,-(sp)
+
+1:
+       mov     (sp),r1
+       jsr     pc,getchar
+       bes     5f
+       cmpb    r0,$'\\
+       beq     3f
+       cmpb    r0,$'\[
+       beq     4f
+       cmpb    r0,$'\{
+       beq     4f
+       cmpb    r0,$'\]
+       beq     1f
+       cmpb    r0,$'\}
+       beq     7f
+       cmpb    r0,$'\n
+       bne     6f
+       jsr     pc,lookchar
+       bes     5f
+       movb    $'\n,r0
+6:
+       tst     switch
+       beq     2f
+       mov     2(sp),r1
+       jsr     pc,putchar
+       br      1b
+2:
+       jsr     r5,putc
+       br      1b
+3:
+       jsr     pc,getchar
+       br      6b
+/      have [ or {
+4:
+       mov     r(r1),-(sp)
+       jsr     pc,getchar
+       bes     1f
+       cmpb    r0,$'0
+       blt     4f
+       cmpb    r0,$'9
+       bgt     4f
+       jsr     pc,getchar
+       cmpb    r0,$'\]
+       beq     3f
+       cmpb    r0,$'\}
+       beq     3f
+
+4:
+       mov     (sp)+,r(r1)
+       mov     2(sp),r0
+       jsr     pc,esub
+       mov     r1,(sp)
+       mov     r0,2(sp)
+       br      1b
+
+/      have arg
+3:
+       tst     switch
+       beq     2f
+       mov     opointer,r1
+       mov     4(sp),r0
+       jsr     pc,putword
+       mov     2(sp),r1
+2:
+       mov     (sp)+,r(r1)
+       jsr     pc,getchar
+       inc     r(r1)   /skip ]
+       jsr     pc,earg
+       br      1b
+
+5:
+       tst     argf
+       bne     1f
+       mov     ipointer,r1
+       jsr     pc,pop
+       bes     1f
+       mov     r0,(sp)
+       br      1b
+7:
+       inc     curlyf
+1:
+       mov     (sp)+,r1
+       mov     (sp)+,r0
+       rts     pc