home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / emulate / sparc / dtrace.c < prev    next >
C/C++ Source or Header  |  1992-01-15  |  2KB  |  98 lines

  1. /*
  2.  * Program to interpret ssim data trace files
  3.  *
  4.  */
  5. #include <stdio.h>
  6. /*
  7.  * Positive entry: read
  8.  * Negative entry: write
  9.  */
  10.  
  11. int array[64] = {
  12.  4, /* ld */
  13.  1, /* ldub */
  14.  2, /* lduh */
  15.  8, /* ldd */
  16. -4, /* st */
  17. -1, /* stb */
  18. -2, /* sth */
  19. -8, /* std */
  20.  0,
  21.  1, /* ldsb */
  22.  2, /* ldsh */
  23.  0,
  24.  0,
  25.  0, /* ldstub */
  26.  0,
  27.  0, /* swap */
  28.  0, /* lda */
  29.  0,
  30.  0, /* lduba */
  31.  0, /* ldda */
  32.  0, /* sta */
  33.  0, /* stba */
  34.  0, /* stha */
  35.  0, /* stda */
  36.  0,
  37.  0, /* ldsba */
  38.  0, /* ldsah */
  39.  0,
  40.  0,
  41.  0, /* ldstuba */
  42.  0,
  43.  0, /* swapa */
  44.  4, /* ldf */
  45.  4, /* ldfsr */
  46.  0,
  47.  8, /* lddf */
  48. -4, /* stf */
  49. -4, /* stfsr */
  50.  0, /* stdfq */
  51. -8  /* stdf */
  52. };
  53.  
  54. FILE *in;
  55.  
  56. main(argc, argv)
  57. int argc;
  58. char **argv; {
  59.   int c, aval;
  60.   long addr;
  61.   if (argc < 2) {
  62.     printf("usage: %s filename\n",argv[0]);
  63.     exit(1);
  64.   }
  65.  
  66. #ifdef MSDOS
  67. #define FMODE "rb"
  68. #else
  69. #define FMODE "r"
  70. #endif /* MSDOS */
  71.  
  72.   if (!(in = fopen(argv[1],FMODE))) {
  73.     perror(argv[1]);
  74.     exit(1);
  75.   }
  76.   while ((c = getc(in)) != EOF) {
  77.     if (c >= 64) {
  78.       printf("%s: bad input\n",argv[1]);
  79.       exit(1);
  80.     }
  81.     if (aval = array[c]) {
  82.       if (aval < 0) {
  83.         printf("write ");
  84.         aval = -aval;
  85.       }
  86.       else {
  87.         printf("read ");
  88.       }
  89.       if (fread((char *)&addr, 4, 1, in) != 1) {
  90.         printf("%s: bad input\n",argv[1]);
  91.         exit(1);
  92.       }
  93.       printf("%d bytes: address 0x%lx\n",aval,addr);
  94.     }
  95.  
  96.   }
  97. }
  98.