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 1515_frexp:
1616_frexpf:
1717 ld iy, 0
18+ lea de, iy - 127 ; bias ; $FFFF81
1819 add iy, sp
1920 ld hl, (iy + 3)
2021 add hl, hl
@@ -29,40 +30,39 @@ _frexpf:
2930 rr b
3031 sbc hl, hl
3132 ld l, a
32- ld de, -127 ; bias
33+ ; ld de, -127 ; bias
3334 add hl, de
35+ .ret_zero:
36+ ex de, hl
3437.ret_subnormal:
3538 res 7, (iy + 5)
36- .ret_zero:
3739.ret_self:
38- ld de, (iy + 9) ; int *expon
39- ex de, hl
40+ ld hl, (iy + 9) ; int *expon
4041 ld (hl), de
4142 ld hl, (iy + 3) ; mantissa
4243 ld e, b ; exponent
4344 ret
4445
4546.inf_nan:
46- ld hl , $7FFFFF ; INT_MAX
47+ ld de , $7FFFFF ; INT_MAX
4748 jr .ret_self
4849
4950.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
5455 ; input: HL output: A
5556 call __ictlz
5657 ld c, a
5758 call __ishl
5859 ld (iy + 3), hl
59- scf
60- sbc hl, hl
60+ sub a, 131 ; (127 + 3) + 1? idk where this magic number comes from
6161 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
6666 ld b, a
6767 jr .ret_subnormal
6868
Original file line number Diff line number Diff line change @@ -31,8 +31,10 @@ size_t run_test(void) {
3131 result .flt = frexpf (input [i ], & expon );
3232 if (result .bin != output [i ].frac .bin || expon != output [i ].expon ) {
3333 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
3638 return i ;
3739 }
3840 }
You can’t perform that action at this time.
0 commit comments