HP OpenVMS Systems

ask the wizard
Content starts here

Macro32 Compiler and Floating Point? (mth$ calls)

» close window

The Question is:

 
I am trying to do a simple thing, but getting no where.
I have a VAX VMS program that called the
MTH$SQRT_R3 routine via JSB on VAX that we need
to run on the Alpha.  JSB entry points are not
supported on the Alpha.
 
I changed the call interface to a CALLS (and then
a CALLG) with no luck.  The call is made, it looks
like it is going to the math library, but R0 is
not updated with the function return value.  In fact
R0 contains whatever was in previously.
 
Basically, here is the code fragment for CALLS:
 
X:   .f_floating 9
 
pushal  x
calls #1,G^mth$sqrt
 
I then tried the portable math library math$sqrt_f (which it looks like
the MTH$ libary call is going to anyway).
 
Same result, no change in R0.  What basic thing
am I missing here? (I tried lib$signal CALLS with
no problem.)
 
 


The Answer is :

 
  The Macro32 compiler is calling a routine that returns its results in
  floating point register F0, and the Macro32 compiler has no idea how
  to access F0 nor any of the other floating point registers.
 
  From C, you can use code such as the following:
 
$ cc x
$ link x
$ run x
4.000000 2.000000
16.000000 4.000000
32.000000 5.656854
$ type x.c
#include [ssdef.h]
#include [mth$routines.h]
#include [stdio.h]
main()
  {
  int RetStat;
 
  float q;
  float x = 4.0;
  float y = 16.0;
  float z = 32.0;
 
  q = mth$sqrt( &x );
  printf("%f %f\n", x, q );
  q = mth$sqrt( &y );
  printf("%f %f\n", y, q );
  q = mth$sqrt( &z );
  printf("%f %f\n", z, q );
 
  return SS$_NORMAL;
  }
 
 
  NOTE: the angle brackets have been replaced by square brackets in the
  above C example.  You will need to convert these back to angle brackets
  before attempting to compile the example.
 
  Conceivably, you could also create a jacket around the DPML call, and
  transfer the results into R0 for the Macro32 code, or you could simply
  call C or other language to perform the necessary task.
 
  Alpha 21264 (EV6) systems include SQRT support in Alpha microprocessor
  hardware, and compilers such as C and the Macro64 assembler (on the
  OpenVMS Freeware) can use this instruction (when told to).
 

answer written or last revised on ( 7-JUN-1999 )

» close window