;multiplicatiom program DADDY ;input multiplicand in DE and input multiplier in A ;output product in HL, carry set if overflow ;********************** Test for zero and leading zeroes, (8-bit ; factor already determined and placed in A) daddy: ld hl,0 ; Clear output product register ld b,8+1 ; Set bit counter and a ; Is multiplier in A sera? (carry cleared) ret z ; Yes, skip multiplication operation; 0 in HL skip: dec b ; Check multiplier bit rla ; Leading zero? jr nc,skip ; Yes, ignore it and check next bit add hl,de ; No, load HL with multiplicand in DE; carry ; cleared ;********************** Multiplication starts in earnest next: dec b ; More multiplier bits? ret z ; No, return with result in HL add hl,hl ; Yes, do a DAD H, doubling the multiplicand ret c ; Overflow, carry set on return rla ; Is the multiplier bit a 1? jr nc,next ; No, check the next bit add hl,de ; Yes, do a DAD D too, adding the initial jr nc,next ; Check the next bit multiplicand ret ; Overflow, carry set on return end