>LIST 1000 REM "B.Filter" 1010[OPT Pass 1020.StopOutput 1030 Lda #true 1040 Sta S_received 1050 Jmp ignore_skip 1051.StartOutput 1060 Lda #false 1070 Sta S_received 1080 Jmp ignore_skip 1090.put_in_RS423 \ ENTERS WITH A CHAR ON STACK 1100 \ Char is in A 1110 And mask 1120 Sta char 1130 Lda XonXoff 1140 Cmp #true 1150 Bne NoXTest 1160 Lda char 1170 Cmp #ASC("S") AND 31 1180 Beq StopOutput 1190 Cmp #ASC("Q") AND 31 1200 Beq StartOutput 1210 .NoXTest 1220 Bit hex_only 1230 Bmi not_hex_only 1240 \ 1250 Cmp #ASC("0") 1260 Bcc test_control 1270 Cmp #ASC("0")+15+1 1280 Bcs test_control \ IF '0' <= A <= '0'+15 THEN ... 1290 Lda hex_needed 1300 Cmp #1 1310 Beq last_nibble 1320 Cmp #2 1330 Beq first_nibble 1331 Jsr dobrk 1340 EQUB 1:EQUS "hex_needed wrong value":EQUB 0 1350 .first_nibble 1360 Lda char 1370 Sec: Sbc #ASC("0") 1380 Asl A: Asl A: Asl A: Asl A 1390 Sta byte 1400 Lda #1 1410 Sta hex_needed 1420 Jmp ignore_skip 1430 .last_nibble 1440 Lda char 1450 Sec: Sbc #ASC("0") 1460 Ora byte 1470 Sta char 1480 Lda #2 1490 Sta hex_needed 1500 .end_case_1 1501BIT esc_seen 1502BMI Shit 1503JMP handle_esc 1508.Shit 1509JMP over_esc_handler 1510\ Jmp over_tests 1520 .test_control 1530 Lda char 1531CMP esc:BEQ got_esc 1540 Cmp #ASC(" ") 1550 Bcs invalid_hex 1560 Jmp ignore_skip 1570 .invalid_hex 1580 Lda #false 1590 Sta hex_only 1600\***WRONG .over_tests 1610 .not_hex_only 1620 Lda char 1630 Cmp esc 1640 Bne test_esc_seen 1650 Bit esc_seen 1660 Bmi got_esc 1670 Lda #false 1680 Sta esc_seen 1690 Jmp end_if_esc_seen 1700 .got_esc 1710 Lda #true 1720 Sta esc_seen 1730 Jmp ignore_skip 1740 .end_if_esc_seen 1750 Jmp no_esc_3\over_esc_handler 1760 .test_esc_seen 1770 Bit esc_seen 1780 Bmi no_esc_3 1790 Jmp handle_esc 1800 .no_esc_3 1810 .test_hex_pair 1820 Lda hex_needed 1830 Cmp #2 1840 Bne next_hex_test 1850 Lda char 1860 Sec: Sbc #ASC("0") 1870 Asl A: Asl A: Asl A: Asl A 1880 Sta byte 1890 Lda #1 1900 Sta hex_needed 1910 Jmp ignore_skip 1920 .next_hex_test 1930 Cmp #1 1940 Beq got_last_digit 1950 Cmp #0 1960 Beq no_hex_fiddles 1961 Jsr dobrk 1970 EQUB 2:EQUS "hex_needed value wrong":EQUB 0 1980 .got_last_digit 1990 Lda char 2000 Sec: Sbc #ASC("0") 2010 Ora byte 2020 Sta char 2030 Lda #0 2040 Sta hex_needed 2050 .no_hex_fiddles 2060 Bit sub_needed 2070 Bmi test_add 2080 Lda char 2090 Sec: Sbc #64 2100 Sta char 2110 Lda #false 2120 Sta sub_needed 2130 .test_add 2140 Bit add_needed 2150 Bmi no_more_tests 2160 Lda char 2170 Eor #&80 2180 Sta char 2190 Lda #false 2200 Sta add_needed 2210 .no_more_tests 2220 .test_new_esc 2230 Bit new_esc_next 2240 Bmi not_new_esc 2250 Lda char 2260 Sta esc 2270 Lda #false 2280 Sta new_esc_next 2290 Jmp ignore_skip 2300 .not_new_esc 2310 Jmp over_final_else 2320 .handle_esc 2330 Lda char 2340 Cmp #ASC("8") 2350 Bne test_7 2351 Lda #0: Sta hex_needed 2352 Lda #false: Sta hex_only 2360 Lda #&FF: Sta mask 2370 Jmp end_case 2380 .test_7 2390 Cmp #ASC("7") 2400 Bne test_4 2401 Lda #0: Sta hex_needed 2402 Lda #false: Sta hex_only 2410 Lda #&7F: Sta mask 2420 Jmp end_case 2430 .test_4 2440 Cmp #ASC("4") 2450 Bne test_minus 2460 Lda #true 2470 Sta hex_only 2480 Lda #2 2490 Sta hex_needed 2500 Jmp end_case 2510 .test_minus 2520 Cmp #ASC("-") 2530 Bne test_plus 2540 Lda #true 2550 Sta sub_needed 2560 Jmp end_case 2570 .test_plus 2580 Cmp #ASC("+") 2590 Bne test_and 2600 Lda #true 2610 Sta add_needed 2620 Jmp end_case 2630 .test_and 2640 Cmp #ASC("&") 2650 Bne test_pling 2660 Lda #2 2670 Sta hex_needed 2680 Jmp end_case 2690 .test_pling 2700 Cmp #ASC("!") 2710 Bne test_query 2720 Lda #true 2730 Sta XonXoff 2740 Jmp end_case 2750 .test_query 2760 Cmp #ASC("?") 2770 Bne test_equals 2780 Lda #false 2790 Sta XonXoff 2800 Jmp end_case 2810 .test_equals 2820 Cmp #ASC("=") 2830 Bne default 2840 Lda #true 2850 Sta new_esc_next 2860 Jmp end_case 2870 .default 2871 Jsr dobrk 2880 EQUB 3:EQUS "Bad protocol after escape":EQUB 0 2890 .end_case 2900 Lda #false 2910 Sta esc_seen 2920 Jmp ignore 2930 .over_final_else 2940 .over_esc_handler 2950\ 2960\ Put char in buffer 2970 Lda char 2980 Rts 2990.ignore_skip \ Fudged return assumes nothing on stack. 2991\****** Actually, PLA below is because it now expects one byte on stack. 3000 Clc \ Would be cleaner to return result in V flag and branch 3010 Ldx #1 \ back at higher level 3020 Pla:Pla:PLA:Rts \ (CLC return because character stolen by us.) 3030] 3040RETURN >*spool