Rev 1870 | Details | Compare with Previous | Last modification | View Log
Rev | Author | Line No. | Line |
---|---|---|---|
1870 | galstaff | 1 | ;dehl = m |
2 | ;dehl' = n |
||
3 | ;out: dehl = m/n |
||
4 | uintdiv32 |
||
5 | ld a,h |
||
6 | cpl |
||
7 | ld h,a |
||
8 | ld a,l |
||
9 | cpl |
||
10 | ld l,a |
||
11 | ld (.dividendlo),hl |
||
12 | ld a,d |
||
13 | cpl |
||
14 | ld h,a |
||
15 | ld a,e |
||
16 | cpl |
||
17 | ld l,a |
||
18 | ld (.dividendhi),hl |
||
19 | ld a,1 |
||
20 | ld bc,0 |
||
21 | ld de,1 |
||
22 | ld hl,0 |
||
23 | ld iy,0 |
||
24 | ld (.templo),hl |
||
25 | ld (.temphi),hl |
||
26 | exx |
||
27 | ld bc,de |
||
28 | ex de,hl |
||
29 | bit 7,b |
||
30 | jr nz,.rshiftloop |
||
31 | .lshiftloop |
||
32 | sla de |
||
33 | rl bc |
||
34 | exx |
||
35 | sla de |
||
36 | rl bc |
||
37 | exx |
||
38 | inc a |
||
39 | bit 7,b |
||
40 | jr z,.lshiftloop |
||
41 | .rshiftloop |
||
42 | .templo=$+2 |
||
43 | ld ix,0 |
||
44 | .temphi=$+1 |
||
45 | ld hl,0 |
||
46 | add ix,de |
||
47 | adc hl,bc |
||
48 | jr c,.nextbit |
||
49 | push ix |
||
50 | push hl |
||
51 | push de |
||
52 | .dividendlo=$+1 |
||
53 | ld de,0 |
||
54 | add ix,de |
||
55 | .dividendhi=$+1 |
||
56 | ld de,0 |
||
57 | adc hl,de |
||
58 | pop de |
||
59 | pop hl |
||
60 | pop ix |
||
61 | jr c,.nextbit |
||
62 | ld (.templo),ix |
||
63 | ld (.temphi),hl |
||
64 | exx |
||
65 | add iy,de |
||
66 | add hl,bc |
||
67 | exx |
||
68 | .nextbit |
||
69 | srl bc |
||
70 | rr de |
||
71 | exx |
||
72 | srl bc |
||
73 | rr de |
||
74 | exx |
||
75 | dec a |
||
76 | jr nz,.rshiftloop |
||
77 | exx |
||
78 | ld de,iy |
||
79 | ex de,hl |
||
80 | ret |
||
81 | |||
82 | ;bc = m |
||
83 | ;de = n |
||
84 | ;out: dehl = m*n |
||
85 | uintmul16 |
||
1945 | galstaff | 86 | ld a,c |
87 | ld c,b |
||
1870 | galstaff | 88 | ld hl,0 |
1945 | galstaff | 89 | ld b,16 |
90 | .loop add hl,hl |
||
91 | rla |
||
92 | rl c |
||
1870 | galstaff | 93 | jr nc,.skip |
94 | add hl,de |
||
1945 | galstaff | 95 | adc a,0 |
96 | jr nc,.skip |
||
97 | inc c |
||
98 | .skip djnz .loop |
||
99 | ld d,c |
||
100 | ld e,a |
||
1870 | galstaff | 101 | ret |