home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.barnyard.co.uk
/
2015.02.ftp.barnyard.co.uk.tar
/
ftp.barnyard.co.uk
/
cpm
/
walnut-creek-CDROM
/
ENTERPRS
/
CPM
/
UTILS
/
S
/
Z80ASM24.ZIP
/
TEST2.ASM
< prev
next >
Wrap
Assembly Source File
|
1991-10-06
|
1KB
|
41 lines
mult: ; unsigned sixteen bit integer multiply.
;
; on entrance: multiplier in de.
; multiplicand in hl.
;
; on exit: result in hl.
;
; register uses:
;
;
; h high order partial result
; l low order partial result
; d high order multiplicand
; e low order multiplicand
; b counter for number of shifts
; c high order bits of multiplier
; a low order bits of multiplier
;
ld b,16 ; number of bits- initialize
ld c,d ; move multiplier
ld a,e ;
ld x,y ; should get 'u' error
load a,b ; should get 'o' error
cp 'A' ; test 'x' format
ex de,hl ; move multiplicand
ld hl,0 ; clear partial result
eject ; test eject processing
;
mloop: srl c ; shift multiplier right
rra ; least significant bit is in carry
jr nc,noadd-$ ; if no carry skip the add
add hl,de ; else add multiplicand to partial result
;
noadd: ex de,hl ; shift multiplicand left
add hl,hl ; by multiplying it by two
ex de,hl
djnz mloop-$ ; repeat until no more bits
ret
;
end