Preserve and restore the caller's FP status register, and ensure
it contains a sane value while we're doing FP ops.
This commit is contained in:
parent
204f44c565
commit
42ca361622
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: sdivsi3.S,v 1.1 2002/07/05 13:32:08 scw Exp $ */
|
||||
/* $NetBSD: sdivsi3.S,v 1.2 2002/09/28 10:33:59 scw Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 2002 Wasabi Systems, Inc.
|
||||
|
@ -76,6 +76,10 @@
|
|||
ENTRY(__sdivsi3)
|
||||
fmov.dq dr0, r1 /* Preserve dr0 (fr0/fr1) in r1 */
|
||||
fmov.dq dr2, r2 /* Preserve dr2 (fr2/fr3) in r2 */
|
||||
fgetscr fr0 /* Fetch FPSCR */
|
||||
fmov.sl fr0, r3 /* Preserve in r3 */
|
||||
fmov.ls r63, fr0
|
||||
fputscr fr0 /* Disable FPU exceptions */
|
||||
fmov.ls r4, fr0 /* fr0 = bitwise copy of dividend */
|
||||
fmov.ls r5, fr2 /* fr2 = bitwise copy of divisor */
|
||||
float.ld fr0, dr0 /* int to double conversion of fr0 */
|
||||
|
@ -85,6 +89,8 @@ ENTRY(__sdivsi3)
|
|||
fmov.qd r2, dr2 /* Restore dr2 */
|
||||
ftrc.dl dr0, fr0 /* double to int conversion */
|
||||
fmov.sl fr0, r0 /* Sign-extended result to r0 */
|
||||
fmov.ls r3, fr0 /* Restore FPSCR */
|
||||
fputscr fr0
|
||||
fmov.qd r1, dr0 /* Restore dr0 */
|
||||
blink tr0, r63
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: udivsi3.S,v 1.1 2002/07/05 13:32:08 scw Exp $ */
|
||||
/* $NetBSD: udivsi3.S,v 1.2 2002/09/28 10:34:00 scw Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright 2002 Wasabi Systems, Inc.
|
||||
|
@ -57,7 +57,7 @@
|
|||
*
|
||||
* Note: These don't follow the regular SH-5 ABI calling convention.
|
||||
* The dividend is passed in r4 instead of r2, the divisor is passed in
|
||||
* r5, and the result is returned in r0. Also, we can only clobber r18-r19.
|
||||
* r5, and the result is returned in r0. Also, we can only clobber r18-r19, r25.
|
||||
*/
|
||||
|
||||
#include <machine/asm.h>
|
||||
|
@ -77,6 +77,10 @@ ENTRY(__udivsi3)
|
|||
ptabs/l r18, tr0
|
||||
fmov.dq dr0, r19 /* Preserve dr0 in r19 */
|
||||
fmov.dq dr2, r0 /* Preserve dr2 in r0 */
|
||||
fgetscr fr0 /* Fetch FPSCR */
|
||||
fmov.sl fr0, r25 /* Preserve in r25 */
|
||||
fmov.ls r63, fr0
|
||||
fputscr fr0 /* Disable FPU exceptions */
|
||||
addz.l r4, r63, r4 /* r4 = zero extended dividend */
|
||||
addz.l r5, r63, r18 /* r18 = zero extended divisor */
|
||||
fmov.qd r4, dr0 /* dr0 = bitwise copy of dividend */
|
||||
|
@ -87,6 +91,8 @@ ENTRY(__udivsi3)
|
|||
fmov.qd r0, dr2 /* Restore dr2 */
|
||||
ftrc.dq dr0, dr0 /* double to int conversion */
|
||||
fmov.dq dr0, r0 /* Result to r0 */
|
||||
fmov.ls r25, fr0 /* Restore FPSCR */
|
||||
fputscr fr0
|
||||
fmov.qd r19, dr0 /* Restore dr0 */
|
||||
addz.l r0, r63, r0 /* Zero extended result to r0 */
|
||||
blink tr0, r63
|
||||
|
|
Loading…
Reference in New Issue