Difference between revisions of "Programming:Integer Multiplication"
From CPCWiki - THE Amstrad CPC encyclopedia!
(Initial version) |
(No difference)
|
Revision as of 04:04, 26 July 2006
Classic 8bit * 8bit Unsigned
Input: H = Multiplier, E = Multiplicand, L = 0, D = 0
Output: HL = Product
sla h ; optimised 1st iteration jr nc,$+3 ld l,e add hl,hl ; unroll 7 times jr nc,$+3 ; ... add hl,de ; ...
Classic 16bit * 8bit Unsigned
Input: A = Multiplier, DE = Multiplicand, HL = 0, C = 0
Output: A:HL = Product
add a,a ; optimised 1st iteration jr nc,$+4 ld h,d ld l,e add hl,hl ; unroll 7 times rla ; ... jr nc,$+4 ; ... add hl,de ; ... adc a,c ; ...