S-C DisAssembler
1000 *SAVE D.CONTROL
1010 *--------------------------------
1020 .MA SET
1030 LDA #]2
1040 STA ]1
1050 LDA /]2
1060 STA ]1+1
1070 .EM
1080 *--------------------------------
1090 .MA MOV
1100 LDA ]1
1110 STA ]2
1120 LDA ]1+1
1130 STA ]2+1
1140 .EM
1150 *--------------------------------
1160 S.C.DISASM
1170 CLD IN CASE STARTED WITH $800G AND CLOBBERED $48
1180 LDY #Q.TITLE
1190 JSR QT.OUT
1200 LDA #0 FOR PASS = 1 TO 2
1210 STA PASS
1220 STA XREF.FLAG
1230 STA SYMBOL.SORTED.FLAG
1240 STA RPTCNT
1250 STA LINNUM
1260 STA LINNUM+1
1270 STA O.REF
1280 STA O.REF.IN
1290 STA STAR.DASH.FLAG
1300 STA I.RANGE
1310 STA I.RANGE+2
1320 LDA #$08
1330 STA I.RANGE+1
1340 LDA #$C0
1350 STA I.RANGE+3
1360 LDA #'Z'
1370 STA LBLCHR.Z
1380 LDA #'I'
1390 STA LBLCHR.I
1400 LDA #'X'
1410 STA LBLCHR.X
1420 LDA #$87
1430 STA TAB.TO.OPCODE
1440 >SET SPTR,SYMBOL.TABLE
1450 >MOV PP,LABELS
1460 *--------------------------------
1470 .1 JSR DISPLAY.PASS.NO
1480 >MOV PP,SRCP
1490 *--------------------------------
1500 .2 JSR CHECK.KEYBOARD.FOR.ABORT
1510 BCS .5 QUIT NOW
1520 JSR SETUP.NEXT.LINE
1530 BCS .4 ...END OF COMMANDS
1540 LDY #0
1550 JSR GNNB
1560 BEQ .2 END OF LINE
1570 CMP #'*' STRICTLY A COMMENT?
1580 BEQ .2 ...YES
1590 CMP #$60 CHANGE LOWER CASE TO UPPER CASE
1600 BCC .3
1610 AND #$5F
1620 .3 STA CMD.CHAR
1630 JSR DO.COMMAND
1640 JMP .2
1650 *---NEXT PASS--------------------
1660 .4 INC PASS
1670 LDA PASS
1680 CMP #2
1690 BCC .1
1700 *--------------------------------
1710 >SET PC,$FFFF
1720 JSR GEN.SYMBOLS.UP.TO.PC
1730 *---TRIM END OF OUTPUT FILE------
1740 .5 JSR CLOSE.OUTPUT.FILE.IF.OPEN ---3-24-87---
1750 *---CLOSE ALL FILES--------------
1760 QUIT
1770 LDA #0
1780 JSR CLOSE.FILE ---3-24-87---
1790 JMP $3D0
1800 *--------------------------------
1810 DO.COMMAND
1820 LDY #-3
1830 .1 INY
1840 INY
1850 INY
1860 LDA COMMANDS,Y
1870 BEQ .5 ...NOT IN TABLE
1880 AND #$7F
1890 CMP CMD.CHAR
1900 BNE .1 ...NOT THIS ONE
1910 LDA COMMANDS+2,Y
1920 PHA HIGH BYTE
1930 LDA COMMANDS+1,Y
1940 PHA LOW BYTE
1950 LDA COMMANDS,Y
1960 BPL .3
1970 .2 JSR GNNB
1980 BEQ .4 ...ERROR
1990 CMP #':'
2000 BNE .2
2010 .3 RTS
2020 .4 LDY #Q.COLON
2030 JMP ERROR
2040 .5 LDY #Q.NOTCMD
2050 JMP ERROR
2060 *--------------------------------
2070 COMMANDS
2080 .DA #"O",OPEN.SRC.FILE-1
2090 .DA #"I",OPEN.OBJ.FILE-1
2100 .DA #"P",POSITION.OBJ.FILE-1
2110 .DA #"L",DEFINE.LABEL.CHARS-1
2120 .DA #"W",SET.LABEL.WIDTH-1
2130 .DA #"C",DISASM.CODE-1
2140 .DA #"H",DISASM.HEX-1
2150 .DA #"X",XREF.OPTION-1
2160 .DA #'"',DISASM.CMNT-1
2170 .DA #'=',DEFINE.LABEL-1
2180 .DA #0
2190 *--------------------------------
2200 GNNB INC CHRPTR
2210 LDY CHRPTR
2220 LDA CMDBUF-1,Y
2230 BEQ .1 ...END OF LINE
2240 CMP #$20
2250 BEQ GNNB
2260 .1 STA CURRCHAR
2270 RTS
2280 *--------------------------------
2290 SETUP.NEXT.LINE
2300 LDA SRCP
2310 CMP HIMEM
2320 LDA SRCP+1
2330 SBC HIMEM+1
2340 BCS .3 ...END OF PROGRAM
2350 JSR GNB SKIP OVER LENGTH BYTE
2360 JSR GNB GET LINE NUMBER
2370 STA CURRENT.LINE.NUMBER
2380 JSR GNB
2390 STA CURRENT.LINE.NUMBER+1
2400 LDX #0
2410 STX CHRPTR
2420 .1 JSR NTKN
2430 STA CMDBUF,X
2440 BEQ .2
2450 INX
2460 CPX #CMDBUF.SZ
2470 BCC .1 STILL ROOM IN LINE
2480 LDA #0
2490 STA CMDBUF-1,X
2500 LDY #Q.CMDFUL
2510 JMP ERROR
2520 .2 CLC
2530 .3 RTS
2540 *--------------------------------
2550 NTKN
2560 LDA RPTCNT
2570 BNE .3
2580 JSR GNB
2590 BPL .4 ...NORMAL CHARACTER
2600 CMP #$C0
2610 BCC .1 ...BLANKS
2620 JSR GNBI $C0 XX YY
2630 STA RPTCNT
2640 JSR GNBI
2650 JMP .2
2660 .1 AND #$3F BLANK COUNT
2670 STA RPTCNT
2680 LDA #$20
2690 .2 STA RPTCHR
2700 .3 DEC RPTCNT
2710 LDA RPTCHR
2720 .4 RTS
2730 *--------------------------------
2740 GNB LDY #0
2750 GNBI LDA (SRCP),Y
2760 INC SRCP
2770 BNE .1
2780 INC SRCP+1
2790 .1 ASL
2800 ROR
2810 RTS
2820 *--------------------------------
2830 XREF.OPTION
2840 .1 JSR GNNB
2850 BEQ .3 LEAVE IT AS IS
2860 CMP #'F'
2870 BEQ .2 TURN XREF'S OFF
2880 CMP #'N'
2890 BNE .1 KEEP SCANNING
2900 CLC TURN XREF'S ON
2910 .2 ROR XREF.FLAG TURN XREF'S ON/OFF
2920 .3 RTS
2930 *--------------------------------
2940 SET.LABEL.WIDTH
2950 JSR GET.HEX.VALUE.GNNB
2960 CPX #0
2970 BNE .1
2980 CMP #63
2990 BCS .1
3000 ADC #$81
3010 STA TAB.TO.OPCODE
3020 RTS
3030 .1 LDY #Q.OVERFLOW
3040 JMP ERROR
3050 *--------------------------------
3060 POSITION.OBJ.FILE
3070 JSR GET.HEX.VALUE.GNNB
3080 STA OFFSET
3090 STX OFFSET+1
3100 JSR MLI SET MARK
3110 .DA #$CE,P.MARK
3120 BCS .1
3130 RTS
3140 .1 LDY #Q.BEYOND
3150 JMP ERROR
3160 *--------------------------------
3170 START.PASS.TWO
3180 LDA SYMBOL.SORTED.FLAG
3190 BNE .1 ...ALREADY SORTED
3200 INC SYMBOL.SORTED.FLAG
3210 JSR SORT.SYMBOLS
3220 >SET LPTR,SYMBOL.TABLE
3230 >SET PC,$FF PAGE ZERO SYMBOLS
3240 JSR GEN.SYMBOLS.UP.TO.PC
3250 >SET PC,$7FF OTHER LOW EXTERNALS
3260 JSR GEN.SYMBOLS.UP.TO.PC
3270 >SET PC,$800 DEFAULT ORIGIN
3280 .1 JSR SETUP.PC
3290 JSR GEN.SYMBOLS.UP.TO.PC.MINUS.ONE
3300 JMP GEN.STAR.DASH
3310 *--------------------------------
3320 GET.HEX.RANGE
3330 JSR GNNB
3340 CMP #'-'
3350 BNE .1 NOT A CONTINUATION RANGE
3360 LDA A2
3370 LDX A2+1
3380 BCS .2 ...ALWAYS
3390 .1 JSR GET.HEX.VALUE
3400 .2 STA A1
3410 STX A1+1
3420 JSR GET.HEX.VALUE.GNNB
3430 STA A2
3440 STX A2+1
3450 CMP A1
3460 TXA
3470 SBC A1+1
3480 BCC .4 BAD RANGE
3490 INC A2 ADJUST END TO END+1
3500 BNE .3
3510 INC A2+1
3520 .3 RTS
3530 .4 LDY #Q.RANGE
3540 JMP ERROR
3550 *--------------------------------
3560 GET.HEX.VALUE.GNNB
3570 JSR GNNB
3580 GET.HEX.VALUE
3590 LDA #0
3600 STA ACCUM
3610 STA ACCUM+1
3620 JSR GET.HEX.DIGIT MUST BE AT LEAST 1 DIGIT
3630 BCC .1
3640 LDY #Q.BADHEX
3650 JMP ERROR
3660 .1 JSR GNNB PRIME NEXT CHAR
3670 JSR GET.HEX.DIGIT
3680 BCC .1
3690 LDA ACCUM
3700 LDX ACCUM+1
3710 RTS
3720 *--------------------------------
3730 GET.HEX.DIGIT
3740 LDA CURRCHAR 30-39, 41-46, 61-66
3750 EOR #$30 00-09, 71-76, 51-56
3760 CMP #$0A
3770 BCC .1 ...0-9
3780 ORA #$20 71-76, 71-76 (ALLOW LOWER CASE TOO)
3790 ADC #$88 FA-FF
3800 CMP #$FA
3810 BCC .3 ...NOT A DIGIT
3820 .1 ASL POSITION NYBBLE
3830 ASL
3840 ASL
3850 ASL
3860 LDX #4 SLIDE DIGIT INTO VALUE
3870 .2 ASL
3880 ROL ACCUM
3890 ROL ACCUM+1
3900 BCS .4
3910 DEX
3920 BNE .2
3930 RTS
3940 .3 SEC SIGNAL NOT A HEX DIGIT
3950 RTS
3960 .4 LDY #Q.OVERFLOW
3970 JMP ERROR
3980 *--------------------------------