Skip to content

Commit 2db70ba

Browse files
ZERICO2005mateoconlechuga
authored andcommitted
implemented (short)shiftRightJam64 and propagateNanF64UI in asm
1 parent 6a554a2 commit 2db70ba

File tree

6 files changed

+124
-2
lines changed

6 files changed

+124
-2
lines changed

src/softfloat/include/primitives.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
4848
| into the least-significant bit of the shifted value by setting the least-
4949
| significant bit to 1. This shifted-and-jammed value is returned.
5050
*----------------------------------------------------------------------------*/
51-
#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
51+
#if 0 && defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
5252
INLINE
5353
uint64_t softfloat_shortShiftRightJam64( uint64_t a, uint_fast8_t dist )
5454
{ return a>>dist | ((a & (((uint_fast64_t) 1<<dist) - 1)) != 0); }
@@ -88,7 +88,7 @@ uint32_t softfloat_shiftRightJam32( uint32_t a, uint_fast16_t dist );
8888
| greater than 64, the result will be either 0 or 1, depending on whether 'a'
8989
| is zero or nonzero.
9090
*----------------------------------------------------------------------------*/
91-
#if defined INLINE_LEVEL && (3 <= INLINE_LEVEL)
91+
#if 0 && defined INLINE_LEVEL && (3 <= INLINE_LEVEL)
9292
INLINE uint64_t softfloat_shiftRightJam64( uint64_t a, uint_fast32_t dist )
9393
{
9494
return

src/softfloat/s_propagateNaNF64UI.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3434
3535
=============================================================================*/
3636

37+
#if 0
38+
3739
#include <stdbool.h>
3840
#include <stdint.h>
3941
#include "platform.h"
@@ -61,3 +63,4 @@ uint_fast64_t
6163

6264
}
6365

66+
#endif
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
assume adl=1
2+
3+
section .text
4+
5+
public _softfloat_propagateNaNF64UI
6+
7+
; at least one of the arguments is NaN
8+
; returns x if it is NaN, otherwise returns y
9+
_softfloat_propagateNaNF64UI:
10+
call __frameset0
11+
ld hl, (ix + 12) ; BC
12+
push hl
13+
ld hl, (ix + 9) ; UDE
14+
push hl
15+
ld hl, (ix + 6) ; UHL
16+
push hl
17+
call __isnanl
18+
ld sp, ix
19+
rrca
20+
jr c, .x_is_NaN
21+
lea ix, ix + 9 ; y is NaN
22+
.x_is_NaN:
23+
ld bc, (ix + 12) ; (ix + 21)
24+
bit 3, c ; test quiet bit
25+
jr nz, .quiet
26+
; raise signal
27+
set 3, c ; set quiet bit
28+
ld hl, ___fe_cur_env
29+
set 4, (hl) ; FE_INVALID
30+
.quiet:
31+
ld de, (ix + 9) ; (ix + 18)
32+
ld hl, (ix + 6) ; (ix + 15)
33+
pop ix
34+
ret
35+
36+
extern __isnanl
37+
extern __frameset0
38+
extern ___fe_cur_env

src/softfloat/s_shiftRightJam64.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3434
3535
=============================================================================*/
3636

37+
#if 0
38+
3739
#include <stdint.h>
3840
#include "platform.h"
3941

@@ -49,3 +51,4 @@ uint64_t softfloat_shiftRightJam64( uint64_t a, uint_fast32_t dist )
4951

5052
#endif
5153

54+
#endif
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
assume adl = 1
2+
3+
section .text
4+
5+
public _softfloat_shortShiftRightJam64
6+
7+
; shift amount is [1, 63]
8+
_softfloat_shortShiftRightJam64:
9+
xor a, a
10+
ld iy, -1
11+
add iy, sp
12+
ld l, (iy + 13) ; shift amount
13+
; scf ; disables jr nc, .overflow_shift
14+
jr _softfloat_shiftRightJam64.hijack
15+
16+
section .text
17+
18+
public _softfloat_shiftRightJam64
19+
20+
; shift amount is non-zero
21+
_softfloat_shiftRightJam64:
22+
ld iy, -1
23+
lea bc, iy + 63 + 1
24+
add iy, sp
25+
ld a, (iy + 16) ; shift amount hi8
26+
or a, a
27+
jr nz, .overflow
28+
ld hl, (iy + 13) ; shift amount lo24
29+
sbc hl, bc
30+
add hl, bc
31+
.overflow:
32+
private _softfloat_shiftRightJam64.hijack
33+
.hijack:
34+
ld de, (iy + 7)
35+
ld bc, (iy + 10)
36+
jr nc, .overflow_shift
37+
push hl ; >> shift
38+
sub a, l ; A = 0 - L
39+
and a, $3F
40+
ld l, a
41+
push hl ; << shift
42+
ld hl, (iy + 4)
43+
call __llshl
44+
xor a, a
45+
call __llcmpzero
46+
jr z, .no_round
47+
inc a ; ld a, 1
48+
.no_round:
49+
pop hl ; SP -= 3
50+
ld hl, (iy + 4)
51+
ld de, (iy + 7)
52+
ld bc, (iy + 10)
53+
call __llshru
54+
or a, l
55+
ld l, a
56+
pop af ; reset SP
57+
ret
58+
59+
.overflow_shift:
60+
; A is zero here
61+
ld hl, (iy + 4)
62+
call __llcmpzero
63+
ret z
64+
xor a, a
65+
sbc hl, hl
66+
ex de, hl
67+
sbc hl, hl
68+
ld b, a
69+
ld c, a
70+
inc hl
71+
ret
72+
73+
extern __llcmpzero
74+
extern __llshl
75+
extern __llshru

src/softfloat/s_shortShiftRightJam64.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
3434
3535
=============================================================================*/
3636

37+
#if 0
38+
3739
#include <stdint.h>
3840
#include "platform.h"
3941

@@ -48,3 +50,4 @@ uint64_t softfloat_shortShiftRightJam64( uint64_t a, uint_fast8_t dist )
4850

4951
#endif
5052

53+
#endif

0 commit comments

Comments
 (0)