From: Lauri P. <lpe...@ni...> - 2000-08-19 01:38:47
|
On Wed, 16 Aug 2000 14:52:08 +0200 (CEST), Christian wrote: >It has been hinted to me that the problem is the loading of unnormalized >80-bit floats which is supported by Motorola FPUs but not Intel ones. Another important thing is the accrued exception byte. It does not contribute to the scroll bars problem, but the library math functions. I had a tester code in CodeWarrior, [floating point=Library, 8-Byte doubles]: int exponent; double d4 = frexp(3.5,&exponent); // Should return: 0.875, 2 There is code like this in Pack5 resource "Elems68k" (the comments are from a test run of the C code above): FMOVE.X (A7)+,FP3 ;FP3 = 0.8074 MOVEQ #$00,D4 ;D4 = 0 FMOVE FPSR,D1 ;D1 = 0 (0.8074 status flags) MOVE.L #$0F000000,D2 ;D2 = 0x0F000000 (condition mask) MOVE.L D1,D3 ;D3 = 0 AND.L D2,D3 ;D3 = 0.8074 condition code byte LSL.L #$5,D3 ;D3 MSBs = 0 (Z,I,NAN) AND.L D2,D0 ;D0 = 0 (entry condition code byte) LSL.L #$5,D0 ;D3 MSBs = 0 (Z,I,NAN of entry) BNE.S Anon6+$0010 ;No jump BCS.S Anon6+$0010 ;No jump, C would be set on N flag TST.L D3 ;D3 0 BNE.S Anon6+$0010 ;No jump FMOVE.W FP3,D2 ;D2 = 1?? FMOVE FPSR,D1 ;D1 = 0 BCLR #$07,D1 SNE D2 ;Set if not equal; D2=0 FMOVE D1,FPSR ;D1 = 0 BTST #$03,D1 ;Test bit 3, INEXACT SNE D0 ;D0 = 0 (is not INEXACT) So the line "FMOVE.W FP3,D2" should set the ACCR_INEX flag. In the original fpu code, this means that in put_fp_value() the put_word() call should set the INEXACT flag if the "value" overflows. In the Windows port I'm doing: put_word(ad, extended_to_signed_16(value)); where extended_to_signed_16() (assembly) sets the exception flags if appropriate. In a non-assembly version, this could be replaced by (untested): // strictly speaking, rounding modes should be honored too :) // Say, 32767.5 may ot may not cause the flag. if( value < -32768.0 || value > 32767.0 ) { ... set the INEXACT flag } else { put_word(ad, (uae_s16) value); } For me it was a surprise that the floating point exceptions are disabled but the ROM was still using the exception flags. But why not. Lauri |