Sunday, February 25, 2018

An updated version that calls the address the ROM places on the direct page + 2 opcodes.
The last 2 bytes could be dropped because they are now taken from direct page RAM.  But I included them so you can compare it to the assembler output.


0 REM01234567890123456789012345678901234567890123456
1 DATA60,54,55,150,246,129,126,38,25,220,247,195,1,5,131,1,1,221,252,206,67,113,236,1
2 DATA221,246,236,3,221,248,236,5,221,250,51,50,56,57,240,129,58,37,1,57,126
4 FORI=0TO44:READ A:POKE 17227+I,A:NEXT:STOP
5 EXEC17227


I was converting the hex bytes from the assembly output to decimal by hand, but it's time consuming.
This last time I used CoCo Emulation on MESS (MAME) to do the conversions for me.
Remove the first two columns from the output and the original code (to the right of the actual code output), added &H to each hex number, separated them by commas, and used a program to output the decimal values.
 Sorry again for the line wrapping, there isn't a simple code embedding option in the blogger editor.


1 DATA &H3C,&H36,&H37,&H96,&HF6,&H81,&H7E,&H26,&H19,&HDC,&HF7,&HC3,&H01,&H05,&H83,&H01,&H01
2 DATA &HDD,&HFC,&HCE,&H43,&H71,&HEC,&H01,&HDD,&HF6,&HEC,&H03,&HDD,&HF8,&HEC,&H05,&HDD,&HFA
3 DATA &H33,&H32,&H38,&H39,&HF0,&H81,&H3A,&H25,&H01,&H39,&H7E,&HE1,&HCC

4 FORI=0TO44:READ A:PRINTA;:NEXT


And the updated assembler output:
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 81 7E        cmpa #$7E ; is it a jmp instruction?
0040   4352 26 19        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 CE 43 71    ldx #PATCH ; get the address of our patch code minus 1 (to avoid using LDD 0,X)
0048   4361 EC 01        ldd 1,X ; get the firs two bytes
0049   4363 DD F6        std $F6 ; save them
0050   4365 EC 03        ldd 3,x ; get the next two
0051   4367 DD F8        std $F8 ; etc...
0052   4369 EC 05        ldd 5,x
0053   436B DD FA        std $FA
0054   436D             exit:
0055   436D 33          pulb ; restore registers
0056   436E 32          pula
0057   436F 38          pulx
0058   4370             
0059   4370 39          rts ; return to BASIC
0060   4371             
0061   4371             ; contains the patch
0062   4371             PATCH:
0063   4371 F0          FCB $F0 ; dummy byte so LDD doesn't have to use LDD 0,X
0064   4372             ; org $00F6 ; the address the patch is meant to run at.  Not really needed due to relative branch.
0065   4372 81 3A        cmpa      #':' ; set Z flag if statement separator
0066   4374 25 01        bcs       AA ; perform more tests if not
0067   4376 39          rts ; return if >= ':' 
0068   4377 7E E1 CC    AA jmp $E1CC ; jump to the parser back end.  The address can be dropped 
0069   437A              ; - because we copy the current one plus 4 now
0070   437A             
0071   437A              end
0072   437A              tasm: Number of errors = 0

1 comment:

  1. Pretty sad that it's quicker to use technology from the 70s/80s than a modern equivalent.

    ReplyDelete