HP OpenVMS Systems

ask the wizard
Content starts here

Alpha, AP, and Variable Argument Lists?

» close window

The Question is:

 
We are currently migrating from Vax to Alpha.  We have a subroutine
 (Get_Argcnt) that returns the argument count and also an argument list
 indicating whether any arguments were omitted.  We have many subroutines that
 call Get_Argcnt and rely on the argume
nt list to determine if an agrument should be referenced.  It's crutial that we
 can continue to use this subroutine. There is an FAQ, Prog9, referring to
 this, but I can't believe that the same functionality can't be accomplished on
 the Alpha.  R25 appare
ntly contains the argument count of the current subroutine.  R16-R21 contain
 the addresses of the first 6 arguments.  I don't understand how to reference
 arguments 7 and beyond. What I really need is the argument count and argument
 list of the previous ca
ll.  I accomplished this on the Vax by getting the previous ap from 8(fp).  How
 can this be done on the Alpha?
 
Thank you,
 
Jerry Ryan
Bissell, Inc
ITS
616-453-4451 x.352
 
 


The Answer is :

 
  The implementation of argument passing is quite different between OpenVMS
  VAX and OpenVMS Alpha -- applications that are dependant on the contents
  of the VAX call stack will require changes when porting to OpenVMS Alpha.
 
  On OpenVMS VAX systems, many programmers used a small routine written in
  Macro32 to fetch the argument count via the saved AP register. Though
  this technique was unsupported and not guaranteed to work in the VAX
  architecture, it worked well enough that various applications have
  come to depend upon it.
 
  This AP-based technique does not work on OpenVMS Alpha systems, even if
  the Macro32 routine is compiled using the OpenVMS Alpha Macro32 compiler,
  due to the different way arguments are passed on OpenVMS Alpha.
 
  Compaq Fortran offers an IARGCOUNT intrinsic function -- which takes no
  arguments and which returns the actual argument count.  Compaq C has full
  stdargs.h support for processing variable argument lists, and C provides
  an extension (va_count) which retrieves the argument count.  These
  compiler-provided mechanisms all have the side-effect of causing the
  compiler to copy and transfer the argument list via memory -- this
  memory-based argument list is called "homed" -- which then allows the
  Fortran programs to test %LOC(arg) .EQ. 0 or the C programs to check
  va_count to see if any argument(s) were omitted.
 
  IARGCOUNT and va_count are available in Compaq Fortran OpenVMS VAX and
  in Compaq C for OpenVMS VAX, and are recommended as a replacement for
  the Macro32 stack-cogniscent routines on both VAX and Alpha platforms.

answer written or last revised on ( 9-APR-2001 )

» close window