The multiply code that will be patched is located at $BB03 in the Color BASIC ROM.
It multplies the FPA1 mantissa by accumulator B, and adds the result to FPA2.
The original code (below) is 43 bytes in length. I'm working on a looping version using the hardware multiply. While it will be much faster than the current ROM, it won't be quite as fast as the code from the MC-10. It just has to fit into those 43 bytes if it's going to work.
;* MULTIPLY FPA1 MANTISSA BY ACCB AND
;* ADD PRODUCT TO FPA2 MANTISSA
LBB03 LDA FPA2 ; GET FPA2 MS BYTE
RORB ; ROTATE CARRY FLAG INTO SHIFT COUNTER;
;* DATA BIT INTO CARRY
BEQ LBB2E ; BRANCH WHEN 8 SHIFTS DONE
BCC LBB20 ; DO NOT ADD FPA1 IF DATA BIT = 0
LDA FPA2+3 ; * ADD MANTISSA LS BYTE
ADDA FPA1+3 ; *
STA FPA2+3 ; *
LDA FPA2+2 ; = ADD MANTISSA NUMBER 3 BYTE
ADCA FPA1+2 ; =
STA FPA2+2 ; =
LDA FPA2+1 ; * ADD MANTISSA NUMBER 2 BYTE
ADCA FPA1+1 ; *
STA FPA2+1 ; *
LDA FPA2 ; = ADD MANTISSA MS BYTE
ADCA FPA1 ; =
LBB20 RORA ; * ROTATE CARRY INTO MS BYTE
STA FPA2 ; *
ROR FPA2+1 ; = ROTATE FPA2 ONE BIT TO THE RIGHT
ROR FPA2+2 ; =
ROR FPA2+3 ; =
ROR FPSBYT ; =
CLRA ; CLEAR CARRY FLAG
BRA LBB03 ; KEEP LOOPING
LBB2E RTS
It multplies the FPA1 mantissa by accumulator B, and adds the result to FPA2.
The original code (below) is 43 bytes in length. I'm working on a looping version using the hardware multiply. While it will be much faster than the current ROM, it won't be quite as fast as the code from the MC-10. It just has to fit into those 43 bytes if it's going to work.
;* MULTIPLY FPA1 MANTISSA BY ACCB AND
;* ADD PRODUCT TO FPA2 MANTISSA
LBB03 LDA FPA2 ; GET FPA2 MS BYTE
RORB ; ROTATE CARRY FLAG INTO SHIFT COUNTER;
;* DATA BIT INTO CARRY
BEQ LBB2E ; BRANCH WHEN 8 SHIFTS DONE
BCC LBB20 ; DO NOT ADD FPA1 IF DATA BIT = 0
LDA FPA2+3 ; * ADD MANTISSA LS BYTE
ADDA FPA1+3 ; *
STA FPA2+3 ; *
LDA FPA2+2 ; = ADD MANTISSA NUMBER 3 BYTE
ADCA FPA1+2 ; =
STA FPA2+2 ; =
LDA FPA2+1 ; * ADD MANTISSA NUMBER 2 BYTE
ADCA FPA1+1 ; *
STA FPA2+1 ; *
LDA FPA2 ; = ADD MANTISSA MS BYTE
ADCA FPA1 ; =
LBB20 RORA ; * ROTATE CARRY INTO MS BYTE
STA FPA2 ; *
ROR FPA2+1 ; = ROTATE FPA2 ONE BIT TO THE RIGHT
ROR FPA2+2 ; =
ROR FPA2+3 ; =
ROR FPSBYT ; =
CLRA ; CLEAR CARRY FLAG
BRA LBB03 ; KEEP LOOPING
LBB2E RTS
No comments:
Post a Comment