1 2 SECTION code_l_sdcc 3 4 PUBLIC l_mul16 5 ;; Parameters: 6 ;; HL, DE (left, right irrelivent) 7 ld b,h 8 ld c,l 9 10 ;; 16-bit multiplication 11 ;; 12 ;; Entry conditions 13 ;; BC = multiplicand 14 ;; DE = multiplier 15 ;; 16 ;; Exit conditions 17 ;; DE = less significant word of product 18 ;; 19 ;; Register used: AF,BC,DE,HL 20l_mul16: 21 ld hl,0 22 ld a,b 23 ; ld c,c 24 ld b,16 25 26 ;; Optimise for the case when this side has 8 bits of data or 27 ;; less. This is often the case with support address calls. 28 or a 29 jp NZ,mul_1 30 31 ld b,8 32 ld a,c 33mul_1: 34 ;; Taken from z88dk, which originally borrowed from the 35 ;; Spectrum rom. 36 add hl,hl 37 rl c 38 rla ;DLE 27/11/98 39 jp NC,mul_2 40 add hl,de 41mul_2: 42 dec b 43 jr NZ,mul_1 44 45 ;; Return in DE 46 ld e,l 47 ld d,h 48 49 ret 50