8 ! 32-bit multiply routine for z80
14 ! register utilization:
15 ! ix: least significant 2 bytes of result
16 ! hl: most significant 2 bytes of result
17 ! bc: least significant 2 bytes of multiplicand
18 ! de: most significant 2 bytes of multiplicand
19 ! iy: 2 bytes of multiplier (first most significant,
20 ! later least significant)
24 pop hl ! return address
26 ld (.mplier+2),de! least significant bytes of
29 ld (.mplier),de ! most sign. bytes
30 pop de ! least significant bytes of
32 pop bc ! most sign. bytes
33 push hl ! return address
39 ld (.flag),a ! indicate that this is
40 ! first pass of main loop
42 ! main loop, done twice, once for each part (2 bytes)
46 ! sub-loop, done 16 times
48 add iy,iy ! shift left multiplier
49 jr nc,3f ! skip if most sign. bit is 0
50 add ix,de ! 32-bit add
54 jr z,4f ! done with this part of multiplier
55 add ix,ix ! 32-bit shift left
59 ! see if we have just processed the first part
60 ! of the multiplier (flag = 0) or the second
66 ld (.flag),a ! set flag
67 ld iy,(.mplier+2)! least significant 2 bytes now in iy
68 add ix,ix ! 32-bit shift left
74 ex (sp),hl ! put most sign. 2 bytes of result
75 ! on stack; put return address in hl
76 push ix ! least sign. 2 bytes of result