Skip to content

Commit 942aafb

Browse files
committed
optimized constant in dto(u)ll
1 parent 6e2f0be commit 942aafb

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/crt/dtoll.src

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,21 +41,24 @@ __dtoull:
4141
ld a, h ; expon
4242
sub a, 52 + 1 - 1 ; float64 mantissa bits + CPL trick - inc HL
4343
jr c, .shift_right
44-
; shift_left
45-
; expon >= 52 or [52, 63]
46-
; A is one less than it should be here to allow for the CPL trick in shift_right
47-
; A is [-1, 10]
48-
cp a, 11 ; only call __llshl if the shift amount is [0, 63]
49-
inc a ; positioning inc a after cp a allows __llshl to be skipped when the shift amount is zero
44+
; .shift_left
45+
; A is [0, 203] or [0, 10] in the non-UB case
46+
; expon >= 52 or [52, 63] in the non-UB case
47+
inc a ; A is one less than it should be here to allow for the CPL trick in shift_right
48+
; C is [16, 31]
49+
cp a, c ; only call __llshl if the shift amount is [0, 63]
5050
ld l, a
5151
ex (sp), hl
52+
; shift is non-zero and [1, 11] in the non-UB case
5253
call c, __llshl
5354
jr .finish
5455
.shift_right:
56+
; A is [-1, -52]
5557
; expon is [0, 51]
5658
cpl
5759
ld l, a
5860
ex (sp), hl
61+
; shift is [0, 51]
5962
call __llshru
6063
.finish:
6164
pop af ; reset SP

0 commit comments

Comments
 (0)