S-C DisAssembler
1000 *SAVE D.LABELS
1010 *--------------------------------
1020 * Format of Pre-Defined Symbol Table
1030 *
1040 * The table begins at the address contained in LABELS,
1050 * and continues up to the bottom of the script (which
1060 * is pointed to by the address in PP).
1070 *
1080 * Each predefined symbol is first parsed into the Label
1090 * Building Buffer, which includes LABEL.LO, LABEL.HI,
1100 * LABEL.LEN, and LABEL.NAME. Then the contents of the
1110 * Label Building Buffer are copied onto the bottom of
1120 * the Pre-Defined Symbol Table.
1130 *
1140 * byte 0: value (lo-byte)
1150 * byte 1: value (hi-byte)
1160 * byte 2: length of name (1...32)
1170 * 3-n: the name in low-ASCII
1180 *--------------------------------
1190 SEARCH.LABEL.TABLE
1200 STY LBL.Y
1210 >MOV LABELS,PLBL
1220 .1 LDA PLBL
1230 CMP PP
1240 LDA PLBL+1
1250 SBC PP+1
1260 BCC .2 MORE TO COMPARE
1270 LDY LBL.Y
1280 CLC SIGNAL NOT FOUND
1290 RTS
1300 .2 LDY #0
1310 LDA (PLBL),Y
1320 INY
1330 CMP LABEL.LO
1340 BNE .3 NOT THIS ONE
1350 LDA (PLBL),Y
1360 CMP LABEL.HI
1370 BNE .3 NOT THIS ONE
1380 LDY LBL.Y
1390 RTS FOUND, CARRY SET
1400 .3 INY POINT AT LENGTH
1410 CLC
1420 LDA #3
1430 ADC (PLBL),Y
1440 ADC PLBL
1450 STA PLBL
1460 BCC .1
1470 INC PLBL+1
1480 BNE .1 ...ALWAYS
1490 *--------------------------------
1500 GEN.NAMED.LABEL
1510 STY LBL.Y
1520 STX LBL.X
1530 LDY #2
1540 LDA (PLBL),Y
1550 STA LABEL.LEN
1560 LDX #0
1570 .1 INY
1580 LDA (PLBL),Y
1590 JSR STUFF.CHAR
1600 INX
1610 CPX LABEL.LEN
1620 BCC .1
1630 .2 LDY LBL.Y
1640 LDX LBL.X
1650 RTS
1660 *--------------------------------
1670 DEFINE.LABEL
1680 LDA PASS
1690 BEQ .1
1700 RTS DO NOTHING IN PASS 2
1710 .1 JSR GET.HEX.VALUE.GNNB
1720 STA LABEL.LO
1730 STX LABEL.HI
1740 JSR SEARCH.LABEL.TABLE
1750 BCC .2 ...NOT ALREADY IN TABLE
1760 LDY #Q.DBLDEF
1770 JMP ERROR
1780 .2 LDA #0
1790 STA LABEL.LEN
1800 LDA CURRCHAR SKIP OVER COMMA
1810 CMP #','
1820 BEQ .3 GOT ONE
1830 LDY #Q.COMMA
1840 JMP ERROR
1850 .3 LDX #0
1860 .4 JSR GNNB
1870 BEQ .5
1880 STA LABEL.NAME,X
1890 INX
1900 CPX #32 Truncate long symbolnames to 32 characters
1910 BCC .4
1920 .5 STX LABEL.LEN
1930 INX ADD 3 TO GET ENTRY LENGTH
1940 INX
1950 TXA 2'S COMPLEMENT (A) = (A-1)eor$FF
1960 EOR #$FF
1970 CLC MOVE BASE DOWN THAT FAR
1980 ADC LABELS
1990 STA LABELS
2000 BCS .6 NO BORROW
2010 DEC LABELS+1
2020 .6 CMP SPTR SEE IF RUNNING INTO SYMBOL TABLE
2030 LDA LABELS+1
2040 SBC SPTR+1
2050 BCS .7 STILL ROOM
2060 LDA #Q.MEMFUL
2070 JMP ERROR
2080 .7 LDY #0
2090 .8 LDA LABEL.LO,Y
2100 STA (LABELS),Y
2110 INY
2120 DEX
2130 BPL .8
2140 LDX #H.LBLS
2150 JMP SHOW.HEX.INFO
2160 *--------------------------------