File tree Expand file tree Collapse file tree 3 files changed +58
-161
lines changed
test/floating_point/float32_frexp/src Expand file tree Collapse file tree 3 files changed +58
-161
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 11 assume adl=1
22
33 section .text
4+
45 public _frexpf
56 public _frexp
67
@@ -11,10 +12,61 @@ _frexp := _frexpf
1112
1213else
1314
14- _frexpf := __frexpf_c
15- _frexp := __frexp_c
15+ _frexp:
16+ _frexpf:
17+ ld iy, 0
18+ add iy, sp
19+ ld hl, (iy + 3)
20+ add hl, hl
21+ ld b, (iy + 6)
22+ ld a, b
23+ adc a, a
24+ jr z, .maybe_subnormal
25+ inc a
26+ jr z, .inf_nan
27+ ; normal
28+ ld b, $7E ; $3F << 1
29+ rr b
30+ sbc hl, hl
31+ ld l, a
32+ ld de, -127 ; bias
33+ add hl, de
34+ .ret_subnormal:
35+ res 7, (iy + 5)
36+ .ret_zero:
37+ .ret_self:
38+ ld de, (iy + 9) ; int *expon
39+ ex de, hl
40+ ld (hl), de
41+ ld hl, (iy + 3) ; mantissa
42+ ld e, b ; exponent
43+ ret
44+
45+ .inf_nan:
46+ ld hl, $7FFFFF ; INT_MAX
47+ jr .ret_self
48+
49+ .maybe_subnormal:
50+ add hl, bc
51+ or a, a
52+ sbc hl, bc
53+ jr z, .ret_zero
54+ ; input: HL output: A
55+ call __ictlz
56+ ld c, a
57+ call __ishl
58+ ld (iy + 3), hl
59+ scf
60+ sbc hl, hl
61+ neg
62+ add a, 130 ; 127 + 3? idk where this magic number comes from
63+ ld l, a
64+ ld a, b ; exponent
65+ xor a, $3F
66+ ld b, a
67+ jr .ret_subnormal
1668
17- extern __frexpf_c
18- extern __frexp_c
69+ extern __ictlz
70+ extern __ishl
1971
2072end if
Original file line number Diff line number Diff line change 88#include <ti/getcsc.h>
99#include <sys/util.h>
1010
11- /* enable if the toolchain is configured to use the subnormal compliant frexpf */
12- #if 0
13-
1411#include "f32_frexp_LUT.h"
1512
1613#define ARRAY_LENGTH (x ) (sizeof(x) / sizeof(x[0]))
@@ -34,6 +31,8 @@ size_t run_test(void) {
3431 result .flt = frexpf (input [i ], & expon );
3532 if (result .bin != output [i ].frac .bin || expon != output [i ].expon ) {
3633 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);
3736 return i ;
3837 }
3938 }
@@ -56,14 +55,3 @@ int main(void) {
5655
5756 return 0 ;
5857}
59-
60- #else
61-
62- int main (void ) {
63- os_ClrHome ();
64- printf ("All tests passed" );
65- while (!os_GetCSC ());
66- return 0 ;
67- }
68-
69- #endif
You can’t perform that action at this time.
0 commit comments