Subversion Repositories MB01 Project

Rev

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

  Tue Jul 17 11:00:23 2018                                                                                               Page    1







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

                       Input  Filename : src\FE\kcbm.asm
                       Output Filename : obj\FE\kcbm.obj
                       Listing Has Been Relocated                               


 2584                           .LIST           on
 2585                           
 2586  F8FFB1                           .INCLUDE inc\dirp00.inc
 2587                           ;----------------------------------------------------------
 2588                           ; DIRP00.ASM
 2589                           ; PROGETTO: B1601
 2590                           ;
 2591                           ; Variabili in Direct Page $00
 2592                           ;----------------------------------------------------------
 2593                           
 2594                           ; sezione COMMON -- questo permette di includere il file in piu' file
 2595                           
 2596                           .LIST on
 2597                           
 2598                           DIRP00: .SECTION page0, ref_only, common        ;Direct-Page 00
 2599                           
 2600  000000                           .ABSOLUTE               ;; inizia sempre da $00
 2601  000000                           .ORG            0x00
 2602  000000                           
 2603  000000  0000             JiffyClk        .DW                     ; contatore 10ms 32 bit
 2604  000002  0000                             .DW
 2605  000004                   SysTmr          .DS     SYSTMRCNT       ; system timer 0 (10ms)
 2606  000008                   SysTMF          .DS     SYSTMRCNT       ; flag timer (80 -> start)
 2607  00000C  00               Bnk0Flag        .DB                     ; <7>: flag test RAM banco 0 ok
 2608                                                                   ; <6>: flag warm reset
 2609  00000D  00               RTCFlag         .DB
 2610                           
 2611  00000E                   diskstat        .DS     2       ; flag device on ata bus #0 & #1
 2612                                                           ; <7>: device ready
 2613                                                           ; <6>: compact flash device (C.F.)
 2614                                                           ; <5>: device identification ok
 2615                                                           ; <4>: MBR loaded
 2616                                                           ; <3>: valid signature in MBR
 2617                                                           ; <2>: first partition found&active
 2618                                                           ; <1>:
 2619                                                           ; <0>: valid partition flag
 2620                           
 2621                                                           ; <7>: device ready
 2622                                                           ; <6>: USB device
 2623                                                           ; <5>: compact flash device (C.F.)
 2624                                                           ; <4>: device identification ok
 2625                                                           ; <3>: MBR loaded
 2626                                                           ; <2>: first partition found&active
 2627                                                           ; <1>: always 1
 2628                                                           ; <0>: valid partition flag
 2629  000010                                                   
  Tue Jul 17 11:00:23 2018                                                                                               Page    2




 2630                           
 2631          00000E           atadev          .EQU    diskstat
 2632                           
 2633  000010                   usbdev          .DS     2       ; flag flash disk on usb bus #0
 2634                                                           ; <7>: device plugged and ready
 2635                                                           ; <6>: always 1 
 2636                                                           ; <5>: device identification ok
 2637                                                           ; <4>: MBR loaded
 2638                                                           ; <3>: valid signature in MBR
 2639                                                           ; <2>: first partition found&active
 2640                                                           ; <1>:
 2641                                                           ; <0>: valid partition flag
 2642                           
 2643  000012                   diskmax         .DS     16      ; disk max. sector's
 2644          000012           atasec          .EQU    diskmax
 2645          00001A           usbsec          .EQU    diskmax+8
 2646                           
 2647                           
 2648  000022                   atambr          .DS     8       ; data for first partition found in mbr
 2649                                                           ; first 3 bytes for start sector of partition
 2650                                                           ; last byte for partition type
 2651  00002A                   usbmbr          .DS     8
 2652                           
 2653  000032                   ataprt          .DS     8       ; total sec's of first partition
 2654  00003A                   usbprt          .DS     8       ; total sec's of first partition
 2655                           
 2656                           
 2657  000042  00               usb0ch          .DB     ; usb0 (ch375/ch376) flag
 2658                                                   ; <7>: module on
 2659                                                   ; <6>: ch376 flag
 2660                                                   ; <5:0>: chip version
 2661                           
 2662  000043  00               usb0st          .DB     ; usb0 status
 2663                                                   ; <7>: usb0 host mode ok
 2664                                                   ; <6>: flash disk attached flag
 2665                                                   ; <5>: usb device attached
 2666                           
 2667  000044  00               fdcdrv          .DB             ; phisycal drive status (drive #0)
 2668                                                           ; <7>: disk format established in bit 0&1 
 2669                                                           ; <6>: double step seek done
 2670                                                           ; <5>: trust format bit's (set after ok r/w)
 2671                                                           ; <4>: write protect bit (if disk in drive)
 2672                                                           ; <3>: don't care
 2673                                                           ; <2>: don't care                               
 2674                                                           ; <1>: HD disk if set else DD disk
 2675                                                           ; <0>: CBM format if set else IBM format
 2676                           
 2677  000045  00               vdrive          .DB             ; virtual drive status (ram disk, drive #1)
 2678                                                           ; <7>: disk format established in bit 0&1 
 2679                                                           ; <6>: change disk simulation (after format)
 2680                                                           ; <5>: don't care
 2681                                                           ; <4>: write protect bit (under sw control)
 2682                                                           ; <3>: don't care
 2683                                                           ; <2>: don't care                               
 2684                                                           ; <1>: HD disk if set else DD disk
 2685                                                           ; <0>: CBM format if set else IBM format
 2686                           
  Tue Jul 17 11:00:23 2018                                                                                               Page    3




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




 2744                           
 2745                                   .ENDS
 2746                           
 2747          [01]             .IFDEF          _ACIA_INC_
 2748                                   .INCLUDE INC\SP.INC
 2749          [00]             .ENDIF
 2750                           
 2753                                   .LIST on
 2754  F8FFB1                           .INCLUDE inc\dpcbm.inc
 2755                           ;; cbm emulation
 2756                           
 2757                           ;;CBMP0 .EQU    $7F00
 2758                           
 2759                           ; sezione COMMON -- questo permette di includere il file in piu' file
 2760                           
 2761                           DPCBM:  .SECTION page0, ref_only, common
 2762                           
 2763  000000                           .ABSOLUTE               ;; inizia sempre da $00
 2764  000000                           .ORG    0x00
 2765                           
 2766                           ;;MAXLF .EQU    $10             ; max. logical files
 2767          00000B           MAXLF   .EQU    11              ; max. logical files
 2768          000008           MAXVIEC .EQU    8               ; max. virtual iec device #
 2769  000000                                   .DS     16
 2770  000010                                   
 2771  000010  00               subflg          .DB     ; ($10)
 2772  000011  00                               .DB     ; ($11)
 2773  000012  00                               .DB     ; ($12)
 2774  000013  00                               .DB     ; ($13)
 2775  000014  0000             lineno          .DW     ; ($14-$15) line number used by editor
 2776  000016  00               tmppt           .DB     ; ($16)
 2777  000017  00               tcnt            .DB     ; ($17) temp. counter/index     
 2778  000018  0000                             .DW     ; ($18-$19)
 2779  00001A  0000                             .DW     ; ($1A-$1B)
 2780  00001C  0000                             .DW     ; ($1C-$1D)
 2781  00001E  0000                             .DW     ; ($1E-$1F)
 2782  000020  00                               .DB     ; ($20)
 2783                           
 2784                           ; basic/p-code virtual machine work area 
 2785  000021  0000                             .DW     ; ($21-$22)
 2786  000023  0000                             .DW     ; ($23-$24)             
 2787  000025  0000                             .DW     ; ($25-$26)
 2788  000027  0000                             .DW     ; ($27-$28)
 2789  000029  0000                             .DW     ; ($29-$2A)             
 2790  00002B  0000                             .DW     ; ($2B-$2C)
 2791  00002D  0000                             .DW     ; ($2D-$2E)
 2792  00002F  0000             arytab          .DW     ; ($2F-$30)
 2793  000031  0000             strend          .DW     ; ($31-$32)
 2794  000033  0000             freetop         .DW     ; ($33-$34)
 2795  000035  0000             freespc         .DW     ; ($35-$36)
 2796  000037  0000             memsiz          .DW     ; ($37-$38)
 2797  000039  0000             curline         .DW     ; ($39-$3A) current line number in execution
 2798  00003B  0000             oldline         .DW     ; ($3B-$3C) previous line number in execution
 2799  00003D  0000             oldtxt          .DW     ; ($3D-$3E) saved pointer to text in basic execution
 2800  00003F  0000             datlin          .DW     ; ($3F-$40)
 2801  000041  0000             datptr          .DW     ; ($41-$42)
 2802  000043  0000             inpptr          .DW     ; ($43-$44)
  Tue Jul 17 11:00:23 2018                                                                                               Page    5




 2803  000045  0000             varnam          .DW     ; ($45-$46)
 2804  000047  0000             varpnt          .DW     ; ($47-$48)
 2805  000049  0000             forpnt          .DW     ; ($49-$4A) basic
 2806  00004B  0000             opptr           .DW     ; ($4B-$4C) basic
 2807  00004D  00               opmask          .DB     ; ($4D)
 2808  00004E  0000             defpnt          .DW     ; ($4E-$4F)
 2809  000050  0000             dscpnt          .DW     ; ($50-$51)
 2810  000052  00               dsclen          .DB     ; ($52)
 2811  000053  00               prompt          .DB     ; ($53) prompt flag/CMD channel - editor/basic ($13)
 2812                           
 2813                           ; equates for p-code virtual machine
 2814          00003B           prtrap          .EQU    oldline         ; ($3B) p-code trap errors flag
 2815          00003C           pcstack         .EQU    oldline+1       ; ($3C-$3D) p-code save stack
 2816          00003E           prterr          .EQU    oldtxt+1        ; ($3E) p-code run time error number
 2817          00003F           psrline         .EQU    datlin          ; ($3F-$40) pascal source line number
 2818          000041           prseed          .EQU    datptr          ; ($41-$42) p-code random generator
 2819          000043           pbrkcnt         .EQU    inpptr          ; ($43) p-code counter for break check
 2820          000044           tmpy            .EQU    inpptr+1        ; ($44) p-code temp. for save Y
 2821          000045           inqidx          .EQU    varnam          ; ($45) p-code index to input buffer
 2822          000046           inqcnt          .EQU    varnam+1        ; ($46) p-code input buffer counter 
 2823          000047           tmpv1           .EQU    varpnt          ; ($47) p-code temp.
 2824          000048           tmpv2           .EQU    varpnt+1        ; ($48) p-code temp.
 2825          000049           tmpa            .EQU    forpnt          ; ($49) p-code temp. save A
 2826          00004A           tmpwa           .EQU    forpnt+1        ; ($4A) p-code tmp. save byte to write
 2827          00004B           tmpx            .EQU    opptr           ; ($4B) p-code tmp. save X when print
 2828          00004C           pcterr          .EQU    opptr+1         ; ($4C) p-code compiler error flag
 2829          00004D           tmpdsk          .EQU    opmask          ; ($4D) p-code default temp. disk unit
 2830          00004E           defprn          .EQU    defpnt          ; ($4E) p-code default printer #device
 2831          00004F           pcdbg           .EQU    defpnt+1        ; ($4F) p-code debug run after error
 2832          000050           pcptr           .EQU    dscpnt          ; ($50-$51) pointer to p-code (debug)
 2833          000052           autolf          .EQU    dsclen          ; ($52) p-code auto line feed flag
 2834                           
 2835  000054                   tmpwrk          .DS 4   ; ($54-$57) temp. area editor/virtual iec
 2836  000058  00               tmpb0           .DB     ; ($58)
 2837  000059  00               argbits         .DB     ; ($59)     FAC #1 guard bits
 2838  00005A  00               tmpb2           .DB     ; ($5A) tmp. byte - used by fpu
 2839  00005B  00               txtlen          .DB     ; ($5B) tmp. word length of text to insert in buffer
 2840  00005C  00               tmpb1           .DB     ; ($5C) tmp. byte used by editor and float point unit
 2841  00005D  0000             tmpval          .DW     ; ($5D-$5E) temp. word used by editor/fpu
 2842  00005F  0000             tlnptr          .DW     ; ($5F-$60) temp. line text pointer used by editor/fpu  
 2843  000061  00               facexp          .DB     ; ($61)     FAC #1 exponent
 2844  000062                   facm            .DS 4   ; ($62-$65) FAC #1 mantissa
 2845  000066  00               facsgn          .DB     ; ($66)     FAC #1 sign
 2846  000067  00               sercnt          .DB     ; ($67)     FAC #1 series evaluation
 2847  000068  00               facov           .DB     ; ($68)     FAC #1 overflow
 2848  000069  00               argexp          .DB     ; ($69)     FAC #2 exponent
 2849  00006A                   argm            .DS 4   ; ($6A-$6D) FAC #2 mantissa
 2850  00006E  00               argsgn          .DB     ; ($6E)     FAC #2 sign
 2851  00006F  00               arisgn          .DB     ; ($6F)     FAC #1 & #2 sign comparison
 2852  000070  00               facbits         .DB     ; ($70)     FAC #1 guard bits
 2853  000071  0000             fbufpt          .DW     ; ($71-$72) FAC series evaluation pointer
 2854  000073  00               fbufpt2         .DB     ; ($73)     FAC series evaluation bank (progr. bank)
 2855                           
 2856                           ; tmp. variables (equates) used by float point unit
 2857          000054           factmp          .EQU    tmpwrk          ; ($54-$57) used by fpu mult/div
 2858          00005A           cprmsk          .EQU    tmpb2           ; ($5A) used by trigs. funcs.
 2859          00005B           faclsb          .EQU    txtlen          ; ($5B) used by float point unit
  Tue Jul 17 11:00:23 2018                                                                                               Page    6




 2860          00005D           dccnt           .EQU    tmpval          ; ($5D) digit count after decimal dot
 2861          00005E           expval          .EQU    tmpval+1        ; ($5E) exponent value when convert
 2862          00005F           dotfg           .EQU    tlnptr          ; ($5F) flag decimal dot when convert
 2863          000060           expsgn          .EQU    tlnptr+1        ; ($60) flag exponent sign when conver
 2864          000067           sgnfg           .EQU    sercnt          ; ($67) flag: minus sign when convert
 2865          000071           decidx          .EQU    fbufpt          ; ($71) string index when convert
 2866          000072           s2fer           .EQU    fbufpt+1        ; ($72) string to float flag error
 2867          000073           decidx2         .EQU    fbufpt+2        ; ($73) used when convert float to str          
 2868                           
 2869  000074  0000             s2fstk          .DW     ; ($74-$75) save stack when string to float conversion  
 2870  000076                   longp           LP      ; ($76-$77-$78) temp. long pointer
 2871  000079  00               s2fptr          .DB     ; ($79) flag trap overflow err. string to float conv.
 2872                           
 2873  00007A  0000             txtp            .DW     ; ($7A-$7B) current pointer to text
 2874  00007C  00               pcdsk           .DB     ; ($7C) flag for pascal compiler
 2875                                                   ; <7> : compile in memory
 2876                           
 2877  00007D                   iecrp           LP      ; ($7D) iec: pointer to read buffer for include file
 2878  000080  00               iecalt          .DB     ; ($80) iec: flag read from include file
 2879  000081                   iectp           LP      ; ($81) iec: pointer to read main text buffer
 2880  000084  00               iecndx          .DB     ; ($84) iec: index main text buffer
 2881  000085  00               ieceof          .DB     ; ($85) iec: end of file flag main text buffer
 2882  000086                   iecwp           LP      ; ($86) iec: pointer to write buffer
 2883  000089  00               iecfg           .DB     ; ($89) iec: flag main text buffer      
 2884  00008A  0000             iecndx2         .DW     ; ($8A) iec: index buffer include file
 2885  00008C  00               iecbuf          .DB     ; ($8C) iec: byte buffer
 2886  00008D  00               svbnk           .DB     ; ($8D) save vbnk when run pascal compiler
 2887  00008E  00               ieceof2         .DB     ; ($8E) iec: flag eof include file 
 2888  00008F  00               vxflag          .DB     ; ($8F) flag valid text in x-bank
 2889  000090  00               kstat           .DB     ; ($90) CBM emulated IEC status
 2890  000091  00               errno           .DB     ; ($91) saved error number
 2891  000092  00               keyfg           .DB     ; ($92) keyboard flag: KbdFlag 
 2892  000093  00               keyctl          .DB     ; ($93) flag control key from get key
 2893  000094  00               keysh           .DB     ; ($94) flag keyboard: KbdShift
 2894  000095  00               keytg           .DB     ; ($95) flag keyboard: KbdToggle
 2895  000096  00               basic           .DB     ; ($96) flag current 'basic' mode
 2896                                                   ;       <7>: flag basic mode
 2897                                                   ;       <6>: flag pascal compiler running                       
 2898  000097  00               runf            .DB     ; ($97) flag current run mode
 2899  000098  00               ldtnd           .DB     ; ($98) number of open files
 2900  000099  00               dfltn           .DB     ; ($99) default input device
 2901  00009A  00               dflto           .DB     ; ($9A) default output device
 2902  00009B  00               skpbk           .DB     ; ($9B) skip blank flag
 2903  00009C  00               w2sf            .DB     ; ($9C) integer to string flag conversion
 2904  00009D  00               msgflg          .DB     ; ($9D) flag message
 2905  00009E  00               autof           .DB     ; ($9E) flag auto-increment line numbering
 2906  00009F  0000             wauto           .DW     ; ($9F-$A0) auto-increment for line numbering
 2907  0000A1  00               tbnk            .DB     ; ($A1) bank that hold basic/pascal text                
 2908  0000A2  00               vbnk            .DB     ; ($A2) bank that hold basic var/pascal pcode-stack             
 2909  0000A3  00               cbnk            .DB     ; ($A3) compiler bank/temp. bank for exchange
 2910  0000A4  00               jbnk            .DB     ; ($A4) bank for obj, when compiling (3 bank max.)
 2911  0000A5  00               xbnk            .DB     ; ($A5) exchange bank for text buffer
 2912  0000A6  00               dbnk            .DB     ; ($A6) bank for ram disk (jbnk + 3)
 2913  0000A7  0000             botmem          .DW     ; ($A7-$A8) start of memory on the text bank
 2914  0000A9  0000             topmem          .DW     ; ($A9-$AA) top of memory on the text bank
 2915  0000AB  0000             txtbeg          .DW     ; ($AB-$AC) begin of text buffer
 2916  0000AD  0000             txtend          .DW     ; ($AD-$AE) end of text buffer + 1
  Tue Jul 17 11:00:23 2018                                                                                               Page    7




 2917  0000AF  0000             txttop          .DW     ; ($AF-$B0) top of memory + 1 reserved to text buffer
 2918  0000B1  0000             varbeg          .DW     ; ($B1-$B2) start of basic var/pcode 
 2919  0000B3  0000             vartop          .DW     ; ($B3-$B4) top of basic var/pcode + 1
 2920  0000B5  0000             xtop            .DW     ; ($B5-$B6) top of text + 1 in x-bank           
 2921  0000B7  00               fnlen           .DB     ; ($B7) length of current filename
 2922  0000B8  00               lacur           .DB     ; ($B8) current logical file number
 2923  0000B9  00               sacur           .DB     ; ($B9) current secondary address
 2924  0000BA  00               facur           .DB     ; ($BA) current device number
 2925  0000BB  0000             fnadr           .DW     ; ($BB-$BC) pointer to current filename
 2926  0000BD  00               fnadr2          .DB     ; ($BD) - bank that hold file name
 2927  0000BE  00               objdsk          .DB     ; ($BE) compiler: option '1' specified
 2928  0000BF  00               truedsk         .DB     ; ($BF) true disk for load pascal soource file
 2929  0000C0  0000             curstk          .DW     ; ($C0-$C1) current stack when in edit mode
 2930  0000C2  00               pcodef          .DB     ; ($C2) flag p-code present for execution
 2931                           
 2932  0000C3                   latb            .DS     MAXLF           ; logical files table
 2933  0000CE                   fatb            .DS     MAXLF           ; devices numbers table
 2934  0000D9                   satb            .DS     MAXLF           ; secondary addresses table
 2935                           
 2936                           ;=============================================================
 2937                           
 2938  0000E4  0000             cmdlin          .DW     ; command line ptr for pscal program
 2939  0000E6  00               fpcflag         .DB     ; fpc flags (new style)
 2940                                                   ; <7>: new style compiler
 2941                                                   ; <6>: no save exec. file
 2942                                                   ; <5>: save obj. file
 2943                           
 2944  0000E6                           .RELATIVE
 2945                                   .ENDS
 2946                           
 2947                           ; basic work area starting at $FF00 of bank that hold text buffer
 2948                           CBMHIM: .SECTION ref_only, common
 2949  000000                           .ABSOLUTE
 2950  00FF00                           .ORG    $FF00
 2951                           ;       .ORG    0
 2952                           
 2953          0000A2           TBUFMAX         .EQU    $A2     ; size of input buffer
 2954          00AA55           VALIDSGN        .EQU    $AA55   ; valid signature
 2955                           
 2956  00FF00                   cbmwork         .DS     4       ; first 4 bytes free for insert text line
 2957  00FF04                   TXTBUF          .DS     TBUFMAX ; input buffer for text insertion
 2958  00FFA6                   NUMSTR          .DS     32      ; room for numeric string
 2959                           
 2960  00FFC6  0000             TMPPTR          .DW             ; temp. pointer
 2961  00FFC8  0000                             .DW
 2962  00FFCA  0000                             .DW
 2963  00FFCC  0000                             .DW
 2964  00FFCE  0000                             .DW
 2965  00FFD0                   GFNAME          .DS     32      ; global file name 
 2966  00FFF0                                   .DS     8
 2967  00FFF8                                   
 2968                                   ;;.ORG  $FFF8
 2969  00FFF8  0000             TXTEND2         .DW             ; saved text end + 1
 2970  00FFFA  0000             TXTVSGN         .DW             ; valid text buffer signature
 2971  00FFFC  0000             XTOP2           .DW             ; saved text end + 1 in exchange bank
 2972  00FFFE  0000             XBVSGN          .DW             ; valid x-bank buffer signature
 2973                           
  Tue Jul 17 11:00:23 2018                                                                                               Page    8




 2974  00FFFE                           .RELATIVE
 2975                                   .ENDS
 2976                           
 2977                           .COMMENT @
 2978                           cbmwork         .EQU    $FF00   ; first 4 bytes free for insert text line
 2979                           TXTBUF          .EQU    $FF04   ; input buffer for text insertion
 2980                           NUMSTR          .EQU    $FFA6   ; room for numeric string
 2981                           
 2982                           TMPPTR          .EQU    $FFC6           ; temp. pointer
 2983                           
 2984                           TXTEND2         .EQU    $FFF8           ; saved text end + 1
 2985                           TXTVSGN         .EQU    $FFFA           ; valid text buffer signature
 2986                           XTOP2           .EQU    $FFFC           ; saved text end + 1 in exchange bank
 2987                           XBVSGN          .EQU    $FFFE           ; valid x-bank buffer signature
 2988                           @
 2989                           
 2990                           ; basic/pascal work area starting at $FF00 of bank that hold variables/p-code
 2991                           CBMHIV: .SECTION common, ref_only
 2992  000000                           .ABSOLUTE
 2993  00FF00                           .ORG    $FF00
 2994                           ;       .ORG    0
 2995                           
 2996          00005A           QINSIZ          .EQU    $5A     ; input buffer max. 90 chars.
 2997          000020           NUMSIZ          .EQU    $20     ; size of numeric buffer for conversion
 2998          000018           MAX2LF          .EQU    ((MAXLF + 1) * 2) ; size of p-code logical files table
 2999          000013           MAXFNLEN        .EQU    19      ; max. length of file name '@x:yyyyyyyyyyyyyyyy'
 3000                           
 3001  00FF00                   MINBUF          .DS     QINSIZ
 3002  00FF5A                   MNUMSTR         .DS     NUMSIZ
 3003  00FF7A  0000             MTMPW0          .DW
 3004  00FF7C  0000             MTMPW1          .DW
 3005  00FF7E  00               MTMPB0          .DB
 3006  00FF7F                   MFNAME          .DS     16      ; file name buffer
 3007  00FF8F                   MTMPNAM         .DS     15      ; tmp. file name
 3008  00FF9E                   MPOW10          .DS     10      ; power of 10 table
 3009  00FFA8                   MTRUE           .DS     6
 3010  00FFAE                   MFALSE          .DS     6
 3011  00FFB4                   MSTDF0          .DS     4       ; descriptor for file #0 (consolle)
 3012  00FFB8                   MSTDF1          .DS     4       ; descriptor for file #1 (disk command chann.)
 3013  00FFBC                   MSTDF2          .DS     4       ; descriptor for file #2 (used by compiler)
 3014  00FFC0                   MMSET           .DS     16      ; set variables
 3015  00FFD0                   MFILET          .DS     MAX2LF  ; table of logical files: #0 consolle, #1 disk
 3016  00FFE8                   FAC1TMP         .DS     5       ; these 3 used by float routines
 3017  00FFED                   FAC2TMP         .DS     5
 3018  00FFF2                   FAC3TMP         .DS     5
 3019  00FFF7                   FAC4TMP         .DS     5       ; free to use
 3020  00FFFC  0000             MTPTR           .DW             ; used by new/dispose
 3021  00FFFE  0000             MTMPW2          .DW
 3022                           
 3023  00FFFE                           .RELATIVE
 3024                                   .ENDS
 3025                           
 3026                           .COMMENT @
 3027                           MINBUF          .EQU    $FF00
 3028                           MNUMSTR         .EQU    $FF5A
 3029                           MTMPW0          .EQU    $FF7A
 3030                           MTMPW1          .EQU    $FF7C
  Tue Jul 17 11:00:23 2018                                                                                               Page    9




 3031                           MTMPB0          .EQU    $FF7E
 3032                           MFNAME          .EQU    $FF7F   ; file name buffer
 3033                           MTMPNAM         .EQU    $FF8F   ; tmp. file name
 3034                           MPOW10          .EQU    $FF9E   ; power of 10 table
 3035                           MTRUE           .EQU    $FFA8
 3036                           MFALSE          .EQU    $FFAE
 3037                           MSTDF0          .EQU    $FFB4   ; descriptor for file #0 (consolle)
 3038                           MSTDF1          .EQU    $FFB8   ; descriptor for file #1 (disk command chann.)
 3039                           MSTDF2          .EQU    $FFBC   ; descriptor for file #2 (used by compiler)
 3040                           MMSET           .EQU    $FFC0   ; set variables
 3041                           MFILET          .EQU    $FFD0   ; table of logical files: #0 consolle, #1 disk
 3042                           FAC1TMP         .EQU    $FFE8   ; these 3 used by float routines
 3043                           FAC2TMP         .EQU    $FFED
 3044                           FAC3TMP         .EQU    $FFF2
 3045                           FAC4TMP         .EQU    $FFF7   ; free to use
 3046                           MTPTR           .EQU    $FFFC   ; used by new/dispose
 3047                           MTMPW2          .EQU    $FFFE
 3048                           @
 3049                           
 3050                           ; temp. file names in x-bank
 3051          00FF00           PASSRC          .EQU    $FF00
 3052          00FF20           OBJDST          .EQU    $FF20
 3053          00FF40           EXEDST          .EQU    $FF40
 3054          00FF60           OBJDEL          .EQU    $FF60
 3055                           
 3056                           
 3057                                   .CODEFE
 3058                                   .LONGA off
 3059                                   .LONGI off
 3060                           
 3061                                   .EXTERN cbm_new2, cbm_res, cbm_rdy
 3062                                   .EXTERN vlsnopn, vsndcmd, vunlsnopn, viec8lsn, viec8tlk
 3063                                   .EXTERN viec8put, viec8get, v8unlsn, v8untlk, v8close
 3064                                   .EXTERN vopnlst
 3065                           
 3066                           ;---------------------------------------------------------------------------
 3067                           ; serial comm device
 3068                           ;---------------------------------------------------------------------------
 3069                           
 3070                           ; A = device #
 3071  FE9DAB                   seropen:
 3072  FE9DAB  A9 05                    lda     #$05
 3073  FE9DAD  38                       sec
 3074  FE9DAE  60                       rts
 3075                           
 3076  FE9DAF                   serclose:
 3077  FE9DAF  60                       rts
 3078                           
 3079                           ;---------------------------------------------------------------------------
 3080                           
 3081  FE9DB0                   iecopen:
 3082  FE9DB0  C9 08                    cmp     #$08
 3083  FE9DB2  90 13                    bcc     ?er5
 3084  FE9DB4  24 7C                    bit     pcdsk
 3085  FE9DB6  30 13                    bmi     ?pcc            ; compiler in memory mode
 3086  FE9DB8  24 E6                    bit     fpcflag
 3087  FE9DBA  10 08                    bpl     ?real           ; old style: always on disk
  Tue Jul 17 11:00:23 2018                                                                                               Page   10




 3088  FE9DBC  A5 B9                    lda     sacur
 3089  FE9DBE  29 0F                    and     #$0F
 3090  FE9DC0  C9 04                    cmp     #4
 3091  FE9DC2  F0 13                    beq     ?obj            ; new style: obj. file in memory
 3092  FE9DC4  4C 4E 9E         ?real:  jmp     ?dsk            ; open real disk
 3093  FE9DC7  A9 05            ?er5:   lda     #$05
 3094  FE9DC9  38                       sec
 3095  FE9DCA  60                       rts
 3096  FE9DCB  A5 B9            ?pcc:   lda     sacur           ; pascal compiler
 3097  FE9DCD  29 0F                    and     #$0F
 3098  FE9DCF  C9 0F                    cmp     #$0F
 3099  FE9DD1  F0 0C                    beq     ?end0
 3100  FE9DD3  C9 04                    cmp     #$04            ; obj. file?
 3101  FE9DD5  D0 0A                    bne     ?tst            ; no
 3102  FE9DD7  64 86            ?obj:   stz     iecwp           ; setup buffer pointer for write obj. file
 3103  FE9DD9  64 87                    stz     iecwp+1
 3104  FE9DDB  A5 A4                    lda     jbnk            ; obj. code in j-bank
 3105  FE9DDD  85 88                    sta     iecwp+2
 3106  FE9DDF  18               ?end0:  clc
 3107  FE9DE0  60               ?end:   rts
 3108  FE9DE1  C9 03            ?tst:   cmp     #$03            ; read main source file?
 3109  FE9DE3  D0 18                    bne     ?inc            ; no
 3110  FE9DE5                           ACC16
 3111  FE9DE5  C2 20                    rep     #PMFLAG
 3112                                   .LONGA  on
 3113                                   .MNLIST
 3114  FE9DE7  A5 AB                    lda     txtbeg          ; pointer to main text buffer
 3115  FE9DE9  85 81                    sta     iectp
 3116  FE9DEB  A4 A1                    ldy     tbnk            ; bank 
 3117  FE9DED  84 83                    sty     iectp+2
 3118  FE9DEF  A7 81                    lda     [iectp]         ; check end of text
 3119  FE9DF1                           ACC08
 3120  FE9DF1  E2 20                    sep     #PMFLAG
 3121                                   .LONGA  off
 3122                                   .MNLIST
 3123  FE9DF3  F0 10                    beq     ?er4            ; empty buffer
 3124  FE9DF5  64 85                    stz     ieceof          ; clear eof flag
 3125  FE9DF7  64 89                    stz     iecfg           ; clear internal eof flag
 3126  FE9DF9  64 84                    stz     iecndx          ; clear index
 3127  FE9DFB  18                       clc
 3128  FE9DFC  60                       rts
 3129  FE9DFD  C9 05            ?inc    cmp     #$05            ; an include file?
 3130  FE9DFF  F0 08                    beq     ?inc2           ; yes
 3131  FE9E01  A9 06                    lda     #$06            ; 'not input file' error
 3132  FE9E03  38                       sec
 3133  FE9E04  60                       rts
 3134  FE9E05  A9 04            ?er4:   lda     #$04            ; 'file not found' error ($04)
 3135  FE9E07  38                       sec
 3136  FE9E08  60                       rts
 3137  FE9E09  64 7D            ?inc2:  stz     iecrp           ; clear buffer pointer
 3138  FE9E0B  64 7E                    stz     iecrp+1
 3139  FE9E0D  A5 A6                    lda     dbnk
 3140  FE9E0F  85 7F                    sta     iecrp+2
 3141                                   ;stz    iecalt          ; include file flag
 3142  FE9E11  64 8E                    stz     ieceof2         ; include fuile eof flag
 3143  FE9E13  64 8A                    stz     iecndx2         ; buffer index
 3144  FE9E15  64 86                    stz     iecndx+2
  Tue Jul 17 11:00:23 2018                                                                                               Page   11




 3145  FE9E17                           
 3146                                   ; open include file
 3147  FE9E17  DA                       phx
 3148  FE9E18  A5 BD                    lda     fnadr2          ; set fname pointer
 3149  FE9E1A  48                       pha
 3150  FE9E1B  D4 BB                    pei     (fnadr)         ; address of cmnd string
 3151  FE9E1D  A9 0E                    lda     #$0E
 3152  FE9E1F  48                       pha                     ; chnl
 3153  FE9E20                           CBMFSCMD                ; send command
 3154  FE9E20  02 80                    cop     FN_CBMFSCMD
 3155                                   .MNLIST
 3156  FE9E22  FA                       plx
 3157  FE9E23  B0 E0                    bcs     ?er4            ; if error
 3158  FE9E25  DA                       phx
 3159  FE9E26  A5 7F                    lda     iecrp+2         ; bank of buffer
 3160  FE9E28  48                       pha
 3161  FE9E29  D4 7D                    pei     (iecrp)         ; address of buffer
 3162  FE9E2B  F4 FE FF                 pea     #$FFFE          ; buffer size
 3163  FE9E2E  A9 0E                    lda     #$0E            ; chnl
 3164  FE9E30  48                       pha
 3165  FE9E31                           CBMFSRD                 ; read buffer
 3166  FE9E31  02 81                    cop     FN_CBMFSRW
 3167  FE9E33  00                       .DB     $00
 3168                                   .MNLIST
 3169  FE9E34  08                       php
 3170  FE9E35  85 76                    sta     longp           ; size
 3171  FE9E37  EB                       xba
 3172  FE9E38  85 77                    sta     longp+1
 3173  FE9E3A  A9 0E                    lda     #$0E
 3174  FE9E3C                           CBMFSCLS                ; close chnl
 3175  FE9E3C  02 82                    cop     FN_CBMFSCLS
 3176                                   .MNLIST
 3177  FE9E3E  28                       plp
 3178  FE9E3F  FA                       plx
 3179  FE9E40  B0 C3                    bcs     ?er4            ; error
 3180  FE9E42                           INDEX16
 3181  FE9E42  C2 10                    rep     #PXFLAG
 3182                                   .LONGI  on
 3183                                   .MNLIST
 3184  FE9E44  A4 76                    ldy     longp
 3185  FE9E46  A9 00                    lda     #0
 3186  FE9E48  97 7D                    sta     [iecrp],y
 3187  FE9E4A                           INDEX08
 3188  FE9E4A  E2 10                    sep     #PXFLAG
 3189                                   .LONGI  off
 3190                                   .MNLIST
 3191  FE9E4C  18                       clc
 3192  FE9E4D  60                       rts
 3193                           
 3194                           ; real disk open
 3195  FE9E4E                   ?dsk:
 3196  FE9E4E  DA                       phx
 3197  FE9E4F  A5 B9                    lda     sacur
 3198  FE9E51  29 0F                    and     #$0F
 3199  FE9E53  AA                       tax                     ; x = sa
 3200  FE9E54  A4 B7                    ldy     fnlen
 3201  FE9E56  D0 10                    bne     ?sz             ; string not empty
  Tue Jul 17 11:00:23 2018                                                                                               Page   12




 3202  FE9E58  E0 0F                    cpx     #$0F
 3203  FE9E5A  F0 18                    beq     ?ret            ; command without string
 3204  FE9E5C  A9 D0                    lda     #<GFNAME        ; set dummy string pointer
 3205  FE9E5E  85 BB                    sta     fnadr
 3206  FE9E60  A9 FF                    lda     #>GFNAME
 3207  FE9E62  85 BC                    sta     fnadr+1
 3208  FE9E64  A5 A1                    lda     tbnk
 3209  FE9E66  85 BD                    sta     fnadr+2
 3210  FE9E68  A9 00            ?sz:    lda     #0
 3211  FE9E6A  97 BB                    sta     [fnadr],y       ; terminate string
 3212  FE9E6C  A5 BD                    lda     fnadr+2         ; param 1: command string
 3213  FE9E6E  48                       pha
 3214  FE9E6F  D4 BB                    pei     (fnadr)
 3215  FE9E71  DA                       phx                     ; channel
 3216  FE9E72                           CBMFSCMD                ; send command (ignore error)
 3217  FE9E72  02 80                    cop     FN_CBMFSCMD
 3218                                   .MNLIST
 3219  FE9E74  FA               ?ret:   plx
 3220  FE9E75  B0 08                    bcs     ?ext
 3221  FE9E77  E0 0F                    cpx     #$0F
 3222  FE9E79  F0 04                    beq     ?ext
 3223  FE9E7B  22 EC 2A F9              jsl     vopnlst
 3224  FE9E7F  18               ?ext:   clc
 3225  FE9E80  60                       rts
 3226  FE9E81                           
 3227  FE9E81                   iecclose:
 3228  FE9E81  A5 BA                    lda     facur
 3229  FE9E83  C9 08                    cmp     #$08
 3230  FE9E85  90 17                    bcc     ?end            ; no disk device
 3231  FE9E87  A5 B9                    lda     sacur
 3232  FE9E89  29 0F                    and     #$0F
 3233  FE9E8B  C9 0F                    cmp     #$0F
 3234  FE9E8D  F0 0E                    beq     ?clc            ; ignore close command channel
 3235  FE9E8F  24 7C                    bit     pcdsk
 3236  FE9E91  10 0C                    bpl     ?dsk            ; real disk
 3237  FE9E93  C9 05                    cmp     #$05            ; ignore close file #2,#3,#4 
 3238  FE9E95  90 07                    bcc     ?end
 3239  FE9E97  64 8A                    stz     iecndx2         ; clear include file index
 3240  FE9E99  64 8B                    stz     iecndx2+1
 3241  FE9E9B  64 8E                    stz     ieceof2         ; clear include file eof flag   
 3242  FE9E9D  18               ?clc:   clc
 3243  FE9E9E  60               ?end:   rts
 3244  FE9E9F  24 E6            ?dsk:   bit     fpcflag
 3245  FE9EA1  10 04                    bpl     ?dsk2           ; old style: always on disk
 3246  FE9EA3  C9 04                    cmp     #4
 3247  FE9EA5  F0 F6                    beq     ?clc            ; obj file new style: in memory
 3248  FE9EA7  22 8C 2E F9      ?dsk2:  jsl     v8close         ; close file on real disk
 3249  FE9EAB  60                       rts
 3250  FE9EAC                           
 3251                           ; A=dev#, sacur=SA#
 3252  FE9EAC                   ieclsn:
 3253  FE9EAC  64 90                    stz     kstat
 3254  FE9EAE  C9 08                    cmp     #$08
 3255  FE9EB0  90 1D                    bcc     ?end
 3256  FE9EB2  18                       clc
 3257  FE9EB3  24 7C                    bit     pcdsk
 3258  FE9EB5  30 18                    bmi     ?end
  Tue Jul 17 11:00:23 2018                                                                                               Page   13




 3259  FE9EB7  A5 B9                    lda     sacur
 3260  FE9EB9  29 0F                    and     #$0F
 3261  FE9EBB  24 E6                    bit     fpcflag
 3262  FE9EBD  10 06                    bpl     ?dsk
 3263  FE9EBF  C9 04                    cmp     #4
 3264  FE9EC1  D0 02                    bne     ?dsk
 3265  FE9EC3  18                       clc
 3266  FE9EC4  60                       rts
 3267  FE9EC5  22 50 2B F9      ?dsk:   jsl     viec8lsn
 3268  FE9EC9  90 04                    bcc     ?end
 3269  FE9ECB  A9 80                    lda     #$80
 3270  FE9ECD  85 90                    sta     kstat
 3271  FE9ECF  60               ?end:   rts
 3272                           
 3273  FE9ED0                   iecunlsn:
 3274  FE9ED0  A5 9A                    lda     dflto
 3275  FE9ED2  C9 08                    cmp     #$08
 3276  FE9ED4  90 13                    bcc     ?end2
 3277  FE9ED6  24 7C                    bit     pcdsk
 3278  FE9ED8  30 0E                    bmi     ?end
 3279  FE9EDA  24 E6                    bit     fpcflag
 3280  FE9EDC  10 06                    bpl     ?dsk
 3281  FE9EDE  A5 B9                    lda     sacur
 3282  FE9EE0  C9 04                    cmp     #4
 3283  FE9EE2  F0 04                    beq     ?end
 3284  FE9EE4  22 80 2D F9      ?dsk:   jsl     v8unlsn
 3285  FE9EE8  18               ?end:   clc     
 3286  FE9EE9  60               ?end2:  rts
 3287                           
 3288                           ; A=dev#, sacur=SA#
 3289  FE9EEA                   iectlk:
 3290  FE9EEA  64 90                    stz     kstat
 3291  FE9EEC  C9 08                    cmp     #$08
 3292  FE9EEE  90 19                    bcc     ?end
 3293  FE9EF0  18                       clc
 3294  FE9EF1  A5 B9                    lda     sacur
 3295  FE9EF3  24 7C                    bit     pcdsk
 3296  FE9EF5  30 13                    bmi     ?tlk
 3297  FE9EF7  A5 B9                    lda     sacur
 3298  FE9EF9  22 B0 2B F9              jsl     viec8tlk
 3299  FE9EFD  B0 06                    bcs     ?er
 3300  FE9EFF  50 08                    bvc     ?end
 3301  FE9F01  A9 40                    lda     #$40
 3302  FE9F03  80 02                    bra     ?er2
 3303  FE9F05  A9 80            ?er:    lda     #$80
 3304  FE9F07  85 90            ?er2:   sta     kstat   
 3305  FE9F09  60               ?end:   rts
 3306  FE9F0A  29 0F            ?tlk:   and     #$0F
 3307  FE9F0C  C9 0F                    cmp     #$0F
 3308  FE9F0E  64 80                    stz     iecalt          ; if = 0 get from cmd. chnl
 3309  FE9F10  F0 09                    beq     ?end2
 3310  FE9F12  38                       sec
 3311  FE9F13  66 80                    ror     iecalt          ; <7>: get from main text buffer
 3312  FE9F15  C9 05                    cmp     #$05            ; include file?
 3313  FE9F17  D0 02                    bne     ?end2           ; no
 3314  FE9F19  46 80                    lsr     iecalt          ; <6>: get from include file
 3315  FE9F1B  18               ?end2:  clc
  Tue Jul 17 11:00:23 2018                                                                                               Page   14




 3316  FE9F1C  60                       rts
 3317                           
 3318  FE9F1D                   iecuntlk:
 3319  FE9F1D  A5 99                    lda     dfltn
 3320  FE9F1F  C9 08                    cmp     #$08
 3321  FE9F21  90 09                    bcc     ?end2
 3322  FE9F23  24 7C                    bit     pcdsk
 3323  FE9F25  30 04                    bmi     ?end
 3324  FE9F27  22 A4 2D F9              jsl     v8untlk
 3325  FE9F2B  18               ?end:   clc     
 3326  FE9F2C  60               ?end2:  rts
 3327                           
 3328                           ; A=data
 3329  FE9F2D                   iecout:
 3330  FE9F2D  85 8C                    sta     iecbuf
 3331  FE9F2F  A5 9A                    lda     dflto
 3332  FE9F31  C9 08                    cmp     #$08
 3333  FE9F33  90 17                    bcc     ?no
 3334  FE9F35  A5 8C                    lda     iecbuf
 3335  FE9F37  24 7C                    bit     pcdsk
 3336  FE9F39  30 14                    bmi     ?wr
 3337  FE9F3B  24 E6                    bit     fpcflag
 3338  FE9F3D  30 10                    bmi     ?wr
 3339  FE9F3F  22 81 2C F9              jsl     viec8put
 3340  FE9F43  90 17                    bcc     ?end2
 3341  FE9F45  A9 80                    lda     #$80
 3342  FE9F47  85 90                    sta     kstat
 3343  FE9F49  A5 8C                    lda     iecbuf
 3344  FE9F4B  60                       rts
 3345  FE9F4C  A5 8C            ?no:    lda     iecbuf
 3346  FE9F4E  60                       rts
 3347  FE9F4F  87 86            ?wr:    sta     [iecwp]         ; put to buffer obj. file
 3348  FE9F51  E6 86                    inc     iecwp           ; update buffer pointer
 3349  FE9F53  D0 06                    bne     ?end
 3350  FE9F55  E6 87                    inc     iecwp+1
 3351  FE9F57  D0 02                    bne     ?end
 3352  FE9F59  E6 88                    inc     iecwp+2
 3353  FE9F5B  18               ?end:   clc
 3354  FE9F5C  60               ?end2:  rts
 3355  FE9F5D                           
 3356  FE9F5D                   iecin:
 3357  FE9F5D  A5 99                    lda     dfltn
 3358  FE9F5F  C9 08                    cmp     #$08
 3359  FE9F61  90 19                    bcc     ?no
 3360  FE9F63  24 7C                    bit     pcdsk
 3361  FE9F65  30 18                    bmi     ?rdt
 3362  FE9F67  22 F7 2C F9              jsl     viec8get
 3363  FE9F6B  B0 0B                    bcs     ?er
 3364  FE9F6D  50 08                    bvc     ?xt             ; no eof
 3365  FE9F6F  85 8C                    sta     iecbuf
 3366  FE9F71  A9 40                    lda     #$40
 3367  FE9F73  85 90                    sta     kstat
 3368  FE9F75  A5 8C                    lda     iecbuf
 3369  FE9F77  60               ?xt:    rts
 3370  FE9F78  A9 80            ?er:    lda     #$80
 3371  FE9F7A  85 90                    sta     kstat
 3372  FE9F7C  A9 0D            ?no:    lda     #$0D    
  Tue Jul 17 11:00:23 2018                                                                                               Page   15




 3373  FE9F7E  60                       rts
 3374                           
 3375                           ; get byte from main text buffer 
 3376  FE9F7F                   ?rdt:
 3377  FE9F7F  A5 80                    lda     iecalt
 3378  FE9F81  F0 37                    beq     ?ext            ; cmd chnl
 3379  FE9F83  C9 40                    cmp     #$40
 3380  FE9F85  F0 35                    beq     ?rda            ; read include file
 3381  FE9F87  DA                       phx
 3382  FE9F88  5A                       phy
 3383  FE9F89  8B                       phb
 3384  FE9F8A  24 85                    bit     ieceof          ; <6>: eof flag
 3385  FE9F8C  50 08                    bvc     ?go             ; no eof
 3386  FE9F8E  A9 0D                    lda     #$0D            ; return CR if eof
 3387  FE9F90  A0 40                    ldy     #$40
 3388  FE9F92  84 90                    sty     kstat           ; I/O status = eof
 3389  FE9F94  80 21                    bra     ?end            ; exit
 3390  FE9F96  A5 8D            ?go:    lda     svbnk           ; local read buffer in real v-bank
 3391  FE9F98  48                       pha
 3392  FE9F99  AB                       plb                     ; set data bank
 3393  FE9F9A  24 89                    bit     iecfg           ; <7>: flag buffer not empty
 3394  FE9F9C  30 03                    bmi     ?get            ; buffer ready
 3395  FE9F9E  20 E3 9F                 jsr     ?ldt            ; fill local read buffer
 3396  FE9FA1  A4 84            ?get:   ldy     iecndx          ; current buffer index
 3397  FE9FA3  B9 00 FF                 lda     $FF00,y         ; get byte from local buffer
 3398  FE9FA6  C8                       iny
 3399  FE9FA7  84 84                    sty     iecndx          ; save new index
 3400  FE9FA9  C9 0A                    cmp     #$0A            ; last byte of buffer?
 3401  FE9FAB  D0 0A                    bne     ?end            ; no -- return byte
 3402  FE9FAD  24 89                    bit     iecfg           ; <6>: eof flag (VF)
 3403  FE9FAF  64 89                    stz     iecfg           ; clear flag: next time must fill buffer
 3404  FE9FB1  50 04                    bvc     ?end            ; no eof
 3405  FE9FB3  A0 40                    ldy     #$40
 3406  FE9FB5  84 85                    sty     ieceof          ; internal flag: end of file
 3407                                   ;sty    kstat           ; I/O status = eof
 3408  FE9FB7  AB               ?end:   plb
 3409  FE9FB8  7A                       ply
 3410  FE9FB9  FA                       plx
 3411  FE9FBA  18               ?ext:   clc
 3412  FE9FBB  60                       rts
 3413                           
 3414  FE9FBC  5A               ?rda:   phy
 3415  FE9FBD  24 8E                    bit     ieceof2         ; <6>: eof flag
 3416  FE9FBF  50 08                    bvc     ?go2            ; no eof
 3417  FE9FC1  A9 40                    lda     #$40
 3418  FE9FC3  85 90                    sta     kstat
 3419  FE9FC5  A9 0D                    lda     #$0D            ; return CR if eof
 3420  FE9FC7  80 17                    bra     ?end2           ; exit
 3421  FE9FC9                   ?go2:   INDEX16
 3422  FE9FC9  C2 10                    rep     #PXFLAG
 3423                                   .LONGI  on
 3424                                   .MNLIST
 3425  FE9FCB  A4 8A                    ldy     iecndx2         ; index
 3426  FE9FCD  B7 7D                    lda     [iecrp],y
 3427  FE9FCF  85 8C                    sta     iecbuf
 3428  FE9FD1  C8                       iny
 3429  FE9FD2  84 8A                    sty     iecndx2
  Tue Jul 17 11:00:23 2018                                                                                               Page   16




 3430  FE9FD4  B7 7D                    lda     [iecrp],y
 3431  FE9FD6                           INDEX08
 3432  FE9FD6  E2 10                    sep     #PXFLAG
 3433                                   .LONGI  off
 3434                                   .MNLIST
 3435  FE9FD8  D0 04                    bne     ?ret
 3436  FE9FDA  A9 40                    lda     #$40
 3437  FE9FDC  85 8E                    sta     ieceof2
 3438  FE9FDE  A5 8C            ?ret:   lda     iecbuf
 3439  FE9FE0  7A               ?end2:  ply
 3440  FE9FE1  18                       clc
 3441  FE9FE2  60                       rts
 3442                           
 3443                           ; fill local buffer from main text buffer
 3444  FE9FE3                   ?ldt:   ACC16
 3445  FE9FE3  C2 20                    rep     #PMFLAG
 3446                                   .LONGA  on
 3447                                   .MNLIST
 3448  FE9FE5  A0 02                    ldy     #$02
 3449  FE9FE7  B7 81                    lda     [iectp],y
 3450  FE9FE9  85 3F                    sta     psrline         ; store current line number
 3451  FE9FEB                           ACC08
 3452  FE9FEB  E2 20                    sep     #PMFLAG
 3453                                   .LONGA  off
 3454                                   .MNLIST
 3455  FE9FED  A2 FF                    ldx     #$FF
 3456  FE9FEF  C8                       iny
 3457  FE9FF0  C8               ?llp:   iny
 3458  FE9FF1  E8                       inx
 3459  FE9FF2  B7 81                    lda     [iectp],y       ; copy text line in local buffer
 3460  FE9FF4  9D 00 FF                 sta     !$FF00,x
 3461  FE9FF7  D0 F7                    bne     ?llp
 3462  FE9FF9  A9 0D                    lda     #$0D
 3463  FE9FFB  9D 00 FF                 sta     !$FF00,x
 3464  FE9FFE  A9 0A                    lda     #$0A
 3465  FEA000  9D 01 FF                 sta     !$FF01,x
 3466  FEA003  A0 80                    ldy     #$80            ; flag buffer is filled 
 3467  FEA005                           ACC16
 3468  FEA005  C2 20                    rep     #PMFLAG
 3469                                   .LONGA  on
 3470                                   .MNLIST
 3471  FEA007  A7 81                    lda     [iectp]         ; update pointer to next text line
 3472  FEA009  85 81                    sta     iectp
 3473  FEA00B  A7 81                    lda     [iectp]
 3474  FEA00D                           ACC08
 3475  FEA00D  E2 20                    sep     #PMFLAG
 3476                                   .LONGA  off
 3477                                   .MNLIST
 3478  FEA00F  D0 02                    bne     ?ok             ; no eof
 3479  FEA011  A0 C0                    ldy     #$C0            ; flag filled buffer + end of file marker
 3480  FEA013  64 84            ?ok:    stz     iecndx          ; clear current index
 3481  FEA015  84 89                    sty     iecfg
 3482  FEA017  60                       rts     
 3483                           
 3484                           ;---------------------------------------------------------------------------
 3485                           ; virtual serial bus device
 3486                           ; device #4,#5: printer port's
  Tue Jul 17 11:00:23 2018                                                                                               Page   17




 3487                           ; device #6,#7: not present
 3488                           ; device #8: all drive's
 3489                           ;
 3490                           ; disk unit:
 3491                           ;               #0..#7: physical drive's
 3492                           ;               #8,#10: ram buffer (compiler only)
 3493                           ;               #9,#11: text buffer (read only, compiler only) 
 3494                           ;---------------------------------------------------------------------------
 3495                           
 3496                           ;---------------------------------------------------------------------------
 3497                           ; open virtual iec device
 3498                           ;---------------------------------------------------------------------------
 3499                           
 3500                           ; open virtual iec device
 3501                           ; A = device #, X = index to logical file table
 3502                           ; output: CF = 1 if error, A = error code
 3503                           ; implementation note---
 3504                           ; for disk device (device #8) secondary address sacur have special meaning:
 3505                           ;       sacur<7>: 1 if write only file, 0 if read only file
 3506                           ;       sacur<6>: 1 if read/write file
 3507                           ; after openning, secondary address have in bit <3:0> the disk unit number
 3508                           ; pascal compiler open at least 3 files: file #1 for chann. command,
 3509                           ; file #3 (read only) for pascal source, file #4 (write only) for obj. code
 3510                           ; file #2 reserved for printer/terminal listing when compiling
 3511                           ; if source file contain an include directive (#filename) then open file #5
 3512                           ; for read include file.
 3513                           
 3514                           ;---------------------------------------------------------------------------
 3515                           ; close channel with iec device
 3516                           ;---------------------------------------------------------------------------
 3517  FEA018                           
 3518                           ;---------------------------------------------------------------------------
 3519                           ; logical file operations and input/output wrapper's
 3520                           ;---------------------------------------------------------------------------
 3521                           
 3522                           ; wrapper for output routine
 3523                           ; before call this, user must call _chkout routine
 3524                           ; A = byte to send to device
 3525  FEA018                   _chrout:
 3526  FEA018  EB                       xba                     ; B = byte to send 
 3527  FEA019  A5 9A                    lda     dflto
 3528  FEA01B  F0 0E                    beq     ?04             ; 0 -> keyboard, not out device
 3529  FEA01D  C9 03                    cmp     #$03
 3530  FEA01F  90 0D                    bcc     ?06             ; 1, 2 -> serial port
 3531  FEA021  D0 04                    bne     ?02             ; 4..MAXVIEC
 3532  FEA023  EB                       xba
 3533  FEA024                           SCNCHAROUT              ; 3 -> screen output
 3534  FEA024  02 05                    cop     $05
 3535                                   .MNLIST
 3536  FEA026  60                       rts
 3537  FEA027  C9 09            ?02:    cmp     #MAXVIEC+1
 3538  FEA029  90 07                    bcc     ?08             ; 4..MAXVIEV -> virtual serial bus
 3539  FEA02B  4C 98 A1         ?04:    jmp     SetErr09        ; illegal device number
 3540  FEA02E  EB               ?06:    xba                     ; output serial/parallel port   
 3541  FEA02F                           DEVCHAROUT
 3542  FEA02F  02 15                    cop     $15
 3543                                   .MNLIST
  Tue Jul 17 11:00:23 2018                                                                                               Page   18




 3544  FEA031  60                       rts
 3545  FEA032  EB               ?08:    xba     
 3546  FEA033  4C 2D 9F                 jmp     iecout          ; virtual iec output
 3547                           
 3548                           ; wrapper for get routine
 3549                           ; before call this user must call _chkin routine
 3550  FEA036                   _getin:
 3551  FEA036  A5 99                    lda     dfltn
 3552  FEA038  D0 0F                    bne     _chrin1
 3553  FEA03A                           KBGETIN                 ; get from keyboard
 3554  FEA03A  02 17                    cop     $17
 3555                                   .MNLIST
 3556  FEA03C  EB                       xba
 3557  FEA03D  85 93                    sta     keyctl          ; store control
 3558  FEA03F  EB                       xba                     ; key code
 3559  FEA040  18                       clc
 3560  FEA041  60                       rts
 3561  FEA042                           
 3562                           ; wrapper for input routine
 3563                           ; before call this user must call _chkin routine
 3564  FEA042                    _chrin:
 3565  FEA042  A5 99                    lda     dfltn
 3566  FEA044  D0 03                    bne     _chrin1 
 3567  FEA046                           KBCHARIN                ; input from keyboard (editor)
 3568  FEA046  02 0F                    cop     $0F
 3569                                   .MNLIST
 3570  FEA048  60                       rts
 3571  FEA049                   _chrin1:
 3572  FEA049  C9 03                    cmp     #$03
 3573  FEA04B  90 02                    bcc     ?01             ; 1,2 -> serial ports
 3574  FEA04D  D0 03                    bne     ?02
 3575  FEA04F                   ?01:    DEVCHARIN               ; input from screen (editor) or serial port             
 3576  FEA04F  02 16                    cop     $16
 3577                                   .MNLIST
 3578  FEA051  60                       rts
 3579  FEA052  C9 09            ?02:    cmp     #MAXVIEC+1
 3580  FEA054  90 03                    bcc     ?06             ; 8..15 -> virtual serial bus
 3581  FEA056  4C 98 A1         ?04:    jmp     SetErr09        ; illegal device number
 3582  FEA059  A5 90            ?06:    lda     kstat           ; virtual iec device
 3583  FEA05B  D0 03                    bne     ?08             ; end of file or error
 3584  FEA05D  4C 5D 9F                 jmp     iecin           ; virtual serial bus input
 3585  FEA060  A9 0D            ?08:    lda     #$0D            ; return a CR
 3586  FEA062  18                       clc
 3587  FEA063  60                       rts
 3588                           
 3589                           ; wrapper for open routine
 3590                           ; before call this user must set: lacur, facur, sacur, fnlen, fnadr, fnadr2
 3591  FEA064                   _open:
 3592  FEA064  A6 B8                    ldx     lacur
 3593  FEA066  20 66 A1                 jsr     lfsrch
 3594  FEA069  F0 33                    beq     ?12             ; file open
 3595  FEA06B  A6 98                    ldx     ldtnd
 3596  FEA06D  E0 0B                    cpx     #MAXLF
 3597  FEA06F  B0 2A                    bcs     ?11             ; too many files
 3598  FEA071  E6 98                    inc     ldtnd
 3599                                   ;stx    lxcur
 3600  FEA073  A5 B8                    lda     lacur
  Tue Jul 17 11:00:23 2018                                                                                               Page   19




 3601  FEA075  95 C3                    sta     latb,x
 3602  FEA077  A5 B9                    lda     sacur
 3603  FEA079  95 D9                    sta     satb,x
 3604  FEA07B  A5 BA                    lda     facur
 3605  FEA07D  95 CE                    sta     fatb,x
 3606  FEA07F  F0 18                    beq     ?10             ; 0 -> keyboard: OK
 3607  FEA081  C9 03                    cmp     #$03
 3608  FEA083  F0 14                    beq     ?10             ; 3 -> screen: OK
 3609  FEA085  90 1A                    bcc     ?15             ; 1,2 -> serial ports
 3610  FEA087  C9 09                    cmp     #MAXVIEC+1
 3611  FEA089  90 09                    bcc     ?07             ; 4..MAXVIEC -> virtual serial bus
 3612  FEA08B  B5 CE            ?05:    lda     fatb,x          ; invalidate device #
 3613  FEA08D  09 80                    ora     #$80
 3614  FEA08F  95 CE                    sta     fatb,x
 3615  FEA091  4C 98 A1                 jmp     SetErr09        ; illegal device number
 3616  FEA094  20 B0 9D         ?07:    jsr     iecopen         ; A = error code if any error
 3617  FEA097  B0 0D                    bcs     ?17             ; ok
 3618  FEA099  18               ?10:    clc                     ; no error
 3619  FEA09A  60               ?10a:   rts
 3620  FEA09B  4C 80 A1         ?11:    jmp     SetErr01        ; too many files
 3621  FEA09E  4C 83 A1         ?12:    jmp     SetErr02        ; file open
 3622  FEA0A1  20 AB 9D         ?15:    jsr     seropen         ; open serial port
 3623  FEA0A4  90 F4                    bcc     ?10a            ; A = error code if any error           
 3624  FEA0A6  48               ?17:    pha                     ; save error code
 3625                                   ;ldx    lxcur
 3626  FEA0A7  B5 CE                    lda     fatb,x          ; invalidate device #
 3627  FEA0A9  09 80                    ora     #$80
 3628  FEA0AB  95 CE                    sta     fatb,x
 3629  FEA0AD  68                       pla
 3630  FEA0AE  4C 9D A1         ?20:    jmp     SetErr          ; set error code
 3631                           
 3632                           ; wrapper for set file for input routine
 3633                           ; before call this user must set X = logical file 
 3634  FEA0B1                   _chkin:
 3635  FEA0B1  20 66 A1                 jsr     lfsrch
 3636  FEA0B4  D0 1D                    bne     ?11             ; file not open
 3637  FEA0B6  20 73 A1                 jsr     lfget
 3638  FEA0B9  F0 14                    beq     ?10a            ; 0 -> keyboard - ok
 3639  FEA0BB  30 08                    bmi     ?05             ; device not present
 3640  FEA0BD  C9 04                    cmp     #$04
 3641  FEA0BF  90 0E                    bcc     ?10a            ; 1,2,3 - ok
 3642  FEA0C1  C9 09                    cmp     #MAXVIEC+1
 3643  FEA0C3  90 03                    bcc     ?10             ; 6..MAXVIEC -> virtual serial bus ok
 3644  FEA0C5  4C 8C A1         ?05:    jmp     SetErr05        ; error: device not present
 3645  FEA0C8  AA               ?10:    tax
 3646  FEA0C9  20 EA 9E                 jsr     iectlk
 3647  FEA0CC  B0 F7                    bcs     ?05
 3648  FEA0CE  8A                       txa
 3649  FEA0CF  85 99            ?10a:   sta     dfltn           ; ok - setup input device
 3650  FEA0D1  18                       clc
 3651  FEA0D2  60                       rts
 3652  FEA0D3  4C 86 A1         ?11:    jmp     SetErr03        ; error: file not open
 3653  FEA0D6  4C 8F A1         ?12:    jmp     SetErr06        ; error: not input file
 3654                           
 3655                           ; wrapper for set file for output routine
 3656                           ; before call this user must set X = logical file 
 3657  FEA0D9                   _chkout:
  Tue Jul 17 11:00:23 2018                                                                                               Page   20




 3658  FEA0D9  20 66 A1                 jsr     lfsrch
 3659  FEA0DC  D0 1D                    bne     ?11             ; file not open
 3660  FEA0DE  20 73 A1                 jsr     lfget
 3661  FEA0E1  F0 1B                    beq     ?12             ; 0 -> keyboard - not output device
 3662  FEA0E3  30 08                    bmi     ?05             ; device not present
 3663  FEA0E5  C9 04                    cmp     #$04
 3664  FEA0E7  90 0E                    bcc     ?10a            ; 1,2,3 - ok
 3665  FEA0E9  C9 09                    cmp     #MAXVIEC+1
 3666  FEA0EB  90 03                    bcc     ?10             ; 4..MAXVIEC -> virtual serial bus ok
 3667  FEA0ED  4C 8C A1         ?05:    jmp     SetErr05        ; error: device not present
 3668  FEA0F0  AA               ?10:    tax     
 3669  FEA0F1  20 AC 9E                 jsr     ieclsn
 3670  FEA0F4  B0 F7                    bcs     ?05
 3671  FEA0F6  8A                       txa
 3672  FEA0F7  85 9A            ?10a:   sta     dflto           ; ok - set output device
 3673  FEA0F9  18                       clc
 3674  FEA0FA  60                       rts
 3675  FEA0FB  4C 86 A1         ?11:    jmp     SetErr03        ; file not open         
 3676  FEA0FE  4C 92 A1         ?12:    jmp     SetErr07        ; error: not output file
 3677                           
 3678                           ; wrapper for close all opened files
 3679  FEA101                   _clall:
 3680  FEA101  20 10 A1                 jsr     _clrch
 3681  FEA104  A6 98            ?02:    ldx     ldtnd
 3682  FEA106  F0 07                    beq     ?04             ; no more files to close
 3683  FEA108  B5 C3                    lda     latb,x          ; logical file number
 3684  FEA10A  20 26 A1                 jsr     _close          ; close file
 3685  FEA10D  80 F5                    bra     ?02             ; loop next file
 3686  FEA10F  60               ?04:    rts
 3687                           
 3688                           ; wrapper for restore default i/o devices
 3689  FEA110                   _clrch:
 3690  FEA110  A2 03                    ldx     #$03            ; default output device
 3691  FEA112  E4 9A                    cpx     dflto
 3692  FEA114  B0 03                    bcs     ?10
 3693  FEA116  20 D0 9E                 jsr     iecunlsn
 3694  FEA119  E4 99            ?10:    cpx     dfltn
 3695  FEA11B  B0 03                    bcs     ?20
 3696  FEA11D  20 1D 9F                 jsr     iecuntlk
 3697  FEA120  86 9A            ?20:    stx     dflto           ; default output device
 3698  FEA122  64 99                    stz     dfltn           ; default input device
 3699  FEA124  18                       clc
 3700  FEA125  60                       rts
 3701                           
 3702                           ; wrapper for close a logical file
 3703                           ; before call this user must set A = logical file to be closed
 3704  FEA126                   _close:
 3705  FEA126  20 69 A1                 jsr     lfsrchx
 3706  FEA129  D0 39                    bne     ?12             ; exit without error (no file found)
 3707  FEA12B  20 73 A1                 jsr     lfget           ; get parameters for logical file
 3708  FEA12E  DA                       phx                     ; save index to logical file table
 3709  FEA12F  A5 BA                    lda     facur           ; device #
 3710  FEA131  30 14                    bmi     ?10             ; illegal device - delete file
 3711  FEA133  F0 12                    beq     ?10             ; no action - delete file
 3712  FEA135  C9 03                    cmp     #3
 3713  FEA137  F0 0E                    beq     ?10             ; no action - delete file
 3714  FEA139  B0 05                    bcs     ?02
  Tue Jul 17 11:00:23 2018                                                                                               Page   21




 3715  FEA13B  20 AF 9D                 jsr     serclose        ; close on device 1 & 2
 3716  FEA13E  80 07                    bra     ?10             ; delete file
 3717  FEA140  C9 09            ?02:    cmp     #MAXVIEC+1
 3718  FEA142  B0 03                    bcs     ?10             ; no action - delete file
 3719  FEA144  20 81 9E                 jsr     iecclose        ; close on devices 4..MAXVIEC
 3720  FEA147  FA               ?10:    plx                     ; index of file to be deleted
 3721  FEA148  C6 98                    dec     ldtnd           ; update number of logical files
 3722  FEA14A  E4 98                    cpx     ldtnd           ; if index is for the last entry, done
 3723  FEA14C  F0 16                    beq     ?12             ; otherwise move files on table
 3724  FEA14E  9B                       txy                     ; Y = index to entry be removed
 3725  FEA14F  A6 98                    ldx     ldtnd
 3726  FEA151  B5 C3                    lda     latb,x
 3727  FEA153  BB                       tyx
 3728  FEA154  95 C3                    sta     latb,x
 3729  FEA156  A6 98                    ldx     ldtnd
 3730  FEA158  B5 CE                    lda     fatb,x
 3731  FEA15A  BB                       tyx
 3732  FEA15B  95 CE                    sta     fatb,x
 3733  FEA15D  A6 98                    ldx     ldtnd
 3734  FEA15F  B5 D9                    lda     satb,x
 3735  FEA161  BB                       tyx
 3736  FEA162  95 D9                    sta     satb,x
 3737  FEA164  18               ?12:    clc
 3738  FEA165  60                       rts
 3739  FEA166                           
 3740                           ; search logical file X in table 'latb'
 3741  FEA166                   lfsrch:
 3742  FEA166  64 90                    stz     kstat
 3743  FEA168  8A                       txa                     ; file number
 3744  FEA169                   lfsrchx:
 3745  FEA169  A6 98                    ldx     ldtnd
 3746  FEA16B  CA               ?01:    dex
 3747  FEA16C  30 04                    bmi     ?02
 3748  FEA16E  D5 C3                    cmp     latb,x
 3749  FEA170  D0 F9                    bne     ?01
 3750  FEA172  60               ?02:    rts
 3751                           
 3752                           ; get parameters of logical file 
 3753  FEA173                   lfget:
 3754                                   ;stx    lxcur
 3755  FEA173  B5 C3                    lda     latb,x
 3756  FEA175  85 B8                    sta     lacur
 3757  FEA177  B5 D9                    lda     satb,x
 3758  FEA179  85 B9                    sta     sacur
 3759  FEA17B  B5 CE                    lda     fatb,x
 3760  FEA17D  85 BA                    sta     facur
 3761  FEA17F  60                       rts
 3762                           
 3763                           ;---------------------------------------------------------------------------
 3764                           ; kernal error's
 3765                           ;---------------------------------------------------------------------------
 3766                           
 3767                           SetErr01:                       ; too many files
 3768  FEA180  A9 01                    lda     #1
 3769  FEA182  2C                       .DB     $2C
 3770                           SetErr02:                       ; file open
 3771  FEA183  A9 02                    lda     #2
  Tue Jul 17 11:00:23 2018                                                                                               Page   22




 3772  FEA185  2C                       .DB     $2C
 3773                           SetErr03:                       ; file not open
 3774  FEA186  A9 03                    lda     #3
 3775  FEA188  2C                       .DB     $2C
 3776                           SetErr04:                       ; file not found
 3777  FEA189  A9 04                    lda     #4
 3778  FEA18B  2C                       .DB     $2C
 3779                           SetErr05:                       ; device not presnt
 3780  FEA18C  A9 05                    lda     #5
 3781  FEA18E  2C                       .DB     $2C
 3782                           SetErr06:                       ; not input file
 3783  FEA18F  A9 06                    lda     #6
 3784  FEA191  2C                       .DB     $2C
 3785                           SetErr07:                       ; not output file
 3786  FEA192  A9 07                    lda     #7
 3787  FEA194  2C                       .DB     $2C
 3788                           SetErr08:                       ; missing file name
 3789  FEA195  A9 08                    lda     #8
 3790  FEA197  2C                       .DB     $2C
 3791                           SetErr09:                       ; illegal device number
 3792  FEA198  A9 09                    lda     #9
 3793  FEA19A  2C                       .DB     $2C
 3794                           SetErr10:                       ; out of memory
 3795  FEA19B  A9 10                    lda     #$10
 3796  FEA19D                   SetErr:
 3797                                   .EXTERN L0FAA
 3798                           
 3799  FEA19D  48                       pha
 3800  FEA19E  20 CC FF                 jsr     FCLRCH          ; restore default I/O
 3801  FEA1A1  24 97                    bit     runf            ; check if running pascal virtual machine
 3802  FEA1A3  30 2B                    bmi     ?20
 3803  FEA1A5  70 29                    bvs     ?20
 3804  FEA1A7  A0 00                    ldy     #$00
 3805  FEA1A9  24 9D                    bit     msgflg          ; <6> -> print kernal msg
 3806  FEA1AB  50 20                    bvc     ?10             ; no print
 3807  FEA1AD  20 38 A2                 jsr     kprint          ; print msg
 3808  FEA1B0  A3 01                    lda     $01,s           ; error code
 3809  FEA1B2  C9 0A                    cmp     #$0A
 3810  FEA1B4  90 12                    bcc     ?08
 3811  FEA1B6  A0 FF                    ldy     #$FF            ; partial remainder
 3812  FEA1B8  38                       sec
 3813  FEA1B9  C8               ?02:    iny
 3814  FEA1BA  E9 0A                    sbc     #$0A
 3815  FEA1BC  B0 FB                    bcs     ?02
 3816  FEA1BE  69 0A                    adc     #$0A
 3817  FEA1C0  EB                       xba
 3818  FEA1C1  98                       tya
 3819  FEA1C2  09 30                    ora     #$30            ; print 0..9
 3820  FEA1C4  20 D2 FF                 jsr     FCHROUT
 3821  FEA1C7  EB                       xba
 3822  FEA1C8  09 30            ?08:    ora     #$30            ; print 0..9
 3823  FEA1CA  20 D2 FF                 jsr     FCHROUT
 3824  FEA1CD  68               ?10:    pla
 3825  FEA1CE  38                       sec                     ; error
 3826  FEA1CF  60                       rts
 3827  FEA1D0                           
 3828  FEA1D0  68               ?20:    pla     
  Tue Jul 17 11:00:23 2018                                                                                               Page   23




 3829  FEA1D1  C9 2B                    cmp     #$2B
 3830  FEA1D3  D0 04                    bne     ?22
 3831  FEA1D5  A9 00                    lda     #0
 3832  FEA1D7  80 06                    bra     ?24
 3833  FEA1D9  C9 10            ?22:    cmp     #$10
 3834  FEA1DB  D0 02                    bne     ?24
 3835  FEA1DD  A9 0A                    lda     #$0A
 3836  FEA1DF  AA               ?24:    tax
 3837  FEA1E0  BF EA A1 FE              lda     >CVTTBL,x
 3838                                   ;sta    iecerr
 3839  FEA1E4  AA                       tax
 3840  FEA1E5  38                       sec
 3841  FEA1E6  4C C0 31                 jmp     L0FAA
 3842  FEA1E9  60                       rts
 3843                           
 3844  FEA1EA                   CVTTBL:
 3845  FEA1EA  14 10 16 15 17           .DB     $14, $10, $16, $15, $17, $18, $0D, $0E, $19, $1A, $01
               18 0D 0E 19 1A 
               01 
 3846  FEA1F5                           
 3847                           
 3848  FEA1F5                   sysmsg:
 3849  FEA1F5                   SYSMSGTBL:
 3850  FEA1F5  0D 49 2F 4F 20           .DC     $0D, 'I/O error '
               65 72 72 6F 72 
               A0 
 3851                           
 3852          00000B           SYSMSG1         .EQU    ($ - SYSMSGTBL)
 3853                           
 3854  FEA200  0D 73 65 61 72           .DC     $0D, 'searching '
               63 68 69 6E 67 
               A0 
 3855                           
 3856          000016           SYSMSG2         .EQU    ($ - SYSMSGTBL)
 3857                           
 3858  FEA20B  0D 6C 6F 61 64           .DC     $0D, 'loading'
               69 6E E7 
 3859                           
 3860          00001E           SYSMSG3         .EQU    ($ - SYSMSGTBL)
 3861                           
 3862  FEA213  0D 73 61 76 69           .DC     $0D, 'saving '
               6E 67 A0 
 3863                           
 3864          000026           SYSMSG4         .EQU    ($ - SYSMSGTBL)
 3865                           
 3866  FEA21B  0D 76 65 72 69           .DC     $0D, 'verifying'
               66 79 69 6E E7 
 3867  FEA225                                                   
 3868          000030           SYSMSG5         .EQU    ($ - SYSMSGTBL)
 3869                           
 3870  FEA225  0D 66 6F 75 6E           .DC     $0D, 'found '
               64 A0 
 3871                           
 3872          000037           SYSMSG6         .EQU    ($ - SYSMSGTBL)
 3873                           
 3874  FEA22C  0D 6F 6B 8D              .DB     $0D, 'ok', $8D
 3875                           
  Tue Jul 17 11:00:23 2018                                                                                               Page   24




 3876          00003B           SYSMSG7         .EQU    ($ - SYSMSGTBL)
 3877                           
 3878  FEA230  66 6F 72 A0              .DC     'for '
 3879                           
 3880  FEA234                           
 3881  FEA234                   sysprint:
 3882  FEA234  24 9D                    bit     msgflg          ; <7> -> print msg
 3883  FEA236  10 11                    bpl     nopr
 3884  FEA238                           
 3885  FEA238                   kprint:
 3886  FEA238  8B                       phb
 3887  FEA239  4B                       phk
 3888  FEA23A  AB                       plb                     ; set data bank = program bank
 3889  FEA23B  B9 F5 A1         ?02:    lda     sysmsg,y
 3890  FEA23E  08                       php
 3891  FEA23F  29 7F                    and     #$7F
 3892  FEA241  20 D2 FF                 jsr     FCHROUT
 3893  FEA244  C8                       iny
 3894  FEA245  28                       plp
 3895  FEA246  10 F3                    bpl     ?02
 3896  FEA248  AB                       plb
 3897  FEA249  18               nopr:   clc
 3898  FEA24A  60                       rts
 3899  FEA24B                           
 3900                           ;---------------------------------------------------------------------------
 3901                           ; kernal miscellaneous
 3902                           ;---------------------------------------------------------------------------
 3903  FEA24B                           
 3904  FEA24B                   _setmsg:
 3905  FEA24B  85 9D                    sta     msgflg
 3906  FEA24D  60                       rts
 3907                           
 3908  FEA24E                   _memtop:
 3909  FEA24E  90 05                    bcc     ?02
 3910  FEA250  A6 A9                    ldx     topmem
 3911  FEA252  A4 AA                    ldy     topmem+1
 3912  FEA254  60                       rts
 3913  FEA255  86 A9            ?02:    stx     topmem
 3914  FEA257  84 AA                    sty     topmem+1
 3915  FEA259  60                       rts
 3916                           
 3917  FEA25A                   _membot:
 3918  FEA25A  90 05                    bcc     ?02
 3919  FEA25C  A6 A7                    ldx     botmem
 3920  FEA25E  A4 A8                    ldy     botmem+1
 3921  FEA260  60                       rts
 3922  FEA261  86 A7            ?02:    stx     botmem
 3923  FEA263  84 A8                    sty     botmem+1
 3924  FEA265  60                       rts
 3925                           
 3926  FEA266                   _scnkey:
 3927  FEA266                           SCNKEYFLG
 3928  FEA266  02 18                    cop     $18
 3929  FEA268  05                       .DB     $05
 3930                                   .MNLIST
 3931  FEA269  85 92                    sta     keyfg
 3932  FEA26B  86 95                    stx     keytg
  Tue Jul 17 11:00:23 2018                                                                                               Page   25




 3933  FEA26D  84 94                    sty     keysh
 3934  FEA26F  60                       rts
 3935  FEA270                                   
 3936  FEA270                   _readst:
 3937  FEA270  A5 90                    lda     kstat
 3938  FEA272  60                       rts
 3939                           
 3940  FEA273                   _setlfs:
 3941  FEA273  85 B8                    sta     lacur
 3942  FEA275  86 BA                    stx     facur
 3943  FEA277  84 B9                    sty     sacur
 3944  FEA279  60                       rts
 3945  FEA27A                           
 3946  FEA27A                   _setnam:
 3947  FEA27A  85 B7                    sta     fnlen
 3948  FEA27C  86 BB                    stx     fnadr
 3949  FEA27E  84 BC                    sty     fnadr+1
 3950  FEA280  60                       rts
 3951                           
 3952  FEA281                   _load:
 3953  FEA281  60                       rts
 3954  FEA282                           
 3955  FEA282                   _save:
 3956  FEA282  60                       rts
 3957                           
 3958                           ; set jiffy clock
 3959                           ; C = 16 bit low, XY = 16 bit high
 3960  FEA283                   _settim:
 3961  FEA283  78                       sei
 3962  FEA284  0B                       phd
 3963  FEA285  F4 00 00                 pea     #0
 3964  FEA288  2B                       pld
 3965  FEA289  85 00                    sta     <JiffyClk
 3966  FEA28B  EB                       xba
 3967  FEA28C  85 01                    sta     <JiffyClk+1
 3968  FEA28E  86 02                    stx     <JiffyClk+2
 3969  FEA290  84 03                    sty     <JiffyClk+3
 3970  FEA292  2B                       pld
 3971  FEA293  58                       cli
 3972  FEA294  60                       rts
 3973                           
 3974                           ; get jiffy clock
 3975                           ; C = 16 bit low, XY = 16 bit high      
 3976  FEA295                   _rdtim:
 3977  FEA295  78                       sei
 3978  FEA296  0B                       phd
 3979  FEA297  F4 00 00                 pea     #0
 3980  FEA29A  2B                       pld
 3981  FEA29B  A5 01                    lda     <JiffyClk+1
 3982  FEA29D  EB                       xba
 3983  FEA29E  A5 00                    lda     <JiffyClk
 3984  FEA2A0  A6 02                    ldx     <JiffyClk+2
 3985  FEA2A2  A4 03                    ldy     <JiffyClk+3
 3986  FEA2A4  2B                       pld
 3987  FEA2A5  58                       cli
 3988  FEA2A6  60                       rts
 3989  FEA2A7                           
  Tue Jul 17 11:00:23 2018                                                                                               Page   26




 3990  FEA2A7                   _chkstop:
 3991  FEA2A7                           SCNKEYBRK
 3992  FEA2A7  02 18                    cop     $18
 3993  FEA2A9  07                       .DB     $07
 3994                                   .MNLIST
 3995  FEA2AA  C9 80                    cmp     #$80            ; set ZF if = $80 (ctrl break detected)
 3996  FEA2AC  D0 05                    bne     ?02
 3997  FEA2AE  08                       php
 3998  FEA2AF  20 10 A1                 jsr     _clrch          ; restore default devices
 3999  FEA2B2  28                       plp
 4000  FEA2B3  60               ?02:    rts
 4001                           
 4002  FEA2B4                   _scrorg:
 4003  FEA2B4                           SCNGETORG
 4004  FEA2B4  02 18                    cop     $18
 4005  FEA2B6  04                       .DB     $04
 4006                                   .MNLIST
 4007  FEA2B7  60                       rts
 4008                           
 4009  FEA2B8                   _scrplot:
 4010  FEA2B8  90 04                    bcc     ?02             ; set pos
 4011  FEA2BA                           SCNGETPOS
 4012  FEA2BA  02 18                    cop     $18
 4013  FEA2BC  02                       .DB     $02
 4014                                   .MNLIST
 4015  FEA2BD  60                       rts
 4016  FEA2BE                   ?02:    SCNSETPOS
 4017  FEA2BE  02 18                    cop     $18
 4018  FEA2C0  03                       .DB     $03
 4019                                   .MNLIST
 4020  FEA2C1  60                       rts
 4021  FEA2C2                           
 4022  FEA2C2                   _iobase:
 4023  FEA2C2  A2 00                    ldx     #$00
 4024  FEA2C4  A0 FD                    ldy     #$FD
 4025  FEA2C6  60                       rts
 4026  FEA2C7                           
 4027  FEA2C7                   _cinit:
 4028  FEA2C7                           SCNINIT
 4029  FEA2C7  02 18                    cop     $18
 4030  FEA2C9  00                       .DB     $00
 4031                                   .MNLIST
 4032  FEA2CA  60                       rts
 4033                           
 4034                           ; cold start ram init (Y = $80 if basic, $00 if pascal) 
 4035  FEA2CB                   _ramtas:
 4036  FEA2CB  AF 80 FF FE              lda     >TXTBNK         ; current data bank
 4037  FEA2CF  48                       pha
 4038  FEA2D0  AB                       plb                     ; set current data bank
 4039  FEA2D1                           ACC16
 4040  FEA2D1  C2 20                    rep     #PMFLAG
 4041                                   .LONGA  on
 4042                                   .MNLIST
 4043  FEA2D3  AF 7E FF FE              lda     >CBMDP          ; set current direct page
 4044  FEA2D7  5B                       tcd
 4045  FEA2D8  A2 00                    ldx     #0              ; clear page 0
 4046  FEA2DA  74 00            ?02:    stz     <$00,x
  Tue Jul 17 11:00:23 2018                                                                                               Page   27




 4047                                   ;stz    !cbmwork,x
 4048  FEA2DC  E8                       inx
 4049  FEA2DD  E8                       inx
 4050  FEA2DE  D0 FA                    bne     ?02
 4051  FEA2E0  8B                       phb
 4052  FEA2E1  FA                       plx
 4053  FEA2E2  86 A1                    stx     tbnk            ; +0: text bank
 4054  FEA2E4  E8                       inx
 4055  FEA2E5  86 A2                    stx     vbnk            ; +1: var/pcode bank
 4056  FEA2E7  E8                       inx
 4057  FEA2E8  86 A5                    stx     xbnk            ; +2: exchange bank
 4058  FEA2EA  E8                       inx
 4059  FEA2EB  86 A3                    stx     cbnk            ; +3: compiler/tmp bank
 4060  FEA2ED  E8                       inx
 4061  FEA2EE  86 A4                    stx     jbnk            ; +4: object code bank for compiler (3 bank)
 4062  FEA2F0  E8                       inx
 4063  FEA2F1  E8                       inx
 4064  FEA2F2  E8                       inx
 4065  FEA2F3  86 A6                    stx     dbnk            ; +7: ram disk
 4066  FEA2F5  84 96                    sty     basic           ; setup basic flag
 4067  FEA2F7  A6 A2                    ldx     vbnk            ; clear working area in var/p-code bank
 4068  FEA2F9  20 93 A3                 jsr     ?30
 4069  FEA2FC  A6 A5                    ldx     xbnk            ; clear working area in exchange bank
 4070  FEA2FE  20 93 A3                 jsr     ?30     
 4071  FEA301  A6 A3                    ldx     cbnk            ; clear working area in compiler/tmp bank
 4072  FEA303  20 93 A3                 jsr     ?30
 4073  FEA306  A0 00                    ldy     #0              ; set up bank 0
 4074  FEA308  5A                       phy
 4075  FEA309  AB                       plb
 4076  FEA30A  AC 0C 00                 ldy     !Bnk0Flag       ; bit 6 mean warm reset
 4077  FEA30D  84 5E                    sty     tmpval+1        ; high in 16 bits!
 4078  FEA30F  AF 7A FF FE              lda     >TOPVAR
 4079  FEA313  85 B3                    sta     vartop          ; setup top mem. basic var/pcode/ex bank
 4080  FEA315  A6 A1                    ldx     tbnk            ; set up current working bank
 4081  FEA317  DA                       phx
 4082  FEA318  AB                       plb
 4083  FEA319  A0 00                    ldy     #$00
 4084  FEA31B  24 5D                    bit     tmpval          ; flag warm reset in tmpval + 1
 4085  FEA31D  70 05                    bvs     ?04             ; was warm reset
 4086  FEA31F  20 95 A3                 jsr     ?32             ; clear working area of text-bank
 4087  FEA322  80 33                    bra     ?14
 4088  FEA324  AD FE FF         ?04:    lda     !XBVSGN         ; check valid signature for text in x-bank
 4089  FEA327  C9 55 AA                 cmp     #VALIDSGN
 4090  FEA32A  D0 07                    bne     ?06             ; not valid
 4091  FEA32C  A2 80                    ldx     #$80            ; bit 7 -> flag valid source text in x-bank
 4092  FEA32E  AD FC FF                 lda     !XTOP2          ; set the end of text pointer
 4093  FEA331  80 08                    bra     ?08     
 4094  FEA333  9C FE FF         ?06:    stz     !XBVSGN         ; clear signature
 4095  FEA336  9C FC FF                 stz     !XTOP2
 4096  FEA339  98                       tya                     ; A = 0
 4097  FEA33A  BB                       tyx                     ; X = 0
 4098  FEA33B  86 8F            ?08:    stx     vxflag          ; set flag
 4099  FEA33D  85 B5                    sta     xtop            ; top of text end on x-bank
 4100  FEA33F  BB                       tyx                     ; clear working area
 4101  FEA340  9E 00 FF         ?12:    stz     !$FF00,x
 4102  FEA343  E8                       inx
 4103  FEA344  E8                       inx
  Tue Jul 17 11:00:23 2018                                                                                               Page   28




 4104  FEA345  E0 F8                    cpx     #$F8
 4105  FEA347  90 F7                    bcc     ?12
 4106  FEA349  AD FA FF                 lda     !TXTVSGN
 4107  FEA34C  C9 55 AA                 cmp     #VALIDSGN
 4108  FEA34F  F0 06                    beq     ?14             ; possible valid source text in buffer
 4109  FEA351  9C FA FF                 stz     !TXTVSGN
 4110  FEA354  9C F8 FF                 stz     !TXTEND2
 4111  FEA357  A9 01 01         ?14:    lda     #$0101
 4112  FEA35A  8D 00 FF                 sta     !cbmwork        ; used by editor
 4113  FEA35D  A9 00 FF                 lda     #cbmwork        ; set top mem
 4114  FEA360  85 A9                    sta     topmem
 4115  FEA362  64 76                    stz     longp
 4116  FEA364  A6 A5                    ldx     xbnk
 4117  FEA366  86 78                    stx     longp+2
 4118  FEA368  98                       tya
 4119  FEA369                           ACC08
 4120  FEA369  E2 20                    sep     #PMFLAG
 4121                                   .LONGA  off
 4122                                   .MNLIST
 4123  FEA36B  87 76                    sta     [longp]         ; first byte always null
 4124  FEA36D                           ACC16
 4125  FEA36D  C2 20                    rep     #PMFLAG
 4126                                   .LONGA  on
 4127                                   .MNLIST
 4128  FEA36F  AD F8 FF                 lda     !TXTEND2
 4129  FEA372  85 5D                    sta     tmpval          ; save end of text to recover   
 4130  FEA374  AD FA FF                 lda     !TXTVSGN
 4131  FEA377  C9 55 AA                 cmp     #VALIDSGN
 4132  FEA37A                           CPU08
 4133  FEA37A  E2 30                    sep     #(PMFLAG.OR.PXFLAG)
 4134                                   .LONGA  off
 4135                                   .LONGI  off
 4136                                   .MNLIST
 4137  FEA37C  D0 04                    bne     ?16
 4138  FEA37E  A9 40                    lda     #$40            ; bit 6 -> possible valid source text
 4139  FEA380  04 8F                    tsb     vxflag
 4140  FEA382  A2 03            ?16:    ldx     #3
 4141  FEA384  86 9A                    stx     dflto           ; default output device
 4142  FEA386  A9 0A                    lda     #$0A
 4143  FEA388  85 9F                    sta     wauto
 4144  FEA38A  A9 80                    lda     #$80
 4145  FEA38C  85 9E                    sta     autof
 4146  FEA38E  A9 40                    lda     #$40
 4147  FEA390  04 96                    tsb     basic           ; editor/emulator mode flag
 4148  FEA392  60                       rts
 4149                           
 4150  FEA393  DA               ?30:    phx                     ; clear working area bank = X
 4151  FEA394  AB                       plb
 4152  FEA395  A2 00            ?32:    ldx     #0              ; clear working area in bank
 4153  FEA397  9E 00 FF         ?34:    stz     !$FF00,x
 4154  FEA39A  E8                       inx
 4155  FEA39B  E8                       inx
 4156  FEA39C  D0 F9                    bne     ?34
 4157  FEA39E  60                       rts
 4158  FEA39F                           
 4159  FEA39F                   _ikeybuf:
 4160  FEA39F  8B                       phb                     ; insert string in keyboard input buffer
  Tue Jul 17 11:00:23 2018                                                                                               Page   29




 4161  FEA3A0  FA                       plx                     ; X = data bank, C = address
 4162  FEA3A1                           SCNKEYBUF
 4163  FEA3A1  02 18                    cop     $18
 4164  FEA3A3  08                       .DB     $08
 4165                                   .MNLIST
 4166  FEA3A4  60                       rts
 4167                           
 4168                           ; cold start CBM emulator
 4169                           ; In    - Y = $00 -> pascal mode
 4170                           ;         Y = $80 -> basic mode
 4171  FEA3A5                   _cold:
 4172  FEA3A5  08                       php                     ; save caller context
 4173  FEA3A6  8B                       phb
 4174  FEA3A7  0B                       phd                     ; status, data bank and direct page
 4175  FEA3A8                           CPU08
 4176  FEA3A8  E2 30                    sep     #(PMFLAG.OR.PXFLAG)
 4177                                   .LONGA  off
 4178                                   .LONGI  off
 4179                                   .MNLIST
 4180  FEA3AA  20 87 FF                 jsr     RAMTAS          ; init memory
 4181  FEA3AD                           ACC16
 4182  FEA3AD  C2 20                    rep     #PMFLAG
 4183                                   .LONGA  on
 4184                                   .MNLIST
 4185  FEA3AF  3B                       tsc
 4186  FEA3B0  85 C0                    sta     curstk          ; current operative stack
 4187  FEA3B2                           ACC08
 4188  FEA3B2  E2 20                    sep     #PMFLAG
 4189                                   .LONGA  off
 4190                                   .MNLIST
 4191  FEA3B4  20 2C A4                 jsr     _basinit
 4192  FEA3B7  20 81 FF                 jsr     CINIT
 4193  FEA3BA  A5 8F                    lda     vxflag          ; save recovery flag
 4194  FEA3BC  85 5A                    sta     tmpb2
 4195  FEA3BE  20 91 06                 jsr     cbm_new2        ; this clear recovery flag
 4196  FEA3C1  24 5A                    bit     tmpb2
 4197  FEA3C3  50 4B                    bvc     ?20
 4198  FEA3C5                           ACC16CLC                ; attempt to recover a source text
 4199  FEA3C5  C2 21                    rep     #(PMFLAG.OR.PCFLAG)
 4200                                   .LONGA  on
 4201                                   .MNLIST
 4202  FEA3C7  A5 AB                    lda     txtbeg          ; attempt to relink
 4203  FEA3C9  85 76                    sta     longp
 4204  FEA3CB                           ACC08
 4205  FEA3CB  E2 20                    sep     #PMFLAG
 4206                                   .LONGA  off
 4207                                   .MNLIST
 4208  FEA3CD  A0 03                    ldy     #$03            ; search end of line
 4209  FEA3CF  C8               ?04:    iny
 4210  FEA3D0  B1 76                    lda     (longp),y
 4211  FEA3D2  D0 FB                    bne     ?04
 4212  FEA3D4  C8                       iny
 4213  FEA3D5                           ACC16CLC
 4214  FEA3D5  C2 21                    rep     #(PMFLAG.OR.PCFLAG)
 4215                                   .LONGA  on
 4216                                   .MNLIST
 4217  FEA3D7  98                       tya
  Tue Jul 17 11:00:23 2018                                                                                               Page   30




 4218  FEA3D8  65 76                    adc     longp
 4219  FEA3DA  85 5F                    sta     tlnptr          ; possible first link
 4220  FEA3DC  85 76            ?06:    sta     longp           ; check all link
 4221  FEA3DE  B2 76                    lda     (longp)
 4222  FEA3E0  F0 15                    beq     ?10             ; end of text
 4223  FEA3E2                           ACC08
 4224  FEA3E2  E2 20                    sep     #PMFLAG
 4225                                   .LONGA  off
 4226                                   .MNLIST
 4227  FEA3E4  A0 03                    ldy     #$03            ; search end of line
 4228  FEA3E6  C8               ?08:    iny
 4229  FEA3E7  B1 76                    lda     (longp),y
 4230  FEA3E9  D0 FB                    bne     ?08
 4231  FEA3EB  C8                       iny
 4232  FEA3EC                           ACC16CLC
 4233  FEA3EC  C2 21                    rep     #(PMFLAG.OR.PCFLAG)
 4234                                   .LONGA  on
 4235                                   .MNLIST
 4236  FEA3EE  98                       tya
 4237  FEA3EF  65 76                    adc     longp           ; compare with stored link
 4238  FEA3F1  D2 76                    cmp     (longp)
 4239  FEA3F3  F0 E7                    beq     ?06             ; check next link
 4240  FEA3F5  D0 17                    bne     ?15             ; mismatch: invalid source text
 4241  FEA3F7  A5 76            ?10:    lda     longp
 4242  FEA3F9  1A                       inc     a
 4243  FEA3FA  1A                       inc     a
 4244  FEA3FB  C5 5D                    cmp     tmpval          ; compare with saved end of text
 4245  FEA3FD  D0 0F                    bne     ?15             ; failed recovery
 4246  FEA3FF  85 AD                    sta     txtend
 4247  FEA401  8D F8 FF                 sta     !TXTEND2        ; valid signature
 4248  FEA404  A5 5F                    lda     tlnptr          ; setup first link
 4249  FEA406  92 AB                    sta     (txtbeg)
 4250  FEA408  A9 55 AA                 lda     #VALIDSGN
 4251  FEA40B  8D FA FF                 sta     !TXTVSGN
 4252  FEA40E                   ?15:    ACC08   
 4253  FEA40E  E2 20                    sep     #PMFLAG
 4254                                   .LONGA  off
 4255                                   .MNLIST
 4256  FEA410  4C A4 01         ?20:    jmp     cbm_rdy 
 4257  FEA413                           
 4258  FEA413                   _mon:
 4259  FEA413  A9 FF                    lda     #$FF    
 4260  FEA415  22 00 00 FF              jsl     MONITOR
 4261  FEA419                           ACC16
 4262  FEA419  C2 20                    rep     #PMFLAG
 4263                                   .LONGA  on
 4264                                   .MNLIST
 4265  FEA41B  AF 7E FF FE              lda     >CBMDP          ; set current direct page
 4266  FEA41F  5B                       tcd
 4267  FEA420                           ACC08
 4268  FEA420  E2 20                    sep     #PMFLAG
 4269                                   .LONGA  off
 4270                                   .MNLIST
 4271  FEA422  A5 A1                    lda     tbnk
 4272  FEA424  48                       pha
 4273  FEA425  AB                       plb
 4274  FEA426                   _warm:
  Tue Jul 17 11:00:23 2018                                                                                               Page   31




 4275  FEA426  20 CB 06                 jsr     cbm_res
 4276  FEA429  4C A4 01                 jmp     cbm_rdy
 4277  FEA42C                           
 4278                           ; init basic memory
 4279  FEA42C                   _basinit:
 4280  FEA42C  38                       sec
 4281  FEA42D  20 9C FF                 jsr     MEMBOT          ; get bottom of memory
 4282  FEA430  86 AB                    stx     txtbeg
 4283  FEA432  84 AC                    sty     txtbeg+1
 4284  FEA434  38                       sec
 4285  FEA435  20 99 FF                 jsr     MEMTOP          ; get top of memory
 4286  FEA438  86 AF                    stx     txttop
 4287  FEA43A  84 B0                    sty     txttop+1
 4288  FEA43C  86 33                    stx     freetop
 4289  FEA43E  84 34                    sty     freetop+1
 4290  FEA440  24 96                    bit     basic
 4291  FEA442  30 06                    bmi     ?02
 4292  FEA444  A9 80                    lda     #$80
 4293  FEA446  85 9B                    sta     skpbk
 4294  FEA448  85 9C                    sta     w2sf
 4295  FEA44A  A2 1B            ?02:    ldx     #$1B
 4296  FEA44C  86 16                    stx     tmppt
 4297  FEA44E  A9 00                    lda     #0
 4298  FEA450  85 68                    sta     facov
 4299  FEA452  85 53                    sta     prompt
 4300  FEA454  92 AB                    sta     (txtbeg)
 4301  FEA456  E6 AB                    inc     txtbeg
 4302  FEA458  D0 02                    bne     ?20
 4303  FEA45A  E6 AC                    inc     txtbeg+1
 4304  FEA45C  60               ?20:    rts
 4305                           
 4306                                   .CBMJMP
 4307                           
 4308                                   .LONGA off
 4309                                   .LONGI off
 4310                           
 4311  FEFF00                           .ORG    $00
 4312                           
 4313                           ; $FF00 - cold start
 4314  FEFF00  4C A5 A3                 jmp     _cold
 4315                           ; $FF03 - warm start
 4316  FEFF03  4C 26 A4                 jmp     _warm
 4317                           
 4318  FEFF30                           .ORG    $30
 4319                           ; jump table for pascal compiler
 4320  FEFF30                           
 4321                                   .EXTERN L0836, L083C, L083F, L0842, L0845, L084B, L084E, L0851
 4322                                   .EXTERN L0854, L0857
 4323  FEFF30                           
 4324                           ; $FF30 ($0836)
 4325  FEFF30  4C E5 35                 jmp     L0836
 4326                           ; $FF33 ($083C)
 4327  FEFF33  4C 98 35                 jmp     L083C
 4328                           ; $FF36 ($083F)
 4329  FEFF36  4C 30 36                 jmp     L083F
 4330                           ; $FF39 ($0842)
 4331  FEFF39  4C EE 36                 jmp     L0842
  Tue Jul 17 11:00:23 2018                                                                                               Page   32




 4332                           ; $FF3C ($0845)
 4333  FEFF3C  4C 16 37                 jmp     L0845
 4334                           ; $FF3F ($084B)
 4335  FEFF3F  4C EE 35                 jmp     L084B
 4336                           ; $FF42 ($084E)
 4337  FEFF42  4C F4 34                 jmp     L084E
 4338                           ; $FF45 ($0851)
 4339  FEFF45  4C 52 35                 jmp     L0851
 4340                           ; $FF48 ($0854)
 4341  FEFF48  4C 3B 37                 jmp     L0854
 4342                           ; $FF4B ($0857)
 4343  FEFF4B  4C 35 37                 jmp     L0857
 4344                           
 4345  FEFF4E                           
 4346  FEFF7A                           .ORG    $7A
 4347                           
 4348  FEFF7A  00FF             TOPVAR:         .DW     $FF00   ; top of memory reserved to var/pcode
 4349  FEFF7C  E0FF             TOPMRD:         .DW     $FFE0   ; top of memory reserved to ram disk
 4350  FEFF7E  007F             CBMDP:          .DW     $7F00   ; direct page used by CBM emulator              
 4351  FEFF80  10               TXTBNK:         .DB     $10     ; bank that hold text buffer
 4352  FEFF81                           
 4353                           ; $FF81 - CINIT
 4354  FEFF81  4C C7 A2                 jmp     _cinit
 4355                           ; $FF84 - IOINIT (no op)
 4356  FEFF84  EA                       nop
 4357  FEFF85  18                       clc
 4358  FEFF86  60                       rts
 4359                           ; $FF87 - RAMTAS
 4360  FEFF87  4C CB A2                 jmp     _ramtas
 4361                           ; $FF8A - RESTOR (no op)
 4362  FEFF8A  EA                       nop
 4363  FEFF8B  18                       clc
 4364  FEFF8C  60                       rts
 4365                           ; $FF8D - VECTOR (no op)
 4366  FEFF8D  EA                       nop
 4367  FEFF8E  18                       clc
 4368  FEFF8F  60                       rts
 4369                           ; $FF90 - SETMSG
 4370  FEFF90  4C 4B A2                 jmp     _setmsg
 4371                           ; $FF93 - SECOND (no op)
 4372  FEFF93  EA                       nop
 4373  FEFF94  18                       clc
 4374  FEFF95  60                       rts
 4375                           ; $FF96 - TKSA (no op)
 4376  FEFF96  EA                       nop
 4377  FEFF97  18                       clc
 4378  FEFF98  60                       rts
 4379                           ; $FF99 - MEMTOP
 4380  FEFF99  4C 4E A2                 jmp     _memtop
 4381                           ; $FF9C - MEMBOT
 4382  FEFF9C  4C 5A A2                 jmp     _membot
 4383                           ; $FF9F - SCNKEY
 4384  FEFF9F  4C 66 A2                 jmp     _scnkey
 4385                           ; $FFA2 - SETTMO (no op)
 4386  FEFFA2  EA                       nop
 4387  FEFFA3  18                       clc
 4388  FEFFA4  60                       rts
  Tue Jul 17 11:00:23 2018                                                                                               Page   33




 4389                           ; $FFA5 - ACPTR
 4390  FEFFA5  4C 5D 9F                 jmp     iecin
 4391                           ; $FFA8 - CIOUT
 4392  FEFFA8  4C 2D 9F                 jmp     iecout
 4393                           ; $FFAB - UNTLK (no op)
 4394  FEFFAB  EA                       nop
 4395  FEFFAC  18                       clc
 4396  FEFFAD  60                       rts
 4397                           ; $FFAE - UNLSN (no op)
 4398  FEFFAE  EA                       nop
 4399  FEFFAF  18                       clc
 4400  FEFFB0  60                       rts
 4401                           ; $FFB1 - LISTEN (no op)
 4402  FEFFB1  EA                       nop
 4403  FEFFB2  18                       clc
 4404  FEFFB3  60                       rts
 4405                           ; $FFB4 - TALK (no op)
 4406  FEFFB4  EA                       nop
 4407  FEFFB5  18                       clc
 4408  FEFFB6  60                       rts
 4409                           ; $FFB7 - READST
 4410  FEFFB7  4C 70 A2                 jmp     _readst
 4411                           ; $FFBA - SETLFS
 4412  FEFFBA  4C 73 A2                 jmp     _setlfs
 4413                           ; $FFBD - SETNAM
 4414  FEFFBD  4C 7A A2                 jmp     _setnam
 4415                           ; $FFC0 - FOPEN
 4416  FEFFC0  4C 64 A0                 jmp     _open
 4417                           ; $FFC3 - FCLOSE
 4418  FEFFC3  4C 26 A1                 jmp     _close
 4419                           ; $FFC6 - FSETIN
 4420  FEFFC6  4C B1 A0                 jmp     _chkin
 4421                           ; $FFC9 - FSETOUT
 4422  FEFFC9  4C D9 A0                 jmp     _chkout
 4423                           ; $FFCC - FCLRCH
 4424  FEFFCC  4C 10 A1                 jmp     _clrch
 4425                           ; $FFCF - FCHRIN
 4426  FEFFCF  4C 42 A0                 jmp     _chrin
 4427                           ; $FFD2 - FCHROUT
 4428  FEFFD2  4C 18 A0                 jmp     _chrout
 4429                           ; $FFD5 - FLOAD
 4430  FEFFD5  4C 81 A2                 jmp     _load
 4431                           ; $FFD8 - FSAVE
 4432  FEFFD8  4C 82 A2                 jmp     _save
 4433                           ; $FFDB - SETTIM
 4434  FEFFDB  4C 83 A2                 jmp     _settim
 4435                           ; $FFDE - RDTIM
 4436  FEFFDE  4C 95 A2                 jmp     _rdtim
 4437                           ; $FFE1 - CHKSTOP
 4438  FEFFE1  4C A7 A2                 jmp     _chkstop
 4439                           ; $FFE4 -  FGETIN
 4440  FEFFE4  4C 36 A0                 jmp     _getin
 4441                           ; $FFE7 - FCLALL
 4442  FEFFE7  4C 01 A1                 jmp     _clall
 4443                           ; $FFEA - UDTIM (no op)
 4444  FEFFEA  EA                       nop
 4445  FEFFEB  18                       clc
  Tue Jul 17 11:00:23 2018                                                                                               Page   34




 4446  FEFFEC  60                       rts
 4447                           ; $FFED - SCRORG
 4448  FEFFED  4C B4 A2                 jmp     _scrorg
 4449                           ; $FFF0 - SCRPLOT
 4450  FEFFF0  4C B8 A2                 jmp     _scrplot
 4451                           ; $FFF3 - GETIOBASE
 4452  FEFFF3  4C C2 A2                 jmp     _iobase
 4453                           ; $FFF6 - IKEYBUF
 4454  FEFFF6  4C 9F A3                 jmp     _ikeybuf
 4455                           ; $FFF9 - GOMON
 4456  FEFFF9  4C 13 A4                 jmp     _mon


             Lines Assembled : 4328                  Errors : 0