home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / sdktools / image / include / mipsinst.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-14  |  11.7 KB  |  325 lines

  1. /*++ BUILD Version: 0001    // Increment this if a change has global effects
  2.  
  3. Copyright (c) 1993-1997  Microsoft Corporation
  4.  
  5. Module Name:
  6.  
  7.     mipsinst.h
  8.  
  9. Abstract:
  10.  
  11.     Mips instruction and floating constant definitions.
  12.  
  13. Author:
  14.  
  15.     David N. Cutler (davec) 8-May-1992
  16.  
  17. Revision History:
  18.  
  19. --*/
  20.  
  21. #ifndef _MIPSINST_
  22. #define _MIPSINST_
  23.  
  24. //
  25. // Define MIPS instruction format structures.
  26. //
  27.  
  28. typedef union _MIPS_INSTRUCTION {
  29.     ULONG Long;
  30.     UCHAR Byte[4];
  31.  
  32.     struct {
  33.         ULONG Target : 26;
  34.         ULONG Opcode : 6;
  35.     } j_format;
  36.  
  37.     struct {
  38.         LONG Simmediate : 16;
  39.         ULONG Rt : 5;
  40.         ULONG Rs : 5;
  41.         ULONG Opcode : 6;
  42.     } i_format;
  43.  
  44.     struct {
  45.         ULONG Uimmediate : 16;
  46.         ULONG Rt : 5;
  47.         ULONG Rs : 5;
  48.         ULONG Opcode : 6;
  49.     } u_format;
  50.  
  51.     struct {
  52.         ULONG Function : 6;
  53.         ULONG Re : 5;
  54.         ULONG Rd : 5;
  55.         ULONG Rt : 5;
  56.         ULONG Rs : 5;
  57.         ULONG Opcode : 6;
  58.     } r_format;
  59.  
  60.     struct {
  61.         ULONG Function : 6;
  62.         ULONG Re : 5;
  63.         ULONG Rd : 5;
  64.         ULONG Rt : 5;
  65.         ULONG Format : 4;
  66.         ULONG Fill1 : 1;
  67.         ULONG Opcode : 6;
  68.     } f_format;
  69.  
  70.     struct {
  71.         ULONG Function : 6;
  72.         ULONG Fd : 5;
  73.         ULONG Fs : 5;
  74.         ULONG Ft : 5;
  75.         ULONG Format : 4;
  76.         ULONG Fill1 : 1;
  77.         ULONG Opcode : 6;
  78.     } c_format;
  79.  
  80. } MIPS_INSTRUCTION, *PMIPS_INSTRUCTION;
  81.  
  82. //
  83. // Define MIPS instruction opcode values.
  84. //
  85.  
  86. #define SPEC_OP 0x0                     // special opcode - use function field
  87. #define BCOND_OP 0x1                    // condition branch
  88. #define J_OP 0x2                        // unconditional jump
  89. #define JAL_OP 0x3                      // jump and link
  90.  
  91. #define BEQ_OP 0x4                      // branch equal
  92. #define BNE_OP 0x5                      // branch not equal
  93. #define BLEZ_OP 0x6                     // branch less than or equal
  94. #define BGTZ_OP 0x7                     // branch greater than
  95.  
  96. #define ADDI_OP 0x8                     // add immediate signed integer
  97. #define ADDIU_OP 0x9                    // add immediate unsigned integer
  98. #define SLTI_OP 0xa                     // set less than signed integer
  99. #define SLTIU_OP 0xb                    // set less than unsigned integer
  100.  
  101. #define ANDI_OP 0xc                     // and unsigned immediate integer
  102. #define ORI_OP 0xd                      // or unsigned immediate integer
  103. #define XORI_OP 0xe                     // exclusive or unsigned immediate
  104. #define LUI_OP  0xf                     // load upper immediate integer
  105.  
  106. #define COP0_OP 0x10                    // coprocessor 0 operation
  107. #define COP1_OP 0x11                    // coprocessor 1 operation
  108.  
  109. #define BEQL_OP 0x14                    // branch equal likely
  110. #define BNEL_OP 0x15                    // branch not equal likely
  111. #define BLEZL_OP 0x16                   // branch less than or equal likely
  112. #define BGTZL_OP 0x17                   // branch greater than likely
  113.  
  114. #define LDL_OP 0x1a                     // load double left integer
  115. #define LDR_OP 0x1b                     // load double right integer
  116.  
  117. #define LB_OP 0x20                      // load byte signed integer
  118. #define LH_OP 0x21                      // load halfword signed integer
  119. #define LWL_OP 0x22                     // load word left integer
  120. #define LW_OP 0x23                      // load word integer
  121.  
  122. #define LBU_OP 0x24                     // load byte unsigned integer
  123. #define LHU_OP 0x25                     // load halfword unsigned integer
  124. #define LWR_OP 0x26                     // load word right integer
  125. #define LWU_OP 0x27                     // load word unsigned integer
  126.  
  127. #define SB_OP 0x28                      // store byte integer
  128. #define SH_OP 0x29                      // store halfword integer
  129. #define SWL_OP 0x2a                     // store word left integer
  130. #define SW_OP 0x2b                      // store word integer register
  131.  
  132. #define SDL_OP 0x2c                     // store double left integer
  133. #define SDR_OP 0x2d                     // store double right integer
  134. #define SWR_OP 0x2e                     // store word right integer
  135. #define CACHE_OP 0x2f                   // cache operation
  136.  
  137. #define LL_OP 0x30                      // load linked integer register
  138. #define LWC1_OP 0x31                    // load word floating
  139. #define LWC2_OP 0x32                    // load word coprocessor 2
  140.  
  141. #define LLD_OP 0x34                     // load locked double integer
  142. #define LDC1_OP 0x35                    // load word double floating
  143. #define LDC2_OP 0x36                    // load double coprocessor 2
  144. #define LD_OP 0x37                      // load double integer
  145.  
  146. #define SC_OP 0x38                      // store conditional word integer
  147. #define SWC1_OP 0x39                    // store word floating
  148. #define SWC2_OP 0x3a                    // store double coprocessor 2
  149.  
  150. #define SDC_OP 0x3c                     // store conditional double integer
  151. #define SDC1_OP 0x3d                    // store double floating
  152. #define SDC2_OP 0x3e                    // store double copreocessor 2
  153. #define SD_OP 0x3f                      // store double integer register
  154.  
  155. //
  156. // Define special function subopcodes.
  157. //
  158.  
  159. #define SLL_OP 0x0                      // shift left logical integer
  160. #define SRL_OP 0x2                      // shift right logical integer
  161. #define SRA_OP 0x3                      // shift right arithmetic integer
  162.  
  163. #define SLLV_OP 0x4                     // shift left logical variable integer
  164. #define SRLV_OP 0x6                     // shift right logical variable integer
  165. #define SRAV_OP 0x7                     // shift right arithmetic variable integer
  166.  
  167. #define JR_OP 0x8                       // jump register
  168. #define JALR_OP 0x9                     // jump and link register
  169.  
  170. #define SYSCALL_OP 0xc                  // system call trap
  171. #define BREAK_OP 0xd                    // breakpoint trap
  172.  
  173. #define MFHI_OP 0x10                    // more from high integer
  174. #define MTHI_OP 0x11                    // move to high integer
  175. #define MFLO_OP 0x12                    // move from low integer
  176. #define MTLO_OP 0x13                    // move to low integer
  177.  
  178. #define MULT_OP 0x18                    // multiply signed integer
  179. #define MULTU_OP 0x19                   // multiply unsigned integer
  180. #define DIV_OP 0x1a                     // divide signed integer
  181. #define DIVU_OP 0x1b                    // divide unsigned integer
  182.  
  183. #define ADD_OP 0x20                     // add signed integer
  184. #define ADDU_OP 0x21                    // add unsigned integer
  185. #define SUP_OP 0x22                     // subtract signed integer
  186. #define SUBU_OP 0x23                    // subtract unsigned integer
  187.  
  188. #define AND_OP 0x24                     // and integer
  189. #define OR_OP 0x25                      // or integer
  190. #define XOR_OP 0x26                     // exclusive or integer
  191. #define NOR_OP 0x27                     // nor integer
  192.  
  193. #define SLT_OP 0x2a                     // set less signed integer
  194. #define SLTU_OP 0x2b                    // set less unsigned integer
  195.  
  196. //
  197. // Define branch conditional subopcodes.
  198. //
  199.  
  200. #define BLTZ_OP 0x0                     // branch less that zero integer
  201. #define BGEZ_OP 0x1                     // branch greater than or equal zero integer
  202. #define BLTZL_OP 0x2                    // branch less that zero integer liekly
  203. #define BGEZL_OP 0x3                    // branch greater than or equal zero integer likely
  204.  
  205. #define BLTZAL_OP 0x10                  // branch less than zero integer and link
  206. #define BGEZAL_OP 0x11                  // branch greater than or equal zero integer and link
  207. #define BLTZALL_OP 0x12                 // branch less than zero integer and link likely
  208. #define BGEZALL_OP 0x13                 // branch greater than or equal zero integer and link likely
  209.  
  210. //
  211. // Coprocessor branch true and false subfunctions and mask values.
  212. //
  213.  
  214. #define COPz_BC_MASK 0x3e10000          // coprocessor z branch condition mask
  215. #define COPz_BF 0x1000000               // coprocessor z branch false subfunction
  216. #define COPz_BT 0x1010000               // coprocessor z branch true subfunction
  217.  
  218. //
  219. // Define floating coprocessor 1 opcodes.
  220. //
  221.  
  222. #define FLOAT_ADD 0                     // floating add
  223. #define FLOAT_SUBTRACT 1                // floating subtract
  224. #define FLOAT_MULTIPLY 2                // floating multiply
  225. #define FLOAT_DIVIDE 3                  // floating divide
  226. #define FLOAT_SQUARE_ROOT 4             // floating square root
  227. #define FLOAT_ABSOLUTE 5                // floating absolute value
  228. #define FLOAT_MOVE 6                    // floating move
  229. #define FLOAT_NEGATE 7                  // floating negate
  230.  
  231. #define FLOAT_ROUND_QUADWORD 8          // floating round to longword
  232. #define FLOAT_TRUNC_QUADWORD 9          // floating truncate to longword
  233. #define FLOAT_CEIL_QUADWORD 10          // floating ceiling
  234. #define FLOAT_FLOOR_QUADWORD 11         // floating floor
  235.  
  236. #define FLOAT_ROUND_LONGWORD 12         // floating round to longword
  237. #define FLOAT_TRUNC_LONGWORD 13         // floating truncate to longword
  238. #define FLOAT_CEIL_LONGWORD 14          // floating ceiling
  239. #define FLOAT_FLOOR_LONGWORD 15         // floating floor
  240.  
  241. #define FLOAT_ILLEGAL 16                // illegal floating opcode
  242.  
  243. #define FLOAT_COMPARE_SINGLE 17         // floating compare single
  244. #define FLOAT_COMPARE_DOUBLE 18         // floating compare double
  245.  
  246. #define FLOAT_CONVERT_SINGLE 32         // floating convert to single
  247. #define FLOAT_CONVERT_DOUBLE 33         // floating convert to double
  248.  
  249. #define FLOAT_CONVERT_LONGWORD 36       // floating convert to longword integer
  250. #define FLOAT_CONVERT_QUADWORD 37       // floating convert to quadword integer
  251.  
  252. #define FLOAT_COMPARE 48                // starting floating compare code
  253.  
  254. //
  255. // Define floating format values.
  256. //
  257.  
  258. #define FORMAT_SINGLE 0                 // single floating format
  259. #define FORMAT_DOUBLE 1                 // double floating format
  260. #define FORMAT_LONGWORD 4               // longword integer format
  261. #define FORMAT_QUADWORD 5               // quadword integer format
  262.  
  263. //
  264. // Define jump indirect return address register.
  265. //
  266.  
  267. #define JUMP_RA 0x3e00008               // jump indirect return address
  268.  
  269. //
  270. // Define maximum and minimum single and double exponent values.
  271. //
  272.  
  273. #define DOUBLE_MAXIMUM_EXPONENT 2047
  274. #define DOUBLE_MINIMUM_EXPONENT 0
  275. #define SINGLE_MAXIMUM_EXPONENT 255
  276. #define SINGLE_MINIMUM_EXPONENT 0
  277.  
  278. //
  279. // Define single and double exponent bias values.
  280. //
  281.  
  282. #define SINGLE_EXPONENT_BIAS 127
  283. #define DOUBLE_EXPONENT_BIAS 1023
  284.  
  285. //
  286. // Define the largest single and double values;
  287. //
  288.  
  289. #define DOUBLE_MAXIMUM_VALUE 0x7fefffffffffffff
  290. #define DOUBLE_MAXIMUM_VALUE_LOW 0xffffffff
  291. #define DOUBLE_MAXIMUM_VALUE_HIGH 0x7fefffff
  292. #define SINGLE_MAXIMUM_VALUE 0x7f7fffff
  293.  
  294. //
  295. // Define single and double quite and signaling Nan values.
  296. //
  297.  
  298. #define DOUBLE_NAN_LOW 0xffffffff
  299. #define DOUBLE_QUIET_NAN 0x7ff7ffff
  300. #define DOUBLE_SIGNAL_NAN 0x7fffffff
  301. #define SINGLE_QUIET_NAN 0x7fbfffff
  302. #define SINGLE_SIGNAL_NAN 0x7fffffff
  303. #define DOUBLE_INTEGER_NAN 0x7fffffffffffffff
  304. #define SINGLE_INTEGER_NAN 0x7fffffff
  305.  
  306. //
  307. // Define positive single and double infinity values.
  308. //
  309.  
  310. #define DOUBLE_INFINITY_VALUE 0x7ff0000000000000
  311. #define DOUBLE_INFINITY_VALUE_LOW 0x0
  312. #define DOUBLE_INFINITY_VALUE_HIGH 0x7ff00000
  313. #define SINGLE_INFINITY_VALUE 0x7f800000
  314.  
  315. //
  316. // Define rounding modes.
  317. //
  318.  
  319. #define ROUND_TO_NEAREST 0              // round to nearest representable value
  320. #define ROUND_TO_ZERO 1                 // round toward zero
  321. #define ROUND_TO_PLUS_INFINITY 2        // round toward plus infinity
  322. #define ROUND_TO_MINUS_INFINITY 3       // round toward minus infinity
  323.  
  324. #endif // MIPSINST
  325.