So I have a value in HL register pair and would like to multiply it by 64
The obvious solution would be
Code: Select all
ADD HL,HL ; * 2
ADD HL,HL ; * 4
ADD HL,HL ; * 8
ADD HL,HL ; * 16
ADD HL,HL ; * 32
ADD HL,HL ; * 64
Code: Select all
ADD HL,HL ; * 2
ADD HL,HL ; * 4
ADD HL,HL ; * 8
ADD HL,HL ; * 16
ADD HL,HL ; * 32
ADD HL,HL ; * 64
If you want to multiply HL by 64, and store result into HL:
Code: Select all
xor a ; HL = hhhhhhhh llllllll, A = 00000000
rr h
rr l
rra ; HL = 0hhhhhhh hlllllll, A = l0000000
rr h
rr l
rra ; HL = 00hhhhhh hhllllll, A = ll000000
ld h,l
ld l,a ; HL = hhllllll ll000000
Fourteen T states faster.
Code: Select all
;A=N
ld l,a
ld h,mul64/256
ld a,(hl)
inc h
ld h,(hl)
ld l,a