
 ttl Symbol Table Handler
 pag

*
* get symbol in table (or install)
*

getsym ldx #ident point to identifier
 ldb #8 set count
2 tst 0,x+
 beq 3f
 decb
 bne 2b
 bra 5f
3 clr 0,x+ clear rest of buffer
 decb
 bne 3b
5 ldy nxtsym set end
 pshs y
 ldy #symtab point to correct table
 tst strflg doing structure?
 beq 55f
 ldy nxtsu adjust for structure search
 sty 0,s
 ldy #sutab
55 ldx 0,s
 bsr hash look up name in table
 beq 8f find?
 tst strflg doing structure?
 bne 57f
 cmpy #symtab+STLEN oflow?
 bhs 9f
 bra 58f
57 cmpy #sutab+SUTLEN oflow?
 bhs 9f
58 ldx #ident point to name
 ldb #8 set count
6 lda 0,x+
 sta sname,y put name in table
 leay 1,y
 decb
 bne 6b
 ldx 0,s point to entry
 leay SYMSIZ,x
 tst strflg doing structure?
 beq 7f
 sty nxtsu
 bra 8f
7 sty nxtsym
8 puls d,pc return
9 puls d clean stack
 ldd #132 set error
 jmp error

*
* hash routine - find symbol in table
*

hash pshs x
1 ldx #ident point to name
 cmpy 0,s end of table?
 beq 4f
 ldb #8 set count
 lda sflags,y check pushed status
 bita #FPSHD
 bne 3f if so, ignore
2 lda 0,x+ get character
 cmpa sname,y
 bne 3f
 leay 1,y
 decb dec the count
 bne 2b
 leax -8,y point to it
 clra show found
 puls d,pc return
3 addb #SYMSIZ-8 find next entry
 leay b,y
 bra 1b
4 andcc #$fb show no find
 puls d,pc return

*
* clear all symbols at current block level
*

clrlev pshs y,x
 ldy nxtsym clear symbols first
 bsr dolclr doit
 stu nxtsym save end pointer
 ldx 2,s now do structures
 ldy nxtsu
 bsr dolclr do it
 dec blklev dec the block level
 puls x,y
 sty nxtsu
 rts return

*
* do actual clearing of symbol table for level
*

dolclr pshs y save table end
 leau 0,x point to start
2 cmpx 0,s end of table?
 beq 6f
 ldy spshd,x check pushed status
 beq 4f
 lda sflags,y get flags of pushed
 anda #(!FPSHD)&$ff clear pushed status
 sta sflags,y
4 ldb #SYMSIZ clear entry
 lda sflags,x get flags
 bita #FLAB is it label?
 beq 5f
 lda blklev check block level
 cmpa #2
 bls 5f
42 lda 0,x+ copy label down
 sta 0,u+
 pshs u
 cmpx 0,s++
 beq 45f
 clr -1,x
45 decb
 bne 42b
 bra 2b
5 clr 0,x+
 decb
 bne 5b
 bra 2b repeat
6 puls y,pc return


