base:short_8bit_multiplication_16bit_product
no way to compare when less than two revisions
Differences
This shows you the differences between two versions of the page.
Previous revisionNext revision | |||
— | base:short_8bit_multiplication_16bit_product [2020-08-29 23:11] – increase performance with one byte cost and FAC2 decremented djmips | ||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== Short 8bit * 8bit = 16bit multiply ====== | ||
+ | |||
+ | A small multiplication routine using the ancient egyptian multiplication algorithm. Factors should be stored in the FAC1 and FAC2 variables, the product can be found in Akku (high byte) and the X-Register (low byte). FAC1 will be destroyed. FAC2 is modified to FAC2-1. No tables required. Mod by djmips to increase performance but increased by one byte in size. There is an unwound version of this posted separately. | ||
+ | |||
+ | < | ||
+ | FAC1 = $58 | ||
+ | FAC2 = $59 | ||
+ | |||
+ | ; A*256 + X = FAC1 * FAC2 | ||
+ | MUL8 | ||
+ | lda #$00 | ||
+ | ldx #$08 | ||
+ | dec FAC2 ; FAC2-1 | ||
+ | clc | ||
+ | m0 bcc m1 | ||
+ | adc FAC2 ; +FAC2-1 + 1 (carry) | ||
+ | m1 ror | ||
+ | ror FAC1 | ||
+ | dex | ||
+ | bpl m0 | ||
+ | ldx FAC1 | ||
+ | rts | ||
+ | </ | ||
base/short_8bit_multiplication_16bit_product.txt · Last modified: 2020-08-30 01:52 by djmips