Re: Porting HP C from Alpha to Itanium - __DIVG_C



Larry Kilgallen wrote:



Thanks, John. I am enough of a non-expert to not know about the
/ROUNDING_MODE=CHOPPED. Perhaps creating a new module would be
the best way to have common source between Alpha and IPF.


Well, there will be some conditionalization in any case.

As I mentioned, on Alpha each module can have its own /ROUNDING_MODE setting and those rounding modes are encoded directly into each instruction. Multiple modes can co-exist in a single application without any additional overhead.

On Itanium, there is one "global" setting in the FPCR (floating point control register) [there is actually more than one, but that isn't relevant to this discussion since the generated code only uses one of them]. We couldn't implement it like we do on Alpha.

So each module records its "preferred" floating settings (VAX vs IEEE, precision, rounding-mode) in the object file. The linker uses the floating settings from the module with the main entry point as the "whole program" setting. This is recorded in the .EXE and is used by the image activator prior to the start of your program. We did this so things like LIB$INITIALIZE routines, AST routines, etc. can all have consistent floating settings. You wouldn't want your timer AST routine to have different settings depending on which piece of code was interrupted by the timer AST, right?

What this means is that for modules that don't contain the main entry point, the settings of /ROUNDING_MODE and /IEEE_MODE are essentially worthless on I64. We didn't want to start automatically inserting calls to SYS$IEEE_SET_FP_xxx into every single routine since most people don't do this style of coding. C does provide /CHECK=FP_MODE to check that the floating settings at run-time match the /ROUNDING_MODE and /IEEE_MODE set at compile-time. You have to insert calls to SYS$IEEE_SET_FP_xxx into your code to set the settings to your liking, do the operation(s) desired, and set them back. You also can't use /CHECK=FP_MODE anymore since that check is performed in the routine prolog BEFORE you get a chance to change the settings via SYS$IEEE_SET_FP_xxx.

So you can conditionalize the current code:

#if alpha
- use __DIVG_C
#endif
#if i64
- call SYS$IEEE_SET_FP_ROUNDING_MODE to truncate (ie chopped)
- use the regular division operator
- restore prior rounding mode
#endif

or if you make a separate module that is compiled with /ROUNDING=CHOPPED, you still have

#if i64
- call SYS$IEEE_SET_FP_ROUNDING_MODE to truncate (ie chopped)
#endif
- use the regular division operator
#if i64
- restore prior rounding mode
#endif



--
John Reagan
OpenVMS Pascal/Macro-32/COBOL Project Leader
Hewlett-Packard Company
.



Relevant Pages

  • Re: Help with IIGS Slot Register $C02D
    ... Control Panel settings for the two internal serial ports. ... The internal serial port firmware reads these locations during its ... external card to the internal port, the initialization routine will fail ... A step/trace of the internal serial port firmware reveals different coding ...
    (comp.sys.apple2)
  • Re: Re: Is anyone able to make My.Settings work? I cant!
    ... I put it back in and now the routine runs and I save the ... I copied the Sub command and the code ... Settings is not "working" since the routine to drive it is back. ... In this millenium there is more than Atari programming. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Re: Is anyone able to make My.Settings work? I cant!
    ... I put it back in and now the routine runs and I save the ... Settings is not "working" since the routine to drive it is back. ... In this millenium there is more than Atari programming. ... Where can I see the "persistent" values so help find the problem area. ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Linksys RV082 feedback needed
    ... I copied all the settings from the old routine, ... I've tried all types of settings, ... I called Linksys tech support, but as you have probably seen else where ... I can't send this unit back, because Linksys ...
    (microsoft.public.windows.server.networking)
  • Re: Porting HP C from Alpha to Itanium - __DIVG_C
    ... So each module records its "preferred" floating settings (VAX vs IEEE, ... You wouldn't want your timer AST routine ...
    (comp.os.vms)