/**************************************************************************/
/*                                                                        */
/*                                 Sources                                */
/*                                from  the                               */
/*                           XSC SOFTWARE PACKAGE                         */
/*                                                                        */
/*                Copyright (c) 1997 University of Karlsruhe              */
/*                     Institute for Appl. Mathematics                    */
/*                                                                        */
/* This program is free software for non-commercial use. For details, see */
/* the file LICENSE.XSC, distributed with this software package.          */
/*                                                                        */
/* This program is distributed WITHOUT ANY WARRANTY. For details, see the */
/* file LICENSE.XSC, distributed with this software package.              */
/*                                                                        */
/**************************************************************************/

/* RCS $Id: f_wrid.c,v 1.2 1997/09/25 17:24:46 ae59 Exp $ */
/*
$Log: f_wrid.c,v $
 * Revision 1.2  1997/09/25  17:24:46  ae59
 * Copyright-message
 *
 * Revision 1.1  1995/06/28  10:36:37  ae59
 * Initial revision
 *
 * Revision 1.1  1995/06/23  08:02:23  ae59
 * added function counters for testing, add files to complete native
 * C interface.
 *
 * Revision 1.1  1995/05/11  15:10:41  ae59
 * inlined 64 bit version is running now
 *
 * Revision 1.2  1995/01/19  11:33:24  ae59
 * casts in output routines to specified data types (unsigned)
 *
 * Revision 1.1  1994/10/27  17:25:20  ae59
 * Initial revision
 *
 */
/****************************************************************/
/*                                                              */
/*      Filename        : f_wrd1.c                              */
/*                                                              */
/*      Entry           : void f_wrd1(desc,r,mode)              */
/*                        f_text *desc;                         */
/*                        d_otpr r;                             */
/*                        a_char mode ;                         */
/*                                                              */
/*      Arguments       : desc   - device descriptor            */
/*                        r      - real value                   */
/*                                                              */
/*      Description     : performs accu hex dump                */
/*                        The first 6 words contain status      */
/*                        information. 64 Bit of guard digits   */
/*                        are build by A_LOWnan and a_Start.    */
/*                        The accu is left aligned. On the      */
/*                        right side there are 28 bits unused   */
/*                        f_wrd1 writes status information      */
/*                        In respect of mode the output is:     */
/*                        'x' : prints all words in the accu in */
/*                              lower case or upper case if 'X' */
/*                        'z' : prints only nonzero words in the*/ 
/*                              accu in lower case or upper if  */
/*                              'Z' is specified.               */
/*                                                              */
/****************************************************************/

#ifndef ALL_IN_ONE
#ifdef AIX
#include "/u/p88c/runtime/o_defs.h"
#else
#include "o_defs.h"
#endif
#define local
#endif

#ifdef LINT_ARGS
local void f_wrid(FILE*   desc,d_otpr r, a_char mode )
#else
local void f_wrid(desc,r,mode )

FILE   *desc;
d_otpr r;
a_char mode ;
#endif
{
	   static int number_values=(80-4)/(2*sizeof(r[0])+1)+1;
	   char format[10];

        E_TPUSH("f_wrid")


	      a_btyp i,k, start, end;

           strcpy(format,(sizeof(r[0]) ==4)?"%08l":"%016l");

		 if (mode =='x' || mode =='X' ) 
		 {
             strcat(format,(mode=='x')?"x ":"X ");

             start= A_START+1;
#ifdef A_LENGTH_64
		   end  = (a_btyp) A_LENGTH_64-1; 
#else
		   end  = (a_btyp) A_LENGTH-1; 
#endif
		 }
		 else
		 if (mode =='z' || mode =='Z' ) 
		 {
             strcat(format,(mode=='z')?"x ":"X ");
             start = (a_btyp) r[A_BEGIN]; 
		   end   = (a_btyp) r[A_END]; 
		 }
		 else
		 {
              e_trap(I_O_ERROR,4,E_TMSG,51,E_TCHR,&mode);
              E_TPOPP("f_wrd1")
              return;
           }

		 fprintf(desc,"Status Words :");
           for (k=0,i=A_BEGIN; i<=A_START; i++,k++)
		 {
		   if (k%number_values == 0) { fprintf(desc,"\n%03ld|",(long)i);k=1;}
		   fprintf(desc,format,(unsigned long)r[i]);
		 }
		 fprintf(desc,"\n\nFixed point mantissa:");
           for (k=0,i=start; i<=end; i++,k++)
		 {
		   if (k%number_values == 0) { fprintf(desc,"\n%03ld|",(long)i);k=1;}
		   fprintf(desc,format,(unsigned long)r[i]);
	      }
        E_TPOPP("f_wrid");
	   return ;
}

