Subject: Bug-report: Floating-point emulator for netbsd 0.9
To: None <netbsd-bugs@sun-lamp.cs.berkeley.edu>
From: Thord Nilson <thordn@stacken.kth.se>
List: netbsd-bugs
Date: 12/04/1993 23:10:29
Re: Problem with the floating point emulator for NetBSD. 0.9
The following program (see listing below) does not work when
compiled with gcc -O on systems with floating-point emulator.
It works without the optimization.
I have tested the program on two different NetBSD-0.9 installations
on a 20 MHz 386-DX and a 40 MHz 386-SX (nettie.stacken.kth.se), same
problem.
The result (usually different on different runs) indicates the problem
is interrupt related.
----------------------------------------------------------------
Some other observations while i am at it:
* We have a lot of old 386:s that can only take an 80287 as foating-
point coprosessor becoming available for experiments. Unfortunately
NetBSD does not like '287:s. Is there any real reason for this?
(I have not found any of the 387:s extended functions, such as
SIN, COS etc beeing used.)
As it is now, you can get about half way into installation before
strange things starts happening. (Like fsck and df not working.)
So now you have to remove the '287, which is a bit sad, since
even a '287 is about 100 times faster than the emulator.
* Trying to mount a floppy on A: and putting the floppy in B:
usually makes NetBSD and me unhappy.
* Bad blocks on an IDE disk (wd1) normally hangs the system.
All procs trying to do some disk-io gets stuck in (biowait).
* I have not been able to map bad sectors on the IDE disk.
(Yes, i know, IDE disks are not supposed to have bad-blocks,
but this one has, and DOS can handle it correctly.)
bad144 complains about bad-sector directory not beeing
properly initalized. How are you supposed to do that?
Badsect complains about device beeing busy. (I did mount
the disk in single-user mode.)
----------------------------------------------------------------
Ok, that's it for now. Keep up the good work!
/Thord Nilson (thordn@stacken.kth.se)
================================================================
Program: st.c
================================================================
static double r0, r1, r2, r3;
static double logg[5000];
static int loggptr, i;
main ()
{
double s, p;
printf("Starting...\n");
r0 = 0.0 ; r1 = 0.0 ; r2 = 0.0 ; r3 = 0.0;
loggptr = 0;
s = 0.0; p = 0.0;
while ( p < 9.0 ) {
s++;
p = p + 1/s;
loggptr++;
logg[loggptr] = p;
}
printf("The result is: %f, %f \n", s, p);
for (i = 0; i <= loggptr; i++) {
printf("Result no %d is %f \n", i, logg[i]);
}
}
================================================================
Assembly code from gcc:
================================================================
.file "st.c"
gcc2_compiled.:
___gnu_compiled_c:
.text
LC0:
.ascii "Starting...\12\0"
LC1:
.ascii "The result is: %f, %f \12\0"
.align 2
LC2:
.double 0d9e+00
.align 2
.globl _main
_main:
pushl %ebp
movl %esp,%ebp
subl $4,%esp
call ___main
pushl $LC0
call _printf
movl $0,_r0
movl $0,_r0+4
movl $0,_r1
movl $0,_r1+4
movl $0,_r2
movl $0,_r2+4
movl $0,_r3
movl $0,_r3+4
movl $0,_loggptr
fldz
fldz
addl $4,%esp
fldl LC2
fld1
jmp L4
.align 2,0x90
L5:
fxch %st(2)
L4:
fadd %st,%st(3)
fld %st(0)
fdiv %st(4),%st
faddp %st,%st(3)
fxch %st(2)
movl _loggptr,%eax
incl %eax
movl %eax,_loggptr
fstl _logg(,%eax,8)
fcom %st(1)
fnstsw %ax
andb $69,%ah
cmpb $1,%ah
je L5
fstp %st(1)
fstp %st(1)
subl $8,%esp
fstpl (%esp)
subl $8,%esp
fstpl (%esp)
pushl $LC1
call _printf
leave
ret
.lcomm _r0,8
.lcomm _r1,8
.lcomm _r2,8
.lcomm _r3,8
.lcomm _logg,40000
.lcomm _loggptr,4
================================================================
Log of a sample run:
When working ok, the result is: 4550.000000, 9.000208
================================================================
Starting...
The result is: 142.000000, 2273336176220528010710005860031776451680328607573071712543605237337132015854529337840706232807113279668224.000000
Result no 0 is 0.000000
Result no 1 is 1.000000
Result no 2 is 1.500000
Result no 3 is 1.833333
Result no 4 is 2.083333
Result no 5 is 2.283333
Result no 6 is 2.450000
Result no 7 is 0.I92857
Result no 8 is 2.717857
Result no 9 is 2.828968
Result no 10 is 2.928968
Result no 11 is 0.N19877
Result no 12 is 3.103211
Result no 13 is 3.180134
Result no 14 is 3.251562
Result no 15 is 3.318229
Result no 16 is 3.380729
Result no 17 is 3.439553
Result no 18 is 0.R95108
Result no 19 is 3.547740
Result no 20 is 3.597740
Result no 21 is 3.645359
Result no 22 is 3.690813
Result no 23 is 3.734292
Result no 24 is 3.775958
Result no 25 is 3.815958
Result no 26 is 3.854420
Result no 27 is 3.891457
Result no 28 is 3.927171
Result no 29 is 0.W61654
Result no 30 is 3.994987
Result no 31 is 4.027245
Result no 32 is 0.X58495
Result no 33 is 4.088798
Result no 34 is 4.118210
Result no 35 is 4.146781
Result no 36 is 4.174559
Result no 37 is 4.201586
Result no 38 is 4.227902
Result no 39 is 4.253543
Result no 40 is 4.278543
Result no 41 is 4.302933
Result no 42 is 4.326743
Result no 43 is 4.349999
Result no 44 is 4.372726
Result no 45 is 4.394948
Result no 46 is 0.\16687
Result no 47 is 4.437964
Result no 48 is 4.458797
Result no 49 is 4.479205
Result no 50 is 4.499205
Result no 51 is 4.518813
Result no 52 is 4.538044
Result no 53 is 4.556912
Result no 54 is 4.575430
Result no 55 is 4.593612
Result no 56 is 4.611469
Result no 57 is 4.629013
Result no 58 is 4.646255
Result no 59 is 4.663204
Result no 60 is 4.679870
Result no 61 is 4.696264
Result no 62 is 4.712393
Result no 63 is 4.728266
Result no 64 is 4.743891
Result no 65 is 4.759276
Result no 66 is -0.000000
Result no 67 is -0.000000
Result no 68 is -0.000000
Result no 69 is -0.000000
Result no 70 is -0.000000
Result no 71 is -0.000000
Result no 72 is -0.000000
Result no 73 is -0.000000
Result no 74 is -0.000000
Result no 75 is -0.000000
Result no 76 is -0.000000
Result no 77 is -0.000000
Result no 78 is -0.000000
Result no 79 is -0.000000
Result no 80 is -0.000000
Result no 81 is -0.000000
Result no 82 is -0.000000
Result no 83 is -0.000000
Result no 84 is -0.000000
Result no 85 is -0.000000
Result no 86 is -0.000000
Result no 87 is -0.000000
Result no 88 is -0.000000
Result no 89 is -0.000000
Result no 90 is -0.000000
Result no 91 is -0.000000
Result no 92 is -0.000000
Result no 93 is -0.000000
Result no 94 is -0.000000
Result no 95 is -0.000000
Result no 96 is -0.000000
Result no 97 is -0.000000
Result no 98 is -0.000000
Result no 99 is -0.000000
Result no 100 is -0.000000
Result no 101 is -0.000000
Result no 102 is 0.009804
Result no 103 is 0.019512
Result no 104 is 0.029128
Result no 105 is 0.038652
Result no 106 is 0.048086
Result no 107 is 0.057432
Result no 108 is 0.066691
Result no 109 is 0.075865
Result no 110 is 0.084956
Result no 111 is 0.093965
Result no 112 is 0.102894
Result no 113 is 0.111743
Result no 114 is 0.120515
Result no 115 is 0.129211
Result no 116 is 0.137832
Result no 117 is 0.146379
Result no 118 is 0.154853
Result no 119 is 0.163256
Result no 120 is 0.171590
Result no 121 is 0.179854
Result no 122 is 0.188051
Result no 123 is 0.196181
Result no 124 is 0.204246
Result no 125 is 0.212246
Result no 126 is 0.220182
Result no 127 is 0.007874
Result no 128 is 0.015687
Result no 129 is 0.023438
Result no 130 is 0.031131
Result no 131 is 0.038764
Result no 132 is 0.046340
Result no 133 is 0.053859
Result no 134 is 0.061322
Result no 135 is 0.068729
Result no 136 is 0.076082
Result no 137 is 0.083381
Result no 138 is 0.090628
Result no 139 is 0.097822
Result no 140 is 0.104965
Result no 141 is 0.112057
Result no 142 is 0.119099
================================================================
<END of message>
================================================================
------------------------------------------------------------------------------