home *** CD-ROM | disk | FTP | other *** search
/ Mac Mania 2 / MacMania 2.toast / Demo's / Tools&Utilities / Programming / SPIM Folder / Sources / reg.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-15  |  2.8 KB  |  101 lines  |  [TEXT/ttxt]

  1. /* SPIM S20 MIPS simulator.
  2.    Declarations of registers and code for accessing them.
  3.    Copyright (C) 1990 by James Larus (larus@cs.wisc.edu).
  4.  
  5.    SPIM is free software; you can redistribute it and/or modify it
  6.    under the terms of the GNU General Public License as published by the
  7.    Free Software Foundation; either version 1, or (at your option) any
  8.    later version.
  9.  
  10.    SPIM is distributed in the hope that it will be useful, but WITHOUT
  11.    ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  12.    FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  13.    for more details.
  14.  
  15.    You should have received a copy of the GNU General Public License
  16.    along with GNU CC; see the file COPYING.  If not, write to James R.
  17.    Larus, Computer Sciences Department, University of Wisconsin--Madison,
  18.    1210 West Dayton Street, Madison, WI 53706, USA or to the Free
  19.    Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
  20.  
  21.  
  22. /* $Header: /var/home/cs354/.spim/RCS/reg.h,v 1.1 1992/10/06 17:34:50 cs354 Exp $
  23. */
  24.  
  25. #ifdef REG_MAIN
  26. #define EXTERN
  27. #else
  28. #define EXTERN extern
  29. #endif
  30.  
  31. typedef int reg_word;
  32.  
  33.  
  34. /* General purpose registers: */
  35.  
  36. EXTERN reg_word R[32];
  37.  
  38. EXTERN reg_word HI, LO;
  39.  
  40. EXTERN mem_addr PC;
  41.  
  42.  
  43.  
  44. /* Floating Point Coprocessor (1) registers :*/
  45.  
  46. EXTERN double *FPR;            /* Dynamically allocate so overlay */
  47. EXTERN float *FGR;            /* is possible */
  48. EXTERN int *FWR;            /* is possible */
  49.  
  50. #define FPR_S(REGNO) (((REGNO) & 0x1) \
  51.               ? (run_error ("Bit 0 in FP reg spec\n") ? 0.0 : 0.0)\
  52.               : FGR[REGNO])
  53.  
  54. #define FPR_D(REGNO) (double) (((REGNO) & 0x1) \
  55.                    ? (run_error ("Bit 0 in FP reg spec\n") ? 0.0 : 0.0)\
  56.                    : FPR[(REGNO) >> 1])
  57.  
  58. #define FPR_W(REGNO) (((REGNO) & 0x1) \
  59.               ? (run_error ("Bit 0 in FP reg spec\n") ? 0 : 0)\
  60.               : FWR[REGNO])
  61.  
  62.  
  63. #define SET_FPR_S(REGNO, VALUE) {if ((REGNO) & 0x1) \
  64.                  run_error ("Bit 0 in FP reg spec\n");\
  65.                  else FGR[REGNO] = (double) (VALUE);}
  66.  
  67. #define SET_FPR_D(REGNO, VALUE) {if ((REGNO) & 0x1) \
  68.                  run_error ("Bit 0 in FP reg spec\n");\
  69.                  else FPR[(REGNO) >> 1] = (double) (VALUE);}
  70.  
  71. #define SET_FPR_W(REGNO, VALUE) {if ((REGNO) & 0x1) \
  72.                  run_error ("Bit 0 in FP reg spec\n");\
  73.                  else FWR[REGNO] = (int) (VALUE);}
  74.  
  75. /* Other Coprocessor Registers The floating point registers
  76.    (coprocessor 1) are allocated elsewhere.  */
  77.  
  78. EXTERN reg_word CpCond[4], CCR[4][32], CPR[4][32];
  79.  
  80.  
  81. /* Exeception Handling Registers (actually registers in Coprocoessor
  82.    0's register file) */
  83.  
  84. EXTERN int exception_occurred;
  85.  
  86. #define Context        (CPR[0][4])
  87. #define BadVAddr    (CPR[0][8])
  88. #define Status_Reg    (CPR[0][12])
  89. #define Cause        (CPR[0][13])
  90. #define EPC        (CPR[0][14])
  91. #define PRId        (CPR[0][15])
  92.  
  93.  
  94. /* Floating point control and condition registers: */
  95.  
  96. #define FCR        CPR[1]
  97. #define FPId        (CPR[1][0])
  98. #define FpCond        (CPR[1][31])
  99.  
  100. #undef EXTERN
  101.