              <<< NOTED::NOTES$7:[NOTES$LIBRARY]HACKERS.NOTE;1 >>>
                               -< ** Hackers ** >-
================================================================================
Note 1422.2               Where am I ?  Vax or Alpha ?                    2 of 2
XDELTA::HOFFMAN "Steve, OpenVMS Engineering"         60 lines  20-JAN-1997 11:40
         -< Alpha Microprocessor Family And Instruction Set Features >-
--------------------------------------------------------------------------------

   To identify an Alpha system, one can look at the architectural-related
   item codes in f$getsyi.  One can also look for a processor hardware
   model code f$getsyi("HW_MODEL") of 1025 (ALPHA$K_ID_BASE) or greater,
   as these values are issued only to Alpha systems, while the smaller
   values are issued to VAX systems...

   With the OpenVMS Alpha dynamic system recognition, the Alpha processor
   definition codes (in module ALPHADEF) are not getting updated as often
   as they probably should be -- OpenVMS queries the console for this and
   other information.  One of the first serious updates to the ALPHADEF
   module in a while was made in OpenVMS Alpha V7.1.

   And for more information on the particular Alpha microprocessor family
   and/or particular instruction set capabilities, one can use the Alpha
   implver and amask instructions:

	--

/*
//  ALPHA_IMPLVER_AMASK_FEATURES.C
//  Retrieve the Alpha microprocessor family and features
//
//  Author: Steve Hoffman, Digital Equipment Corporation
//  hoffman@xdelta.enet.dec.com, 16-Jan-1997.
//
//  DEC C under OpenVMS (likely also works under Digital UNIX)
//
//  See the Alpha Architecture Reference Manual for the current
//  microprocessor family codes, as well as the instruction set
//  extension definition codes.
*/
#include <stdio.h>
#include <c_asm.h>
main()
    {
    int implver = asm("implver %r0;");
    int amask = asm("amask %a0,%r0;", -1 );
    printf("Alpha Microprocessor Family:\n");
    /*
    //  The "family" includes various derivative microprocessors
    */
    switch ( implver )
        {
        case 0: printf("  EV4 family\n"); break;
        case 1: printf("  EV5 family\n"); break;
        case 2: printf("  EV6 family\n"); break;
        default: printf("  unknown family; implver %d\n", implver ); break;
        }
    /*
    //  The bit is *clear* if the capability is *present*...
    */
    printf("Alpha extensions available:\n");
    if ( amask == -1 ) printf("  none\n");
    if (!( amask & 1L<<0 )) printf("  byte-word, at al\n");
    if (!( amask & 1L<<1 )) printf("  square root, et al\n");
    if (!( amask & 1L<<8 )) printf("  Audio and video, et al\n");
    return 1;
    }

