home *** CD-ROM | disk | FTP | other *** search
/ Mac Mania 2 / MacMania 2.toast / Demo's / Tools&Utilities / Programming / SPIM Folder / Sources / spim.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-12-06  |  5.4 KB  |  244 lines  |  [TEXT/ttxt]

  1. /* SPIM S20 MIPS simulator.
  2.    Definitions for the SPIM S20.
  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/spim.h,v 1.4 1992/10/12 11:34:38 cs354 Exp $
  23. */
  24.  
  25. #ifndef MACINTOSH
  26. #include <sys/types.h>
  27. #endif
  28.  
  29. #ifdef ultrix
  30. #define const
  31. #endif
  32.  
  33. #define streq(s1, s2) !strcmp(s1, s2)
  34.  
  35. /* Round V to next greatest B boundary */
  36.  
  37. #define ROUND(V, B) (((int) V + (B-1)) & ~(B-1))
  38.  
  39.  
  40. /* Sign-extend a short to a long */
  41.  
  42. #define SIGN_EX(X)    ((X) & 0x8000 ? (X) | 0xffff0000 : (X))
  43.  
  44.  
  45. #define K 1024
  46.  
  47. /* Triple containing a string and two integers.     Used in tables
  48.    mapping from a name to values. */
  49.  
  50. typedef struct strint
  51. {
  52.   char *name;
  53.   int value1;
  54.   int value2;
  55. } inst_info;
  56.  
  57. /* Type of a memory address. */
  58.  
  59. typedef unsigned long mem_addr;
  60.  
  61. /* Useful and pervasive declarations: */
  62.  
  63. void exit(int);
  64. double atof (const char *);
  65. long atol(const char *);
  66. int atoi (const char *);
  67. #ifdef WIN32
  68. #include <memory.h>
  69. #include <stdlib.h>
  70. #define bcopy(src,dest,n) memcpy(dest,src,n)
  71. #define bcmp(p1,p2,n) memcmp(p1,p2,n)
  72. #define bzero(p, n) memset(p, 0, n)
  73. #else
  74. #ifdef MACINTOSH
  75. #include <memory.h>
  76. #include <stdlib.h>
  77. #define bcopy(src,dest,n) memcpy(dest,src,n)
  78. #define bcmp(p1,p2,n) memcmp(p1,p2,n)
  79. #define bzero(p, n) memset(p, 0, n)
  80. #else
  81. void bzero (void *, size_t);
  82. void bcopy (void *, void *, size_t);
  83. int bcmp(void *, void *, size_t);
  84. char *realloc (void *, size_t);
  85. char *malloc (size_t);
  86. #endif
  87. #endif
  88. int fclose (FILE *);
  89. int strcmp (const char *, const char *);
  90. char *strcpy (char *, const char *);
  91. char *strncpy (char *, const char *, int);
  92. void write_output (long, char *);
  93. void read_input(char *, int);
  94. void initialize_world(int);
  95. void initialize_registers(void );
  96. int read_assembly_file(char *);
  97. unsigned long starting_address(void );
  98. void initialize_run_stack(int argc,const char **argv );
  99. int run_program(unsigned long pc,int steps,int display,int cont_bkpt);
  100.  
  101. /* spim-uti.c */
  102.  
  103. void add_breakpoint(unsigned long addr);
  104. void delete_breakpoint(unsigned long addr);
  105. void fatal_error(char *);
  106. void list_breakpoints(void );
  107. int run_error (char *);
  108. void error (char *);
  109. inst_info *map_string_to_inst_info(inst_info tbl[],int tbl_len,
  110.     register char *id);
  111. inst_info *map_int_to_inst_info(inst_info tbl[],int tbl_len,
  112.     register int num);
  113.  
  114. /* scanner */
  115.  
  116. void intialize_scanner(FILE *);
  117. void print_erroneous_line (void);
  118. void scanner_start_line (void);
  119. int register_name_to_number (const char *);
  120. int yylex(void);
  121.  
  122. /* parser */
  123.  
  124. void fix_current_label_address (mem_addr);
  125. struct immexpr *branch_offset (int);
  126. int op_to_imm_op (int);
  127. int imm_op_to_op (int);
  128. void yyerror (const char *);
  129.  
  130. /* Variables: */
  131.  
  132. extern int bare_machine;    /* Simulate bare instruction set */
  133. extern int quiet;        /* No warning messages */
  134. extern int source_file;        /* Program is source, not binary */
  135. extern char mess_buff[];
  136.  
  137.  
  138. extern int message_out, console_out;    /* Real type depends on X/terminal interface */
  139.  
  140.  
  141.  
  142. #define BYTES_PER_WORD 4    /* On the MIPS processor */
  143.  
  144.  
  145. /* Sizes of memory segments. */
  146.  
  147. /* Initial size of text segment. */
  148.  
  149. #ifndef TEXT_SIZE
  150. #define TEXT_SIZE    64*K    /* 64 KB */
  151. #endif
  152.  
  153. /* Initial size of k_text segment. */
  154.  
  155. #ifndef K_TEXT_SIZE
  156. #define K_TEXT_SIZE    64*K    /* 64 KB */
  157. #endif
  158.  
  159. /* The data segment must be larger than 64K since we immediate grab
  160.    64K for the small data segment pointed to by $gp. The data segment is
  161.    expanded by an sbrk system call. */
  162.  
  163. /* Initial size of data segment. */
  164.  
  165. #ifndef DATA_SIZE
  166. #define DATA_SIZE    128*K    /* 128 KB */
  167. #endif
  168.  
  169. /* Maximum size of data segment. */
  170.  
  171. #ifndef DATA_LIMIT
  172. #define DATA_LIMIT    1000*K    /* 1 MB */
  173. #endif
  174.  
  175. /* Initial size of k_data segment. */
  176.  
  177. #ifndef K_DATA_SIZE
  178. #define K_DATA_SIZE    64*K    /* 64 KB */
  179. #endif
  180.  
  181. /* Maximum size of k_data segment. */
  182.  
  183. #ifndef K_DATA_LIMIT
  184. #define K_DATA_LIMIT    1000*K    /* 1 MB */
  185. #endif
  186.  
  187.  
  188. /* The stack grows down automatically. */
  189.  
  190. /* Initial size of stack segment. */
  191.  
  192. #ifndef STACK_SIZE
  193. #define STACK_SIZE    64*K    /* 64 KB */
  194. #endif
  195.  
  196. /* Maximum size of stack segment. */
  197.  
  198. #ifndef STACK_LIMIT
  199. #define STACK_LIMIT    256*K    /* 1 MB */
  200. #endif
  201.  
  202.  
  203. /* Name of the function to invoke at start up */
  204.  
  205. #define DEFAULT_RUN_LOCATION "__start"
  206.  
  207.  
  208. /* Default number of instructions to execute. */
  209.  
  210. #define DEFAULT_RUN_STEPS 2147483647
  211.  
  212.  
  213. /* Address to branch to when exception occurs */
  214.  
  215. #define EXCEPTION_ADDR 0x80000080
  216.  
  217.  
  218. /* Maximum size of object stored in the small data segment pointed to by
  219.    $gp */
  220.  
  221. #define SMALL_DATA_SEG_MAX_SIZE 8
  222.  
  223.  
  224.  
  225. /* Argument passing registers */
  226.  
  227. #define REG_V0 2
  228. #define REG_A0 4
  229. #define REG_A1 5
  230. #define REG_A2 6
  231. #define REG_A3 7
  232. #define REG_FA0 12
  233.  
  234.  
  235. /* Result registers */
  236.  
  237. #define REG_RES 2
  238. #define REG_FRES 0
  239.  
  240.  
  241. /* $gp registers */
  242.  
  243. #define REG_GP 28
  244.