embedded systems developers tools, cross compilers
  Home  |   SwiftX Archive  |   SwiftForth Archive  |

Re: MAKE-ROUND Use

From: Bulgrien, Dennis <Dennis.Bulgrien_at_TripointGlobal.com>
Date: Thu, 28 Feb 2002 16:54:28 -0600

Solved without Windex bottle of RAID. There was an erronious TRUNCATE in my
code that that "fixed". I still don't know why MAKE-ROUND doesn't work, but
a nice way to change the default ANS behavior is below:

{ ---------------------------------------------------------------------
Floating point initialization

FPOPT_* Offsets into 'FPOPT structure
  'FPOPT 3 + C@ 64 53 24
  ------------- -- -- --
  Nearest 3 2 0
  Down 7 6 4
  Up B A 8
  Truncate F E C

//NDP sets the NDP default to rounding precision 64-bits and rounding
control nearest instead of the ANS default of truncation.
See SwiftX\XComp\FpMath.f (/NDP) and FP-ROUND for FPU control word bits.
Note: SwiftX must be closed to restore 'FPOPT table to Forth Inc. defaults.
--------------------------------------------------------------------- }

HOST

0 CONSTANT FPOPT_STACK
1 CONSTANT FPOPT_WAIT
2 CONSTANT FPOPT_FPUCW
4 CONSTANT FPOPT_PRECISION
5 CONSTANT FPOPT_FORMAT

: //NDP ( -- )
  $322 'FPOPT FPOPT_FPUCW + H! \ install desired NDP options
  /NDP \ reconfigure NDP options
;
//NDP

-----Original Message-----
From: Bulgrien, Dennis
Sent: Thursday, February 28, 2002 14:36
To: swiftx_at_forth.com
Subject: [swiftx] Re: MAKE-ROUND Use

I'm trying to understand (/NDP) and MAKE-ROUND . FLDCW must an 80X86 NPC
register. I would like to see the definition. FpMath.f says /NDP sets the
Control Register to the value saved in the floating point options registry
settings only SwiftX doesn't have an interface to the registry!
________________________________________
Tools | Words | ...double-click:

***** ASSEMBLER *****
FLDCW
***** ASM-WORDLIST *****
FLDCW

LOCATE FLDCW FLDCW Can't be located
________________________________________
FpMath.f:

CODE (/NDP)
   FINIT 'FPOPT 2+ EDX ADDR 0 [EDX] FLDCW
   ' /FSTACK >CODE JMP
   END-CODE

' (/NDP) IS /NDP /NDP

CODE MAKE-ROUND
   FP-ROUND EAX ADDR
   0 [EAX] FLDCW
   FNEXT
________________________________________
PS. Setting FP-ROUND FP_ROUND_TRUNC + alone doesn't provide consistent
results without:
0 CONSTANT FPOPT_STACK
1 CONSTANT FPOPT_WAIT
2 CONSTANT FPOPT_FPUCW
4 CONSTANT FPOPT_PRECISION
5 CONSTANT FPOPT_FORMAT
... 'FPOPT FPOPT_FPUCW + H!

-----Original Message-----
From: Bulgrien, Dennis
Sent: Wednesday, February 27, 2002 13:35
To: swiftx_at_forth.com
Subject: [swiftx] Re: MAKE-ROUND Use

...or prefereably:
0 CONSTANT FP_ROUND_ROUND
2 CONSTANT FP_ROUND_DOWN
4 CONSTANT FP_ROUND_UP
6 CONSTANT FP_ROUND_TRUNC

  FP-ROUND FP_ROUND_ROUND + H@
  FP-ROUND FP_ROUND_TRUNC + H!

-----Original Message-----
From: Bulgrien, Dennis
Sent: Wednesday, February 27, 2002 13:33
To: swiftx_at_forth.com
Subject: [swiftx] Re: MAKE-ROUND Use

The following code makes it happen but it is such a horrible solution. What
is says in English is "Whenever the floating point chip is set up for
truncation really set it to round to the nearest value instead." Its like
putting RAID in a Windex bottle to keep the flies off the window. Something
more intentional desired...

  FP-ROUND 0 + H@
  FP-ROUND 6 + H!

-----Original Message-----
From: Bulgrien, Dennis
Sent: Wednesday, February 27, 2002 13:16
To: swiftx_at_forth.com
Subject: [swiftx] MAKE-ROUND Use

SwiftX HOST is apparently set for ANS use of floating point truncation by
default. I need floating point operations on the host to be rounded to
match the higher precision target floating point calculations. Words such
as ROUND and MAKE-ROUND are intended to allow this to be changed prior to
calculations but I have not gotten them to work. Even changing the FPU
control word with $322 'FPOPT 2 + H! doesn't ($322 is 64-bit round nearest;
LOCATE FP-ROUND ). Any ideas?
----------------------------------------------------------------------
swiftx_at_forth.com The SwiftX programming discussion email list
To unsubscribe, send subject "unsubscribe swiftx" to listar_at_forth.com
For help with listar commands, send subject "help" to listar_at_forth.com
Archives are located at http://www.forth.com/swiftx -- check them out!
----------------------------------------------------------------------
THIS LIST IS NOT FOR BUG REPORTS! Send bug reports to support_at_forth.com.
Received on Thu Feb 28 2002 - 14:55:51 PST

This archive was generated by hypermail 2.2.0 : Wed Jan 07 2009 - 03:04:23 PST