      SUBROUTINE AHEX(IVAL,INDX)
C 
C 
C     THIS SUBROUTINE CONVERTS A VALUE BETWEEN 0 AND (2**IFBIT-1) 
C     INTO HEXADECIMAL OR OCTAL CHARACTERS.  VALUES OUTSIDE THIS
C     RANGE ARE RETURNED AS ASTERISKS.
C 
C     ENTRY PARAMETERS
C        LOCT - FLAG INDICATING WHETHER VALUE IS TO BE OCTAL OR HEX 
C        INDX - INDEX FOR IADDR ARRAY WHERE OUTPUT CHARACTERS ARE PUT 
C        IVAL - VALUE TO CONVERT
C     EXIT PARAMETERS 
C        IADDR - ARRAY THAT HOLDS HEXADECIMAL OUTPUT CHARACTERS 
C
C 
      REAL IVAL,IVAL1,IVAL2 
      DIMENSION JVAL(3) 
      DIMENSION NUMS(16)
      INTEGER FTYPE
      REAL ITABV(249) 
      COMMON ICRD,IPRT,MCFLE,IDFLE,MCREC,IDREC,IFORM,ITRUN,ILOUT,IXCOL
      COMMON MLAB,MOPC,IBIT,ICCNT,IWORD,IERRL,IERRI,IEND,IFRMC
      COMMON LSOR,LIF,LSYM,LREF,LDEF,LOCT,ITRMI,ITRMO
      COMMON ILEN,KLEN,LLEN,KWORD,IFLD(2400),IYFLD,IZFLD
      COMMON IFBIT,ZVAL,CVAL,JREAD,IN(80),INB(80),LINE,IPAGE,LISN
      COMMON IALPH(37),IAST,IDOLR,ISHRP
      COMMON ICOLN,IBLNK,ICTAB,ISEMI,ICOMM,IPLUS,IMIN,IMULT,IDIV
      COMMON IRPAR,ILPAR,IATT(9),JATT(5),LATT(9),IFPAR(16),NBASE,JBASE
      COMMON ICOL,IFCOL,MCOL,MLCOL,IOLIN,ICNT,LTITL(50),IADDR(4,12)
      COMMON ITYPE,JTYPE,FTYPE,IERR,IERRS,IOPVA,JCOL,IBUG
      COMMON ITAB(4,249),ITABS(249),ITABV,NAME(4),INDEX,INDET,ISYM,LTAB
      COMMON IXTAB(256),MXREF,IXT,IXPNT,IXCNT,IXPAG,MCORE(128)
C INCLUDE(:F1:METAD.COM)
      EQUIVALENCE (NUMS(1),IALPH(1))
C   
C     CHECK FOR LEGAL VALUE
      IF(IVAL) 900,30,30
30    IF(IVAL-ZVAL) 40,40,900
C     SET NUMBER BASE 
40    J1 = 256
      J2 = 3
      J3 = 16 
C     INITIALIZE ADDRESS ARRAY INDEX
      K=4 
      IF(LOCT) 50,60,50 
50    J1 = 512
      J2 = 4
      J3 = 8
      K = 1 
C     BREAK 36 BIT REAL NUMBER INTO THREE 12 BIT INTEGERS 
60    IVAL1 = IVAL/4096.
      JVAL(1) = IVAL1/4096. 
      IVAL1 = JVAL(1) 
      IVAL1 = IVAL-IVAL1*4096.*4096.
      JVAL(2) = IVAL1/4096. 
      IVAL2 = JVAL(2) 
      JVAL(3) = IVAL1-IVAL2*4096. 
C     FILL ADDRESS ARRAY WITH HOLLERITH ADDRESS 
      DO 80 I=1,3 
      J4 = J1 
      DO 80 J=1,J2
      M1 = JVAL(I)/J4 
      JVAL(I) = JVAL(I)-M1*J4 
      J4 = J4/J3
      M1 = M1+1 
      IADDR(INDX,K) = NUMS(M1)
      K = K+1 
80    CONTINUE
C     SUPPRESS LEADING ZEROS IF LISTING IS IN HEX 
      IF(LOCT) 990,810,990
C     CHANGE IFBIT TO 19 TO KEEP FROM PRINTING BIG SYMBOL VALUES
810   I = 11-(IFBIT-1)/4
      DO 840 J=1,I
      IADDR(INDX,J) = IBLNK 
840   CONTINUE
      GO TO 990 
C     SET ADDRESS TO ASTERISKS
900   DO 910 J=1,12 
      IADDR(INDX,J) = IAST
910   CONTINUE
990   RETURN
      END 
ADDRESS TO ASTERISKS
900   DO 910 J=1,12 
      IADDR(INDX,J) = IAST
910   CONTINUE
990   RETURN
      END 
