home *** CD-ROM | disk | FTP | other *** search
/ Magazyn Exec 5 / CD_Magazyn_EXEC_nr_5.iso / Programy / Programowanie / PPC / wosdb_src.lzx / ppc_disasm.h < prev    next >
Encoding:
C/C++ Source or Header  |  2000-11-10  |  3.4 KB  |  110 lines

  1. /* $VER: ppc_disasm.h V0.1 (23.05.1998)
  2.  *
  3.  * Disassembler module for the PowerPC microprocessor family
  4.  * Copyright (c) 1998-2000  Frank Wille
  5.  *
  6.  * ppc_disasm.c is freeware and may be freely redistributed as long as
  7.  * no modifications are made and nothing is charged for it.
  8.  * Non-commercial usage is allowed without any restrictions.
  9.  * EVERY PRODUCT OR PROGRAM DERIVED DIRECTLY FROM MY SOURCE MAY NOT BE
  10.  * SOLD COMMERCIALLY WITHOUT PERMISSION FROM THE AUTHOR.
  11.  *
  12.  *
  13.  * v0.1  (23.05.1998) phx
  14.  *       First version, which implements all PowerPC instructions.
  15.  * v0.0  (09.05.1998) phx
  16.  *       File created.
  17.  */
  18.  
  19.  
  20. #ifndef PPC_DISASM_H
  21. #define PPC_DISASM_H
  22.  
  23.  
  24. /* version/revision */
  25. #define PPCDISASM_VER 1
  26. #define PPCDISASM_REV 2
  27.  
  28.  
  29. /* typedefs */
  30. typedef unsigned int ppc_word;
  31. #ifndef NULL
  32. #define NULL (0L)
  33. #endif
  34.  
  35.  
  36. /* endianess */
  37. #if !defined(BIGENDIAN) && !defined(LITTLEENDIAN)
  38. #error Define either BIGENDIAN or LITTLEENDIAN!
  39. #define BIGENDIAN
  40. #endif
  41.  
  42.  
  43. /* general defines */
  44. #define PPCIDXMASK      0xfc000000
  45. #define PPCIDX2MASK     0x000007fe
  46. #define PPCDMASK        0x03e00000
  47. #define PPCAMASK        0x001f0000
  48. #define PPCBMASK        0x0000f800
  49. #define PPCCMASK        0x000007c0
  50. #define PPCMMASK        0x0000003e
  51. #define PPCCRDMASK      0x03800000
  52. #define PPCCRAMASK      0x001c0000
  53. #define PPCLMASK        0x00600000
  54. #define PPCOE           0x00000400
  55.  
  56. #define PPCIDXSH        26
  57. #define PPCDSH          21
  58. #define PPCASH          16
  59. #define PPCBSH          11
  60. #define PPCCSH          6
  61. #define PPCMSH          1
  62. #define PPCCRDSH        23
  63. #define PPCCRASH        18
  64. #define PPCLSH          21
  65. #define PPCIDX2SH       1
  66.  
  67. #define PPCGETIDX(x)    (((x)&PPCIDXMASK)>>PPCIDXSH)
  68. #define PPCGETD(x)      (((x)&PPCDMASK)>>PPCDSH)
  69. #define PPCGETA(x)      (((x)&PPCAMASK)>>PPCASH)
  70. #define PPCGETB(x)      (((x)&PPCBMASK)>>PPCBSH)
  71. #define PPCGETC(x)      (((x)&PPCCMASK)>>PPCCSH)
  72. #define PPCGETM(x)      (((x)&PPCMMASK)>>PPCMSH)
  73. #define PPCGETCRD(x)    (((x)&PPCCRDMASK)>>PPCCRDSH)
  74. #define PPCGETCRA(x)    (((x)&PPCCRAMASK)>>PPCCRASH)
  75. #define PPCGETL(x)      (((x)&PPCLMASK)>>PPCLSH)
  76. #define PPCGETIDX2(x)   (((x)&PPCIDX2MASK)>>PPCIDX2SH)
  77.  
  78.  
  79. /* Disassembler structure, the interface to the application */
  80.  
  81. struct DisasmPara_PPC {
  82.   ppc_word *instr;              /* pointer to instruction to disassemble */
  83.   ppc_word *iaddr;              /* instr.addr., usually the same as instr */
  84.   char *opcode;                 /* buffer for opcode, min. 10 chars. */
  85.   char *operands;               /* operand buffer, min. 24 chars. */
  86. /* changed by disassembler: */
  87.   unsigned char type;           /* type of instruction, see below */
  88.   unsigned char flags;          /* additional flags */
  89.   unsigned short sreg;          /* register in load/store instructions */
  90.   ppc_word displacement;        /* branch- or load/store displacement */
  91. };
  92.  
  93. #define PPCINSTR_OTHER      0   /* no additional info for other instr. */
  94. #define PPCINSTR_BRANCH     1   /* branch dest. = PC+displacement */
  95. #define PPCINSTR_LDST       2   /* load/store instruction: displ(sreg) */
  96. #define PPCINSTR_IMM        3   /* 16-bit immediate val. in displacement */
  97.  
  98. #define PPCF_ILLEGAL   (1<<0)   /* illegal PowerPC instruction */
  99. #define PPCF_UNSIGNED  (1<<1)   /* unsigned immediate instruction */
  100. #define PPCF_SUPER     (1<<2)   /* supervisor level instruction */
  101. #define PPCF_64        (1<<3)   /* 64-bit only instruction */
  102.  
  103.  
  104. /* ppc_disasm.o prototypes */
  105. #ifndef PPC_DISASM_C
  106. extern ppc_word *PPC_Disassemble(struct DisasmPara_PPC *);
  107. #endif
  108.  
  109. #endif
  110.