;*****************************************************************
; Procedure Name  : multiply_8
;
; Author          : Marc Gale (Xalthorn or Eldara)
;
; Description     : Multiply two bytes together
;
; On Entry        : A = Multiplier
;                   B = Multiplicand
;
; During          : DE is used to store the result
;                   HL are preserved, used and then restored
;
; On Exit         : Nothing intentional.
;*****************************************************************
multiply_8:
 push   hl              ; preserve HL
 ld     hl,0            ; initialise result to zero
 ld     d,0             ; set up DE to hold the ...
 ld     e,b             ; ... multiplicand
 
 add    a,a             ; double the multiplier
 jr     nc,.m1          ; if we didn't need to carry, no effect
 add    hl,de           ; add the multiplicand to the result
.m1
 add    hl,hl           ; double the result
 add    a,a             ; this repeats until we've done it ...
 jr     nc,.m2          ; ... eight times, once per bit
 add    hl,de
.m2
 add    hl,hl
 add    a,a
 jr     nc,.m3
 add    hl,de
.m3
 add    hl,hl
 add    a,a
 jr     nc,.m4
 add    hl,de
.m4
 add    hl,hl
 add    a,a
 jr     nc,.m5
 add    hl,de
.m5
 add    hl,hl
 add    a,a
 jr     nc,.m6
 add    hl,de
.m6
 add    hl,hl
 add    a,a
 jr     nc,.m7
 add    hl,de
.m7
 add    hl,hl
 add    a,a
 jr     nc,.done
 add    hl,de
.done
 ld     d,h                     ; put the result in DE
 ld     e,l
 pop    hl                      ; restore HL
 ret
