File tree Expand file tree Collapse file tree 1 file changed +8
-12
lines changed Expand file tree Collapse file tree 1 file changed +8
-12
lines changed Original file line number Diff line number Diff line change @@ -24,31 +24,27 @@ __ftod:
2424 jr z, .nan
2525.normal:
2626 ; (Float64_bias - Float32_bias) - 1 (undoing inc a)
27- ld c, $80 - 1 ; ld bc, $380 - 1
28- ld d, 0
29- ld e, a
30- ; DE = expon
31- ex de, hl
32- add hl, bc
33- ld a, h
34- ld c, l
35- ex de, hl
27+ ; (Float64_bias - Float32_bias) = $0380
28+ add a, $80 - 1
29+ ld c, a
30+ adc a, b
31+ sub a, c
3632; HL = mant
3733; C = lo expon
3834; A = hi expon
3935.shift_28: ; Float64_mant_bits - Float32_mant_bits
40- ld b, 4
36+ inc b ; ld b, 4
4137.loop:
4238 add hl, hl
4339 rl c
4440 rla
4541 djnz .loop
42+ .zero: ; <-- A is zero on this path
4643 ld b, a
4744
4845 ; zero low bits
4946.infinite:
5047 or a, a
51- .zero:
5248 ex de, hl
5349 sbc hl, hl
5450.finish:
@@ -59,13 +55,13 @@ __ftod:
5955
6056.mant_zero:
6157 adc a, a
62- ld b, e ; maybe load all ones or all zeros including signbit
6358 ld c, l ; HL is zero here
6459 jr z, .zero
6560 inc a
6661 jr nz, .normal
6762 ; infinite
6863 ld c, $F0
64+ ld b, e ; load all ones with the signbit
6965 jr .infinite
7066
7167.subnormal:
You can’t perform that action at this time.
0 commit comments