Darren from the yahoo MC-10 group suggested this change.
The patch code is relocatable now in case the normal start address of a BASIC program is different on some machine.
The BASIC code has the new DATA, but the POKE and EXEC are still position dependent.
0 REM01234567890123456789012345678901234567890123456
1 DATA 60,54,55,150,246,129,126,38,26,220,247,195,1,5
2 DATA 131,1,1,221,252,141,1,1,56,236,18,221,246,236,20,221
3 DATA 248,236,22,221,250,51,50,56,57,129,58,37,1,57,126
4 FORI=0TO44:READ A:POKE 17227+I,A:NEXT:STOP
5 EXEC17227
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/28/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 81 7E cmpa #$7E ; is it a jmp instruction?
0040 4352 26 1A bne exit ; if not we exit
0041 4354
0042 4354 DC F7 ldd $F7 ; grab the current address JMP calls
0043 4356 C3 01 05 addd #$0105 ; hopefully this will skip the compare & branch now on the direct page
0044 4359 83 01 01 subd #$0101 ; - to avoid putting a zero in the code.
0045 435C DD FC std $FC ; save it at the end of the new code
0046 435E
0047 435E ; ldx #PATCH ; get the address of our patch code minus 1 (to avoid using LDD 0,X)
0048 435E ;pc relative version of ldx to make code relocatable
0049 435E 8D 01 bsr pcRel+1 ; push PC (avoiding zero byte)
0050 4360 pcRel:
0051 4360 01 nop ; origin for PC-relative indexing
0052 4361 38 pulx ; X = pcRel
0053 4362
0054 4362 EC 12 ldd PATCH-pcRel,X ; get the firs two bytes
0055 4364 DD F6 std $F6 ; save them
0056 4366 EC 14 ldd PATCH-pcRel+2,x ; get the next two
0057 4368 DD F8 std $F8 ; etc...
0058 436A EC 16 ldd PATCH-pcRel+4,x
0059 436C DD FA std $FA
0060 436E exit:
0061 436E 33 pulb ; restore registers
0062 436F 32 pula
0063 4370 38 pulx
0064 4371
0065 4371 39 rts ; return to BASIC
0066 4372
0067 4372 ; contains the patch
0068 4372 PATCH:
0069 4372 ; FCB $F0 ; dummy byte so LDD doesn't have to use LDD 0,X
0070 4372 ; org $00F6 ; the address the patch is meant to run at. Not really needed due to relative branch.
0071 4372 81 3A cmpa #':' ; set Z flag if statement separator
0072 4374 25 01 bcs AA ; perform more tests if not
0073 4376 39 rts ; return if >= ':'
0074 4377 7E E1 CC AA jmp $E1CC ; jump to the parser back end. The address can be dropped
0075 437A ; - because we copy the current one plus 4 now
0076 437A
0077 437A end
0078 437A tasm: Number of errors = 0
The patch code is relocatable now in case the normal start address of a BASIC program is different on some machine.
The BASIC code has the new DATA, but the POKE and EXEC are still position dependent.
0 REM01234567890123456789012345678901234567890123456
1 DATA 60,54,55,150,246,129,126,38,26,220,247,195,1,5
2 DATA 131,1,1,221,252,141,1,1,56,236,18,221,246,236,20,221
3 DATA 248,236,22,221,250,51,50,56,57,129,58,37,1,57,126
4 FORI=0TO44:READ A:POKE 17227+I,A:NEXT:STOP
5 EXEC17227
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/28/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 81 7E cmpa #$7E ; is it a jmp instruction?
0040 4352 26 1A bne exit ; if not we exit
0041 4354
0042 4354 DC F7 ldd $F7 ; grab the current address JMP calls
0043 4356 C3 01 05 addd #$0105 ; hopefully this will skip the compare & branch now on the direct page
0044 4359 83 01 01 subd #$0101 ; - to avoid putting a zero in the code.
0045 435C DD FC std $FC ; save it at the end of the new code
0046 435E
0047 435E ; ldx #PATCH ; get the address of our patch code minus 1 (to avoid using LDD 0,X)
0048 435E ;pc relative version of ldx to make code relocatable
0049 435E 8D 01 bsr pcRel+1 ; push PC (avoiding zero byte)
0050 4360 pcRel:
0051 4360 01 nop ; origin for PC-relative indexing
0052 4361 38 pulx ; X = pcRel
0053 4362
0054 4362 EC 12 ldd PATCH-pcRel,X ; get the firs two bytes
0055 4364 DD F6 std $F6 ; save them
0056 4366 EC 14 ldd PATCH-pcRel+2,x ; get the next two
0057 4368 DD F8 std $F8 ; etc...
0058 436A EC 16 ldd PATCH-pcRel+4,x
0059 436C DD FA std $FA
0060 436E exit:
0061 436E 33 pulb ; restore registers
0062 436F 32 pula
0063 4370 38 pulx
0064 4371
0065 4371 39 rts ; return to BASIC
0066 4372
0067 4372 ; contains the patch
0068 4372 PATCH:
0069 4372 ; FCB $F0 ; dummy byte so LDD doesn't have to use LDD 0,X
0070 4372 ; org $00F6 ; the address the patch is meant to run at. Not really needed due to relative branch.
0071 4372 81 3A cmpa #':' ; set Z flag if statement separator
0072 4374 25 01 bcs AA ; perform more tests if not
0073 4376 39 rts ; return if >= ':'
0074 4377 7E E1 CC AA jmp $E1CC ; jump to the parser back end. The address can be dropped
0075 437A ; - because we copy the current one plus 4 now
0076 437A
0077 437A end
0078 437A tasm: Number of errors = 0
No comments:
Post a Comment