Thursday, February 22, 2018

Code update

A small code update.  This version checks to see if the MC-10 patch is already installed.  That way any BASIC that installs the patch itself will have the proper JMP to it' ROM stay intact.
This is the output from the assembler.
From left to right, line #, address, hex representation of the assembled code, source code.
You want to trim off the line number column, address column and original code.
Then convert the hexadecimal values to decimals.  That's what goes in the DATA statements.

*edit* this has been updated again in an attempt to improve compatibility.

0001   0000             ; Simple speed up for MC-10 Microcolor BASIC
0002   0000             ; (C) 2018  James Diffendaffer
0003   0000             ; May be freely redistributed
0004   0000             ; Date:  2/25/2018
0005   0000             ; code to patch the CHRGET function on the direct page
0006   0000             ; chrget is used to parse through the BASIC code and gets called a lot.
0007   0000             ; by checking the most frequent case in RAM, it saves a 3 clock cycle jmp
0008   0000             ; to the remainder of the function in ROM.  
0009   0000             
0010   0000             ; definitions for the TASM cross assembler needed for 6803 syntax
0011   0000             .MSFIRST        ; Most Significant byte first
0012   0000             
0013   0000             #define EQU     .EQU
0014   0000             #define ORG     .ORG
0015   0000             #define RMB     .BLOCK
0016   0000             #define FCB     .BYTE
0017   0000             #define FCC     .TEXT
0018   0000             #define FDB     .WORD
0019   0000             #define END .END
0020   0000             #define FCS .TEXT
0021   0000             
0022   0000             #define equ     .EQU
0023   0000             #define org     .ORG
0024   0000             #define rmb     .BLOCK
0025   0000             #define fcb     .BYTE
0026   0000             #define fcc     .TEXT
0027   0000             #define fdb     .WORD
0028   0000             #define end .END
0029   0000             #define fcs .TEXT
0030   0000             
0031   0000             ;start of code
0032   434B              org $434B ;1st address after a REM on the first line of codeof the program.
0033   434B              ;this is constant on startup in Microcolor BASIC
0034   434B             
0035   434B 3C          pshx ;preserve register contents
0036   434C 36          psha
0037   434D 37          pshb
0038   434E 96 F6        ldaa $F6
0039   4350 91 7E        cmpa $7E ; is it a jmp instruction?
0040   4352 26 16        bne exit ; if not we exit
0041   4354             
0042   4354 DC 7F        ldd $7F ; grab the current address JMP calls
0043   4356 C3 00 04    addd #$4 ; hopefully this will skip the compare & branch now on the direct page
0044   4359 DD FC        std $FC ; save it at the end of the new code
0045   435B             
0046   435B CE 43 6E    ldx #PATCH ; get the address of our patch code minus 1 (to avoid using LDD 0,X)
0047   435E EC 01        ldd 1,X ; get the firs two bytes
0048   4360 DD F6        std $F6 ; save them
0049   4362 EC 03        ldd 3,x ; get the next two
0050   4364 DD F8        std $F8 ; etc...
0051   4366 EC 05        ldd 5,x
0052   4368 DD FA        std $FA
0053   436A             exit:
0054   436A 33          pulb ; restore registers
0055   436B 32          pula
0056   436C 38          pulx
0057   436D             
0058   436D 39          rts ; return to BASIC
0059   436E             
0060   436E             ; contains the patch
0061   436E             PATCH:
0062   436E F0          FCB $F0 ; dummy byte so LDD doesn't have to use LDD 0,X
0063   436F             ; org $00F6 ; the address the patch is meant to run at.  Not really needed due to relative branch.
0064   436F 81 3A        cmpa      #':' ; set Z flag if statement separator
0065   4371 25 01        bcs       AA ; perform more tests if not
0066   4373 39          rts ; return if >= ':' 
0067   4374 7E E1 CC    AA jmp $E1CC ; jump to the parser back end.  The address can be dropped 
0068   4377              ; - because we copy the current one plus 4 now
0069   4377             
0070   4377              end
0071   4377              tasm: Number of errors = 0

No comments:

Post a Comment