NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

kern/47810: FREM emulation of m68k FPE is wrong



>Number:         47810
>Category:       kern
>Synopsis:       FREM emulation of m68k FPE is wrong
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    kern-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu May 09 05:30:00 +0000 2013
>Originator:     Tetsuya Isaki
>Release:        NetBSD/x68k
>Organization:
>Environment:
NetBSD 6.99.19 x68k
>Description:
The FREM emulation of m68k FPE is wrong at several values.
>How-To-Repeat:
% dmesg | grep FPU
X68030 (m68030 CPU/MMU, emulator FPU, 29MHz clock) on XM6i v0.41
% cat main.c
#include<stdio.h>
extern double my_frem(double, double);
int main()
{
        double x;
        double y = 4.0;

        for (x = 0.0; x > -5.0; x -= 1.0) {
                printf("FREM(%g, %g) = %g\n", x, y, my_frem(x, y));
        }
}
% cat frem_s.s 
        .text
        .even
        .globl  my_frem
        .type   my_frem,@function
my_frem:
        fmoved  %sp@(4),%fp0
        fremd   %sp@(12),%fp0
        rts
% gcc -o frem main.c frem_s.s
% ./frem
FREM(0, 4) = -4     <-- NG!
FREM(-1, 4) = -1
FREM(-2, 4) = -2
FREM(-3, 4) = -7    <-- NG!
FREM(-4, 4) = -0
%

FREM(0, 4) should be 0 but it returns -4,
FREM(-3,4) should be 1 but it returns -7.
>Fix:
I have and I will commit it soon.
This PR is just for a record.



Home | Main Index | Thread Index | Old Index