Monday, October 3, 2022

Updated BASIC hardware multiply patch to enable 6309 native mode

I updated my BASIC multiply patch to enable 6309 native mode during the first call to the multiply code.  The picture below shows a head to head comparison in the speed difference between the standard ROM code, and with this patch.
Just remember, DO NOT USE DISK COMMANDS WHEN 6309 NATIVE MODE IS ENABLED!
It will cause bad things to happen since the fast interrupt is different in native mode.
I may create a USR function to enable/disable it so native mode is under program control, but for now this will do.
 

Thanks to L. Curtis Boyle and William Astle for answering questions, and suggestions for 6309 addition.



REM COCO3 HARDWARE MULTIPLY PATCH.
REM JUST ADD A GOSUB 10000 AT THE TOP OF YOUR CODE TO ADD IT

REM ADDRESS WE ARE STORING THE MULTIPLY PATCH IN RAM
10000 AD=VAL("&HFA0C")
REM POKE THE MULTIPLY PATCH INTO RAM.  THE +17 ON THE FOR LOOP IS TO ADD THE 6309 SUPPORT
REM REMOVE THAT AND LINE 10004 TO GET RID OF 6309 SUPPORT
REM DO NOT USE DISK ACCESS ONCE NATIVE MODE IS ENABLED!
10001 FORI=0 TO 64+17:READ B$:A=VAL("&H"+B$):POKE AD+I,A:NEXT
REM MAKE BASIC JUMP TO OUR MULTIPY INSTEAD OF USING IT'S CODE. $BB00 JMP $FA0C
10002 POKE VAL("&HBB02"),VAL("&H7E"):POKE VAL("&HBB03"),VAL("&HFA"):POKE VAL("&HBB04"),VAL("&H0C")
10003 RETURN
REM THE FOLLOWING LINE ADDS CODE TO CHECK FOR 6309 DURING FIRST CALL TO MULTIPLY
REM IF 6309 IS FOUND, IT TURNS ON NATIVE MODE.  DO NOT DO DISK ACCESS IN NATIVE MODE.  PRESS RESET WILL TO TURN IT OFF
10004 DATA CC,FF,FF,10,4F,5D,26,03,11,3D,01,30,8C,03,BF,BB,03
10005 DATA 32,79,E7,60,96,60,3D,ED,63,E6,60,96,5E,3D,ED,61,E6,60,96,5D
10006 DATA 3D,ED,65,E6,60,96,5F,3D,E3,62,ED,62,EC,65,E9,61,89,00,ED,60
10007 DATA EC,63,D3,15,97,16,D7,63,EC,61,D9,14,99,13,DD,14,A6,60,89,00
10008 DATA 97,13,32,67,39


1 comment:

  1. 6309 mod looks something like this. It was written on the fly, and was hand assembled, so it never fully looked like source code. The discussion is in the assembly area of the coco discord group:

    LDD #$FFFF ; set all bits
    CLRD ; 6309 opcode that runs as 8 bit on 6809
    TSTB ; did it clear B (16 bit)?
    BNE skip ; if not... not a 6309
    LDMD #1 ; enable native mode
    skip:
    LEAX #startaddress,PCR ;normal address for multiply patch
    STX $BB03 ; update where we JMP from ROM to multiply patch
    startaddress:
    ; rest of patch starts here

    ReplyDelete