Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
|
|
@ -0,0 +1,27 @@
|
|||
doMultiply:
|
||||
;returns HL = HL times A. No overflow protection.
|
||||
push bc
|
||||
push de
|
||||
rrca ;test if A is odd or even by dividing A by 2.
|
||||
jr c, isOdd
|
||||
;is even
|
||||
|
||||
ld b,a
|
||||
loop_multiplyByEvenNumber:
|
||||
add hl,hl ;double A until B runs out.
|
||||
djnz loop_multiplyByEvenNumber
|
||||
pop de
|
||||
pop bc
|
||||
ret
|
||||
|
||||
isOdd:
|
||||
push hl
|
||||
pop de ;de contains original HL. We'll need it later.
|
||||
ld b,a
|
||||
loop_multiplyByOddNumber:
|
||||
add hl,hl
|
||||
djnz loop_multiplyByOddNumber
|
||||
add hl,de ;now add in original HL for the leftover add.
|
||||
pop de
|
||||
pop bc
|
||||
ret
|
||||
Loading…
Add table
Add a link
Reference in a new issue