home *** CD-ROM | disk | FTP | other *** search
- *
- * This program is in the public domain. PostScript is a trademark
- * of Adobe Systems.
- * Greg Lee, July, 1987.
- * U.S. mail: 562 Moore Hall, Dept. of Linguistics
- * INTERNET: lee@uhccux.uhcc.hawaii.edu
- * UUCP: {ihnp4,dcdwest,ucbvax}!sdcsvax!nosc!uhccux!lee
- * BITNET: lee%uhccux.uhcc.hawaii.edu@rutgers.edu
- *
-
-
- * link with ffpa.o
- xref FFPAFP
- * link with lmath.o
- xref lmulu
- xref ldivu
- xref ldivs
- * link with files.o
- xref readln
- xref runclose
- xref showreal
- xref show8x
- xref showdec
- xref newline
- xref getstr
- xref msg,longmsg
- xref ioinit
- xref endio
- * in control.o
- xref initloops
- xref _exec
- * in graphics.o
- xref initgr,endgr
- * in rmath.o
- xref _gsave,_grestore
- * in dict.o
- xref systemdict
- xref fdict,enddict
- xref .true,.false
-
-
-
- xdef reinterp
-
- xdef ihandle,ohandle
- xdef rastport,wbscreen
- xdef intuitionbase
- xdef graphicsbase
- xdef mathffpbase
- xdef mathtransbase
-
-
-
-
- idnt PS
-
- section one
-
- include "ps.h"
-
-
- math macro
- move.l A6,-(SP)
- move.l mathffpbase,A6
- jsr _LVO\1(A6)
- move.l (SP)+,A6
- endm
-
-
- lref Open,1
- lref Close,2
- lref Read,3
- lref Write,4
- lref Input,5
- lref Output,6
- lref DeleteFile,8
- lref IoErr,18
- lref LoadSeg,21
- lref UnLoadSeg,22
- lref IsInteractive,32
-
- lref SPFix,1
- lref SPFlt,2
- lref SPCmp,3
- lref SPTst,4
- lref SPAbs,5
- lref SPNeg,6
- lref SPAdd,7
- lref SPSub,8
- lref SPMul,9
- lref SPDiv,10
-
-
-
- _RTS equ %0100111001110101
- _JSR equ %0100111010111001 destination abs. long
- _JMP equ %0100111011111001 destination abs. long
- _MOVELD0 equ %0010000000111100 source immediate long
- _MOVEVD0 equ %0010000000111001 source abs. long
- _MOVEWD2 equ %0011010000111100 source immediate word
- _MOVEVD2 equ %0011010000111001 source abs. long
-
-
-
- main
- move.l SP,stacksave
- bsr ioinit
- bsr initgr
-
-
- * here on error to redo stack
- main1
- bsr _clear
- bsr dsclear
-
- * get more stuff to interpret
- main.in
- bsr getstr
- * (from here, A1 -> next stuff to interpret)
-
-
- * interpret next symbol
- main.next
- bsr skipsp
- beq main.in
-
- pea main.next
- move.b compilelevel,D3
-
- * if it's a number, push it
- bsr testnumber
- beq pushnum
-
- * name literal?
- cmp.b #'/',D0
- beq pushlit
-
- cmp.b #'(',D0
- beq pushstr
-
- cmp.b #'{',D0
- beq start_compile
-
- cmp.b #'}',D0
- beq end_compile
-
- cmp.b #'%',D0
- beq getstr
-
- * interpret a name
- bsr findsym
- tst.l D2
- bpl name.ok
- say_undefined
- print unknown
- bra reinterp
-
- name.ok
- move.b compilelevel,D3
- beq no.dummies
- cmp.w #Dummy,D2
- bne no.dummies
- bsr vpush
- lea _exec,A0
- move.l A0,D0
- bra stowcall
-
- no.dummies
- cmp.w #ICode,D2
- bne vpush
-
- tst.b D3
- bne stowcall
-
- move.l A1,-(SP)
- move.l D0,A0
- jsr (A0)
- move.l (SP)+,A1
- rts
-
- * exit
- system
- bsr endgr
- bsr endio
- moveq #0,D0
- rts
- ***********************
-
- DEF clear
- lea istacktop,A5
- moveq #Illegal,D0
- move.l D0,-(A5)
- move.w D0,-(A5)
- rts
-
- countistack
- moveq #-1,D0
- moveq #Illegal,D2
- move.l A5,A0
- 1$ addq.l #1,D0
- move.w (A0),D1
- addq.l #6,A0
- cmp.w D1,D2
- bne 1$
- rts
-
-
- DEF count
- bsr countistack
- RETURN Integer
-
- index1istack
- bsr popnum
- addq.l #1,D0
- bgt ..ndxis
- bra iuflow
- indexistack
- bsr popnum
- ..ndxis
- move.l D0,D3
- bmi iuflow
- bsr countistack
- cmp.l D0,D3
- bhi iuflow
- move.l D3,D0
- subq #1,D0
- mulu #6,D0
- move.l A5,A2
- add.l D0,A2
- rts
-
- DEF copy
- bsr indexistack
- bra 2$
- 1$ move.w (A2)+,D2
- move.l (A2),D0
- bsr r.ipush
- subq.l #8,A2
- 2$ dbra D3,1$
- rts
-
- DEF index
- bsr index1istack
- move.w (A2)+,D2
- move.l (A2)+,D0
- bra r.ipush
-
- DEF roll
- bsr popnum
- move.l D0,-(SP)
- bsr indexistack
- move.l (SP)+,D0
- subq.l #1,D3
- bmi 2$
- move.l D3,D4
- 1$ move.l D4,D3
- bsr roll1
- bne 1$
- 2$ rts
- roll1
- tst.l D0
- beq 1$
- bmi rollm
- bra rollp
- 1$ rts
-
- rollp
- subq.l #1,D0
- move.l D0,-(SP)
- move.l A5,A0
- move.l A5,A1
- move.w (A0)+,-(SP)
- move.l (A0)+,-(SP)
- bra 2$
- 1$ move.w (A0)+,(A1)+
- move.l (A0)+,(A1)+
- 2$ dbra D3,1$
- move.l (SP)+,D0
- move.w (SP)+,(A1)+
- move.l D0,(A1)
- move.l (SP)+,D0
- rts
-
- rollm
- addq.l #1,D0
- move.l D0,-(SP)
- move.l A2,A1
- move.l A2,A0
- subq.l #6,A0
- move.w (A2)+,-(SP)
- move.l (A2)+,-(SP)
- bra 2$
- 1$ move.w (A0)+,(A1)+
- move.l (A0),(A1)
- subq.l #8,A0
- subq.l #8,A1
- 2$ dbra D3,1$
- move.l (SP)+,D0
- move.w (SP)+,(A1)+
- move.l D0,(A1)
- move.l (SP)+,D0
- rts
-
- dsclear
- lea dstacktop,A0
- move.l A0,dstack
- moveq #0,D0
- move.w D0,dstackcnt
- lea sstacktop,A0
- move.l A0,sstack
- moveq #0,D0
- move.w D0,sstackcnt
- rts
-
-
- start_compile
- addq.l #1,A1
- move.b compilelevel,D0
- move.w D0,-(SP)
- move.l nextcode,A0
- move.w #ICode,D2
- move.w (SP),D0
- tst.b D0
- beq 2$
- add.l #6+4+6+6,A0 allow for push & jmp if doing sub-proc
- 2$ move.l A0,D0
- * if doing sub-proc, this generates code to do the push
- bsr ipush
- move.w (SP),D0
- addq.b #1,D0
- move.b D0,compilelevel
- move.w (SP)+,D0
- tst.b D0
- bne 3$
- rts
- 3$
- move.w #_JMP,D0
- bsr stowword
- move.l nextcode,A0
- move.l A0,-(SP) where to put dest of jmp
- moveq #0,D0 leave room for dest of jmp
- bsr stowword
- bsr stowword
-
- bsr main.next go compile the sub-procedure
- * should return to here when get matching '}'
- move.l (SP)+,A0 patch in dest of jmp
- move.l nextcode,(A0)
- rts
-
-
- end_compile
- addq.l #1,A1
- move.b compilelevel,D0
- beq 2$ unmatched '}'
- move.w D0,-(SP)
- move.w #_RTS,D0
- bsr stowword
- move.w (SP)+,D0
- subq.b #1,D0
- move.b D0,compilelevel
- beq 1$
- addq.l #4,SP discard ret to main.next and ret to above
- 1$ rts
- 2$ print rbrace
- bra reinterp
-
- testnumber
- cmp.b #'-',D0
- beq ..endtestn
- cmp.b #'+',D0
- beq ..endtestn
- cmp.b #'.',D0 (only if next is digit?)
- beq ..endtestn
- testdig
- cmp.b #'0',D0 * is it a decimal digit?
- bcs ..endtestn
- cmp.b #'9',D0
- bhi ..endtestn
- cmp.b D0,D0
- ..endtestn
- rts
-
- pushstr
- addq.l #1,A1
- move.w #1,parenlevel
- move.l farea,D0
- btst #0,D0
- beq 1$
- bsr stowbyte
- move.l farea,D0
- 1$
- move.l D0,-(SP) place to put length
- move.w #String,D2
- bsr ipush
-
- moveq #0,D0
- move.w D0,-(SP) count length
- bsr stowbyte room for length
- bsr stowbyte
-
- ..nextsbyte
- addq.w #1,(SP)
- pea ..nextsbyte
- move.b (A1)+,D0
- bne 2$
- move.b #10,D0
- bsr stowbyte
- bra getstr
-
- 2$ cmp.b #'(',D0
- bne 3$
- add.w #1,parenlevel
- bra stowbyte
-
- 3$ cmp.b #')',D0
- bne 4$
- sub.w #1,parenlevel
- bne stowbyte
- addq.l #4,SP discard ret to ..nextsbyte
-
- move.w (SP)+,D0
- subq.w #1,D0 correct for ')' not stored
- move.l (SP)+,A0
- move.w D0,(A0)
- rts
-
- 4$ cmp.b #'\',D0
- bne stowbyte
- move.b (A1)+,D0
- beq getstr
- move.b D0,D1
-
- move.b #10,D0
- cmp.b #'n',D1
- beq stowbyte
-
- move.b #13,D0
- cmp.b #'r',D1
- beq stowbyte
-
- move.b #9,D0
- cmp.b #'t',D1
- beq stowbyte
-
- move.b #8,D0
- cmp.b #'b',D1
- beq stowbyte
-
- move.b #12,D0
- cmp.b #'f',D1
- beq stowbyte
-
- cmp.b #'0',D1
- bcs ..noct
- cmp.b #'7',D1
- bhi ..noct
- moveq #0,D0
- bsr ..isoct
- bsr ..isoct
- sub.b #'0',D1
- asl.b #3,D0
- add.b D1,D0
- bra stowbyte
-
- ..isoct
- sub.b #'0',D1
- asl.b #3,D0
- add.b D1,D0
- move.b (A1),D1
- cmp.b #'0',D1
- bcs 1$
- cmp.b #'7',D1
- bhi 1$
- addq.l #1,A1
- rts
- 1$ addq.l #4,SP
- bra stowbyte
-
- ..noct
- move.b D1,D0
- cmp.b #'\',D1
- beq stowbyte
- cmp.b #'(',D1
- beq stowbyte
- cmp.b #')',D1
- beq stowbyte
- rts
-
-
- pushlit
- addq.l #1,A1 past '/'
- move.l farea,A0 save to push
- moveq #0,D3 count
- bsr stowbyte room for length
- 1$ move.b (A1)+,D0
- bsr testendchar
- bne 2$
- move.b D3,(A0)
- subq.l #1,A1
- move.l A0,D0
- move.w #Name,D2
- bra ipush
- 2$ bsr stowbyte
- addq.l #1,D3
- bra 1$
-
- pushnum
- moveq #0,D1
- move.l D1,D2 neg flag
- move.l D1,D3 dec point flag
- move.l A1,A0
- cmp.b #'-',(A0)
- bne 1$
- move.b (A1)+,D2
- 1$ move.b (A1)+,D0
- bsr testdig
- bne 2$
- sub.b #'0',D0
- ext.w D0
- ext.l D0
-
- move.l D0,-(SP)
- add.l D1,D1
- move.l D1,D0
- lsl.l #2,D1
- add.l D0,D1
- move.l (SP)+,D0
- add.l D0,D1
- bra 1$
-
- 2$ tst.b D3
- beq 6$
- cmp.b #'E',D0
- bne realpush
- 3$ move.b (A1)+,D0
- cmp.b #'-',D0
- bne 5$
- 4$ move.b (A1)+,D0
- 5$ bsr testdig
- beq 4$
- bra realpush
-
- 6$ cmp.b #'E',D0
- beq 3$
- cmp.b #'.',D0
- bne intpush
- move.b D0,D3
- bra 1$
-
- realpush
- subq.l #1,A1
- move.l A1,-(SP)
- jsr FFPAFP
- move.l (SP)+,A1
- bvs 1$
- move.w #Real,D2
- move.l D7,D0
- bra ipush
- 1$ print fperr
- bra reinterp
-
- intpush
- subq.l #1,A1
- move.b D2,D3
- move.w #Integer,D2
- move.l D1,D0
- tst.b D3
- beq ipush
- neg.l D0
-
- ipush
- move.b compilelevel,D3
- beq r.ipush
- bsr stowmovel
- bsr stowmovew
- ..iptype
- lea r.ipush,A0
- move.l A0,D0
- bra stowcall
-
- vpush
- tst.b D3
- beq r.ipush
- move.l A2,D0 get address of value
- addq.l #2,D0
- move.l A2,-(SP)
- bsr stowmovev
- move.l (SP)+,D0 get address of type
- bsr stowmovevw
- bra ..iptype
-
- xdef r.ipush
- r.ipush
- * move.l istack,A5
- move.l D0,-(A5)
- move.w D2,-(A5)
- cmp.l #istackbot,A5
- bhi ipush.ok
- print overflow
- reinterp
- move.b #0,compilelevel
- bsr initloops
- bsr runclose
- move.l stacksave,SP
- bra main1
-
- ipush.ok
- * move.l A5,istack
- rts
-
-
- xdef ipop
- ipop
- DEF pop
- * move.l istack,A5
- move.w (A5)+,D2
- cmp.w #Illegal,D2
- bne ..ippok
- iuflow
- print underflow
- bra reinterp
- ..ippok
- move.l (A5)+,D0
- * move.l A5,istack
- rts
-
- xdef popnum
- popnum
- bsr ipop
- cmp.w #Integer,D2
- beq 1$
- cmp.w #Real,D2
- bne type_mismatch
- move.l D1,-(SP)
- math SPFix
- move.l (SP)+,D1
- move.w #Integer,D2
- 1$ rts
-
- skipsp
- move.b (A1),D0
- beq 2$
- cmp.b #10,D0
- beq 1$
- cmp.b #' ',D0
- bne 2$
- 1$ addq.l #1,A1
- bra skipsp
- 2$ rts
-
- testendchar
- tst.b D0
- beq 1$
- cmp.b #' ',D0
- beq 1$
- cmp.b #10,D0
- beq 1$
- cmp.b #'}',D0
- beq 1$
- cmp.b #'{',D0
- beq 1$
- cmp.b #')',D0
- beq 1$
- cmp.b #'(',D0
- beq 1$
- cmp.b #'/',D0
- beq 1$
- cmp.b #'%',D0
- beq 1$
- cmp.b #']',D0
- beq 1$
- cmp.b #'[',D0
- beq 1$
- cmp.b #'>',D0
- beq 1$
- cmp.b #'<',D0
- 1$ rts
-
- * A1 -> name to look for
- * return with A1 -> past name
- * D2 = -1 if not found, else D2 = type
- * D0 = value & A2 -> type of entry
- findsym
- move.l A1,A0
- moveq #0,D3
- move.l D3,D2
-
- 1$ move.b (A0)+,D0 get length in D3
- bsr testendchar
- beq 2$
- addq.l #1,D3
- bra 1$
- 2$ tst.l D3
- bne 4$
- cmp.b #'[',D0
- beq 3$
- cmp.b #']',D0
- bne .nonefound
- 3$ moveq #1,D3
- 4$ bsr allsym
- tst.l D2
- bpl 5$
- move.b compilelevel,D1
- bne dummyentry
- 5$ add.l D3,A1
- rts
-
- allsym
- move.w dstackcnt,D1
- move.l dstack,A0
- 1$ subq.w #1,D1
- bmi 2$
- move.l (A0)+,A2
- addq.l #2,A2
- movem.l A0/D1,-(SP)
- moveq #0,D2
- bsr nextsym
- movem.l (SP)+,A0/D1
- tst.l D2
- bmi 1$
- rts
- 2$ moveq #0,D2
- lea systemdict,A2
-
- * also called by dictsearch
- nextsym
- move.l (A2)+,D0
- beq .nonefound
- move.l D0,A3 A3 -> name in dict
- move.l A1,A0 A0 -> name
- move.l D3,D1
- move.w (A2)+,D2 D2 = type
- move.l (A2)+,D0 D0 = value
-
- cmp.b (A3)+,D1 same length?
- bne nextsym
-
- subq.l #1,D1
- 4$ cmp.b (A3)+,(A0)+
- dbne D1,4$
- bne nextsym
- subq.l #6,A2
- rts
-
- .nonefound
- moveq #-1,D2
- rts
-
- * from above -- A1 -> name; D3 = length
- dummyentry
- move.l A1,A0
- add.l D3,A0
- move.l A0,-(SP)
- move.l farea,A0 save for entry name
- move.l D3,D0
- bsr stowbyte length
- bra 2$
- 1$ move.b (A1)+,D0
- bsr stowbyte
- 2$ dbra D3,1$
-
- lea say_undefined,A1
- move.l A1,D0
- move.l #Dummy,D2
- bsr newentry
- subq.l #6,A0
- move.l A0,A2
- bsr vpush
- lea _exec,A0
- move.l #ICode,D2
- move.l A0,D0
- move.l (SP)+,A1
- rts
-
-
-
- DEF begin
- ARG Dictionary
- lea dstackcnt,A0
- cmp.w #DstackSize,(A0)
- beq 1$
- addq.w #1,(A0)
- move.l dstack,A0
- move.l D0,-(A0)
- move.l A0,dstack
- rts
- 1$ print dstackov
- bra reinterp
-
- DEF end
- lea dstackcnt,A0
- tst.w (A0)
- beq 1$
- subq.w #1,(A0)
- move.l dstack,A0
- move.l (A0)+,D0
- move.l A0,dstack
- rts
- 1$ print dstackuv
- bra reinterp
-
- **********
-
-
- stowbyte
- move.l farea,A2
- move.b D0,(A2)+
- cmp.l #endsarea,A2
- bne 1$
- print areafull
- bra reinterp
- 1$ move.l A2,farea
- rts
-
- * store instruction 'move.w <D0>,D2'
- stowmovevw
- move.l D0,-(SP)
- move.w #_MOVEVD2,D0
- bra ..stowi
- * store instruction 'move.w #<D2>,D2'
- stowmovew
- move.w #_MOVEWD2,D0
- bsr stowword
- move.w D2,D0
- bra stowword
- * store instruction 'move.l <D0>,D0'
- stowmovev
- move.l D0,-(SP)
- move.w #_MOVEVD0,D0
- bra ..stowi
- * store instruction 'move.l #<D0>,D0'
- stowmovel
- move.l D0,-(SP)
- move.w #_MOVELD0,D0
- bra ..stowi
- * store instruction 'jsr <D0>'
- stowcall
- move.l D0,-(SP)
- move.w #_JSR,D0 change to BSR?
- ..stowi
- bsr stowword
- move.l (SP),D0
- swap D0
- bsr stowword
- move.l (SP)+,D0
-
- stowword
- move.l nextcode,A2
- move.w D0,(A2)+
- cmp.l #endcode,A2
- bls 1$
- print codefull
- bra reinterp
- 1$ move.l A2,nextcode
- rts
-
- stowlong
- swap D0
- bsr stowword
- swap D0
- bra stowword
-
- ************************************
-
- DEF hex
- bsr ipop
- bsr show8x
- move.l A0,D0
- RETURN Name
-
- DEF quit
- move.l stacksave,SP
- bsr runclose
- bra system
-
- DEF cvs
- ARG String
- move.l D0,-(SP)
- moveq #-1,D0 flag this is a string conversion
- bra ..prnt
- ..cvs2
- * it better be long enough
- move.l (SP)+,A1
- move.l A1,D0
- * A0 -> name; A1 -> string
- moveq #0,D1
- move.b D1,(A1)+
- move.b (A0),D1
- 1$ move.b (A0)+,(A1)+
- dbra D1,1$
- RETURN String
-
- ..pors
- move.l (SP)+,D0
- bne ..cvs2
- bsr msg
- bra newline
-
- DEF print
- ARG String
- move.l D0,A0
- moveq #0,D3
- move.w (A0)+,D3
- bra longmsg
-
-
- DEF equalsprint
- moveq #0,D0 flag this is a print
- ..prnt
- move.l D0,-(SP)
- bsr ipop
- cmp.w #Integer,D2
- bne 2$
- bsr showdec
- bra ..pors
-
- 2$ cmp.w #Name,D2
- bne 3$
- move.l D0,A0
- bra ..pors
-
- 3$ cmp.w #String,D2
- bne 4$
- move.l D0,A0
- move.l (SP)+,D1
- beq 30$
- move.l (SP)+,D1
- bra r.ipush it's already a string -- should copy it?
- 30$
- moveq #0,D3
- move.w (A0)+,D3
- bsr longmsg
- bra newline
-
- 4$ cmp.w #Boolean,D2
- bne 6$
- lea .true,A0
- tst.l D0
- bne 5$
- lea .false,A0
- 5$ bra ..pors
-
- 6$ cmp.w #Real,D2
- bne 7$
- bsr showreal
- bra ..pors
-
- 7$
- lea nsv,A0
- bra ..pors
-
-
- DEF string
- bsr popnum
- move.l D0,D3
- swap D0
- tst.w D0
- bne 2$
-
- move.l farea,D0
- btst #0,D0
- beq 1$
- bsr stowbyte
- move.l farea,D0
- 1$
- move.l D0,A2
- add.l D3,A2
- addq.l #2,A2
- cmp.l #endsarea,A2
- bcs 3$
- 2$ print areafull
- bra reinterp
- 3$ move.l D0,A0
- move.w D3,(A0)
- move.l A2,farea
- RETURN String
-
- DEF dict
- moveq #-1,D4
- bra ..arry
-
- DEF array
- moveq #0,D4
- ..arry
- bsr popnum
- move.l nextcode,A2
- move.l A2,A0
- move.w D0,(A2)+
- add.l D0,D0 bytes -> words
- move.l D0,D1
- add.l D1,D0
- add.l D1,D0 length * 3
- tst.l D4
- beq 1$
- add.l D1,D0
- add.l D1,D0 length * 5
- addq.l #4,D0 +1 for null at end
- move.l A2,A0
- clr.w (A2)+ current length is 0
- clr.l (A2) flag end
- 1$ add.l D0,A2
- cmp.l #endcode,A2
- bls 2$
- ERR codefull
- 2$ move.l A2,nextcode
- move.l A0,D0
- tst.l D4
- bne 3$
- RETURN Array
- 3$ RETURN Dictionary
-
- DEF fontalloc
- move.l nextcode,A0
- lea 12(A0),A2
- cmp.l #endcode,A2
- bls 1$
- ERR codefull
- 1$ move.l A2,nextcode
- rts
-
-
- DEF maxlength
- bsr ipop
- move.l D0,A0
- subq.l #2,A0
- bra ..lngth
-
- DEF length
- bsr ipop
- move.l D0,A0
- cmp.w #String,D2
- beq ..rlngth
- cmp.w #Array,D2
- beq ..rlngth
- ..lngth
- cmp.w #Dictionary,D2
- bne type_mismatch
- ..rlngth
- moveq #0,D0
- move.w (A0),D0
- move.w #Integer,D2
- bra r.ipush
-
-
- arrayref
- bsr popnum
- move.l D0,D1 the index
- bsr ipop
- move.l D0,A0 base of array
- moveq #0,D3
- cmp.w #Array,D2
- beq 1$
- cmp.w #String,D2
- bne type_mismatch
- 1$ move.w (A0)+,D3
- subq.l #1,D3 length - 1 is max index
- bmi 3$
- cmp.l D3,D1 past end?
- bhi 3$
- cmp.w #Array,D2
- beq 2$
- add.l D1,A0 ret not equal
- rts
- 2$ add.l D1,D1 word reference
- move.l D1,D0
- add.l D1,D0 times 3
- add.l D1,D0
- add.l D0,A0 index to element
- cmp.l D0,D0
- rts
- 3$ print arr_err
- bra reinterp
-
-
- DEF get
- bsr arrayref
- bne 1$
- move.w (A0)+,D2 type
- move.l (A0),D0 value
- bra r.ipush
- 1$ move.w #Integer,D2
- moveq #0,D0
- move.b (A0),D0
- bra r.ipush
-
- DEF put
- bsr ipop
- move.l D0,-(SP)
- move.w D2,-(SP)
- bsr arrayref
- bne 1$
- move.w (SP)+,(A0)+
- move.l (SP)+,(A0)
- rts
- 1$ move.w (SP)+,D2
- move.l (SP)+,D0
- cmp.w #Integer,D2
- bne type_mismatch
- move.b D0,(A0)
- rts
-
- DEF mark
- moveq #0,D0
- RETURN Mark
-
- DEF rbracket
- moveq #0,D3 count array elements
- 1$ bsr ipop
- cmp.w #Mark,D2
- beq 2$
- addq.l #1,D3
- move.l D0,-(SP)
- move.w D2,-(SP)
- bra 1$
- 2$ move.l nextcode,D0
- move.w #Array,D2
- bsr r.ipush
- move.l D3,D0
- bsr stowword
- bra 4$
-
- 3$ move.w (SP)+,D0
- bsr stowword
- move.l (SP)+,D0
- bsr stowlong
- 4$ dbra D3,3$
- rts
-
-
- DEF def
- bsr ipop
- movem.l D0/D2,-(SP)
- ARG Name
- move.l D0,A1 first check dict to see if old symbol
- move.l D0,-(SP) save for name of new entry
- bsr alldictsearch
- move.l (SP)+,D0
- tst.l D2 found?
- bmi newentry1
- * replace old entry
- movem.l (SP)+,D0/D2
- *(perhaps change this so that when types don't match,
- * make old entry nameless and create new entry, to prevent
- * problem with previously compiled code)
- move.w D2,(A2)+ new type
- move.l D0,(A2) new value
- rts
-
- * called from findsym
- newentry
- movem.l D0/D2,-(SP)
- move.l A0,D0
- * make new entry
- * type & value on stack; D0 -> name
- newentry1
- move.w dstackcnt,D1
- bne 4$
- move.l nextentry,A0
- move.l D0,(A0)+
- movem.l (SP)+,D0/D2
- move.w D2,(A0)+
- move.l D0,(A0)+
- clr.l (A0)
- cmp.l #enddict,A0
- bhi 3$
- move.l A0,nextentry
- rts
- 3$ print fulldict
- bra reinterp
- 4$ move.l dstack,A0
- move.l (A0),A0 address of dict -> current size
- move.w -(A0),D1 D1 = maxsize
- addq.l #2,A0 point at current size again
- cmp.w (A0),D1 if max <= current, no room
- bls 3$
- moveq #0,D1 form address for new entry
- move.w (A0),D1
- add.l D1,D1 word
- move.l D1,D2 5 * new current size
- add.l D1,D1
- add.l D1,D1
- add.l D2,D1
-
- addq.w #1,(A0)+ new current size, & point to 1st entry
- add.l D1,A0 point to new entry
- tst.l (A0) if not null, imp. error
- bne imp_error
-
- move.l D0,(A0)+
- movem.l (SP)+,D0/D2
- move.w D2,(A0)+
- move.l D0,(A0)+
- clr.l (A0)
-
- rts
-
- alldictsearch
- move.l dstack,A0
- move.w dstackcnt,D3
- 1$ subq.w #1,D3
- bmi 3$
- move.l (A0)+,A2
- addq.l #2,A2 past current length
- movem.l D3/A0,-(SP)
- bsr dictsearch
- movem.l (SP)+,D3/A0
- tst.l D2
- * bmi 1$ (it was a mistake to search past top dictionary)
- rts
- 3$ lea systemdict,A2
- xdef dictsearch
- * A1 -> Name (bstr)
- * A2 -> dict
- * returns D2 = -1 if not found
- * else D2 = type
- * D0 = value
- * A2 -> type in entry
- dictsearch
- move.l A1,-(SP)
- moveq #0,D3 len
- move.l D3,D2
- move.b (A1)+,D3
- bsr nextsym
- move.l (SP)+,A1
- rts
-
-
- DEF exch
- bsr ipop
- move.l D0,D1
- move.w D2,D3
- bsr ipop
- exg D0,D1
- exg D2,D3
- bsr r.ipush
- move.l D1,D0
- move.w D3,D2
- bra r.ipush
-
- DEF dup
- bsr ipop
- bsr r.ipush
- bra r.ipush
-
- DEF true
- moveq #-1,D0
- RETURN Boolean
-
- DEF false
- moveq #0,D0
- RETURN Boolean
-
- DEF cvr
- ARG Integer
- math SPFlt
- RETURN Real
-
- DEF cvi
- ARG Real
- math SPFix
- RETURN Integer
-
- **************
-
- DEF save
- lea sstackcnt,A0
- cmp.w #SstackSize,(A0)
- beq 1$
- addq.w #1,(A0)
- move.l sstack,A0
- move.l farea,-(A0)
- move.l nextentry,-(A0)
- move.l nextcode,-(A0)
- move.l A0,sstack
- bsr _gsave
- moveq #0,D0
- RETURN Save
- 1$ print sstkov
- bra reinterp
-
- DEF restore
- ARG Save
- lea sstackcnt,A0
- tst.w (A0)
- beq 1$
- subq.w #1,(A0)
- move.l sstack,A0
- move.l (A0)+,nextcode
- move.l (A0)+,A1
- clr.l (A1)
- move.l A1,nextentry
- move.l (A0)+,farea
- bra _grestore
- 1$ print sstkuv
- bra reinterp
-
-
- ****************
-
- imp_error
- print imperr
- bra reinterp
-
- xdef type_mismatch
- type_mismatch
- print mismatch
- bra reinterp
-
- *****************************
- section three,bss
-
- stacksave ds.l 1
-
- graphicsbase ds.l 1
- intuitionbase ds.l 1
- mathffpbase ds.l 1
- mathtransbase ds.l 1
-
- wbscreen ds.l 1
- rastport ds.l 1
-
- ohandle ds.l 1
- ihandle ds.l 1
-
-
- codearea ds.w CodeSize
- endcode ds.w 4
-
- istack ds.l 1
- ds.b 12
- istackbot ds.b 6*IstackSize
- istacktop ds.l 1
-
- dstackcnt ds.w 1
- dstack ds.l 1
- ds.b 8
- dstackbot ds.b 4*DstackSize
- dstacktop ds.l 1
-
-
- sstackcnt ds.w 1
- sstack ds.l 1
- ds.b 12
- sstackbot ds.b 12*SstackSize
- sstacktop ds.l 1
-
- fsarea ds.b SAreaSize
- endsarea ds.b 2
-
- section two,data
-
- farea dc.l fsarea
- nextentry dc.l fdict
- nextcode dc.l codearea
- compilelevel dc.w 0
- parenlevel dc.w 0
-
-
- bstr underflow,<stack underflow>
- bstr overflow,<stack overflow>
- bstr areafull,<string area is full>
- bstr mismatch,<type mismatch>
- bstr nsv,<--nostringval-->
- bstr fulldict,<dictionary is full>
- bstr codefull,<code area is full>
- bstr unknown,<unknown symbol>
- bstr rbrace,<unmatched right brace>
- bstr fperr,<floating point error>
- bstr arr_err,<bad array reference>
- bstr dstackov,<dict stack overflow>
- bstr dstackuv,<dict stack underflow>
- bstr imperr,<implementation error>
- bstr sstkov,<save stack overflow>
- bstr sstkuv,<save stack underflow>
-
- end
-
-