File tree Expand file tree Collapse file tree 2 files changed +19
-17
lines changed
test/floating_point/float32_frexp/src Expand file tree Collapse file tree 2 files changed +19
-17
lines changed Original file line number Diff line number Diff line change 15
15
_frexp:
16
16
_frexpf:
17
17
ld iy, 0
18
+ lea de, iy - 127 ; bias ; $FFFF81
18
19
add iy, sp
19
20
ld hl, (iy + 3)
20
21
add hl, hl
@@ -29,40 +30,39 @@ _frexpf:
29
30
rr b
30
31
sbc hl, hl
31
32
ld l, a
32
- ld de, -127 ; bias
33
+ ; ld de, -127 ; bias
33
34
add hl, de
35
+ .ret_zero:
36
+ ex de, hl
34
37
.ret_subnormal:
35
38
res 7, (iy + 5)
36
- .ret_zero:
37
39
.ret_self:
38
- ld de, (iy + 9) ; int *expon
39
- ex de, hl
40
+ ld hl, (iy + 9) ; int *expon
40
41
ld (hl), de
41
42
ld hl, (iy + 3) ; mantissa
42
43
ld e, b ; exponent
43
44
ret
44
45
45
46
.inf_nan:
46
- ld hl , $7FFFFF ; INT_MAX
47
+ ld de , $7FFFFF ; INT_MAX
47
48
jr .ret_self
48
49
49
50
.maybe_subnormal:
50
- add hl, bc
51
- or a, a
52
- sbc hl, bc
53
- jr z , .ret_zero
51
+ ld e, d ; ld de, -1
52
+ add hl, de
53
+ inc hl ; restore HL
54
+ jr nc , .ret_zero
54
55
; input: HL output: A
55
56
call __ictlz
56
57
ld c, a
57
58
call __ishl
58
59
ld (iy + 3), hl
59
- scf
60
- sbc hl, hl
60
+ sub a, 131 ; (127 + 3) + 1? idk where this magic number comes from
61
61
cpl
62
- add a, 131 ; 127 + 3 + 1? idk where this magic number comes from
63
- ld l, a
64
- ld a, b ; exponent
65
- xor a, $3F
62
+ ld e, a ; DE was -1 from before
63
+ ; copy exponent of 0.5f
64
+ ld a, b
65
+ xor a, $3F
66
66
ld b, a
67
67
jr .ret_subnormal
68
68
Original file line number Diff line number Diff line change @@ -31,8 +31,10 @@ size_t run_test(void) {
31
31
result .flt = frexpf (input [i ], & expon );
32
32
if (result .bin != output [i ].frac .bin || expon != output [i ].expon ) {
33
33
if (!(isnan (result .flt ) && isnan (output [i ].frac .flt ))) {
34
- // printf("G: %08lX %d\n", result.bin, expon);
35
- // printf("T: %08lX %d\n", output[i].frac.bin, output[i].expon);
34
+ #if 0
35
+ printf ("G: %08lX %d\n" , result .bin , expon );
36
+ printf ("T: %08lX %d\n" , output [i ].frac .bin , output [i ].expon );
37
+ #endif
36
38
return i ;
37
39
}
38
40
}
You can’t perform that action at this time.
0 commit comments