Subversion Repositories MB01 Project

Rev

Blame | Last modification | View Log | Download | RSS feed

  Tue Jul 17 11:00:18 2018                                                                                               Page    1







          2500 A.D. 65816 Macro Assembler #26960 - Version 5.02g
          -----------------------------------------------------

                       Input  Filename : src\F8\sp.asm
                       Output Filename : obj\F8\sp.obj
                       Listing Has Been Relocated                               


 2605                           .LIST           on
 2606                           
 2607  F8FFB1                           .INCLUDE INC\DIRP00.INC
 2608                           ;----------------------------------------------------------
 2609                           ; DIRP00.ASM
 2610                           ; PROGETTO: B1601
 2611                           ;
 2612                           ; Variabili in Direct Page $00
 2613                           ;----------------------------------------------------------
 2614                           
 2615                           ; sezione COMMON -- questo permette di includere il file in piu' file
 2616                           
 2617                           .LIST on
 2618                           
 2619                           DIRP00: .SECTION page0, ref_only, common        ;Direct-Page 00
 2620                           
 2621  000000                           .ABSOLUTE               ;; inizia sempre da $00
 2622  000000                           .ORG            0x00
 2623  000000                           
 2624  000000  0000             JiffyClk        .DW                     ; contatore 10ms 32 bit
 2625  000002  0000                             .DW
 2626  000004                   SysTmr          .DS     SYSTMRCNT       ; system timer 0 (10ms)
 2627  000008                   SysTMF          .DS     SYSTMRCNT       ; flag timer (80 -> start)
 2628  00000C  00               Bnk0Flag        .DB                     ; <7>: flag test RAM banco 0 ok
 2629                                                                   ; <6>: flag warm reset
 2630  00000D  00               RTCFlag         .DB
 2631                           
 2632  00000E                   diskstat        .DS     2       ; flag device on ata bus #0 & #1
 2633                                                           ; <7>: device ready
 2634                                                           ; <6>: compact flash device (C.F.)
 2635                                                           ; <5>: device identification ok
 2636                                                           ; <4>: MBR loaded
 2637                                                           ; <3>: valid signature in MBR
 2638                                                           ; <2>: first partition found&active
 2639                                                           ; <1>:
 2640                                                           ; <0>: valid partition flag
 2641                           
 2642                                                           ; <7>: device ready
 2643                                                           ; <6>: USB device
 2644                                                           ; <5>: compact flash device (C.F.)
 2645                                                           ; <4>: device identification ok
 2646                                                           ; <3>: MBR loaded
 2647                                                           ; <2>: first partition found&active
 2648                                                           ; <1>: always 1
 2649                                                           ; <0>: valid partition flag
 2650  000010                                                   
  Tue Jul 17 11:00:18 2018                                                                                               Page    2




 2651                           
 2652          00000E           atadev          .EQU    diskstat
 2653                           
 2654  000010                   usbdev          .DS     2       ; flag flash disk on usb bus #0
 2655                                                           ; <7>: device plugged and ready
 2656                                                           ; <6>: always 1 
 2657                                                           ; <5>: device identification ok
 2658                                                           ; <4>: MBR loaded
 2659                                                           ; <3>: valid signature in MBR
 2660                                                           ; <2>: first partition found&active
 2661                                                           ; <1>:
 2662                                                           ; <0>: valid partition flag
 2663                           
 2664  000012                   diskmax         .DS     16      ; disk max. sector's
 2665          000012           atasec          .EQU    diskmax
 2666          00001A           usbsec          .EQU    diskmax+8
 2667                           
 2668                           
 2669  000022                   atambr          .DS     8       ; data for first partition found in mbr
 2670                                                           ; first 3 bytes for start sector of partition
 2671                                                           ; last byte for partition type
 2672  00002A                   usbmbr          .DS     8
 2673                           
 2674  000032                   ataprt          .DS     8       ; total sec's of first partition
 2675  00003A                   usbprt          .DS     8       ; total sec's of first partition
 2676                           
 2677                           
 2678  000042  00               usb0ch          .DB     ; usb0 (ch375/ch376) flag
 2679                                                   ; <7>: module on
 2680                                                   ; <6>: ch376 flag
 2681                                                   ; <5:0>: chip version
 2682                           
 2683  000043  00               usb0st          .DB     ; usb0 status
 2684                                                   ; <7>: usb0 host mode ok
 2685                                                   ; <6>: flash disk attached flag
 2686                                                   ; <5>: usb device attached
 2687                           
 2688  000044  00               fdcdrv          .DB             ; phisycal drive status (drive #0)
 2689                                                           ; <7>: disk format established in bit 0&1 
 2690                                                           ; <6>: double step seek done
 2691                                                           ; <5>: trust format bit's (set after ok r/w)
 2692                                                           ; <4>: write protect bit (if disk in drive)
 2693                                                           ; <3>: don't care
 2694                                                           ; <2>: don't care                               
 2695                                                           ; <1>: HD disk if set else DD disk
 2696                                                           ; <0>: CBM format if set else IBM format
 2697                           
 2698  000045  00               vdrive          .DB             ; virtual drive status (ram disk, drive #1)
 2699                                                           ; <7>: disk format established in bit 0&1 
 2700                                                           ; <6>: change disk simulation (after format)
 2701                                                           ; <5>: don't care
 2702                                                           ; <4>: write protect bit (under sw control)
 2703                                                           ; <3>: don't care
 2704                                                           ; <2>: don't care                               
 2705                                                           ; <1>: HD disk if set else DD disk
 2706                                                           ; <0>: CBM format if set else IBM format
 2707                           
  Tue Jul 17 11:00:18 2018                                                                                               Page    3




 2708  000046  00               fdcctl          .DB             ; fdc controller status
 2709                                                           ; <7>: drive is attached
 2710                                                           ; <6>: drive need recalibration (restore)
 2711                                                           ; <5>: FDC controller ok
 2712                                                           ; <4>: motor on
 2713                                                           ; <3>: dma is active
 2714                                                           ; <2>: dma chip ok (post routine)
 2715                                                           ; <1>: clock rate (1=HD,0=DD)
 2716                                                           ; <0>: disk ready
 2717                           
 2718  000047  00               fdctrk          .DB             ; fd: current seek track
 2719  000048  00               fdcerr          .DB             ; fd: last error code
 2720  000049  00               ataerr          .DB             ; ata: last error code
 2721  00004A  00               ataxer          .DB             ; ata: last extended error code
 2722                           
 2723  00004B  00               CtrlBrk         .DB             ; flag CTRL+BREAK (NMI)
 2724                           
 2725  00004C  0000             MemTop          .DW             ; top memoria RAM
 2726  00004E  00                               .DB             ; banco top mem
 2727                           
 2728  00004F  00               DflTxtIn        .DB             ; device di default text input 
 2729  000050  00               DflTxtOut       .DB             ; device di default text output
 2730                           
 2731  000051                   COPPtr          LP              ; long pointer for COP decoding
 2732  000054  00               COPIdx          .DB             ; COP signature/index
 2733                           
 2734  000055  00               BiosEnt         .DB             ; flag accesso a bios setup
 2735                           
 2736                           ; variabili utilizzate da ACIA
 2737  000056                   spwrk           .DS     $30
 2738                           
 2739                           ; bios mem
 2740  000086  0000             nsize           .DW     ; dimensione blocco da allocare
 2741                           ;bsize          .DW     ; dimensione vera blocco free
 2742  000088  0000             splitsz         .DW     ; dimensione blocco splittato
 2743  00008A  0000             bfree           .DW     ; puntatore blocco free
 2744  00008C  0000             hdrptr          .DW     ; puntatore header heap
 2745                           
 2746  00008E  0000             pbrklv          .DW     ; current break level of current process
 2747  000090  0000             pbrkmin         .DW     ; minimum breal level of current process
 2748  000092  0000             pbrkmax         .DW     ; maximum breal level of current process
 2749  000094                           
 2750                           ; bios temp. work area
 2751  000094                   bwrktmp         .DS     $28
 2752                           
 2753  0000BC  00               coptmp          .DB     ; temp. used while cop
 2754                           
 2755  0000BD  00               tstser          .DB     ; check ser/usb test board post
 2756                                                   ; <7>: VIA2 ok
 2757                                                   ; <6>: PICRAM ok
 2758                                                   ; <1>: UART 16C550 ok
 2759                                                   ; <0>: R65C51 ok
 2760                           
 2761                           
 2762                           ;crc16          .DW
 2763                           
 2764  0000BD                           .RELATIVE
  Tue Jul 17 11:00:18 2018                                                                                               Page    4




 2765                           
 2766                                   .ENDS
 2767                           
 2768          [01]             .IFDEF          _ACIA_INC_
 2769  F8FFB1                           .INCLUDE INC\SP.INC
 2770                           ;;
 2771                           ;; Copyright (c) 2016 Marco Granati <mg@unet.bz>
 2772                           ;;
 2773                           ;; Permission to use, copy, modify, and distribute this software for any
 2774                           ;; purpose with or without fee is hereby granted, provided that the above
 2775                           ;; copyright notice and this permission notice appear in all copies.
 2776                           ;;
 2777                           ;; THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
 2778                           ;; WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
 2779                           ;; MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
 2780                           ;; ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
 2781                           ;; WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
 2782                           ;; ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
 2783                           ;; OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 2784                           ;;
 2785                           
 2786                           ;; name: sp.inc 
 2787                           ;; rev.: 2016/07/28
 2788                           ;; bios C816 version v1.0
 2789                           
 2790                           .LIST on
 2791                           
 2792          000001           SOH             .EQU    $01
 2793          000002           STX             .EQU    $02
 2794          000003           ETX             .EQU    $03
 2795          000004           EOT             .EQU    $04
 2796          000005           ENQ             .EQU    $05
 2797          000006           ACK             .EQU    $06
 2798          000010           DLE             .EQU    $10
 2799          000016           SYN             .EQU    $16
 2800                           
 2801          002000           SOBUFSIZ        .EQU    $2000   ; dimensione coda TX1/TX2 ACIA (8K)
 2802                           ;SOBUFSIZ       .EQU    $0100   ; dimensione coda TX1/TX2 ACIA (8K)
 2803          004000           SIBUFSIZ        .EQU    $4000   ; dimensione coda RX1/RX2 ACIA (16K)
 2804                           ;SIBUFSIZ       .EQU    $0100   ; dimensione coda RX1/RX2 ACIA (16K)
 2805                           
 2806          000080           NGUARD1         .EQU    $80     ; numero bytes di guardia buffer RX XON/XOFF
 2807          000040           NGUARD2         .EQU    $40     ; numero bytes di guardia buffer RX handshake
 2808                           ;NGUARD1                .EQU    $40     ; numero bytes di guardia buffer RX XON/XOFF
 2809                           ;NGUARD2                .EQU    $20     ; numero bytes di guardia buffer RX handshake
 2810          001000           NFREE1          .EQU    $1000   ; minimo posto in coda RX per cancellare pausa remota
 2811          000800           NFREE2          .EQU    $0800
 2812                           ;NGUARD3                .EQU    $F0
 2813                           ;NGUARD4                .EQU    $F8
 2814                           
 2815                           ;---------------------------------------------------------------------------
 2816                           ; direct page var's for serial ports handling 
 2817                           ;---------------------------------------------------------------------------
 2818                           
 2819                           DPSP:   .SECTION page0, common, ref_only, offset spwrk  ;ACIA D.P.
 2820                           
 2821  000056                   _DPSP_START     .DS     0
  Tue Jul 17 11:00:18 2018                                                                                               Page    5




 2822                           
 2823                           ; WARNING: not change order and type of the following variables
 2824                           
 2825                           ; acia 1 var's
 2826  000056  00               splin           .DB             ; interrupt status register
 2827  000057  00               spcsr           .DB             ; control status register
 2828  000058  00               spfr            .DB             ; format register
 2829  000059  00               spout           .DB             ; XON/XOFF send flag
 2830                           
 2831                           ; acia 2 var's
 2832  00005A  00               splin2          .DB             ; interrupt status register
 2833  00005B  00               spcsr2          .DB             ; control status register
 2834  00005C  00               spfr2           .DB             ; format register
 2835  00005D  00               spout2          .DB             ; XON/XOFF send flag
 2836                           
 2837                           ; serial port's mode & status
 2838  00005E  00               spmode          .DB             ; <7>: 0=no handshake, 1=handshake
 2839                                                           ; <6>: 0=software/1=hardware handshake
 2840                                                           ; <5>: not used
 2841                                                           ; <4>: baud rate: 0=19200, 1=38400
 2842                                                           ; <3>: 0=odd parity, 1=even parity
 2843                                                           ; <2>: 0=no parity, 1=parity as specified
 2844                                                           ;      by bit <3>
 2845                                                           ; <1>: interface type: 0=RS232, 1=RS485
 2846                                                           ; <0>: RS232: uplink flow control (RTS/DCD)
 2847                                                           ;      RS485: 120 ohm termination on
 2848                                                           ; if bit 7=1 and bit 1=1, bit 6 is forced to 0
 2849  00005F                                           
 2850  00005F  00               spstat          .DB             ; serial port status            
 2851                                                           ; <7>: rx error (data discarded)
 2852                                                           ; <6>: rx buffer overflow
 2853                                                           ; <5>: remote disconnession (DSR line = 1)
 2854                                                           ; <4>: output buffer overflow
 2855                                                           ; <3>: not used
 2856                                                           ; <2>: framing error
 2857                                                           ; <1>: parity error
 2858                                                           ; <0>: overrun error
 2859                           
 2860  000060  00               sppause         .DB             ; local/remote pause flag's             
 2861                                                           ; <7>: remote pause (sent an XON or set RTS=1)
 2862                                                           ; <6>: local pause (received an XON or CTS=1)
 2863                           
 2864  000061  00               sptmp           .DB             ; temp. byte used while get data
 2865                           
 2866                           ; serial port's mode & status
 2867  000062  00               spmode2         .DB             ; <7>: 0=no handshake, 1=handshake
 2868                                                           ; <6>: 0=software/1=hardware handshake
 2869                                                           ; <5>: not used
 2870                                                           ; <4>: baud rate: 0=19200, 1=38400
 2871                                                           ; <3>: 0=odd parity, 1=even parity
 2872                                                           ; <2>: 0=no parity, 1=parity as specified
 2873                                                           ;      by bit <3>
 2874                                                           ; <1>: interface type: 0=RS232, 1=RS485
 2875                                                           ; <0>: RS232: uplink flow control (RTS/DCD)
 2876                                                           ;      RS485: 120 ohm termination on
 2877                                                           ; if bit 7=1 and bit 1=1, bit 6 is forced to 0
 2878  000063                                           
  Tue Jul 17 11:00:18 2018                                                                                               Page    6




 2879  000063  00               spstat2         .DB             ; serial port status            
 2880                                                           ; <7>: rx error (data discarded)
 2881                                                           ; <6>: rx buffer overflow
 2882                                                           ; <5>: remote disconnession (DSR line = 1)
 2883                                                           ; <4>: output buffer overflow
 2884                                                           ; <3>: not used
 2885                                                           ; <2>: framing error
 2886                                                           ; <1>: parity error
 2887                                                           ; <0>: overrun error
 2888                           
 2889  000064  00               sppause2        .DB             ; local/remote pause flag's             
 2890                                                           ; <7>: remote pause (sent XOFF/XON or RTS=1/0)
 2891                                                           ; <6>: local pause (rx XOFF/XON or CTS=0/1)
 2892                           
 2893  000065  00               sppost          .DB             ; after POST must hold $C0
 2894                           
 2895  000066  0000             ibuftail        .DW             ; pointer to tail of input buffer
 2896  000068  0000             ibufhead        .DW             ; pointer to head of input buffer
 2897  00006A  0000             ibuftail2       .DW
 2898  00006C  0000             ibufhead2       .DW
 2899                           
 2900  00006E  0000             obuftail        .DW             ; pointer to tail of output buffer
 2901  000070  0000             obufhead        .DW             ; pointer to head of output buffer
 2902  000072  0000             obuftail2       .DW
 2903  000074  0000             obufhead2       .DW
 2904                           
 2905  000076  0000             ibufcnt         .DW             ; count of bytes in input buffer
 2906  000078  0000             obufcnt         .DW             ; count of bytes in output buffer
 2907  00007A  0000             ibufcnt2        .DW
 2908  00007C  0000             obufcnt2        .DW
 2909                           
 2910  00007E  0000             icntmin         .DW             ; min. count for clear remote pause  
 2911  000080  0000             icntmax         .DW             ; max. count for set remote pause
 2912  000082  0000             icntmin2        .DW
 2913  000084  0000             icntmax2        .DW
 2914                           
 2915  000086                   _DPSP_END       .DS     0
 2916          000030           DPSPSIZ         .EQU    (_DPSP_END - _DPSP_START)
 2917                           
 2918                           
 2919                                   .ENDS
 2920                           
 2921          00005F           ACIArxe_1       .EQU    spstat
 2922          000063           ACIArxe_2       .EQU    spstat2
 2923          00005E           ACIAhsk_1       .EQU    spmode
 2924          000062           ACIAhsk_2       .EQU    spmode2
 2925          000060           ACIAPause_1     .EQU    sppause
 2926          000064           ACIAPause_2     .EQU    sppause2
 2927          000057           ACIAcsr_1       .EQU    spcsr
 2928          00005B           ACIAcsr_2       .EQU    spcsr2
 2929          000058           ACIAfr_1        .EQU    spfr
 2930          00005C           ACIAfr_2        .EQU    spfr2
 2931          000060           ACIAOut_1       .EQU    sppause
 2932          000064           ACIAOut_2       .EQU    sppause2
 2933          000076           ACIAICnt_1      .EQU    ibufcnt
 2934          00007A           ACIAICnt_2      .EQU    ibufcnt2
 2935          000068           ACIAIHead_1     .EQU    ibufhead
  Tue Jul 17 11:00:18 2018                                                                                               Page    7




 2936          00006C           ACIAIHead_2     .EQU    ibufhead2
 2937          000066           ACIAITail_1     .EQU    ibuftail
 2938          00006A           ACIAITail_2     .EQU    ibuftail2
 2939          000078           ACIAOCnt_1      .EQU    obufcnt
 2940          00007C           ACIAOCnt_2      .EQU    obufcnt2
 2941          000070           ACIAOHead_1     .EQU    obufhead
 2942          000074           ACIAOHead_2     .EQU    obufhead2
 2943          00006E           ACIAOTail_1     .EQU    obuftail
 2944          000072           ACIAOTail_2     .EQU    obuftail2
 2945                           
 2946          002000           ACIAOBUFLEN     .EQU    SOBUFSIZ
 2947          004000           ACIAIBUFLEN     .EQU    SIBUFSIZ
 2948          050000           ACIAOUTBUF1     .EQU    SPOUTBUFF
 2949          052000           ACIAOUTBUF2     .EQU    SPOUTBUFF2
 2950          054000           ACIAINBUF1      .EQU    SPINBUFF
 2951          058000           ACIAINBUF2      .EQU    SPINBUFF2
 2952                           
 2953          000061           ACIATmp         .EQU    sptmp
 2954                           
 2962                           .LIST   on
 2963                           
 2964                           ; page 0 local var's (declared in bios temp. work area)
 2965                           _P0BTMP:        .SECTION page0, ref_only, offset bwrktmp        ; DP Tmp. BIOS
 2966                           
 2967  000094  0000             crc16           .DW
 2968  000096  0000             bycnt           .DW             ; data packet lenght
 2969  000098  0000             byndx           .DW             ; data buffer index
 2970  00009A  00               pkttyp          .DB             ; expected packet type
 2971  00009B  00               pktnum          .DB             ; current packet number
 2972  00009C  00               expect          .DB             ; expected packet number
 2973  00009D  00               tmpx            .DB
 2974                           
 2975                                   .ENDS
 2976                           
 2977                                   .CODEF8
 2978  F8045B                           
 2979                                   .LONGA  off
 2980                                   .LONGI  off
 2981                           
 2982                           ; X=serial port
 2983  F8045B                   _spget0:
 2984  F8045B  8A                       txa
 2985  F8045C  D0 55                    bne     _spget1
 2986  F8045E                           
 2987  F8045E                           SPGETB  0
 2988          [01]                     .IFZ    0
 2989          000000           k       .SET    0
 2990          054000           SIBUFADDR       .SET    SPINBUFF
 2991          [01]                     .ELSE
 2992                           k       .SET    4
 2993                           SIBUFADDR       .SET    SPINBUFF2
 2994          [00]                     .ENDIF
 2995                           
 2996  F8045E  78                       sei                     ; disable interrupt
 2997  F8045F  38                       sec                     ; assume error
 2998  F80460  86 61                    stx     sptmp           ; save X reg.
 2999  F80462  A5 5F                    lda     spstat+k        ; rx pending error?
  Tue Jul 17 11:00:18 2018                                                                                               Page    8




 3000  F80464  30 47                    bmi     ?done           ; yes, exit
 3001  F80466  A9 00                    lda     #0              ; assume no data available
 3002  F80468  A8                       tay                     ; Y = 0
 3003  F80469                           INDEX16
 3004                                   .MLIST
 3005  F80469  C2 10                    rep     #PXFLAG
 3006                                   .LONGI  on
 3007                                   .MNLIST
 3008  F8046B  A6 76                    ldx     ibufcnt+k       ; available new data?
 3009  F8046D  F0 3E                    beq     ?done           ; input queue is empty (exit with CF=1, A=0)
 3010  F8046F  CA                       dex                     ; update count
 3011  F80470  86 76                    stx     ibufcnt+k
 3012  F80472  A6 68                    ldx     ibufhead+k      ; head input buffer pointer
 3013  F80474  BF 00 40 05              lda     >SIBUFADDR,x    ; get byte from queue
 3014  F80478  E8                       inx                     ; update head pointer
 3015  F80479  E0 00 40                 cpx     #SIBUFSIZ
 3016  F8047C  90 01                    bcc     ?upd
 3017  F8047E  BB                       tyx                     ; circular queue
 3018  F8047F  86 68            ?upd:   stx     ibufhead+k
 3019  F80481  24 60                    bit     sppause+k       ; remote pause is on?
 3020  F80483  10 27                    bpl     ?ok             ; no
 3021  F80485  A6 76                    ldx     ibufcnt+k       
 3022  F80487  E4 7E                    cpx     icntmin+k       ; can clear remote pause?
 3023  F80489  B0 21                    bcs     ?ok             ; no
 3024  F8048B  24 5E                    bit     spmode+k        ; handshake is on?
 3025  F8048D  10 1D                    bpl     ?ok             ; no
 3026  F8048F  EB                       xba                     ; save data
 3027  F80490  70 10                    bvs     ?hw             ; hardware handshake
 3028  F80492  A9 11                    lda     #SPXON          ; software handshake: send an XON
 3029  F80494  2C 51 FD                 bit     .ABS.ACIACSR+k  ; check TUR bit
 3030  F80497  50 05                    bvc     ?def            ; can't send an XON at this time
 3031  F80499  8D 53 FD                 sta     .ABS.ACIATDR+k  ; send now an XON
 3032  F8049C  80 09                    bra     ?crp            ; clear remote pause flag
 3033  F8049E  85 59            ?def:   sta     spout+k         ; XON is deffered
 3034  F804A0  80 09                    bra     ?xba
 3035  F804A2  A5 58            ?hw:    lda     spfr+k          ; hardware handshake: set RTS=0
 3036  F804A4  8D 51 FD                 sta     .ABS.ACIAFR+k
 3037  F804A7  A9 80            ?crp:   lda     #$80
 3038  F804A9  14 60                    trb     sppause+k       ; clear remote pause flag
 3039  F804AB  EB               ?xba:   xba                     ; recover data
 3040  F804AC  18               ?ok:    clc
 3041  F804AD                   ?done:  INDEX08
 3042                                   .MLIST
 3043  F804AD  E2 10                    sep     #PXFLAG
 3044                                   .LONGI  off
 3045                                   .MNLIST
 3046  F804AF  A6 61                    ldx     sptmp           ; restore X reg.
 3047  F804B1  58                       cli
 3048  F804B2  60                       rts                     ; CF=1 & A=0 mean: no data available 
 3049  F804B3                           .ENDM
 3050  F804B3                           
 3051  F804B3                   _spget1:
 3052  F804B3                           SPGETB  1
 3053                           
 3054                                   .MLIST
 3055          [01]                     .IFZ    1
 3056                           k       .SET    0
  Tue Jul 17 11:00:18 2018                                                                                               Page    9




 3057                           SIBUFADDR       .SET    SPINBUFF
 3058          [01]                     .ELSE
 3059          000004           k       .SET    4
 3060          058000           SIBUFADDR       .SET    SPINBUFF2
 3061          [00]                     .ENDIF
 3062                           
 3063  F804B3  78                       sei                     ; disable interrupt
 3064  F804B4  38                       sec                     ; assume error
 3065  F804B5  86 61                    stx     sptmp           ; save X reg.
 3066  F804B7  A5 63                    lda     spstat+k        ; rx pending error?
 3067  F804B9  30 47                    bmi     ?done           ; yes, exit
 3068  F804BB  A9 00                    lda     #0              ; assume no data available
 3069  F804BD  A8                       tay                     ; Y = 0
 3070  F804BE                           INDEX16
 3071                                   .MLIST
 3072  F804BE  C2 10                    rep     #PXFLAG
 3073                                   .LONGI  on
 3074                                   .MNLIST
 3075  F804C0  A6 7A                    ldx     ibufcnt+k       ; available new data?
 3076  F804C2  F0 3E                    beq     ?done           ; input queue is empty (exit with CF=1, A=0)
 3077  F804C4  CA                       dex                     ; update count
 3078  F804C5  86 7A                    stx     ibufcnt+k
 3079  F804C7  A6 6C                    ldx     ibufhead+k      ; head input buffer pointer
 3080  F804C9  BF 00 80 05              lda     >SIBUFADDR,x    ; get byte from queue
 3081  F804CD  E8                       inx                     ; update head pointer
 3082  F804CE  E0 00 40                 cpx     #SIBUFSIZ
 3083  F804D1  90 01                    bcc     ?upd
 3084  F804D3  BB                       tyx                     ; circular queue
 3085  F804D4  86 6C            ?upd:   stx     ibufhead+k
 3086  F804D6  24 64                    bit     sppause+k       ; remote pause is on?
 3087  F804D8  10 27                    bpl     ?ok             ; no
 3088  F804DA  A6 7A                    ldx     ibufcnt+k       
 3089  F804DC  E4 82                    cpx     icntmin+k       ; can clear remote pause?
 3090  F804DE  B0 21                    bcs     ?ok             ; no
 3091  F804E0  24 62                    bit     spmode+k        ; handshake is on?
 3092  F804E2  10 1D                    bpl     ?ok             ; no
 3093  F804E4  EB                       xba                     ; save data
 3094  F804E5  70 10                    bvs     ?hw             ; hardware handshake
 3095  F804E7  A9 11                    lda     #SPXON          ; software handshake: send an XON
 3096  F804E9  2C 55 FD                 bit     .ABS.ACIACSR+k  ; check TUR bit
 3097  F804EC  50 05                    bvc     ?def            ; can't send an XON at this time
 3098  F804EE  8D 57 FD                 sta     .ABS.ACIATDR+k  ; send now an XON
 3099  F804F1  80 09                    bra     ?crp            ; clear remote pause flag
 3100  F804F3  85 5D            ?def:   sta     spout+k         ; XON is deffered
 3101  F804F5  80 09                    bra     ?xba
 3102  F804F7  A5 5C            ?hw:    lda     spfr+k          ; hardware handshake: set RTS=0
 3103  F804F9  8D 55 FD                 sta     .ABS.ACIAFR+k
 3104  F804FC  A9 80            ?crp:   lda     #$80
 3105  F804FE  14 64                    trb     sppause+k       ; clear remote pause flag
 3106  F80500  EB               ?xba:   xba                     ; recover data
 3107  F80501  18               ?ok:    clc
 3108  F80502                   ?done:  INDEX08
 3109                                   .MLIST
 3110  F80502  E2 10                    sep     #PXFLAG
 3111                                   .LONGI  off
 3112                                   .MNLIST
 3113  F80504  A6 61                    ldx     sptmp           ; restore X reg.
  Tue Jul 17 11:00:18 2018                                                                                               Page   10




 3114  F80506  58                       cli
 3115  F80507  60                       rts                     ; CF=1 & A=0 mean: no data available 
 3116  F80508                           .ENDM
 3117                           
 3118                           ; X=serial port
 3119                                   .PUBLIC _spput0
 3120  F80508                   _spput0:
 3121  F80508  9B                       txy
 3122  F80509  D0 6D                    bne     _spput1
 3123  F8050B                           
 3124  F8050B                           SPPUTB  0
 3125                           
 3126                                   .MLIST
 3127          [01]                     .IFZ    0
 3128          000000           k       .SET    0
 3129          050000           SOBUFADDR       .SET    SPOUTBUFF
 3130          [01]                     .ELSE
 3131                           k       .SET    4
 3132                           SOBUFADDR       .SET    SPOUTBUFF2
 3133          [00]                     .ENDIF
 3134                           
 3135  F8050B  78                       sei                     ; disable interrupt
 3136  F8050C  86 61                    stx     sptmp           ; save X reg. 
 3137  F8050E  A0 00                    ldy     #0              ; Y = 0
 3138  F80510                           INDEX16
 3139                                   .MLIST
 3140  F80510  C2 10                    rep     #PXFLAG
 3141                                   .LONGI  on
 3142                                   .MNLIST
 3143  F80512  A6 78                    ldx     obufcnt+k
 3144  F80514  E0 00 20                 cpx     #SOBUFSIZ       ; output buffer is full?
 3145  F80517  90 07                    bcc     ?str            ; no, store byte
 3146  F80519  24 56                    bit     splin+k
 3147  F8051B  10 55                    bpl     ?done           ; exit with CF=1, Y=0: output buffer is full
 3148  F8051D  88                       dey
 3149  F8051E  80 52                    bra     ?done           ; exit with CF=1, Y=$FF: remote terminal off
 3150  F80520  E8               ?str:   inx                     ; update count
 3151  F80521  86 78                    stx     obufcnt+k
 3152  F80523  A6 6E                    ldx     obuftail+k      ; output buffer tail pointer
 3153  F80525  9F 00 00 05              sta     >SOBUFADDR,x    ; store byte in output buffer
 3154  F80529  E8                       inx                     ; update tail pointer
 3155  F8052A  E0 00 20                 cpx     #SOBUFSIZ       
 3156  F8052D  90 01                    bcc     ?upd
 3157  F8052F  BB                       tyx                     ; circular queue
 3158  F80530  86 6E            ?upd:   stx     obuftail+k
 3159  F80532  2C 51 FD                 bit     .ABS.ACIACSR+k  ; check TUR bit: try to free output buffer
 3160  F80535  50 3A                    bvc     ?ok             ; can't send now: send by ISR
 3161  F80537  EB                       xba                     ; save data
 3162  F80538  A5 59                    lda     spout+k         ; XON/XOFF send pending?
 3163  F8053A  F0 17                    beq     ?snd            ; no
 3164  F8053C  8D 53 FD                 sta     .ABS.ACIATDR+k  ; send an XON/XOFF
 3165  F8053F  C9 11                    cmp     #SPXON
 3166  F80541  D0 08                    bne     ?xon
 3167  F80543  A9 80                    lda     #$80
 3168  F80545  04 60                    tsb     sppause+k       ; set remote pause
 3169  F80547  64 59                    stz     spout+k         ; clear XOFF flag
 3170  F80549  80 25                    bra     ?xba            ; done
  Tue Jul 17 11:00:18 2018                                                                                               Page   11




 3171  F8054B  A9 80            ?xon:   lda     #$80
 3172  F8054D  14 60                    trb     sppause+k       ; clear remote pause
 3173  F8054F  64 59                    stz     spout+k         ; clear XON flag
 3174  F80551  80 1D                    bra     ?xba            ; done
 3175  F80553  24 60            ?snd:   bit     sppause+k
 3176  F80555  70 19                    bvs     ?xba            ; local pause is on, can't send at this time
 3177  F80557  A6 78                    ldx     obufcnt+k
 3178  F80559  F0 15                    beq     ?xba            ; output buffer is empty
 3179  F8055B  CA                       dex                     ; update count
 3180  F8055C  86 78                    stx     obufcnt+k       
 3181  F8055E  A6 70                    ldx     obufhead+k
 3182  F80560  BF 00 00 05              lda     >SOBUFADDR,x    ; get data from output buffer
 3183  F80564  8D 53 FD                 sta     .ABS.ACIATDR+k  ; send data
 3184  F80567  E8                       inx                     ; update head pointer
 3185  F80568  E0 00 20                 cpx     #SOBUFSIZ       
 3186  F8056B  90 01                    bcc     ?upd2
 3187  F8056D  BB                       tyx                     ; circular queue
 3188  F8056E  86 70            ?upd2:  stx     obufhead+k
 3189  F80570  EB               ?xba:   xba                     ; return A = sent data
 3190  F80571  18               ?ok:    clc                     ; no error
 3191  F80572                   ?done:  INDEX08
 3192                                   .MLIST
 3193  F80572  E2 10                    sep     #PXFLAG
 3194                                   .LONGI  off
 3195                                   .MNLIST
 3196  F80574  A6 61                    ldx     sptmp           ; restore X reg.        
 3197  F80576  58                       cli
 3198  F80577  60                       rts
 3199  F80578                           .ENDM
 3200  F80578                           
 3201  F80578                   _spput1:
 3202  F80578                           SPPUTB  1
 3203                           
 3204                                   .MLIST
 3205          [01]                     .IFZ    1
 3206                           k       .SET    0
 3207                           SOBUFADDR       .SET    SPOUTBUFF
 3208          [01]                     .ELSE
 3209          000004           k       .SET    4
 3210          052000           SOBUFADDR       .SET    SPOUTBUFF2
 3211          [00]                     .ENDIF
 3212                           
 3213  F80578  78                       sei                     ; disable interrupt
 3214  F80579  86 61                    stx     sptmp           ; save X reg. 
 3215  F8057B  A0 00                    ldy     #0              ; Y = 0
 3216  F8057D                           INDEX16
 3217                                   .MLIST
 3218  F8057D  C2 10                    rep     #PXFLAG
 3219                                   .LONGI  on
 3220                                   .MNLIST
 3221  F8057F  A6 7C                    ldx     obufcnt+k
 3222  F80581  E0 00 20                 cpx     #SOBUFSIZ       ; output buffer is full?
 3223  F80584  90 07                    bcc     ?str            ; no, store byte
 3224  F80586  24 5A                    bit     splin+k
 3225  F80588  10 55                    bpl     ?done           ; exit with CF=1, Y=0: output buffer is full
 3226  F8058A  88                       dey
 3227  F8058B  80 52                    bra     ?done           ; exit with CF=1, Y=$FF: remote terminal off
  Tue Jul 17 11:00:18 2018                                                                                               Page   12




 3228  F8058D  E8               ?str:   inx                     ; update count
 3229  F8058E  86 7C                    stx     obufcnt+k
 3230  F80590  A6 72                    ldx     obuftail+k      ; output buffer tail pointer
 3231  F80592  9F 00 20 05              sta     >SOBUFADDR,x    ; store byte in output buffer
 3232  F80596  E8                       inx                     ; update tail pointer
 3233  F80597  E0 00 20                 cpx     #SOBUFSIZ       
 3234  F8059A  90 01                    bcc     ?upd
 3235  F8059C  BB                       tyx                     ; circular queue
 3236  F8059D  86 72            ?upd:   stx     obuftail+k
 3237  F8059F  2C 55 FD                 bit     .ABS.ACIACSR+k  ; check TUR bit: try to free output buffer
 3238  F805A2  50 3A                    bvc     ?ok             ; can't send now: send by ISR
 3239  F805A4  EB                       xba                     ; save data
 3240  F805A5  A5 5D                    lda     spout+k         ; XON/XOFF send pending?
 3241  F805A7  F0 17                    beq     ?snd            ; no
 3242  F805A9  8D 57 FD                 sta     .ABS.ACIATDR+k  ; send an XON/XOFF
 3243  F805AC  C9 11                    cmp     #SPXON
 3244  F805AE  D0 08                    bne     ?xon
 3245  F805B0  A9 80                    lda     #$80
 3246  F805B2  04 64                    tsb     sppause+k       ; set remote pause
 3247  F805B4  64 5D                    stz     spout+k         ; clear XOFF flag
 3248  F805B6  80 25                    bra     ?xba            ; done
 3249  F805B8  A9 80            ?xon:   lda     #$80
 3250  F805BA  14 64                    trb     sppause+k       ; clear remote pause
 3251  F805BC  64 5D                    stz     spout+k         ; clear XON flag
 3252  F805BE  80 1D                    bra     ?xba            ; done
 3253  F805C0  24 64            ?snd:   bit     sppause+k
 3254  F805C2  70 19                    bvs     ?xba            ; local pause is on, can't send at this time
 3255  F805C4  A6 7C                    ldx     obufcnt+k
 3256  F805C6  F0 15                    beq     ?xba            ; output buffer is empty
 3257  F805C8  CA                       dex                     ; update count
 3258  F805C9  86 7C                    stx     obufcnt+k       
 3259  F805CB  A6 74                    ldx     obufhead+k
 3260  F805CD  BF 00 20 05              lda     >SOBUFADDR,x    ; get data from output buffer
 3261  F805D1  8D 57 FD                 sta     .ABS.ACIATDR+k  ; send data
 3262  F805D4  E8                       inx                     ; update head pointer
 3263  F805D5  E0 00 20                 cpx     #SOBUFSIZ       
 3264  F805D8  90 01                    bcc     ?upd2
 3265  F805DA  BB                       tyx                     ; circular queue
 3266  F805DB  86 74            ?upd2:  stx     obufhead+k
 3267  F805DD  EB               ?xba:   xba                     ; return A = sent data
 3268  F805DE  18               ?ok:    clc                     ; no error
 3269  F805DF                   ?done:  INDEX08
 3270                                   .MLIST
 3271  F805DF  E2 10                    sep     #PXFLAG
 3272                                   .LONGI  off
 3273                                   .MNLIST
 3274  F805E1  A6 61                    ldx     sptmp           ; restore X reg.        
 3275  F805E3  58                       cli
 3276  F805E4  60                       rts
 3277  F805E5                           .ENDM
 3278  F805E5                           
 3279                           ; A=mode, X=serial #
 3280  F805E5                   spset:
 3281  F805E5  9B                       txy
 3282  F805E6  F0 02                    beq     ?sr0            ; serial #0
 3283  F805E8  A2 04                    ldx     #4              ; serial #1
 3284  F805EA  78               ?sr0:   sei                     ; disable interrupt
  Tue Jul 17 11:00:18 2018                                                                                               Page   13




 3285  F805EB  95 5E                    sta     spmode,x
 3286  F805ED  A8                       tay
 3287  F805EE  A9 7F                    lda     #$7F            ; disable all interrupts
 3288  F805F0  9D 50 FD                 sta     .ABS.ACIAIER,x
 3289  F805F3  BD 53 FD                 lda     .ABS.ACIARDR,x  ; discard any pending received data
 3290  F805F6  BD 50 FD                 lda     .ABS.ACIAISR,x  ; read current interrupt status
 3291  F805F9  BD 51 FD                 lda     .ABS.ACIACSR,x  ; save current control status
 3292  F805FC  95 57                    sta     spcsr,x
 3293  F805FE  98                       tya                     ; mode
 3294  F805FF  29 0C                    and     #00001100B      ; mask on bits 3 & 2 (parity mode)
 3295  F80601  09 E0                    ora     #11100000B      ; 8 data bits, RTS=DTR=low
 3296  F80603  95 58                    sta     spfr,x          ; value of format register
 3297                                   ;ora    #00000011B
 3298  F80605  9D 51 FD                 sta     .ABS.ACIAFR,x   ; set format register: RTS=DTR=1
 3299  F80608  98                       tya     
 3300  F80609  A0 4E                    ldy     #01001110B      ; access to ACR, one stop bit, 38400
 3301  F8060B  89 10                    bit     #00010000B
 3302  F8060D  D0 02                    bne     ?br             ; select baud rate=38400
 3303  F8060F  A0 4D                    ldy     #01001101B      ; access to ACR, one stop bit, 19200
 3304  F80611  98               ?br:    tya
 3305  F80612  9D 51 FD                 sta     .ABS.ACIACR,x   ; set control register
 3306  F80615  9E 52 FD                 stz     .ABS.ACIAACR,x  ; set aux. control reg. (normal tx, parity)
 3307  F80618  A9 80                    lda     #$80
 3308  F8061A  0C 1F FD                 tsb     VIA1+VIAPRANH   ; enble RS232
 3309  F8061D  A9 02                    lda     #00000010B      ; check RS485
 3310  F8061F  34 5E                    bit     spmode,x
 3311  F80621  F0 1B                    beq     ?cnt            ; interface type: RS232
 3312  F80623  B5 5E                    lda     spmode,x
 3313  F80625  29 BF                    and     #10111111B      ; software handshake only for RS485
 3314  F80627  95 5E                    sta     spmode,x
 3315  F80629  A9 80                    lda     #$80
 3316  F8062B  1C 1F FD                 trb     VIA1+VIAPRANH   ; enble RS485 interface
 3317  F8062E  A9 40                    lda     #$40
 3318  F80630  1C 0F FD                 trb     VIA0+VIAPRANH   ; disable 120 ohm termination
 3319  F80633  A9 01                    lda     #00000001B      ; check termination status
 3320  F80635  34 5E                    bit     spmode,x
 3321  F80637  F0 05                    beq     ?cnt            ; termination off
 3322  F80639  A9 40                    lda     #$40
 3323  F8063B  0C 0F FD                 tsb     VIA0+VIAPRANH   ; enable 120 ohm termination
 3324  F8063E  74 60            ?cnt:   stz     sppause,x       ; init work area
 3325  F80640  74 59                    stz     spout,x
 3326  F80642  74 5F                    stz     spstat,x
 3327  F80644  34 5E                    bit     spmode,x
 3328  F80646                           CPU16                   ; init buffer's pointer's
 3329                                   .MLIST
 3330  F80646  C2 30                    rep     #(PMFLAG.OR.PXFLAG)
 3331                                   .LONGA  on
 3332                                   .LONGI  on
 3333                                   .MNLIST
 3334  F80648  70 08                    bvs     ?hw             ; hardware handshake
 3335  F8064A  A9 80 00                 lda     #NGUARD1
 3336  F8064D  A0 00 10                 ldy     #NFREE1
 3337  F80650  80 06                    bra     ?do
 3338  F80652  A9 40 00         ?hw:    lda     #NGUARD2
 3339  F80655  A0 00 08                 ldy     #NFREE2
 3340  F80658  95 80            ?do:    sta     icntmax,x
 3341  F8065A  94 7E                    sty     icntmin,x
  Tue Jul 17 11:00:18 2018                                                                                               Page   14




 3342  F8065C  38                       sec
 3343  F8065D  A9 00 40                 lda     #SIBUFSIZ
 3344  F80660  F5 80                    sbc     icntmax,x
 3345  F80662  95 80                    sta     icntmax,x
 3346  F80664  74 66                    stz     ibuftail,x
 3347  F80666  74 68                    stz     ibufhead,x
 3348  F80668  74 76                    stz     ibufcnt,x
 3349  F8066A  74 6E                    stz     obuftail,x
 3350  F8066C  74 70                    stz     obufhead,x
 3351  F8066E  74 78                    stz     obufcnt,x
 3352  F80670                           CPU08
 3353  F80670  E2 30                    sep     #(PMFLAG.OR.PXFLAG)
 3354                                   .LONGA  off
 3355                                   .LONGI  off
 3356                                   .MNLIST
 3357  F80672  BD 53 FD                 lda     .ABS.ACIARDR,x  ; discard any pending received data
 3358  F80675  BD 50 FD                 lda     .ABS.ACIAISR,x  ; read current interrupt status
 3359  F80678  BD 51 FD                 lda     .ABS.ACIACSR,x  ; save current control status
 3360  F8067B  95 57                    sta     spcsr,x
 3361  F8067D  29 3B                    and     #00111011B      ; mask lines level
 3362  F8067F  89 08                    bit     #00001000B      ; check DSR line level
 3363  F80681  F0 02                    beq     ?sav            ; DSR is low
 3364  F80683  09 40                    ora     #01000000B      ; DSR is high
 3365  F80685  0A               ?sav:   asl     a               ; 7:DSR, 6:CTS, 5:DCD, 2:DTR, 1:RTS
 3366  F80686  95 56                    sta     splin,x         ; save lines level
 3367  F80688  A9 F9                    lda     #$F9            ; enable interrupts
 3368  F8068A  9D 50 FD                 sta     .ABS.ACIAIER,x
 3369  F8068D  58                       cli
 3370  F8068E  60                       rts
 3371                           
 3372                           ; X=serial #
 3373  F8068F                   spres:
 3374  F8068F  9B                       txy
 3375  F80690  F0 02                    beq     ?sr0            ; serial #0
 3376  F80692  A2 04                    ldx     #4              ; serial #1
 3377  F80694  78               ?sr0:   sei                     ; disable interrupt
 3378  F80695  A9 7F                    lda     #$7F            ; disable all interrupts
 3379  F80697  9D 50 FD                 sta     .ABS.ACIAIER,x
 3380  F8069A  B5 58                    lda     spfr,x
 3381  F8069C  09 03                    ora     #00000011B      ; set RTS=DTR=1
 3382  F8069E  9D 51 FD                 sta     .ABS.ACIAFR,x
 3383  F806A1  BD 53 FD                 lda     .ABS.ACIARDR,x  ; discard any pending received data
 3384  F806A4  BD 50 FD                 lda     .ABS.ACIAISR,x  ; read current interrupt status
 3385  F806A7  BD 51 FD                 lda     .ABS.ACIACSR,x  ; save current control status
 3386  F806AA  95 57                    sta     spcsr,x
 3387  F806AC  58                       cli
 3388  F806AD  60                       rts
 3389                           
 3390                           ;---- TRANSFER
 3391                           
 3392                           ; X=port (0 or 4)
 3393                           ; get byte with timeout
 3394  F806AE                   sptget:
 3395  F806AE  A9 20                    lda     #$20            ; set T2 count PB6 pulse (1ms)
 3396  F806B0  0C 0B FD                 tsb     .ABS.VIA0+VIAACR        
 3397  F806B3  9C 08 FD                 stz     .ABS.VIA0+VIAT2CL
 3398  F806B6  A9 04                    lda     #4              ; set 1024ms timeout
  Tue Jul 17 11:00:18 2018                                                                                               Page   15




 3399  F806B8  8D 09 FD                 sta     .ABS.VIA0+VIAT2CH
 3400  F806BB  20 5B 04         ?lp:    jsr     _spget0         ; get byte within timeout
 3401  F806BE  90 0C                    bcc     ?exit           ; ok, data available
 3402  F806C0  A8                       tay                     ; CF=1 here
 3403  F806C1  D0 09                    bne     ?exit           ; some rx error(s) 
 3404  F806C3  A9 20                    lda     #T2IFRB
 3405  F806C5  2C 0D FD                 bit     .ABS.VIA0+VIAIFR
 3406  F806C8  F0 F1                    beq     ?lp             ; no timeout: loop
 3407  F806CA  A9 08                    lda     #$08            ; set timeout error - CF=1 here
 3408  F806CC  60               ?exit:  rts
 3409                           
 3410  F806CD                   sndnack:
 3411                                   ;ldy    #NACK
 3412  F806CD  80 02                    bra     sndack2
 3413  F806CF                           
 3414  F806CF                   sndack:
 3415  F806CF  A0 06                    ldy     #ACK
 3416  F806D1                           
 3417  F806D1                   sndack2:
 3418  F806D1  84 9D                    sty     tmpx
 3419  F806D3  A9 16                    lda     #SYN
 3420  F806D5  20 00 07                 jsr     sptput
 3421  F806D8  B0 48                    bcs     exit1
 3422  F806DA  A5 9D                    lda     tmpx
 3423  F806DC  20 00 07                 jsr     sptput
 3424  F806DF  B0 41                    bcs     exit1
 3425  F806E1  A5 9B                    lda     pktnum
 3426                           
 3427  F806E3                   spxput:
 3428  F806E3  C9 16                    cmp     #SYN
 3429  F806E5  F0 0C                    beq     ?esc
 3430  F806E7  C9 11                    cmp     #SPXON
 3431  F806E9  F0 08                    beq     ?esc
 3432  F806EB  C9 13                    cmp     #SPXOFF
 3433  F806ED  F0 04                    beq     ?esc
 3434  F806EF  C9 10                    cmp     #DLE
 3435  F806F1  D0 0D                    bne     sptput
 3436  F806F3  49 20            ?esc:   eor     #$20
 3437  F806F5  85 9D                    sta     tmpx
 3438  F806F7  A9 10                    lda     #DLE
 3439  F806F9  20 00 07                 jsr     sptput
 3440  F806FC  B0 24                    bcs     exit1
 3441  F806FE  A5 9D                    lda     tmpx
 3442                           
 3443                           ; X=port (0 or 4)
 3444                           ; put byte with timeout
 3445  F80700                   sptput:
 3446  F80700  A8                       tay                     ; Y=data
 3447  F80701  A9 20                    lda     #$20            ; set T2 count PB6 pulse (1ms)
 3448  F80703  0C 0B FD                 tsb     .ABS.VIA0+VIAACR        
 3449  F80706  9C 08 FD                 stz     .ABS.VIA0+VIAT2CL
 3450  F80709  A9 04                    lda     #4              ; set 1024ms timeout
 3451  F8070B  8D 09 FD                 sta     .ABS.VIA0+VIAT2CH
 3452  F8070E  98               ?lp:    tya                     ; byte to send  
 3453  F8070F  20 08 05                 jsr     _spput0         ; put byte within timeout
 3454  F80712  90 0E                    bcc     exit1           ; ok
 3455  F80714  C8                       iny                     ; Y=$FF if remote disconnession
  Tue Jul 17 11:00:18 2018                                                                                               Page   16




 3456  F80715  F0 09                    beq     ?err            ; remote terminal disconnected
 3457  F80717  A8                       tay                     ; Y=data
 3458  F80718  A9 20                    lda     #T2IFRB
 3459  F8071A  2C 0D FD                 bit     .ABS.VIA0+VIAIFR
 3460  F8071D  F0 EF                    beq     ?lp             ; no timeout: loop
 3461  F8071F  98                       tya                     ; restore data
 3462  F80720  A0 80            ?err:   ldy     #$80            ; timeout or remote disconnession
 3463  F80722  60               exit1:  rts
 3464                           
 3465                           ; frame alignment
 3466                           ; A=expected packet type (SOH or STX)
 3467                           ; X=0 (serial port 0)
 3468                           ; exit with CF=0 if no error (ZF=0 if STX/SOH, ZF=1 if EOT)
 3469  F80723                   fndsyn:
 3470  F80723  85 9A                    sta     pkttyp  
 3471  F80725  20 AE 06                 jsr     sptget
 3472  F80728  B0 26                    bcs     ?done           ; error
 3473  F8072A  C9 16                    cmp     #SYN
 3474  F8072C  D0 F5                    bne     fndsyn          ; skip bytes until find start of trame
 3475  F8072E  20 AE 06         ?lp:    jsr     sptget          ; next byte
 3476  F80731  B0 1D                    bcs     ?done           ; error
 3477  F80733  C9 16                    cmp     #SYN            ; discard further consecutive sync's
 3478  F80735  F0 F7                    beq     ?lp
 3479  F80737  C5 9A                    cmp     pkttyp          ; expected SOH, STX or EOT
 3480  F80739  D0 08                    bne     ?eot
 3481  F8073B  A9 FF                    lda     #$FF            ; initialize crc computation
 3482  F8073D  85 94                    sta     crc16
 3483  F8073F  85 95                    sta     crc16+1         ; if received STX or SOH exit with ZF=0 
 3484  F80741  18               ?ok:    clc                     ; no error
 3485  F80742  60                       rts
 3486  F80743  A4 9A            ?eot:   ldy     pkttyp          ; when expect STX, an EOT is legal
 3487  F80745  C0 02                    cpy     #STX
 3488  F80747  D0 04                    bne     ?err            ; unexpected packet type
 3489  F80749  C9 04                    cmp     #EOT            ; received an EOT?
 3490  F8074B  F0 F4                    beq     ?ok             ; exit with ZF=1 (EOT)
 3491  F8074D  A9 10            ?err:   lda     #$10            ; unexpected packet type error  
 3492  F8074F  38                       sec
 3493  F80750  60               ?done:  rts
 3494                           
 3495                           ; get escaped byte
 3496                           ; X=serial port
 3497  F80751                   spxget:
 3498  F80751  20 AE 06                 jsr     sptget
 3499  F80754  B0 10                    bcs     ?done
 3500  F80756  C9 16                    cmp     #SYN            ; here a SYN is an error
 3501  F80758  F0 0C                    beq     ?done           ; exit 
 3502  F8075A  C9 10                    cmp     #DLE
 3503  F8075C  D0 07                    bne     ?ok
 3504  F8075E  20 AE 06                 jsr     sptget
 3505  F80761  B0 03                    bcs     ?done
 3506  F80763  49 20                    eor     #$20
 3507  F80765  18               ?ok:    clc
 3508  F80766  60               ?done:  rts
 3509                           
 3510  F80767                   updcrc:
 3511  F80767  A8                       tay
 3512  F80768  45 95                    eor     crc16+1         ; quick CRC computation with lookup tables
  Tue Jul 17 11:00:18 2018                                                                                               Page   17




 3513  F8076A  AA                       tax                     ; index for lookup table
 3514  F8076B  A5 94                    lda     crc16
 3515  F8076D  5F BC 09 F8              eor     >crchi,x
 3516  F80771  85 95                    sta     crc16+1
 3517  F80773  BF BC 08 F8              lda     >crclo,x
 3518  F80777  85 94                    sta     crc16
 3519  F80779  98                       tya
 3520  F8077A  60                       rts
 3521                           
 3522                           ; X=serial port (0 or 4)
 3523  F8077B                   getdat:
 3524  F8077B                           ACC16
 3525  F8077B  C2 20                    rep     #PMFLAG
 3526                                   .LONGA  on
 3527                                   .MNLIST
 3528  F8077D  A9 00 02                 lda     #$200
 3529  F80780  A4 9A                    ldy     pkttyp
 3530  F80782  C0 02                    cpy     #STX
 3531  F80784  F0 03                    beq     ?st
 3532  F80786  A9 10 00                 lda     #$10
 3533  F80789  85 96            ?st:    sta     bycnt
 3534  F8078B  64 98                    stz     byndx
 3535  F8078D                           ACC08
 3536  F8078D  E2 20                    sep     #PMFLAG
 3537                                   .LONGA  off
 3538                                   .MNLIST
 3539  F8078F  20 51 07         ?lp:    jsr     spxget
 3540  F80792  B0 2A                    bcs     ?err
 3541  F80794  20 67 07                 jsr     updcrc
 3542  F80797                           INDEX16
 3543  F80797  C2 10                    rep     #PXFLAG
 3544                                   .LONGI  on
 3545                                   .MNLIST
 3546  F80799  A6 98                    ldx     byndx
 3547  F8079B  9F 00 9A 01              sta     >SPBUF,x
 3548  F8079F  E8                       inx
 3549  F807A0  86 98                    stx     byndx
 3550  F807A2  E4 96                    cpx     bycnt
 3551  F807A4                           INDEX08
 3552  F807A4  E2 10                    sep     #PXFLAG
 3553                                   .LONGI  off
 3554                                   .MNLIST
 3555  F807A6  A2 00                    ldx     #0
 3556  F807A8  90 E5                    bcc     ?lp
 3557  F807AA  20 51 07                 jsr     spxget
 3558  F807AD  B0 0F                    bcs     ?err
 3559  F807AF  C5 94                    cmp     crc16
 3560  F807B1  D0 0B                    bne     ?err
 3561  F807B3  20 51 07                 jsr     spxget
 3562  F807B6  B0 06                    bcs     ?err
 3563  F807B8  C5 95                    cmp     crc16+1
 3564  F807BA  D0 02                    bne     ?err
 3565  F807BC  18                       clc
 3566  F807BD  60                       rts
 3567  F807BE  38               ?err:   sec
 3568  F807BF  60                       rts
 3569  F807C0                           
  Tue Jul 17 11:00:18 2018                                                                                               Page   18




 3570                           ; X=serial port (0 or 4)
 3571  F807C0                   getpkt:
 3572  F807C0  A9 02                    lda     #STX
 3573  F807C2  20 23 07                 jsr     fndsyn
 3574  F807C5  B0 1E                    bcs     ?done
 3575  F807C7  20 51 07                 jsr     spxget
 3576  F807CA  B0 19                    bcs     ?done
 3577  F807CC  85 9B                    sta     pktnum
 3578  F807CE  20 51 07                 jsr     spxget
 3579  F807D1  B0 12                    bcs     ?done
 3580  F807D3  49 FF                    eor     #$FF
 3581  F807D5  C5 9B                    cmp     pktnum
 3582  F807D7  D0 0C                    bne     ?err
 3583  F807D9  C5 9C                    cmp     expect
 3584  F807DB  D0 08                    bne     ?err
 3585  F807DD  20 7B 07                 jsr     getdat
 3586  F807E0  B0 03                    bcs     ?err    
 3587                           
 3588                                   ; send positive ACK
 3589  F807E2  4C CF 06                 jmp     sndack  
 3590  F807E5                           
 3591  F807E5                   ?err:
 3592  F807E5  60               ?done:  rts
 3593                           
 3594  F807E6                           
 3595                           ;------------------
 3596                           
 3597  F807E6                   lspget:
 3598                                   .PUBLIC lspget
 3599  F807E6  0B                       phd                     ; save DP
 3600  F807E7  8B                       phb                     ; save DBR
 3601  F807E8  F4 00 00                 pea     #0              ; set DP = $0000
 3602  F807EB  2B                       pld
 3603  F807EC  A0 00                    ldy     #0              ; set DBR = $00
 3604  F807EE  5A                       phy
 3605  F807EF  AB                       plb
 3606  F807F0  20 5B 04                 jsr     _spget0
 3607  F807F3  AB                       plb
 3608  F807F4  2B                       pld
 3609  F807F5  6B                       rtl
 3610  F807F6                           
 3611  F807F6                   lspput:
 3612                                   .PUBLIC lspput
 3613  F807F6  0B                       phd                     ; save DP
 3614  F807F7  8B                       phb                     ; save DBR
 3615  F807F8  F4 00 00                 pea     #0              ; set DP = $0000
 3616  F807FB  2B                       pld
 3617  F807FC  A0 00                    ldy     #0              ; set DBR = $00
 3618  F807FE  5A                       phy
 3619  F807FF  AB                       plb
 3620  F80800  20 08 05                 jsr     _spput0
 3621  F80803  AB                       plb
 3622  F80804  2B                       pld
 3623  F80805  6B                       rtl
 3624                           
 3625  F80806                   lspset:
 3626                                   .PUBLIC lspset
  Tue Jul 17 11:00:18 2018                                                                                               Page   19




 3627  F80806  0B                       phd                     ; save DP
 3628  F80807  8B                       phb                     ; save DBR
 3629  F80808  F4 00 00                 pea     #0              ; set DP = $0000
 3630  F8080B  2B                       pld
 3631  F8080C  A0 00                    ldy     #0              ; set DBR = $00
 3632  F8080E  5A                       phy
 3633  F8080F  AB                       plb
 3634  F80810  20 E5 05                 jsr     spset
 3635  F80813  AB                       plb
 3636  F80814  2B                       pld
 3637  F80815  6B                       rtl
 3638                           
 3639  F80816                   lspres:
 3640                                   .PUBLIC lspres
 3641  F80816  0B                       phd                     ; save DP
 3642  F80817  8B                       phb                     ; save DBR
 3643  F80818  F4 00 00                 pea     #0              ; set DP = $0000
 3644  F8081B  2B                       pld
 3645  F8081C  A0 00                    ldy     #0              ; set DBR = $00
 3646  F8081E  5A                       phy
 3647  F8081F  AB                       plb
 3648  F80820  20 8F 06                 jsr     spres
 3649  F80823  AB                       plb
 3650  F80824  2B                       pld
 3651  F80825  6B                       rtl
 3652                           
 3653  F80826                   crc16a:
 3654  F80826  EB                       xba
 3655  F80827  A9 00                    lda     #0
 3656  F80829  A2 08                    ldx     #8
 3657  F8082B                           ACC16
 3658  F8082B  C2 20                    rep     #PMFLAG
 3659                                   .LONGA  on
 3660                                   .MNLIST
 3661  F8082D  45 94                    eor     crc16
 3662  F8082F  0A               ?lp:    asl     a
 3663  F80830  90 03                    bcc     ?skp
 3664  F80832  49 21 10                 eor     #$1021
 3665  F80835  CA               ?skp:   dex
 3666  F80836  D0 F7                    bne     ?lp
 3667  F80838  85 94                    sta     crc16
 3668  F8083A                           ACC08
 3669  F8083A  E2 20                    sep     #PMFLAG
 3670                                   .LONGA  off
 3671                                   .MNLIST
 3672  F8083C  60                       rts
 3673                           
 3674  F8083D                   crc16b:
 3675  F8083D  A2 08                    ldx     #8
 3676  F8083F  A8               ?lp:    tay
 3677  F80840  45 94                    eor     crc16
 3678  F80842  4A                       lsr     a
 3679  F80843                           ACC16
 3680  F80843  C2 20                    rep     #PMFLAG
 3681                                   .LONGA  on
 3682                                   .MNLIST
 3683  F80845  08                       php
  Tue Jul 17 11:00:18 2018                                                                                               Page   20




 3684  F80846  A5 94                    lda     crc16
 3685  F80848  4A                       lsr     a
 3686  F80849  28                       plp
 3687  F8084A  90 03                    bcc     ?nxt
 3688  F8084C  49 08 84                 eor     #$8408
 3689  F8084F  85 94            ?nxt:   sta     crc16
 3690  F80851                           ACC08
 3691  F80851  E2 20                    sep     #PMFLAG
 3692                                   .LONGA  off
 3693                                   .MNLIST
 3694  F80853  98                       tya
 3695  F80854  4A                       lsr     a
 3696  F80855  CA                       dex
 3697  F80856  D0 E7                    bne     ?lp
 3698  F80858  60                       rts
 3699  F80859                           
 3700  F80859                   crccalc:
 3701  F80859  0B                       phd
 3702  F8085A  F4 00 00                 pea     #0
 3703  F8085D  2B                       pld
 3704  F8085E  86 FF                    stx     $ff
 3705                           
 3706  F80860  A9 FF                    lda     #$FF
 3707  F80862  85 94                    sta     crc16
 3708  F80864  85 95                    sta     crc16+1
 3709  F80866  20 99 08                 jsr     crctb
 3710  F80869                           ACC16
 3711  F80869  C2 20                    rep     #PMFLAG
 3712                                   .LONGA  on
 3713                                   .MNLIST
 3714  F8086B  A5 94                    lda     crc16
 3715  F8086D  85 F0                    sta     $f0
 3716  F8086F                           ACC08
 3717  F8086F  E2 20                    sep     #PMFLAG
 3718                                   .LONGA  off
 3719                                   .MNLIST
 3720  F80871  A9 00                    lda     #$00
 3721  F80873  85 94                    sta     crc16
 3722  F80875  A9 00                    lda     #$00
 3723  F80877  85 95                    sta     crc16+1 
 3724  F80879  20 99 08                 jsr     crctb
 3725  F8087C                           ACC16
 3726  F8087C  C2 20                    rep     #PMFLAG
 3727                                   .LONGA  on
 3728                                   .MNLIST
 3729  F8087E  A5 94                    lda     crc16
 3730  F80880  85 F2                    sta     $f2
 3731  F80882                           ACC08
 3732  F80882  E2 20                    sep     #PMFLAG
 3733                                   .LONGA  off
 3734                                   .MNLIST
 3735  F80884  A9 0F                    lda     #$0F
 3736  F80886  85 94                    sta     crc16
 3737  F80888  A9 1D                    lda     #$1D
 3738  F8088A  85 95                    sta     crc16+1 
 3739  F8088C  20 99 08                 jsr     crctb
 3740  F8088F                           ACC16
  Tue Jul 17 11:00:18 2018                                                                                               Page   21




 3741  F8088F  C2 20                    rep     #PMFLAG
 3742                                   .LONGA  on
 3743                                   .MNLIST
 3744  F80891  A5 94                    lda     crc16
 3745  F80893  85 F4                    sta     $f4
 3746  F80895                           ACC08   
 3747  F80895  E2 20                    sep     #PMFLAG
 3748                                   .LONGA  off
 3749                                   .MNLIST
 3750  F80897  2B                       pld
 3751  F80898  6B                       rtl
 3752                           
 3753                           
 3754  F80899                   crctb:
 3755  F80899  64 FE                    stz     $fe
 3756  F8089B                   ?lp:
 3757  F8089B  A6 FE                    ldx     $fe
 3758  F8089D  E4 FF                    cpx     $ff
 3759  F8089F  B0 1A                    bcs     ?end
 3760  F808A1  BF 00 00 10              lda     >$100000,x
 3761  F808A5  E8                       inx
 3762  F808A6  86 FE                    stx     $fe
 3763                           
 3764  F808A8  45 95                    eor     crc16+1                 ; Quick CRC computation with lookup tables
 3765  F808AA  AA                       tax                     ; updates the two bytes at crc & crc+1
 3766  F808AB  A5 94                    lda     crc16           ; with the byte send in the "A" register
 3767  F808AD  5F BC 09 F8              eor     >crchi,x
 3768  F808B1  85 95                    sta     crc16+1
 3769  F808B3  BF BC 08 F8              lda     >crclo,x
 3770  F808B7  85 94                    sta     crc16
 3771  F808B9                           
 3772  F808B9  80 E0                    bra     ?lp
 3773  F808BB                   ?end:           
 3774  F808BB  60                       rts                     ; y=82 on exit
 3775                           
 3776  F808BC                   crclo
 3777  F808BC  00 21 42 63 84    .byte $00,$21,$42,$63,$84,$A5,$C6,$E7,$08,$29,$4A,$6B,$8C,$AD,$CE,$EF
               A5 C6 E7 08 29 
               4A 6B 8C AD CE 
               EF 
 3778  F808CC  31 10 73 52 B5    .byte $31,$10,$73,$52,$B5,$94,$F7,$D6,$39,$18,$7B,$5A,$BD,$9C,$FF,$DE
               94 F7 D6 39 18 
               7B 5A BD 9C FF 
               DE 
 3779  F808DC  62 43 20 01 E6    .byte $62,$43,$20,$01,$E6,$C7,$A4,$85,$6A,$4B,$28,$09,$EE,$CF,$AC,$8D
               C7 A4 85 6A 4B 
               28 09 EE CF AC 
               8D 
 3780  F808EC  53 72 11 30 D7    .byte $53,$72,$11,$30,$D7,$F6,$95,$B4,$5B,$7A,$19,$38,$DF,$FE,$9D,$BC
               F6 95 B4 5B 7A 
               19 38 DF FE 9D 
               BC 
 3781  F808FC  C4 E5 86 A7 40    .byte $C4,$E5,$86,$A7,$40,$61,$02,$23,$CC,$ED,$8E,$AF,$48,$69,$0A,$2B
               61 02 23 CC ED 
               8E AF 48 69 0A 
               2B 
 3782  F8090C  F5 D4 B7 96 71    .byte $F5,$D4,$B7,$96,$71,$50,$33,$12,$FD,$DC,$BF,$9E,$79,$58,$3B,$1A
  Tue Jul 17 11:00:18 2018                                                                                               Page   22




               50 33 12 FD DC 
               BF 9E 79 58 3B 
               1A 
 3783  F8091C  A6 87 E4 C5 22    .byte $A6,$87,$E4,$C5,$22,$03,$60,$41,$AE,$8F,$EC,$CD,$2A,$0B,$68,$49
               03 60 41 AE 8F 
               EC CD 2A 0B 68 
               49 
 3784  F8092C  97 B6 D5 F4 13    .byte $97,$B6,$D5,$F4,$13,$32,$51,$70,$9F,$BE,$DD,$FC,$1B,$3A,$59,$78
               32 51 70 9F BE 
               DD FC 1B 3A 59 
               78 
 3785  F8093C  88 A9 CA EB 0C    .byte $88,$A9,$CA,$EB,$0C,$2D,$4E,$6F,$80,$A1,$C2,$E3,$04,$25,$46,$67
               2D 4E 6F 80 A1 
               C2 E3 04 25 46 
               67 
 3786  F8094C  B9 98 FB DA 3D    .byte $B9,$98,$FB,$DA,$3D,$1C,$7F,$5E,$B1,$90,$F3,$D2,$35,$14,$77,$56
               1C 7F 5E B1 90 
               F3 D2 35 14 77 
               56 
 3787  F8095C  EA CB A8 89 6E    .byte $EA,$CB,$A8,$89,$6E,$4F,$2C,$0D,$E2,$C3,$A0,$81,$66,$47,$24,$05
               4F 2C 0D E2 C3 
               A0 81 66 47 24 
               05 
 3788  F8096C  DB FA 99 B8 5F    .byte $DB,$FA,$99,$B8,$5F,$7E,$1D,$3C,$D3,$F2,$91,$B0,$57,$76,$15,$34
               7E 1D 3C D3 F2 
               91 B0 57 76 15 
               34 
 3789  F8097C  4C 6D 0E 2F C8    .byte $4C,$6D,$0E,$2F,$C8,$E9,$8A,$AB,$44,$65,$06,$27,$C0,$E1,$82,$A3
               E9 8A AB 44 65 
               06 27 C0 E1 82 
               A3 
 3790  F8098C  7D 5C 3F 1E F9    .byte $7D,$5C,$3F,$1E,$F9,$D8,$BB,$9A,$75,$54,$37,$16,$F1,$D0,$B3,$92
               D8 BB 9A 75 54 
               37 16 F1 D0 B3 
               92 
 3791  F8099C  2E 0F 6C 4D AA    .byte $2E,$0F,$6C,$4D,$AA,$8B,$E8,$C9,$26,$07,$64,$45,$A2,$83,$E0,$C1
               8B E8 C9 26 07 
               64 45 A2 83 E0 
               C1 
 3792  F809AC  1F 3E 5D 7C 9B    .byte $1F,$3E,$5D,$7C,$9B,$BA,$D9,$F8,$17,$36,$55,$74,$93,$B2,$D1,$F0 
               BA D9 F8 17 36 
               55 74 93 B2 D1 
               F0 
 3793                           
 3794                           ; hi byte CRC lookup table (should be page aligned)
 3795  F809BC                   crchi
 3796  F809BC  00 10 20 30 40    .byte $00,$10,$20,$30,$40,$50,$60,$70,$81,$91,$A1,$B1,$C1,$D1,$E1,$F1
               50 60 70 81 91 
               A1 B1 C1 D1 E1 
               F1 
 3797  F809CC  12 02 32 22 52    .byte $12,$02,$32,$22,$52,$42,$72,$62,$93,$83,$B3,$A3,$D3,$C3,$F3,$E3
               42 72 62 93 83 
               B3 A3 D3 C3 F3 
               E3 
 3798  F809DC  24 34 04 14 64    .byte $24,$34,$04,$14,$64,$74,$44,$54,$A5,$B5,$85,$95,$E5,$F5,$C5,$D5
               74 44 54 A5 B5 
               85 95 E5 F5 C5 
  Tue Jul 17 11:00:18 2018                                                                                               Page   23




               D5 
 3799  F809EC  36 26 16 06 76    .byte $36,$26,$16,$06,$76,$66,$56,$46,$B7,$A7,$97,$87,$F7,$E7,$D7,$C7
               66 56 46 B7 A7 
               97 87 F7 E7 D7 
               C7 
 3800  F809FC  48 58 68 78 08    .byte $48,$58,$68,$78,$08,$18,$28,$38,$C9,$D9,$E9,$F9,$89,$99,$A9,$B9
               18 28 38 C9 D9 
               E9 F9 89 99 A9 
               B9 
 3801  F80A0C  5A 4A 7A 6A 1A    .byte $5A,$4A,$7A,$6A,$1A,$0A,$3A,$2A,$DB,$CB,$FB,$EB,$9B,$8B,$BB,$AB
               0A 3A 2A DB CB 
               FB EB 9B 8B BB 
               AB 
 3802  F80A1C  6C 7C 4C 5C 2C    .byte $6C,$7C,$4C,$5C,$2C,$3C,$0C,$1C,$ED,$FD,$CD,$DD,$AD,$BD,$8D,$9D
               3C 0C 1C ED FD 
               CD DD AD BD 8D 
               9D 
 3803  F80A2C  7E 6E 5E 4E 3E    .byte $7E,$6E,$5E,$4E,$3E,$2E,$1E,$0E,$FF,$EF,$DF,$CF,$BF,$AF,$9F,$8F
               2E 1E 0E FF EF 
               DF CF BF AF 9F 
               8F 
 3804  F80A3C  91 81 B1 A1 D1    .byte $91,$81,$B1,$A1,$D1,$C1,$F1,$E1,$10,$00,$30,$20,$50,$40,$70,$60
               C1 F1 E1 10 00 
               30 20 50 40 70 
               60 
 3805  F80A4C  83 93 A3 B3 C3    .byte $83,$93,$A3,$B3,$C3,$D3,$E3,$F3,$02,$12,$22,$32,$42,$52,$62,$72
               D3 E3 F3 02 12 
               22 32 42 52 62 
               72 
 3806  F80A5C  B5 A5 95 85 F5    .byte $B5,$A5,$95,$85,$F5,$E5,$D5,$C5,$34,$24,$14,$04,$74,$64,$54,$44
               E5 D5 C5 34 24 
               14 04 74 64 54 
               44 
 3807  F80A6C  A7 B7 87 97 E7    .byte $A7,$B7,$87,$97,$E7,$F7,$C7,$D7,$26,$36,$06,$16,$66,$76,$46,$56
               F7 C7 D7 26 36 
               06 16 66 76 46 
               56 
 3808  F80A7C  D9 C9 F9 E9 99    .byte $D9,$C9,$F9,$E9,$99,$89,$B9,$A9,$58,$48,$78,$68,$18,$08,$38,$28
               89 B9 A9 58 48 
               78 68 18 08 38 
               28 
 3809  F80A8C  CB DB EB FB 8B    .byte $CB,$DB,$EB,$FB,$8B,$9B,$AB,$BB,$4A,$5A,$6A,$7A,$0A,$1A,$2A,$3A
               9B AB BB 4A 5A 
               6A 7A 0A 1A 2A 
               3A 
 3810  F80A9C  FD ED DD CD BD    .byte $FD,$ED,$DD,$CD,$BD,$AD,$9D,$8D,$7C,$6C,$5C,$4C,$3C,$2C,$1C,$0C
               AD 9D 8D 7C 6C 
               5C 4C 3C 2C 1C 
               0C 
 3811  F80AAC  EF FF CF DF AF    .byte $EF,$FF,$CF,$DF,$AF,$BF,$8F,$9F,$6E,$7E,$4E,$5E,$2E,$3E,$0E,$1E 
               BF 8F 9F 6E 7E 
               4E 5E 2E 3E 0E 
               1E 


             Lines Assembled : 3473                  Errors : 0