home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / vc98 / include / alphaops.h < prev    next >
C/C++ Source or Header  |  1998-04-25  |  43KB  |  1,242 lines

  1. /*++
  2.  
  3. Copyright (c) 1992-1996  Digital Equipment Corporation
  4.  
  5. Module Name:
  6.  
  7.     alphaops.h
  8.  
  9. Abstract:
  10.  
  11.     Alpha AXP instruction and floating constant definitions.
  12.  
  13. Author:
  14.  
  15. Revision History:
  16.  
  17. --*/
  18.  
  19. #ifndef _ALPHAOPS_
  20. #define _ALPHAOPS_
  21.  
  22. //
  23. // Instruction types.
  24. //      The Alpha architecture does not number the instruction types,
  25. //      this numbering is for software decoding only.
  26. //
  27.  
  28. #define ALPHA_UNKNOWN           0       // Reserved or illegal
  29. #define ALPHA_MEMORY            1       // Memory (load/store)
  30. #define ALPHA_FP_MEMORY         2       // Floating point Memory
  31. #define ALPHA_MEMSPC            3       // Memory special
  32. #define ALPHA_JUMP              4       // Jump (memory formation)
  33. #define ALPHA_BRANCH            5       // Branch
  34. #define ALPHA_FP_BRANCH         6       // Floating Point Branch
  35. #define ALPHA_OPERATE           7       // Register-register operate
  36. #define ALPHA_LITERAL           8       // Literal-register operate
  37. #define ALPHA_FP_OPERATE        9       // Floating point operate
  38. #define ALPHA_FP_CONVERT        10      // Floating point convert
  39. #define ALPHA_CALLPAL           11      // Call to PAL
  40. #define ALPHA_EV4_PR            12      // EV4 MTPR/MFPR PAL mode instructions
  41. #define ALPHA_EV4_MEM           13      // EV4 special memory PAL mode access
  42. #define ALPHA_EV4_REI           14      // EV4 PAL mode switch
  43.  
  44. //
  45. // Instruction Opcodes.
  46. //
  47.  
  48. #define CALLPAL_OP      0x00    // ALPHA_CALLPAL
  49. #define _01_OP          0x01    // - reserved opcode
  50. #define _02_OP          0x02    // - reserved opcode
  51. #define _03_OP          0x03    // - reserved opcode
  52. #define _04_OP          0x04    // - reserved opcode
  53. #define _05_OP          0x05    // - reserved opcode
  54. #define _06_OP          0x06    // - reserved opcode
  55. #define _07_OP          0x07    // - reserved opcode
  56. #define _0A_OP                  0x0A    // - reserved opcode
  57. #define _0C_OP                  0x0C    // - reserved opcode
  58. #define _0D_OP                  0x0D    // - reserved opcode
  59. #define _0E_OP                  0x0E    // - reserved opcode
  60. #define _1C_OP                  0x1C    // - reserved opcode
  61. #define LDA_OP          0x08    // ALPHA_MEMORY
  62. #define LDAH_OP         0x09    // ALPHA_MEMORY
  63. #define LDBU_OP         0x0A    // ALPHA_MEMORY
  64. #define LDQ_U_OP        0x0B    // ALPHA_MEMORY
  65. #define LDWU_OP         0x0C    // ALPHA_MEMORY
  66. #define STW_OP          0x0D    // ALPHA_MEMORY
  67. #define STB_OP          0x0E    // ALPHA_MEMORY
  68. #define STQ_U_OP        0x0F    // ALPHA_MEMORY
  69. #define ARITH_OP        0x10    // ALPHA_OPERATE or ALPHA_LITERAL
  70. #define BIT_OP          0x11    // ALPHA_OPERATE or ALPHA_LITERAL
  71. #define BYTE_OP         0x12    // ALPHA_OPERATE or ALPHA_LITERAL
  72. #define MUL_OP          0x13    // ALPHA_OPERATE or ALPHA_LITERAL
  73. #define _14_OP          0x14    // - reserved opcode
  74. #define VAXFP_OP        0x15    // ALPHA_FP_OPERATE
  75. #define IEEEFP_OP       0x16    // ALPHA_FP_OPERATE
  76. #define FPOP_OP         0x17    // ALPHA_FP_OPERATE
  77. #define MEMSPC_OP       0x18    // ALPHA_MEMORY
  78. #define PAL19_OP        0x19    // - reserved for PAL mode
  79. //#define MFPR_OP         0x19    // ALPHA_MFPR
  80. #define JMP_OP          0x1A    // ALPHA_JUMP
  81. #define PAL1B_OP        0x1B    // - reserved for PAL mode
  82. #define SEXT_OP         0x1C    // ALPHA_OPERATE
  83. #define PAL1D_OP        0x1D    // - reserved for PAL mode
  84. //#define MTPR_OP         0x1D    // ALPHA_MTPR
  85. #define PAL1E_OP        0x1E    // - reserved for PAL mode
  86. #define PAL1F_OP        0x1F    // - reserved for PAL mode
  87. #define LDF_OP          0x20    // ALPHA_MEMORY
  88. #define LDG_OP          0x21    // ALPHA_MEMORY
  89. #define LDS_OP          0x22    // ALPHA_MEMORY
  90. #define LDT_OP          0x23    // ALPHA_MEMORY
  91. #define STF_OP          0x24    // ALPHA_MEMORY
  92. #define STG_OP          0x25    // ALPHA_MEMORY
  93. #define STS_OP          0x26    // ALPHA_MEMORY
  94. #define STT_OP          0x27    // ALPHA_MEMORY
  95. #define LDL_OP          0x28    // ALPHA_MEMORY
  96. #define LDQ_OP          0x29    // ALPHA_MEMORY
  97. #define LDL_L_OP        0x2A    // ALPHA_MEMORY
  98. #define LDQ_L_OP        0x2B    // ALPHA_MEMORY
  99. #define STL_OP          0x2C    // ALPHA_MEMORY
  100. #define STQ_OP          0x2D    // ALPHA_MEMORY
  101. #define STL_C_OP        0x2E    // ALPHA_MEMORY
  102. #define STQ_C_OP        0x2F    // ALPHA_MEMORY
  103. #define BR_OP           0x30    // ALPHA_BRANCH
  104. #define FBEQ_OP         0x31    // ALPHA_BRANCH
  105. #define FBLT_OP         0x32    // ALPHA_BRANCH
  106. #define FBLE_OP         0x33    // ALPHA_BRANCH
  107. #define BSR_OP          0x34    // ALPHA_BRANCH
  108. #define FBNE_OP         0x35    // ALPHA_BRANCH
  109. #define FBGE_OP         0x36    // ALPHA_BRANCH
  110. #define FBGT_OP         0x37    // ALPHA_BRANCH
  111. #define BLBC_OP         0x38    // ALPHA_BRANCH
  112. #define BEQ_OP          0x39    // ALPHA_BRANCH
  113. #define BLT_OP          0x3A    // ALPHA_BRANCH
  114. #define BLE_OP          0x3B    // ALPHA_BRANCH
  115. #define BLBS_OP         0x3C    // ALPHA_BRANCH
  116. #define BNE_OP          0x3D    // ALPHA_BRANCH
  117. #define BGE_OP          0x3E    // ALPHA_BRANCH
  118. #define BGT_OP          0x3F    // ALPHA_BRANCH
  119.  
  120. #define LDA_OP_STR      "lda"
  121. #define LDAH_OP_STR     "ldah"
  122. #define LDBU_OP_STR     "ldbu"
  123. #define LDQ_U_OP_STR    "ldq_u"
  124. #define STQ_U_OP_STR    "stq_u"
  125. #define LDF_OP_STR      "ldf"
  126. #define LDG_OP_STR      "ldg"
  127. #define LDS_OP_STR      "lds"
  128. #define LDT_OP_STR      "ldt"
  129. #define LDWU_OP_STR     "ldwu"
  130. #define STF_OP_STR      "stf"
  131. #define STG_OP_STR      "stg"
  132. #define STS_OP_STR      "sts"
  133. #define STT_OP_STR      "stt"
  134. #define LDL_OP_STR      "ldl"
  135. #define LDQ_OP_STR      "ldq"
  136. #define LDL_L_OP_STR    "ldl_l"
  137. #define LDQ_L_OP_STR    "ldq_l"
  138. #define SEXT_OP_STR     "sext"
  139. #define STB_OP_STR      "stb"
  140. #define STL_OP_STR      "stl"
  141. #define STQ_OP_STR      "stq"
  142. #define STL_C_OP_STR    "stl_c"
  143. #define STQ_C_OP_STR    "stq_c"
  144. #define STW_OP_STR      "stw"
  145. #define BR_OP_STR       "br"
  146. #define FBEQ_OP_STR     "fbeq"
  147. #define FBLT_OP_STR     "fblt"
  148. #define FBLE_OP_STR     "fble"
  149. #define BSR_OP_STR      "bsr"
  150. #define FBNE_OP_STR     "fbne"
  151. #define FBGE_OP_STR     "fbge"
  152. #define FBGT_OP_STR     "fbgt"
  153. #define BLBC_OP_STR     "blbc"
  154. #define BEQ_OP_STR      "beq"
  155. #define BLT_OP_STR      "blt"
  156. #define BLE_OP_STR      "ble"
  157. #define BLBS_OP_STR     "blbs"
  158. #define BNE_OP_STR      "bne"
  159. #define BGE_OP_STR      "bge"
  160. #define BGT_OP_STR      "bgt"
  161.  
  162. //
  163. // Type (1) Memory Instruction Format.
  164. // Type (2) Memory Special Instruction Format.
  165. //
  166. //  3         2 2       2 2       1 1
  167. //  1         6 5       1 0       6 5                             0
  168. // +-----------+---------+---------+-------------------------------+
  169. // |   opcode  |   Ra    |   Rb    |          Memory_disp          |
  170. // +-----------+---------+---------+-------------------------------+
  171. //
  172. //      LDAx    Ra.wq,disp.ab(Rb.ab)            x = (,H)
  173. //      LDx     Ra.wq,disp.ab(Rb.ab)            x = (L,Q,F,G,S,T)
  174. //      LDQ_U   Ra.wq,disp.ab(Rb.ab)
  175. //      LDx_L   Ra.wq,disp.ab(Rb.ab)            x = (L,Q)
  176. //      STx_C   Ra.mq,disp.ab(Rb.ab)            x = (L,Q)
  177. //      STx     Ra.rq,disp.ab(Rb.ab)            x = (L,Q,F,G,S,T)
  178. //      STQ_U   Ra.rq,disp.ab(Rb.ab)
  179. //
  180.  
  181. typedef struct _Alpha_Memory_Format {
  182.         LONG MemDisp : 16;
  183.         ULONG Rb : 5;
  184.         ULONG Ra : 5;
  185.         ULONG Opcode : 6;
  186. } Alpha_Memory_Format;
  187.  
  188. //
  189. // Special Memory instruction function codes (in Memdisp).
  190. //
  191.  
  192. #define TRAPB_FUNC        0x0000
  193. #define EXCB_FUNC         0x0400
  194. #define MB_FUNC           0x4000
  195. #define WMB_FUNC          0x4400
  196. #define MB2_FUNC          0x4800
  197. #define MB3_FUNC          0x4C00
  198. #define FETCH_FUNC        0x8000
  199. #define FETCH_M_FUNC      0xA000
  200. #define RPCC_FUNC         0xC000
  201. #define RC_FUNC           0xE000
  202. #define RS_FUNC           0xF000
  203.  
  204. #define TRAPB_FUNC_STR     "trapb"
  205. #define EXCB_FUNC_STR      "excb"
  206. #define MB_FUNC_STR        "mb"
  207. #define MB1_FUNC_STR       "wmb"
  208. #define MB2_FUNC_STR       "mb2"
  209. #define MB3_FUNC_STR       "mb3"
  210. #define FETCH_FUNC_STR     "fetch"
  211. #define FETCH_M_FUNC_STR   "fetch_m"
  212. #define RPCC_FUNC_STR      "rpcc"
  213. #define RC_FUNC_STR        "rc"
  214. #define RS_FUNC_STR        "rs"
  215.  
  216. //
  217. // Type (3) Memory Format Jump Instructions.
  218. //
  219. //  3         2 2       2 2       1 1 1 1
  220. //  1         6 5       1 0       6 5 4 3                         0
  221. // +-----------+---------+---------+---+---------------------------+
  222. // |   opcode  |   Ra    |   Rb    |Fnc|            Hint           |
  223. // +-----------+---------+---------+---+---------------------------+
  224. //
  225. //      xxx     Ra.wq,(Rb.ab),hint      xxx = (JMP, JSR, RET, JSR_COROUTINE)
  226. //
  227.  
  228. typedef struct _Alpha_Jump_Format {
  229.         LONG Hint : 14;
  230.         ULONG Function : 2;
  231.         ULONG Rb : 5;
  232.         ULONG Ra : 5;
  233.         ULONG Opcode : 6;
  234. } Alpha_Jump_Format;
  235.  
  236. //
  237. // Jump function codes (in Function, opcode 1A, JMP_OP).
  238. //
  239.  
  240. #define JMP_FUNC        0x0     // Jump
  241. #define JSR_FUNC        0x1     // Jump to Subroutine
  242. #define RET_FUNC        0x2     // Return from Subroutine
  243. #define JSR_CO_FUNC     0x3     // Jump to Subroutine Return
  244.  
  245. #define JMP_FUNC_STR      "jmp"
  246. #define JSR_FUNC_STR      "jsr"
  247. #define RET_FUNC_STR      "ret"
  248. #define JSR_CO_FUNC_STR   "jsr_coroutine"
  249.  
  250. //
  251. // The exception handling compatible return instruction has a hint value
  252. // of 0001. Define a macro that identifies these return instructions.
  253. // The Rb register field is masked out since it is normally, but not
  254. // required to be, RA_REG.
  255. //
  256.  
  257. #define IS_RETURN_0001_INSTRUCTION(Instruction) \
  258.     (((Instruction) & 0xFFE0FFFF) == 0x6BE08001)
  259.  
  260. //
  261. // Type (4) Branch Instruction Format.
  262. //
  263. //  3         2 2       2 2
  264. //  1         6 5       1 0                                       0
  265. // +-----------+---------+-----------------------------------------+
  266. // |   opcode  |   Ra    |             Branch_disp                 |
  267. // +-----------+---------+-----------------------------------------+
  268. //
  269. //      Bxx     Ra.rq,disp.al           x = (EQ,NE,LT,LE,GT,GE,LBC,LBS)
  270. //      BxR     Ra.wq,disp.al           x = (,S)
  271. //      FBxx    Ra.rq,disp.al           x = (EQ,NE,LT,LE,GT,GE)
  272. //
  273.  
  274. typedef struct _Alpha_Branch_Format {
  275.         LONG BranchDisp : 21;
  276.         ULONG Ra : 5;
  277.         ULONG Opcode : 6;
  278. } Alpha_Branch_Format;
  279.  
  280. //
  281. // Type (5) Operate Register Instruction Format.
  282. // Type (6) Operate Literal Instruction Format.
  283. //               bop = Rb.rq or #b.ib
  284. //
  285. //  3         2 2       2 2       1 1   1 1 1
  286. //  1         6 5       1 0       6 5   3 2 1           5 4       0
  287. // +-----------+---------+---------+-----+-+-------------+---------+
  288. // |   opcode  |   Ra    |   Rb    | SBZ |0|  function   |   Rc    |
  289. // +-----------+---------+---------+-----+-+-------------+---------+
  290. //  3         2 2       2 2             1 1 1
  291. //  1         6 5       1 0             3 2 1           5 4       0
  292. // +-----------+---------+---------------+-+-------------+---------+
  293. // |   opcode  |   Ra    |      LIT      |1|  function   |   Rc    |
  294. // +-----------+---------+---------------+-+-------------+---------+
  295. //
  296. //
  297. //      ADDx    Ra.rq,bop,Rc.wq /V      x = (Q,L)
  298. //      SxADDy  Ra.rq,bop,Rc.wq         x = (4,8), y = (Q, L)
  299. //      CMPx    Ra.rq,bop,Rc.wq         x = (EQ,LT,LE,ULT,ULE)
  300. //      MULx    Ra.rq,bop,Rc.wq /V      x = (Q,L)
  301. //      UMULH   Ra.rq,bop,Rc.wq
  302. //      SUBx    Ra.rq,bop,Rc.wq /V      x = (Q,L)
  303. //      SxSUBy  Ra.rq,bop,Rc.wq         x = (4,8), y = (Q, L)
  304. //      xxx     Ra.rq,bop,Rc.wq         xxx = (AND,BIS,XOR,BIC,ORNOT,EQV)
  305. //      CMOVxx  Ra.rq,bop,Rc.wq         xx = (EQ,NE,LT,LE,GT,GE,LBC,LBS)
  306. //      SxL     Ra.rq,bop,Rc.wq         x = (L,R)
  307. //      SRA     Ra.rq,bop,Rc.wq
  308. //      CMPBGE  Ra.rq,bop,Rc.wq
  309. //      EXTxx   Ra.rq,bop,Rc.wq         xx = (BL,WL,WH,LL,LH,WL,QH)
  310. //      INSxx   Ra.rq,bop,Rc.wq         xx = (BL,WL,WH,LL,LH,WL,QH)
  311. //      MSKxx   Ra.rq,bop,Rc.wq         xx = (BL,WL,WH,LL,LH,WL,QH)
  312. //      ZAPx    Ra.rq,bop,Rc.wq         x = (,NOT)
  313. //
  314.  
  315. typedef struct _Alpha_OpReg_Format {
  316.         ULONG Rc : 5;
  317.         ULONG Function : 7;
  318.         ULONG RbvType : 1;              // 0 for register format
  319.         ULONG SBZ : 3;
  320.         ULONG Rb : 5;
  321.         ULONG Ra : 5;
  322.         ULONG Opcode : 6;
  323. } Alpha_OpReg_Format;
  324.  
  325. typedef struct _Alpha_OpLit_Format {
  326.         ULONG Rc : 5;
  327.         ULONG Function : 7;
  328.         ULONG RbvType : 1;              // 1 for literal format
  329.         ULONG Literal : 8;
  330.         ULONG Ra : 5;
  331.         ULONG Opcode : 6;
  332. } Alpha_OpLit_Format;
  333.  
  334. #define RBV_REGISTER_FORMAT 0
  335. #define RBV_LITERAL_FORMAT 1
  336.  
  337. //
  338. // Arithmetic operate function codes (in Function, Opcode 10, ARITH_OP).
  339. //
  340.  
  341. #define ADDL_FUNC       0x00    // Add Longword
  342. #define ADDLV_FUNC      0x40    // Add Longword, Integer Overflow Enable
  343. #define S4ADDL_FUNC     0x02    // Scaled Add Longword by 4
  344. #define S8ADDL_FUNC     0x12    // Scaled Add Longword by 8
  345.  
  346. #define ADDQ_FUNC       0x20    // Add Quadword
  347. #define ADDQV_FUNC      0x60    // Add Quadword, Integer Overflow Enable
  348. #define S4ADDQ_FUNC     0x22    // Scaled Add Quadword by 4
  349. #define S8ADDQ_FUNC     0x32    // Scaled Add Quadword by 8
  350.  
  351. #define SUBL_FUNC       0x09    // Subtract Longword
  352. #define SUBLV_FUNC      0x49    // Subtract Longword, Integer Overflow Enable
  353. #define S4SUBL_FUNC     0x0B    // Scaled Subtract Longword by 4
  354. #define S8SUBL_FUNC     0x1B    // Scaled Subtract Longword by 8
  355.  
  356. #define SUBQ_FUNC       0x29    // Subtract Quadword
  357. #define SUBQV_FUNC      0x69    // Subtract Quadword, Integer Overflow Enable
  358. #define S4SUBQ_FUNC     0x2B    // Scaled Subtract Quadword by 4
  359. #define S8SUBQ_FUNC     0x3B    // Scaled Subtract Quadword by 8
  360.  
  361. #define CMPEQ_FUNC      0x2D    // Compare Signed Quadword Equal
  362. #define CMPLT_FUNC      0x4D    // Compare Signed Quadword Less Than
  363. #define CMPLE_FUNC      0x6D    // Compare Signed Quadword Less Than or Equal
  364. #define CMPULT_FUNC     0x1D    // Compare Unsigned Quadword Less Than
  365. #define CMPULE_FUNC     0x3D    // Compare Unsigned Quadword Less Than or Equal
  366. #define CMPBGE_FUNC     0x0F    // Compare 8 Unsigned Bytes Greater Than or Equal
  367.  
  368. #define ADDL_FUNC_STR     "addl"
  369. #define ADDLV_FUNC_STR    "addl/v"
  370. #define S4ADDL_FUNC_STR   "s4addl"
  371. #define S8ADDL_FUNC_STR   "s8addl"
  372.  
  373. #define ADDQ_FUNC_STR     "addq"
  374. #define ADDQV_FUNC_STR    "addq/v"
  375. #define S4ADDQ_FUNC_STR   "s4addq"
  376. #define S8ADDQ_FUNC_STR   "s8addq"
  377.  
  378. #define SUBL_FUNC_STR     "subl"
  379. #define SUBLV_FUNC_STR    "subl/v"
  380. #define S4SUBL_FUNC_STR   "s4subl"
  381. #define S8SUBL_FUNC_STR   "s8subl"
  382.  
  383. #define SUBQ_FUNC_STR     "subq"
  384. #define SUBQV_FUNC_STR    "subq/v"
  385. #define S4SUBQ_FUNC_STR   "s4subq"
  386. #define S8SUBQ_FUNC_STR   "s8subq"
  387.  
  388. #define CMPEQ_FUNC_STR    "cmpeq"
  389. #define CMPLT_FUNC_STR    "cmplt"
  390. #define CMPLE_FUNC_STR    "cmple"
  391. #define CMPULT_FUNC_STR   "cmpult"
  392. #define CMPULE_FUNC_STR   "cmpule"
  393. #define CMPBGE_FUNC_STR   "cmpbge"
  394.  
  395. //
  396. // Bit and conditional operate function codes (in Function, Opcode 11, BIT_OP).
  397. //
  398.  
  399. #define AND_FUNC        0x00    // Logical Product
  400. #define BIC_FUNC        0x08    // Logical Product with Complement
  401. #define BIS_FUNC        0x20    // Logical Sum (OR)
  402. #define EQV_FUNC        0x48    // Logical Equivalence (XORNOT)
  403. #define ORNOT_FUNC      0x28    // Logical Sum with Complement
  404. #define XOR_FUNC        0x40    // Logical Difference
  405.  
  406. #define CMOVEQ_FUNC     0x24    // CMOVE if Register Equal to Zero
  407. #define CMOVGE_FUNC     0x46    // CMOVE if Register Greater Than or Equal to Zero
  408. #define CMOVGT_FUNC     0x66    // CMOVE if Register Greater Than Zero
  409. #define CMOVLBC_FUNC    0x16    // CMOVE if Register Low Bit Clear
  410. #define CMOVLBS_FUNC    0x14    // CMOVE if Register Low Bit Set
  411. #define CMOVLE_FUNC     0x64    // CMOVE if Register Less Than or Equal to Zero
  412. #define CMOVLT_FUNC     0x44    // CMOVE if Register Less Than Zero
  413. #define CMOVNE_FUNC     0x26    // CMOVE if Register Not Equal to Zero
  414.  
  415. #define AND_FUNC_STR       "and"
  416. #define BIC_FUNC_STR       "bic"
  417. #define BIS_FUNC_STR       "bis"
  418. #define EQV_FUNC_STR       "eqv"
  419. #define ORNOT_FUNC_STR     "ornot"
  420. #define XOR_FUNC_STR       "xor"
  421.  
  422. #define CMOVEQ_FUNC_STR    "cmoveq"
  423. #define CMOVGE_FUNC_STR    "cmovge"
  424. #define CMOVGT_FUNC_STR    "cmovgt"
  425. #define CMOVLBC_FUNC_STR   "cmovlbc"
  426. #define CMOVLBS_FUNC_STR   "cmovlbs"
  427. #define CMOVLE_FUNC_STR    "cmovle"
  428. #define CMOVLT_FUNC_STR    "cmovlt"
  429. #define CMOVNE_FUNC_STR    "cmovne"
  430.  
  431. //
  432. // Shift and byte operate function codes (in Function, Opcode 12, BYTE_OP).
  433. //
  434.  
  435. #define SLL_FUNC        0x39    // Shift Left Logical
  436. #define SRL_FUNC        0x34    // Shift Right Logical
  437. #define SRA_FUNC        0x3C    // Shift Right Arithmetic
  438.  
  439. #define EXTBL_FUNC      0x06    // Extract Byte Low
  440. #define EXTWL_FUNC      0x16    // Extract Word Low
  441. #define EXTLL_FUNC      0x26    // Extract Longword Low
  442. #define EXTQL_FUNC      0x36    // Extract Quadword Low
  443. #define EXTWH_FUNC      0x5A    // Extract Word High
  444. #define EXTLH_FUNC      0x6A    // Extract Longword High
  445. #define EXTQH_FUNC      0x7A    // Extract Quadword High
  446.  
  447. #define INSBL_FUNC      0x0B    // Insert Byte Low
  448. #define INSWL_FUNC      0x1B    // Insert Word Low
  449. #define INSLL_FUNC      0x2B    // Insert Longword Low
  450. #define INSQL_FUNC      0x3B    // Quadword Low
  451. #define INSWH_FUNC      0x57    // Insert Word High
  452. #define INSLH_FUNC      0x67    // Insert Longword High
  453. #define INSQH_FUNC      0x77    // Insert Quadword High
  454.  
  455. #define MSKBL_FUNC      0x02    // Mask Byte Low
  456. #define MSKWL_FUNC      0x12    // Mask Word Low
  457. #define MSKLL_FUNC      0x22    // Mask Longword Low
  458. #define MSKQL_FUNC      0x32    // Mask Quadword Low
  459. #define MSKWH_FUNC      0x52    // Mask Word High
  460. #define MSKLH_FUNC      0x62    // Mask Longword High
  461. #define MSKQH_FUNC      0x72    // Mask Quadword High
  462.  
  463. #define ZAP_FUNC        0x30    // Zero Bytes
  464. #define ZAPNOT_FUNC     0x31    // Zero Bytes Not
  465.  
  466. #define SLL_FUNC_STR    "sll"
  467. #define SRL_FUNC_STR    "srl"
  468. #define SRA_FUNC_STR    "sra"
  469.  
  470. #define EXTBL_FUNC_STR  "extbl"
  471. #define EXTWL_FUNC_STR  "extwl"
  472. #define EXTLL_FUNC_STR  "extll"
  473. #define EXTQL_FUNC_STR  "extql"
  474. #define EXTWH_FUNC_STR  "extwh"
  475. #define EXTLH_FUNC_STR  "extlh"
  476. #define EXTQH_FUNC_STR  "extqh"
  477.  
  478. #define INSBL_FUNC_STR  "insbl"
  479. #define INSWL_FUNC_STR  "inswl"
  480. #define INSLL_FUNC_STR  "insll"
  481. #define INSQL_FUNC_STR  "insql"
  482. #define INSWH_FUNC_STR  "inswh"
  483. #define INSLH_FUNC_STR  "inslh"
  484. #define INSQH_FUNC_STR  "insqh"
  485.  
  486. #define MSKBL_FUNC_STR  "mskbl"
  487. #define MSKWL_FUNC_STR  "mskwl"
  488. #define MSKLL_FUNC_STR  "mskll"
  489. #define MSKQL_FUNC_STR  "mskql"
  490. #define MSKWH_FUNC_STR  "mskwh"
  491. #define MSKLH_FUNC_STR  "msklh"
  492. #define MSKQH_FUNC_STR  "mskqh"
  493.  
  494. #define ZAP_FUNC_STR    "zap"
  495. #define ZAPNOT_FUNC_STR "zapnot"
  496.  
  497. //
  498. // Integer multiply operate function codes (in Function, Opcode 13, MUL_OP).
  499. //
  500.  
  501. #define MULL_FUNC       0x00    // Multiply Longword
  502. #define MULLV_FUNC      0x40    // Multiply Longword, Integer Overflow Enable
  503. #define MULQ_FUNC       0x20    // Multiply Quadword
  504. #define MULQV_FUNC      0x60    // Multiply Quadword, Integer Overflow Enable
  505. #define UMULH_FUNC      0x30    // Unsinged Multiply Quadword High
  506.  
  507. #define MULL_FUNC_STR   "mull"
  508. #define MULLV_FUNC_STR  "mull/v"
  509. #define MULQ_FUNC_STR   "mulq"
  510. #define MULQV_FUNC_STR  "mulq/v"
  511. #define UMULH_FUNC_STR  "umulh"
  512.  
  513. //
  514. // Sign extend operate function codes (in Function, Opcode 1c, SEXT_OP).
  515. //
  516.  
  517. #define SEXTB_FUNC 0
  518. #define SEXTW_FUNC 1
  519.  
  520. #define SEXTB_FUNC_STR      "sextb"
  521. #define SEXTW_FUNC_STR      "sextw"
  522.  
  523. //
  524. // Type (7) Floating-point Operate Instruction Format.
  525. // Type (8) Floating-point Convert Instruction Format.
  526. //
  527. // Type 6 and 7 are the same, except for type 7
  528. //      Fc == F31 (1s) and Fb is the source.
  529. //
  530. //  3         2 2       2 2       1 1
  531. //  1         6 5       1 0       6 5                   5 4       0
  532. // +-----------+---------+---------+---------------------+---------+
  533. // |   opcode  |   Fa    |   Fb    |      function       |   Fc    |
  534. // +-----------+---------+---------+---------------------+---------+
  535. //
  536.  
  537. typedef struct _Alpha_FpOp_Format {
  538.         ULONG Fc : 5;
  539.         ULONG Function : 11;
  540.         ULONG Fb : 5;
  541.         ULONG Fa : 5;
  542.         ULONG Opcode : 6;
  543. } Alpha_FpOp_Format;
  544.  
  545. //
  546. // Format independent function codes (in Function, Opcode 17)
  547. //
  548.  
  549. #define CVTLQ_FUNC      0x010
  550. #define CPYS_FUNC       0x020
  551. #define CPYSN_FUNC      0x021
  552. #define CPYSE_FUNC      0x022
  553. #define MT_FPCR_FUNC    0x024
  554. #define MF_FPCR_FUNC    0x025
  555. #define FCMOVEQ_FUNC    0x02A
  556. #define FCMOVNE_FUNC    0x02B
  557. #define FCMOVLT_FUNC    0x02C
  558. #define FCMOVGE_FUNC    0x02D
  559. #define FCMOVLE_FUNC    0x02E
  560. #define FCMOVGT_FUNC    0x02F
  561. #define CVTQL_FUNC      0x030
  562. #define CVTQLV_FUNC     0x130
  563. #define CVTQLSV_FUNC    0x530
  564.  
  565. #define CVTLQ_FUNC_STR      "cvtlq"
  566. #define CPYS_FUNC_STR       "cpys"
  567. #define CPYSN_FUNC_STR      "cpysn"
  568. #define CPYSE_FUNC_STR      "cpyse"
  569. #define MT_FPCR_FUNC_STR    "mt_fpcr"
  570. #define MF_FPCR_FUNC_STR    "mf_fpcr"
  571. #define FCMOVEQ_FUNC_STR    "fcmoveq"
  572. #define FCMOVNE_FUNC_STR    "fcmovne"
  573. #define FCMOVLT_FUNC_STR    "fcmovlt"
  574. #define FCMOVGE_FUNC_STR    "fcmovge"
  575. #define FCMOVLE_FUNC_STR    "fcmovle"
  576. #define FCMOVGT_FUNC_STR    "fcmovgt"
  577. #define CVTQL_FUNC_STR      "cvtql"
  578. #define CVTQLV_FUNC_STR     "cvtql/v"
  579. #define CVTQLSV_FUNC_STR    "cvtql/sv"
  580.  
  581. //
  582. // IEEE function codes without flags (in Function, Opcode 16).
  583. //
  584.  
  585. #define MSK_FP_OP       0x03F
  586.  
  587. #define ADDS_FUNC       0x000
  588. #define SUBS_FUNC       0x001
  589. #define MULS_FUNC       0x002
  590. #define DIVS_FUNC       0x003
  591. #define ADDT_FUNC       0x020
  592. #define SUBT_FUNC       0x021
  593. #define MULT_FUNC       0x022
  594. #define DIVT_FUNC       0x023
  595. #define CMPTUN_FUNC     0x024
  596. #define CMPTEQ_FUNC     0x025
  597. #define CMPTLT_FUNC     0x026
  598. #define CMPTLE_FUNC     0x027
  599. #define CVTTS_FUNC      0x02C
  600. #define CVTTQ_FUNC      0x02F
  601. #define CVTQS_FUNC      0x03C
  602. #define CVTQT_FUNC      0x03E
  603.  
  604. #define ADDS_FUNC_STR       "adds"
  605. #define SUBS_FUNC_STR       "subs"
  606. #define MULS_FUNC_STR       "muls"
  607. #define DIVS_FUNC_STR       "divs"
  608. #define ADDT_FUNC_STR       "addt"
  609. #define SUBT_FUNC_STR       "subt"
  610. #define MULT_FUNC_STR       "mult"
  611. #define DIVT_FUNC_STR       "divt"
  612. #define CMPTUN_FUNC_STR     "cmptun"
  613. #define CMPTEQ_FUNC_STR     "cmpteq"
  614. #define CMPTLT_FUNC_STR     "cmptlt"
  615. #define CMPTLE_FUNC_STR     "cmptle"
  616. #define CVTTS_FUNC_STR      "cvtts"
  617. #define CVTTQ_FUNC_STR      "cvttq"
  618. #define CVTQS_FUNC_STR      "cvtqs"
  619. #define CVTQT_FUNC_STR      "cvtqt"
  620.  
  621. //
  622. // CVTST is a little different.
  623. //
  624.  
  625. #define CVTST_FUNC      0x2AC
  626. #define CVTST_S_FUNC    0x6AC
  627.  
  628. #define CVTST_FUNC_STR      "cvtst"
  629. #define CVTST_S_FUNC_STR    "cvtst/s"
  630.  
  631. //
  632. // VAX function codes without flags (in Function, Opcode 15).
  633. //
  634.  
  635. #define ADDF_FUNC       0x000
  636. #define CVTDG_FUNC      0x01E
  637. #define ADDG_FUNC       0x020
  638. #define CMPGEQ_FUNC     0x025
  639. #define CMPGLT_FUNC     0x026
  640. #define CMPGLE_FUNC     0x027
  641. #define CVTGF_FUNC      0x02C
  642. #define CVTGD_FUNC      0x02D
  643. #define CVTQF_FUNC      0x03C
  644. #define CVTQG_FUNC      0x03E
  645. #define DIVF_FUNC       0x003
  646. #define DIVG_FUNC       0x023
  647. #define MULF_FUNC       0x002
  648. #define MULG_FUNC       0x022
  649. #define SUBF_FUNC       0x001
  650. #define SUBG_FUNC       0x021
  651. #define CVTGQ_FUNC      0x0AF
  652.  
  653. #define ADDF_FUNC_STR       "addf"
  654. #define CVTDG_FUNC_STR      "cvtdg"
  655. #define ADDG_FUNC_STR       "addg"
  656. #define CMPGEQ_FUNC_STR     "cmpgeq"
  657. #define CMPGLT_FUNC_STR     "cmpglt"
  658. #define CMPGLE_FUNC_STR     "cmpgle"
  659. #define CVTGF_FUNC_STR      "cvtgf"
  660. #define CVTGD_FUNC_STR      "cvtgd"
  661. #define CVTQF_FUNC_STR      "cvtqf"
  662. #define CVTQG_FUNC_STR      "cvtqg"
  663. #define DIVF_FUNC_STR       "divf"
  664. #define DIVG_FUNC_STR       "divg"
  665. #define MULF_FUNC_STR       "mulf"
  666. #define MULG_FUNC_STR       "mulg"
  667. #define SUBF_FUNC_STR       "subf"
  668. #define SUBG_FUNC_STR       "subg"
  669. #define CVTGQ_FUNC_STR      "cvtgq"
  670.  
  671. //
  672. // Define subfields within the 11 bit IEEE floating operate function field.
  673. //
  674.  
  675. #define FP_FUNCTION_MASK      0x03F     // Function code including format
  676.  
  677. //
  678. // Define the 2 bit format field.
  679. //
  680.  
  681. #define FP_FORMAT_MASK        0x030
  682. #define FP_FORMAT_S           0x000     // Single (32 bit floating)
  683. #define FP_FORMAT_X           0x010     // Extended (128 bit floating)
  684. #define FP_FORMAT_T           0x020     // Double (64 bit floating)
  685. #define FP_FORMAT_Q           0x030     // Quad (64 bit integer)
  686. #define FP_FORMAT_SHIFT       4
  687.  
  688. //
  689. // Define the 2 bit rounding mode field.
  690. //
  691.  
  692. #define FP_ROUND_MASK         0x0C0
  693. #define FP_ROUND_C            0x000     // Chopped
  694. #define FP_ROUND_M            0x040     // Minus Infinity
  695. #define FP_ROUND_N            0x080     // Nearest
  696. #define FP_ROUND_D            0x0C0     // Dynamic
  697. #define FP_ROUND_SHIFT        6
  698.  
  699. //
  700. // Define the 3 bit trap enable field.
  701. //
  702.  
  703. #define FP_TRAP_ENABLE_MASK   0x700
  704. #define FP_TRAP_ENABLE_NONE   0x000
  705. #define FP_TRAP_ENABLE_U      0x100     // Underflow
  706. #define FP_TRAP_ENABLE_I      0x200     // Inexact
  707.  
  708. #define FP_TRAP_ENABLE_S      0x400     // Software Completion
  709. #define FP_TRAP_ENABLE_SU     0x500
  710. #define FP_TRAP_ENABLE_SUI    0x700
  711.  
  712. #define FP_TRAP_ENABLE_V      0x100     // Integer Overflow
  713. #define FP_TRAP_ENABLE_SV     0x500
  714. #define FP_TRAP_ENABLE_SVI    0x700
  715.  
  716. #define FP_TRAP_ENABLE_SHIFT  8
  717.  
  718. //
  719. // VAX and IEEE function flags (or'd with VAX and IEEE function code)
  720. //
  721.  
  722. #define MSK_FP_FLAGS    0x7C0
  723.  
  724. #define C_FLAGS         0x000
  725. #define M_FLAGS         0x040
  726. #define NONE_FLAGS      0x080
  727. #define D_FLAGS         0x0C0
  728. #define UC_FLAGS        0x100
  729. #define VC_FLAGS        0x100
  730. #define UM_FLAGS        0x140
  731. #define VM_FLAGS        0x140
  732. #define U_FLAGS         0x180
  733. #define V_FLAGS         0x180
  734. #define UD_FLAGS        0x1C0
  735. #define VD_FLAGS        0x1C0
  736. #define SC_FLAGS        0x400
  737. #define S_FLAGS         0x480
  738. #define SUC_FLAGS       0x500
  739. #define SVC_FLAGS       0x500
  740. #define SUM_FLAGS       0x540
  741. #define SVM_FLAGS       0x540
  742. #define SU_FLAGS        0x580
  743. #define SV_FLAGS        0x580
  744. #define SUD_FLAGS       0x5C0
  745. #define SVD_FLAGS       0x5C0
  746. #define SUIC_FLAGS      0x700
  747. #define SVIC_FLAGS      0x700
  748. #define SUIM_FLAGS      0x740
  749. #define SVIM_FLAGS      0x740
  750. #define SUI_FLAGS       0x780
  751. #define SVI_FLAGS       0x780
  752. #define SUID_FLAGS      0x7C0
  753. #define SVID_FLAGS      0x7C0
  754.  
  755. #define C_FLAGS_STR       "/c"
  756. #define M_FLAGS_STR       "/m"
  757. #define NONE_FLAGS_STR    ""
  758. #define D_FLAGS_STR       "/d"
  759. #define UC_FLAGS_STR      "/uc"
  760. #define VC_FLAGS_STR      "/vc"
  761. #define UM_FLAGS_STR      "/um"
  762. #define VM_FLAGS_STR      "/vm"
  763. #define U_FLAGS_STR       "/u"
  764. #define V_FLAGS_STR       "/v"
  765. #define UD_FLAGS_STR      "/ud"
  766. #define VD_FLAGS_STR      "/vd"
  767. #define SC_FLAGS_STR      "/sc"
  768. #define S_FLAGS_STR       "/s"
  769. #define SUC_FLAGS_STR     "/suc"
  770. #define SVC_FLAGS_STR     "/svc"
  771. #define SUM_FLAGS_STR     "/sum"
  772. #define SVM_FLAGS_STR     "/svm"
  773. #define SU_FLAGS_STR      "/su"
  774. #define SV_FLAGS_STR      "/sv"
  775. #define SUD_FLAGS_STR     "/sud"
  776. #define SVD_FLAGS_STR     "/svd"
  777. #define SUIC_FLAGS_STR    "/suic"
  778. #define SVIC_FLAGS_STR    "/svic"
  779. #define SUIM_FLAGS_STR    "/suim"
  780. #define SVIM_FLAGS_STR    "/svim"
  781. #define SUI_FLAGS_STR     "/sui"
  782. #define SVI_FLAGS_STR     "/svi"
  783. #define SUID_FLAGS_STR    "/suid"
  784. #define SVID_FLAGS_STR    "/svid"
  785.  
  786. //
  787. // Type (9) PALcode Instruction Format.
  788. //
  789. //  3         2 2
  790. //  1         6 5                                                 0
  791. // +-----------+---------------------------------------------------+
  792. // |   opcode  |                  PALcode func                     |
  793. // +-----------+---------------------------------------------------+
  794. //
  795.  
  796. typedef struct _Alpha_PAL_Format {
  797.         ULONG Function : 26;
  798.         ULONG Opcode : 6;
  799. } Alpha_PAL_Format;
  800.  
  801. //
  802. // Call to PAL function codes (in Function, Opcode 0, CALLPAL_OP).
  803. //
  804. // N.B. - if new call pal functions are added, they must also be added
  805. // in genalpha.c, genalpha.c will generate the include file for .s files
  806. // that will define the call pal mnemonics for assembly language use
  807. //
  808.  
  809. #define PRIV_PAL_FUNC 0x0
  810. #define UNPRIV_PAL_FUNC 0x80
  811.  
  812.  
  813. //
  814. // Unprivileged call pal functions.
  815. //
  816.  
  817. #define BPT_FUNC       (UNPRIV_PAL_FUNC | 0x00)
  818. #define CALLSYS_FUNC   (UNPRIV_PAL_FUNC | 0x03)
  819. #define IMB_FUNC       (UNPRIV_PAL_FUNC | 0x06)
  820. #define GENTRAP_FUNC   (UNPRIV_PAL_FUNC | 0xAA)
  821. #define RDTEB_FUNC     (UNPRIV_PAL_FUNC | 0xAB)
  822. #define KBPT_FUNC      (UNPRIV_PAL_FUNC | 0xAC)
  823. #define CALLKD_FUNC    (UNPRIV_PAL_FUNC | 0xAD)
  824.  
  825. #define BPT_FUNC_STR       "bpt"
  826. #define CALLSYS_FUNC_STR   "callsys"
  827. #define IMB_FUNC_STR       "imb"
  828. #define RDTEB_FUNC_STR     "rdteb"
  829. #define GENTRAP_FUNC_STR   "gentrap"
  830. #define KBPT_FUNC_STR      "kbpt"
  831. #define CALLKD_FUNC_STR    "callkd"
  832.  
  833. //
  834. // Priveleged call pal functions.
  835. //
  836.  
  837. #define HALT_FUNC       (PRIV_PAL_FUNC | 0x00)
  838. #define RESTART_FUNC    (PRIV_PAL_FUNC | 0x01)
  839. #define DRAINA_FUNC     (PRIV_PAL_FUNC | 0x02)
  840. #define REBOOT_FUNC     (PRIV_PAL_FUNC | 0x03)
  841. #define INITPAL_FUNC    (PRIV_PAL_FUNC | 0x04)
  842. #define WRENTRY_FUNC    (PRIV_PAL_FUNC | 0x05)
  843. #define SWPIRQL_FUNC    (PRIV_PAL_FUNC | 0x06)
  844. #define RDIRQL_FUNC     (PRIV_PAL_FUNC | 0x07)
  845. #define DI_FUNC         (PRIV_PAL_FUNC | 0X08)
  846. #define EI_FUNC         (PRIV_PAL_FUNC | 0x09)
  847. #define SWPPAL_FUNC     (PRIV_PAL_FUNC | 0x0A)
  848. #define SSIR_FUNC       (PRIV_PAL_FUNC | 0x0C)
  849. #define CSIR_FUNC       (PRIV_PAL_FUNC | 0x0D)
  850. #define RFE_FUNC        (PRIV_PAL_FUNC | 0x0E)
  851. #define RETSYS_FUNC     (PRIV_PAL_FUNC | 0x0F)
  852. #define SWPCTX_FUNC     (PRIV_PAL_FUNC | 0x10)
  853. #define SWPPROCESS_FUNC (PRIV_PAL_FUNC | 0x11)
  854. #define RDMCES_FUNC     (PRIV_PAL_FUNC | 0x12)
  855. #define WRMCES_FUNC     (PRIV_PAL_FUNC | 0x13)
  856. #define TBIA_FUNC       (PRIV_PAL_FUNC | 0x14)
  857. #define TBIS_FUNC       (PRIV_PAL_FUNC | 0x15)
  858. #define DTBIS_FUNC      (PRIV_PAL_FUNC | 0x16)
  859. #define TBISASN_FUNC    (PRIV_PAL_FUNC | 0x17)
  860. #define RDKSP_FUNC      (PRIV_PAL_FUNC | 0x18)
  861. #define SWPKSP_FUNC     (PRIV_PAL_FUNC | 0x19)
  862. #define RDPSR_FUNC      (PRIV_PAL_FUNC | 0x1A)
  863. #define RDPCR_FUNC      (PRIV_PAL_FUNC | 0x1C)
  864. #define RDTHREAD_FUNC   (PRIV_PAL_FUNC | 0x1E)
  865. #define TBIM_FUNC       (PRIV_PAL_FUNC | 0x20)
  866. #define TBIMASN_FUNC    (PRIV_PAL_FUNC | 0x21)
  867. #define TBIM64_FUNC     (PRIV_PAL_FUNC | 0x22)
  868. #define TBIS64_FUNC     (PRIV_PAL_FUNC | 0x23)
  869. #define RDCOUNTERS_FUNC (PRIV_PAL_FUNC | 0x30)
  870. #define RDSTATE_FUNC    (PRIV_PAL_FUNC | 0x31)
  871. #define WRPERFMON_FUNC  (PRIV_PAL_FUNC | 0x32)
  872.  
  873. #define HALT_FUNC_STR       "halt"
  874. #define RESTART_FUNC_STR    "restart"
  875. #define DRAINA_FUNC_STR     "draina"
  876. #define REBOOT_FUNC_STR     "reboot"
  877. #define INITPAL_FUNC_STR    "initpal"
  878. #define WRENTRY_FUNC_STR    "wrentry"
  879. #define SWPIRQL_FUNC_STR    "swpirql"
  880. #define RDIRQL_FUNC_STR     "rdirql"
  881. #define DI_FUNC_STR         "di"
  882. #define EI_FUNC_STR         "ei"
  883. #define SWPPAL_FUNC_STR     "swppal"
  884. #define SSIR_FUNC_STR       "ssir"
  885. #define CSIR_FUNC_STR       "csir"
  886. #define RFE_FUNC_STR        "rfe"
  887. #define RETSYS_FUNC_STR     "retsys"
  888. #define SWPCTX_FUNC_STR     "swpctx"
  889. #define SWPPROCESS_FUNC_STR "swpprocess"
  890. #define RDMCES_FUNC_STR     "rdmces"
  891. #define WRMCES_FUNC_STR     "wrmces"
  892. #define TBIA_FUNC_STR       "tbia"
  893. #define TBIS_FUNC_STR       "tbis"
  894. #define DTBIS_FUNC_STR      "dtbis"
  895. #define TBISASN_FUNC_STR    "tbisasn"
  896. #define RDKSP_FUNC_STR      "rdksp"
  897. #define SWPKSP_FUNC_STR     "swpksp"
  898. #define RDPSR_FUNC_STR      "rdpsr"
  899. #define RDPCR_FUNC_STR      "rdpcr"
  900. #define RDTHREAD_FUNC_STR   "rdthread"
  901. #define TBIM_FUNC_STR       "tbim"
  902. #define TBIMASN_FUNC_STR    "tbimasn"
  903. #define TBIM64_FUNC_STR     "tbim64"
  904. #define TBIS64_FUNC_STR     "tbis64"
  905. #define RDCOUNTERS_FUNC_STR "rdcounters"
  906. #define RDSTATE_FUNC_STR    "rdstate"
  907. #define WRPERFMON_FUNC_STR "wrperfmon"
  908.  
  909. //
  910. // 21064 (ev4) - specific call pal functions.
  911. //
  912.  
  913. #define INITPCR_FUNC    (PRIV_PAL_FUNC | 0x38)
  914.  
  915. #define INITPCR_FUNC_STR   "initpcr"
  916.  
  917. //
  918. // Type (10) EV4 MTPR/MFPR PAL mode instructions.
  919. //
  920. //  3         2 2       2 2       1 1
  921. //  1         6 5       1 0       6 5             8 7 6 5 4       0
  922. // +-----------+---------+---------+---------------+-+-+-+---------+
  923. // |   opcode  |   Ra    |   Rb    |      IGN      |P|A|I|  Index  |
  924. // +-----------+---------+---------+---------------+-+-+-+---------+
  925. //
  926.  
  927. typedef struct _Alpha_EV4_PR_Format {
  928.         ULONG Index : 5;
  929.         ULONG Ibox : 1;
  930.         ULONG Abox : 1;
  931.         ULONG PalTemp : 1;
  932.         ULONG IGN : 8;
  933.         ULONG Rb : 5;
  934.         ULONG Ra : 5;
  935.         ULONG Opcode : 6;
  936. } Alpha_EV4_PR_Format;
  937.  
  938. //
  939. // Type (10) EV5 MTPR/MFPR PAL mode instructions.
  940. //
  941. //  3         2 2       2 2       1 1
  942. //  1         6 5       1 0       6 5                              0
  943. // +-----------+---------+---------+-------------------------------+
  944. // |   opcode  |   Ra    |   Rb    |            Index              |
  945. // +-----------+---------+---------+-------------------------------+
  946. //
  947.  
  948. typedef struct _Alpha_EV5_PR_Format {
  949.         ULONG Index : 16;
  950.         ULONG Rb : 5;
  951.         ULONG Ra : 5;
  952.         ULONG Opcode : 6;
  953. } Alpha_EV5_PR_Format;
  954.  
  955. #define MTPR_OP       0x1D
  956. #define MFPR_OP       0x19
  957.  
  958. #define MTPR_OP_STR   "mt"
  959. #define MFPR_OP_STR   "mf"
  960.  
  961. //
  962. // Type (11) EV4 special memory PAL mode access.
  963. //
  964. //  3         2 2       2 2       1 1 1 1 1 1
  965. //  1         6 5       1 0       6 5 4 3 2 1                     0
  966. // +-----------+---------+---------+-+-+-+-+-----------------------+
  967. // |   opcode  |   Ra    |   Rb    |P|A|R|Q|         Disp          |
  968. // +-----------+---------+---------+-+-+-+-+-----------------------+
  969. //
  970.  
  971. typedef struct _Alpha_EV4_MEM_Format {
  972.         ULONG Disp : 12;
  973.         ULONG QuadWord : 1;
  974.         ULONG RWcheck : 1;
  975.         ULONG Alt : 1;
  976.         ULONG Physical : 1;
  977.         ULONG Rb : 5;
  978.         ULONG Ra : 5;
  979.         ULONG Opcode : 6;
  980. } Alpha_EV4_MEM_Format;
  981.  
  982. //
  983. // Type (11) EV5 special memory PAL mode access.
  984. //
  985. //  3         2 2       2 2       1 1 1 1 1 1
  986. //  1         6 5       1 0       6 5 4 3 2 1                     0
  987. // +-----------+---------+---------+-+-+-+-+-----------------------+
  988. // |   opcode  |   Ra    |   Rb    |P|A|R|Q|         Disp          |
  989. // +-----------+---------+---------+-+-+-+-+-----------------------+
  990. //
  991.  
  992. typedef struct _Alpha_EV5_MEM_Format {
  993.         ULONG Disp : 10;
  994.         ULONG Lock_Cond: 1;
  995.         ULONG Vpte: 1;
  996.         ULONG QuadWord : 1;
  997.         ULONG RWcheck : 1;
  998.         ULONG Alt : 1;
  999.         ULONG Physical : 1;
  1000.         ULONG Rb : 5;
  1001.         ULONG Ra : 5;
  1002.         ULONG Opcode : 6;
  1003. } Alpha_EV5_MEM_Format;
  1004.  
  1005. #define HWLD_OP      0x1B
  1006. #define HWST_OP      0x1F
  1007.  
  1008. #define HWLD_OP_STR  "hwld"
  1009. #define HWST_OP_STR  "hwst"
  1010.  
  1011. // Type (12) EV4 PAL mode switch.
  1012. //
  1013. //  3         2 2       2 2       1 1 1 1
  1014. //  1         6 5       1 0       6 5 4 3                         0
  1015. // +-----------+---------+---------+-+-+---------------------------+
  1016. // |   opcode  |   Ra    |   Rb    |1|0|          IGN              |
  1017. // +-----------+---------+---------+-+-+---------------------------+
  1018.  
  1019. typedef struct _Alpha_EV4_REI_Format {
  1020.         ULONG IGN : 14;
  1021.         ULONG zero : 1;
  1022.         ULONG one : 1;
  1023.         ULONG Rb : 5;
  1024.         ULONG Ra : 5;
  1025.         ULONG Opcode : 6;
  1026. } Alpha_EV4_REI_Format;
  1027.  
  1028. // Type (12) EV5 PAL mode switch.
  1029. //
  1030. //  3         2 2       2 2       1 1 1 1
  1031. //  1         6 5       1 0       6 5 4 3                         0
  1032. // +-----------+---------+---------+-+-+---------------------------+
  1033. // |   opcode  |   Ra    |   Rb    |1|0|          IGN              |
  1034. // +-----------+---------+---------+-+-+---------------------------+
  1035.  
  1036. typedef struct _Alpha_EV5_REI_Format {
  1037.         ULONG IGN : 14;
  1038.         ULONG Type: 2;
  1039.         ULONG Rb : 5;
  1040.         ULONG Ra : 5;
  1041.         ULONG Opcode : 6;
  1042. } Alpha_EV5_REI_Format;
  1043.  
  1044. #define REI_OP    0x1E
  1045.  
  1046. #define REI_OP_STR  "rei"
  1047.  
  1048. //
  1049. //
  1050. //
  1051. typedef union _Alpha_Instruction {
  1052.         ULONG Long;
  1053.         UCHAR Byte[4];
  1054.  
  1055.         Alpha_Memory_Format Memory;
  1056.         Alpha_Jump_Format Jump;
  1057.         Alpha_Branch_Format Branch;
  1058.         Alpha_OpReg_Format OpReg;
  1059.         Alpha_OpLit_Format OpLit;
  1060.         Alpha_FpOp_Format FpOp;
  1061.         Alpha_PAL_Format Pal;
  1062.         Alpha_EV4_PR_Format EV4_PR;
  1063.         Alpha_EV4_MEM_Format EV4_MEM;
  1064.         Alpha_EV4_REI_Format EV4_REI;
  1065.         Alpha_EV5_PR_Format EV5_PR;
  1066.         Alpha_EV5_MEM_Format EV5_MEM;
  1067.         Alpha_EV5_REI_Format EV5_REI;
  1068. } ALPHA_INSTRUCTION, *PALPHA_INSTRUCTION;
  1069.  
  1070. //
  1071. // Define standard integer register assignments.
  1072. //
  1073.  
  1074. #define V0_REG      0       // v0 - return value register
  1075.  
  1076. #define T0_REG      1       // t0 - temporary register
  1077. #define T1_REG      2       // t1 - temporary register
  1078. #define T2_REG      3       // t2 - temporary register
  1079. #define T3_REG      4       // t3 - temporary register
  1080. #define T4_REG      5       // t4 - temporary register
  1081. #define T5_REG      6       // t5 - temporary register
  1082. #define T6_REG      7       // t6 - temporary register
  1083. #define T7_REG      8       // t7 - temporary register
  1084.  
  1085. #define S0_REG      9       // s0 - saved register
  1086. #define S1_REG      10      // s1 - saved register
  1087. #define S2_REG      11      // s2 - saved register
  1088. #define S3_REG      12      // s3 - saved register
  1089. #define S4_REG      13      // s4 - saved register
  1090. #define S5_REG      14      // s5 - saved register
  1091.  
  1092. #define S6_REG      15      // s6 - saved register, aka fp
  1093. #define FP_REG      15      // fp - frame pointer register
  1094.  
  1095. #define A0_REG      16      // a0 - argument register
  1096. #define A1_REG      17      // a1 - argument register
  1097. #define A2_REG      18      // a2 - argument register
  1098. #define A3_REG      19      // a3 - argument register
  1099. #define A4_REG      20      // a4 - argument register
  1100. #define A5_REG      21      // a5 - argument register
  1101.  
  1102. #define T8_REG      22      // t8 - temporary register
  1103. #define T9_REG      23      // t9 - temporary register
  1104. #define T10_REG     24      // t10 - temporary register
  1105. #define T11_REG     25      // t11 - temporary register
  1106.  
  1107. #define RA_REG      26      // ra - return address register
  1108. #define T12_REG     27      // t12 - temporary register
  1109. #define AT_REG      28      // at - assembler temporary register
  1110. #define GP_REG      29      // gp - global pointer register
  1111. #define SP_REG      30      // sp - stack pointer register
  1112. #define ZERO_REG    31      // zero - zero register
  1113.  
  1114. //
  1115. // Define standard floating point register assignments.
  1116. //
  1117.  
  1118. #define F0_REG      0       // floating return value register (real)
  1119. #define F1_REG      1       // floating return value register (imaginary)
  1120. #define F16_REG     16      // floating argument register
  1121. #define FZERO_REG   31      // floating zero register
  1122.  
  1123. //
  1124. //  Define standard integer register strings
  1125. //
  1126.  
  1127. #define V0_REG_STR      "v0"     // - return value register
  1128.  
  1129. #define T0_REG_STR      "t0"     // - temporary register
  1130. #define T1_REG_STR      "t1"     // - temporary register
  1131. #define T2_REG_STR      "t2"     // - temporary register
  1132. #define T3_REG_STR      "t3"     // - temporary register
  1133. #define T4_REG_STR      "t4"     // - temporary register
  1134. #define T5_REG_STR      "t5"     // - temporary register
  1135. #define T6_REG_STR      "t6"     // - temporary register
  1136. #define T7_REG_STR      "t7"     // - temporary register
  1137.  
  1138. #define S0_REG_STR      "s0"     // - saved register
  1139. #define S1_REG_STR      "s1"     // - saved register
  1140. #define S2_REG_STR      "s2"     // - saved register
  1141. #define S3_REG_STR      "s3"     // - saved register
  1142. #define S4_REG_STR      "s4"     // - saved register
  1143. #define S5_REG_STR      "s5"     // - saved register
  1144.  
  1145. #define S6_REG_STR      "s6"     // - saved register, aka fp
  1146. #define FP_REG_STR      "fp"     // - frame pointer register
  1147.  
  1148. #define A0_REG_STR      "a0"     // - argument register
  1149. #define A1_REG_STR      "a1"     // - argument register
  1150. #define A2_REG_STR      "a2"     // - argument register
  1151. #define A3_REG_STR      "a3"     // - argument register
  1152. #define A4_REG_STR      "a4"     // - argument register
  1153. #define A5_REG_STR      "a5"     // - argument register
  1154.  
  1155. #define T8_REG_STR      "t8"     // - temporary register
  1156. #define T9_REG_STR      "t9"     // - temporary register
  1157. #define T10_REG_STR     "t10"    // - temporary register
  1158. #define T11_REG_STR     "t11"    // - temporary register
  1159.  
  1160. #define RA_REG_STR      "ra"     // - return address register
  1161. #define T12_REG_STR     "t12"    // - temporary register
  1162. #define AT_REG_STR      "at"     // - assembler temporary register
  1163. #define GP_REG_STR      "gp"     // - global pointer register
  1164. #define SP_REG_STR      "sp"     // - stack pointer register
  1165. #define ZERO_REG_STR    "zero"   // - zero register
  1166.  
  1167. //
  1168. // Define maximum and minimum single and double exponent values.
  1169. //
  1170.  
  1171. #define DOUBLE_MAXIMUM_EXPONENT 2047
  1172. #define DOUBLE_MINIMUM_EXPONENT 0
  1173.  
  1174. #define SINGLE_MAXIMUM_EXPONENT 255
  1175. #define SINGLE_MINIMUM_EXPONENT 0
  1176.  
  1177. //
  1178. // Define single and double exponent bias values.
  1179. //
  1180.  
  1181. #define SINGLE_EXPONENT_BIAS 127
  1182. #define DOUBLE_EXPONENT_BIAS 1023
  1183.  
  1184. //
  1185. // Define the largest single and double values.
  1186. //
  1187.  
  1188. #define SINGLE_MAXIMUM_VALUE 0x7f7fffff
  1189.  
  1190. #define DOUBLE_MAXIMUM_VALUE_HIGH 0x7fefffff
  1191. #define DOUBLE_MAXIMUM_VALUE_LOW 0xffffffff
  1192.  
  1193. //
  1194. // Define single and double quiet and signaling Nan values
  1195. // (these are identical to X86 formats; Mips is different).
  1196. //
  1197.  
  1198. #define SINGLE_QUIET_NAN_PREFIX 0x7fc00000
  1199. #define SINGLE_SIGNAL_NAN_PREFIX 0x7f800000
  1200. #define SINGLE_QUIET_NAN_VALUE 0xffc00000
  1201.  
  1202. #define DOUBLE_QUIET_NAN_PREFIX_HIGH 0x7ff80000
  1203. #define DOUBLE_SIGNAL_NAN_PREFIX_HIGH 0x7ff00000
  1204. #define DOUBLE_QUIET_NAN_VALUE_HIGH 0xfff80000
  1205. #define DOUBLE_QUIET_NAN_VALUE_LOW 0x0
  1206.  
  1207. //
  1208. // Define positive single and double infinity values.
  1209. //
  1210.  
  1211. #define SINGLE_INFINITY_VALUE 0x7f800000
  1212.  
  1213. #define DOUBLE_INFINITY_VALUE_HIGH 0x7ff00000
  1214. #define DOUBLE_INFINITY_VALUE_LOW 0x0
  1215.  
  1216. //
  1217. // Quadword versions of the above.
  1218. //
  1219.  
  1220. #define DOUBLE_MAXIMUM_VALUE        ((ULONGLONG)0x7fefffffffffffff)
  1221. #define DOUBLE_INFINITY_VALUE       ((ULONGLONG)0x7ff0000000000000)
  1222. #define DOUBLE_QUIET_NAN_VALUE      ((ULONGLONG)0xfff8000000000000)
  1223.  
  1224. //
  1225. // Define result values for IEEE floating point comparison operations.
  1226. // True is 2.0 and False is 0.0.
  1227. //
  1228.  
  1229. #define FP_COMPARE_TRUE             ((ULONGLONG)0x4000000000000000)
  1230. #define FP_COMPARE_FALSE            ((ULONGLONG)0x0000000000000000)
  1231.  
  1232. //
  1233. // Define Alpha AXP rounding modes.
  1234. //
  1235.  
  1236. #define ROUND_TO_ZERO 0                 // round toward zero
  1237. #define ROUND_TO_MINUS_INFINITY 1       // round toward minus infinity
  1238. #define ROUND_TO_NEAREST 2              // round to nearest representable value
  1239. #define ROUND_TO_PLUS_INFINITY 3        // round toward plus infinity
  1240.  
  1241. #endif // _ALPHAOPS_
  1242.