Date: Fri, 22 Jan 93 08:34:46 MET From: MAHB AT IBM DOT RZ DOT TU-CLAUSTHAL DOT DE Subject: coprocessor exception To: djgpp AT sun DOT soe DOT clarkson DOT edu Consider the following program: /* this is test.c */ int main(){ double x,y; x = 0.0; y = 1.0/x; return 0; } Obviously this program should produce an exception. But this does *not* happen. Running the code under debug32 gives the following output. c:/djgpp/bin/debug32.exe version 1.09 Copyright (C) 1991 DJ Delorie 4064+4096+0 = 8160 XMS driver detected 356 Kb conventional, 7360 Kb extended - 7716 Kb total RAM available Reading symbols... Building symbol trees... DONE >> n _main() (test.c#1): int main(){ 00001070: 55 push ebp ebp=00000000 00001071: 89e5 mov ebp,esp esp=7ffffd30 00001073: 83ec10 sub esp,0x10 esp=7ffffd30 00001076: e821000000 call ___main #3: x = 0.0; 0000107b: c745f800000000 mov [ebp-8],0 ebp=7ffffd30 00001082: c745fc00000000 mov [ebp-4],0 ebp=7ffffd30 #4: y = 1.0/x; 00001089: d9e8 fld1 0000108b: dc75f8 fdivq [ebp-8] ebp=7ffffd30 >> n 0000108e: dd5df0 fstpq [ebp-16] ebp=7ffffd30 >> npx Control: 0xffff037a Status: 0xffffb884 Tag: 0xffff3fff st(0) + 8000 0000 0000 0000 e 3fff Valid 1 st(1) + 0080 0200 4000 8000 e 4140 Empty st(2) - 488c 0001 4a20 8408 e 48c4 Empty st(3) + c018 0100 0110 0110 e 41a0 Empty st(4) - 0400 4400 2400 0100 e 4015 Empty st(5) + 0000 0000 0000 0000 e 0000 Empty st(6) + a000 0000 0000 0000 e 4002 Empty st(7) - 8000 0000 0000 0000 e 7fff Empty #5: return 0; 00001091: 31c0 xor eax,eax eax=00001174 00001093: eb03 jmp _main+40 (0x1098 ) #6: } 00001098: c9 leave 00001099: c3 ret 0000105a: 83c40c add esp,0xc esp=7ffffd38 0000105d: 50 push eax eax=00000000 0000105e: e865010000 call _exit Program exited normally, return code 0 (0x0) 00001542: cd21 int 0x21 XMS memory freed As you can see, the fdiv instruction sets the coprocessor status word correctly (division by zero is indicated), the zero division flag in the coprocessor control word is *not* masked! So, why isn't there an exception? Any suggestions? Henning Behnke