Skip to content

Commit 57dc83c

Browse files
committed
refact: slightly optimize MUL32
1 parent 539df7b commit 57dc83c

8 files changed

Lines changed: 40 additions & 24 deletions

File tree

src/arch/zx48k/library-asm/_mul32.asm

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@ __MUL32_64START:
2828
; sinclair zx81 rom for the mantissa multiply
2929

3030
__LMUL:
31-
and a ; reset carry flag
32-
sbc hl,hl ; result bits 32..47 = 0
31+
xor a ; reset carry flag
32+
ld h, a ; result bits 32..47 = 0
33+
ld l, a
3334
exx
34-
sbc hl,hl ; result bits 48..63 = 0
35+
ld h, a ; result bits 48..63 = 0
36+
ld l, a
3537
exx
3638
ld a,b ; mpr is b'c'ac
3739
ld b,33 ; initialize loop counter

src/arch/zxnext/library-asm/_mul32.asm

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,12 @@ __MUL32_64START:
2828
; sinclair zx81 rom for the mantissa multiply
2929

3030
__LMUL:
31-
and a ; reset carry flag
32-
sbc hl,hl ; result bits 32..47 = 0
31+
xor a ; reset carry flag
32+
ld h, a ; result bits 32..47 = 0
33+
ld l, a
3334
exx
34-
sbc hl,hl ; result bits 48..63 = 0
35+
ld h, a ; result bits 48..63 = 0
36+
ld l, a
3537
exx
3638
ld a,b ; mpr is b'c'ac
3739
ld b,33 ; initialize loop counter

tests/functional/fact.asm

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,10 +226,12 @@ __MUL32_64START:
226226
; this routine was with tiny differences in the
227227
; sinclair zx81 rom for the mantissa multiply
228228
__LMUL:
229-
and a ; reset carry flag
230-
sbc hl,hl ; result bits 32..47 = 0
229+
xor a ; reset carry flag
230+
ld h, a ; result bits 32..47 = 0
231+
ld l, a
231232
exx
232-
sbc hl,hl ; result bits 48..63 = 0
233+
ld h, a ; result bits 48..63 = 0
234+
ld l, a
233235
exx
234236
ld a,b ; mpr is b'c'ac
235237
ld b,33 ; initialize loop counter

tests/functional/ltee9.asm

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,12 @@ __MUL32_64START:
222222
; this routine was with tiny differences in the
223223
; sinclair zx81 rom for the mantissa multiply
224224
__LMUL:
225-
and a ; reset carry flag
226-
sbc hl,hl ; result bits 32..47 = 0
225+
xor a ; reset carry flag
226+
ld h, a ; result bits 32..47 = 0
227+
ld l, a
227228
exx
228-
sbc hl,hl ; result bits 48..63 = 0
229+
ld h, a ; result bits 48..63 = 0
230+
ld l, a
229231
exx
230232
ld a,b ; mpr is b'c'ac
231233
ld b,33 ; initialize loop counter

tests/functional/modf16c.asm

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -331,10 +331,12 @@ __MUL32_64START:
331331
; this routine was with tiny differences in the
332332
; sinclair zx81 rom for the mantissa multiply
333333
__LMUL:
334-
and a ; reset carry flag
335-
sbc hl,hl ; result bits 32..47 = 0
334+
xor a ; reset carry flag
335+
ld h, a ; result bits 32..47 = 0
336+
ld l, a
336337
exx
337-
sbc hl,hl ; result bits 48..63 = 0
338+
ld h, a ; result bits 48..63 = 0
339+
ld l, a
338340
exx
339341
ld a,b ; mpr is b'c'ac
340342
ld b,33 ; initialize loop counter

tests/functional/mulf16a.asm

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,12 @@ __MUL32_64START:
105105
; this routine was with tiny differences in the
106106
; sinclair zx81 rom for the mantissa multiply
107107
__LMUL:
108-
and a ; reset carry flag
109-
sbc hl,hl ; result bits 32..47 = 0
108+
xor a ; reset carry flag
109+
ld h, a ; result bits 32..47 = 0
110+
ld l, a
110111
exx
111-
sbc hl,hl ; result bits 48..63 = 0
112+
ld h, a ; result bits 48..63 = 0
113+
ld l, a
112114
exx
113115
ld a,b ; mpr is b'c'ac
114116
ld b,33 ; initialize loop counter

tests/functional/read13.asm

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -534,10 +534,12 @@ __MUL32_64START:
534534
; this routine was with tiny differences in the
535535
; sinclair zx81 rom for the mantissa multiply
536536
__LMUL:
537-
and a ; reset carry flag
538-
sbc hl,hl ; result bits 32..47 = 0
537+
xor a ; reset carry flag
538+
ld h, a ; result bits 32..47 = 0
539+
ld l, a
539540
exx
540-
sbc hl,hl ; result bits 48..63 = 0
541+
ld h, a ; result bits 48..63 = 0
542+
ld l, a
541543
exx
542544
ld a,b ; mpr is b'c'ac
543545
ld b,33 ; initialize loop counter

tests/functional/subrec.asm

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,12 @@ __MUL32_64START:
238238
; this routine was with tiny differences in the
239239
; sinclair zx81 rom for the mantissa multiply
240240
__LMUL:
241-
and a ; reset carry flag
242-
sbc hl,hl ; result bits 32..47 = 0
241+
xor a ; reset carry flag
242+
ld h, a ; result bits 32..47 = 0
243+
ld l, a
243244
exx
244-
sbc hl,hl ; result bits 48..63 = 0
245+
ld h, a ; result bits 48..63 = 0
246+
ld l, a
245247
exx
246248
ld a,b ; mpr is b'c'ac
247249
ld b,33 ; initialize loop counter

0 commit comments

Comments
 (0)