File tree Expand file tree Collapse file tree 3 files changed +129
-144
lines changed
test/floating_point/float64_from_integer/src Expand file tree Collapse file tree 3 files changed +129
-144
lines changed Load Diff This file was deleted.
Original file line number Diff line number Diff line change 2
2
3
3
section .text
4
4
5
- public __ultod, __ltod
5
+ if 0
6
6
; public __utod, __itod
7
7
8
8
; __utod:
@@ -41,4 +41,125 @@ __ltod:
41
41
pop af, af, iy
42
42
ret
43
43
44
- extern __ultod_c, __lneg
44
+ extern __ultod_c
45
+
46
+ end if
47
+
48
+ public __itod
49
+ __itod:
50
+ push hl
51
+ add hl, hl
52
+ pop hl
53
+ push af
54
+ ld e, 0
55
+ call c, __ineg
56
+ jr __ltod.hijack
57
+
58
+ section .text
59
+
60
+ public __utod
61
+ __utod:
62
+ ld e, 0
63
+
64
+ require __ultod
65
+
66
+ section .text
67
+
68
+ public __ultod
69
+ __ultod:
70
+ or a, a
71
+ push af
72
+ jr __ltod.hijack
73
+
74
+ section .text
75
+
76
+ public __ltod
77
+ __ltod:
78
+ rlc e
79
+ push af
80
+ rrc e
81
+ call c, __lneg
82
+
83
+ require __ltod.hijack
84
+
85
+ section .text
86
+
87
+ private __ltod.hijack
88
+ __ltod.hijack:
89
+ call __lctlz
90
+ cp a, 32
91
+ jr z, .zero
92
+ ; clears the MSB since the float will be normalized
93
+ ; x <<= clz_result + 1; /* shift by 32 is UB */
94
+ if 0
95
+ ; calculate the exponent
96
+ push hl
97
+ ; 1023 + 31 = 1054 = 0x41E
98
+ inc.s bc
99
+ or a, a
100
+ ld b, a ; <<= 8
101
+ ld hl, $041E00
102
+ ld c, l ; ld c, 0
103
+ sbc hl, bc
104
+ ld l, e ; (expon16 << (16 + 24)) | (mant48)
105
+ ex de, hl
106
+ pop hl
107
+
108
+ ld b, a
109
+ inc b
110
+ ld a, e
111
+ .loop32: ; shift by 32 is not UB here!
112
+ add hl, hl
113
+ rla
114
+ djnz .loop32
115
+ ld e, a
116
+ else
117
+ ; calculate the exponent
118
+ push hl
119
+ ; 1023 + 31 = 1054 = 0x41E
120
+ inc.s bc
121
+ or a, a
122
+ ld b, a ; <<= 8
123
+ ld hl, $041E00
124
+ ld c, l ; ld c, 0
125
+ sbc hl, bc
126
+ ld l, e ; (expon16 << (16 + 24)) | (mant48)
127
+ ex de, hl
128
+
129
+ pop bc
130
+ ld l, a
131
+ ld a, e
132
+ call __lshl
133
+ push bc
134
+ pop hl
135
+ ; shift by 32 is UB
136
+ add hl, hl
137
+ rla
138
+ ld e, a
139
+ end if
140
+
141
+ ; UDE:D has expon, E:UHL has mant
142
+ ; Float64_mant_bits - uint48_bits = 4
143
+ ld c, 16 + 4
144
+ push bc
145
+ call __llshl
146
+ pop af ; reset SP
147
+ .finish:
148
+ pop af
149
+ ret nc ; positive
150
+ set 7, b
151
+ ret ; negative
152
+
153
+ .zero:
154
+ sbc hl, hl
155
+ ex de, hl
156
+ sbc hl, hl
157
+ ld b, e
158
+ ld c, e
159
+ pop af
160
+ ret
161
+
162
+ extern __lneg
163
+ extern __lctlz
164
+ extern __lshl
165
+ extern __llshl
Original file line number Diff line number Diff line change @@ -38,16 +38,20 @@ size_t run_test(const char** failed_func) {
38
38
39
39
result .flt = (long double )((uint32_t )input [i ].u32 );
40
40
if (result .bin != output [i ].fu32 .bin ) {
41
+ printf ("%zu: ultod\n" , i );
41
42
print_failed ((uint64_t )input [i ].u32 , result .bin , output [i ].fu32 .bin );
42
43
* failed_func = "ultod" ;
43
- return i ;
44
+ // return i;
45
+ while (!os_GetCSC ());
44
46
}
45
47
46
48
result .flt = (long double )((int32_t )input [i ].u32 );
47
49
if (result .bin != output [i ].fi32 .bin ) {
50
+ printf ("%zu: ltod\n" , i );
48
51
print_failed ((uint64_t )input [i ].u32 , result .bin , output [i ].fi32 .bin );
49
52
* failed_func = "ltod" ;
50
- return i ;
53
+ // return i;
54
+ while (!os_GetCSC ());
51
55
}
52
56
53
57
result .flt = (long double )((uint64_t )input [i ].u64 );
You can’t perform that action at this time.
0 commit comments