home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / unix / volume25 / trash / part01 / instrn.h < prev    next >
Encoding:
C/C++ Source or Header  |  1992-03-22  |  1.6 KB  |  55 lines

  1. /*
  2.  * See optab.c.
  3.  */
  4. #define    OP(a,b,c,d)    {a,b,c,d}
  5.  
  6. /*
  7.  * An entry in the table of instructions
  8.  * each of which describes the known
  9.  * info. about the instruction's arguments
  10.  * - see optab.c.
  11.  */
  12. typedef struct instrn    instrn;
  13. struct instrn
  14. {
  15.     char    *i_name;    /* Printable name.            */
  16.     int    i_format;    /* Instruction format -- see p.A-3.    */
  17. #define    IF_U    0        /*            undefined    */
  18. #define    IF_I    1        /*            immediate    */
  19. #define    IF_J    2        /*            jump        */
  20. #define    IF_R    3        /*            register    */
  21.                 /* See p.B-2 and foll.            */
  22. #define    IF_I1    4        /*            immediate(cop1)    */
  23. #define    IF_M1    5        /*            move (cop1)    */
  24. #define    IF_C1    6        /*            control (cop1)    */
  25. #define    IF_R1    7        /*            register (cop1)    */
  26.     dinstrn    *(*i_handler)(); /* Routine that performs the instn's fn.*/
  27.     char    *i_pageno;    /* The "mips RISC ARCHITECTURE" book.    */
  28. };
  29.  
  30. /*
  31.  * Floating point register formats.
  32.  */
  33. #define    FMT_SINGLE        0
  34. #define    FMT_DOUBLE        1
  35. #define    FMT_FIXED        4
  36.  
  37. /*
  38.  * Extract subfields from an instruction.
  39.  */
  40. #define    i_to_op(i)        (((i) >> 26) & 0x3F)
  41. #define    i_to_rs(i)        (((i) >> 21) & 0x1F)
  42. #define    i_to_rt(i)        (((i) >> 16) & 0x1F)
  43. #define    i_to_immediate(i)    (((i) >> 0) & 0xFFFF)
  44. #define    i_to_target(i)        (((i) >> 0) & 0x3FFFFFF)
  45. #define    i_to_rd(i)        (((i) >> 11) & 0x1F)
  46. #define    i_to_shamt(i)        (((i) >> 6) & 0x1F)
  47. #define    i_to_funct(i)        (((i) >> 0) & 0x3F)
  48. #define    is_cop1_group1(i)    ((((i) >> 25) & 0x1) == 0)
  49. #define    i_to_cop1_group1(i)    ((((i) >> 16) & 0x1) | (((i) >> 21) & (0x7 << 1)))
  50. #define    i_to_cop1_group2(i)    i_to_funct(i)
  51. #define    i_to_fmt(i)        (i_to_rs(i) & 0xF)
  52. #define    i_to_ft(i)        i_to_rt(i)
  53. #define    i_to_fs(i)        i_to_rd(i)
  54. #define    i_to_fd(i)        i_to_shamt(i)
  55.