Skip to content

Commit a311c29

Browse files
ZERICO2005mateoconlechuga
authored andcommitted
saved 3 bytes and 3F in dtoll
1 parent 30229fe commit a311c29

File tree

1 file changed

+14
-11
lines changed

1 file changed

+14
-11
lines changed

src/crt/dtoll.src

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,28 +13,31 @@ __dtoull:
1313
jr z, .zero_or_one
1414
bit 7, b
1515
push af
16-
res 7, b
16+
; res 7, b ; not needed since this bit is shifted out later on
1717
push hl
1818
; -((Float64_mant_bits + Float64_bias) << 4)
19-
ld hl, $FFC010 ; -16368 ; -$3FF0
19+
; ld hl, $FFC010 ; -16368 ; -$3FF0
2020

21-
; clears the exponent field without touching the mantissa
22-
; sets the LSB of the exponent since x is normalized
23-
ld a, c
24-
or a, l ; or a, $10
25-
and a, $1F
26-
27-
add hl, bc
21+
; extract the exponent
22+
ld h, b
23+
ld l, c
2824
; HL <<= 4
2925
add hl, hl
3026
add hl, hl
3127
add hl, hl
3228
add hl, hl
29+
; inc hl
3330

31+
; clears the exponent field without touching the mantissa
32+
; sets the LSB of the exponent since x is normalized
33+
ld a, c
34+
or a, $10
35+
and a, $1F
3436
ld c, a
3537
ld b, 0
36-
ld a, h
37-
sub a, 52 + 1 ; float64 mantissa bits
38+
39+
ld a, h ; expon
40+
sub a, 52 + 1 - 1 ; float64 mantissa bits + CPL trick - inc HL
3841
jr c, .shift_right
3942
; shift_left
4043
; expon >= 52 or [52, 63]

0 commit comments

Comments
 (0)