java.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252
  1. /* Universal Disassembler Function Library
  2. * https://gitlab.com/bztsrc/udisasm
  3. *
  4. * ----- GENERATED FILE, DO NOT EDIT! -----
  5. *
  6. * Copyright (C) 2017 bzt (bztsrc@gitlab)
  7. *
  8. * Permission is hereby granted, free of charge, to any person
  9. * obtaining a copy of this software and associated documentation
  10. * files (the "Software"), to deal in the Software without
  11. * restriction, including without limitation the rights to use, copy,
  12. * modify, merge, publish, distribute, sublicense, and/or sell copies
  13. * of the Software, and to permit persons to whom the Software is
  14. * furnished to do so, subject to the following conditions:
  15. *
  16. * The above copyright notice and this permission notice shall be
  17. * included in all copies or substantial portions of the Software.
  18. *
  19. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  20. * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  21. * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  22. * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
  23. * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
  24. * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  25. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  26. * DEALINGS IN THE SOFTWARE.
  27. *
  28. * @brief Disassembler source generated from java.txt
  29. */
  30. #ifdef __cplusplus
  31. extern "C" {
  32. #endif
  33. #define disasm_arch "java"
  34. enum { disasm_arg_NONE,disasm_arg_ofs,disasm_arg_ofe, disasm_arg_a0, disasm_arg_label, disasm_arg_label4, disasm_arg_a1, disasm_arg_a2 };
  35. /*** private functions ***/
  36. char *disasm_str(char*s,int n) {if(!s)return "?";while(n){s++;if(!*s){s++;n--;}}return *s?s:"?";}
  37. /*** public API ***/
  38. uint64_t disasm(uint64_t addr, char *str)
  39. {
  40. uint16_t op=0, om=0;
  41. int64_t a0, a1, a2;
  42. uint8_t ic8;
  43. uint16_t ic16;
  44. uint32_t ic32;
  45. char *names=NULL,*olds=str;
  46. uint8_t args[4]={0,0,0,0};
  47. ic8=*((uint8_t*)addr);
  48. ic16=*((uint16_t*)addr);
  49. ic32=*((uint32_t*)addr);
  50. /* handle multiple NOPs at once */
  51. if(ic8==0x0) {
  52. while(*((uint8_t*)addr)==ic8) { op++; addr+=1; }
  53. if(str!=NULL) str+=sprintf(str," %d x nop",op);
  54. *str=0;
  55. return addr;
  56. }
  57. /* decode instruction */
  58. if(ic32==0xab) {
  59. names="lookupswitch\0";
  60. args[0]=disasm_arg_a0; args[1]=disasm_arg_a1;
  61. addr+=4;
  62. a0=(int64_t)(*((int32_t*)addr));addr+=4;
  63. a1=(int64_t)(*((int32_t*)addr));addr+=4;
  64. addr+=a1*8;
  65. } else
  66. if(ic32==0xc4) {
  67. names="tableswitch\0";
  68. args[0]=disasm_arg_a0; args[1]=disasm_arg_a1; args[2]=disasm_arg_a2;
  69. addr+=4;
  70. a0=(int64_t)(*((int32_t*)addr));addr+=4;
  71. a1=(int64_t)(*((int32_t*)addr));addr+=4;
  72. a2=(int64_t)(*((int32_t*)addr));addr+=4;
  73. addr+=(a2-a1)*2;
  74. } else
  75. if((ic8&0xfd)==0x11) {
  76. names="sipush\0ldc_w\0";
  77. op=((ic8>>1)&0x1);
  78. args[0]=disasm_arg_a0;
  79. addr+=1;
  80. a0=(int64_t)(*((int16_t*)addr));addr+=2;
  81. } else
  82. if(ic8==0x14) {
  83. names="ldc2_w\0";
  84. args[0]=disasm_arg_a0;
  85. addr+=1;
  86. a0=(int64_t)(*((int16_t*)addr));addr+=2;
  87. } else
  88. if((ic8&0xd0)==0x10) {
  89. names="bipush\0sipush\0ldc\0ldc_w\0ldc2_w\0iload\0lload\0fload\0dload\0aload\0iload_0\0iload_1\0iload_2\0iload_3\0lload_0\0lload_1\0faload\0daload\0aaload\0baload\0caload\0saload\0istore\0lstore\0fstore\0dstore\0astore\0istore_0\0istore_1\0istore_2\0istore_3\0lstore_0\0";
  90. op=((ic8>>1)&0x10)|((ic8)&0xf);
  91. args[0]=disasm_arg_a0;
  92. addr+=1;
  93. a0=(int64_t)(*((int8_t*)addr));addr+=1;
  94. } else
  95. if((ic16&0xd0ff)==0x10c4) {
  96. names="?\0?\0?\0?\0?\0iload\0lload\0fload\0dload\0aload\0?\0?\0?\0?\0?\0?\0?\0?\0?\0?\0?\0?\0istore\0lstore\0fstore\0dstore\0astore\0";
  97. op=((ic16>>9)&0x10)|((ic16>>8)&0xf);
  98. args[0]=disasm_arg_a0;
  99. addr+=2;
  100. a0=(int64_t)(*((int16_t*)addr));addr+=2;
  101. } else
  102. if(ic8==0x84) {
  103. names="iinc\0";
  104. args[0]=disasm_arg_a0; args[1]=disasm_arg_a1;
  105. addr+=1;
  106. a0=(int64_t)(*((int8_t*)addr));addr+=1;
  107. a1=(int64_t)(*((int8_t*)addr));addr+=1;
  108. } else
  109. if(ic16==0x84c4) {
  110. names="iinc\0";
  111. args[0]=disasm_arg_a0; args[1]=disasm_arg_a1;
  112. addr+=2;
  113. a0=(int64_t)(*((int16_t*)addr));addr+=2;
  114. a1=(int64_t)(*((int16_t*)addr));addr+=2;
  115. } else
  116. if((ic8&0xf8)==0x98) {
  117. names="dcmpg\0ifeq\0ifne\0iflt\0ifge\0ifgt\0ifle\0if_icmpeq\0";
  118. op=((ic8)&0x7);
  119. args[0]=disasm_arg_label;
  120. addr+=1;
  121. a0=(int64_t)(*((int16_t*)addr));addr+=2;
  122. } else
  123. if(ic8==0xa9) {
  124. names="ret\0";
  125. args[0]=disasm_arg_a0;
  126. addr+=1;
  127. a0=(int64_t)(*((int8_t*)addr));addr+=1;
  128. } else
  129. if(ic16==0xa9c4) {
  130. names="ret\0";
  131. args[0]=disasm_arg_a0;
  132. addr+=2;
  133. a0=(int64_t)(*((int16_t*)addr));addr+=2;
  134. } else
  135. if((ic8&0xf0)==0xa0) {
  136. names="if_icmpne\0if_icmplt\0if_icmpge\0if_icmpgt\0if_icmple\0if_acmpeq\0if_acmpne\0goto\0jsr\0ret\0?\0?\0ireturn\0lreturn\0freturn\0dreturn\0";
  137. op=((ic8)&0xf);
  138. args[0]=disasm_arg_label;
  139. addr+=1;
  140. a0=(int64_t)(*((int16_t*)addr));addr+=2;
  141. } else
  142. if(ic8==0xb9) {
  143. names="invokeinterface\0";
  144. args[0]=disasm_arg_a0; args[1]=disasm_arg_a1;
  145. addr+=1;
  146. a0=(int64_t)(*((int16_t*)addr));addr+=2;
  147. a1=(int64_t)(*((int16_t*)addr));addr+=2;
  148. } else
  149. if(ic8==0xba) {
  150. names="invokedynamic\0";
  151. args[0]=disasm_arg_a0;
  152. addr+=1;
  153. a0=(int64_t)(*((int32_t*)addr));addr+=4;
  154. } else
  155. if(ic8==0xbc) {
  156. names="newarray\0";
  157. args[0]=disasm_arg_a0;
  158. addr+=1;
  159. a0=(int64_t)(*((int8_t*)addr));addr+=1;
  160. } else
  161. if(ic16==0xbcc4) {
  162. names="newarray\0";
  163. args[0]=disasm_arg_a0;
  164. addr+=2;
  165. a0=(int64_t)(*((int16_t*)addr));addr+=2;
  166. } else
  167. if(ic16==0xbdc4) {
  168. names="anewarray\0";
  169. args[0]=disasm_arg_a0;
  170. addr+=2;
  171. a0=(int64_t)(*((int32_t*)addr));addr+=4;
  172. } else
  173. if((ic8&0xf0)==0xb0) {
  174. names="areturn\0return\0getstatic\0putstatic\0getfield\0putfield\0invokevirtual\0invokespecial\0invokestatic\0invokeinterface\0invokedynamic\0new\0newarray\0anewarray\0arraylength\0athrow\0";
  175. op=((ic8)&0xf);
  176. args[0]=disasm_arg_a0;
  177. addr+=1;
  178. a0=(int64_t)(*((int16_t*)addr));addr+=2;
  179. } else
  180. if((ic8&0xfe)==0xc0) {
  181. names="checkcast\0instanceof\0";
  182. op=((ic8)&0x1);
  183. args[0]=disasm_arg_a0;
  184. addr+=1;
  185. a0=(int64_t)(*((int16_t*)addr));addr+=2;
  186. } else
  187. if(ic8==0xc5) {
  188. names="multianewarray\0";
  189. args[0]=disasm_arg_a0; args[1]=disasm_arg_a1;
  190. addr+=1;
  191. a0=(int64_t)(*((int16_t*)addr));addr+=2;
  192. a1=(int64_t)(*((int8_t*)addr));addr+=1;
  193. } else
  194. if(ic16==0xc5c4) {
  195. names="multianewarray\0";
  196. args[0]=disasm_arg_a0; args[1]=disasm_arg_a1;
  197. addr+=2;
  198. a0=(int64_t)(*((int32_t*)addr));addr+=4;
  199. a1=(int64_t)(*((int16_t*)addr));addr+=2;
  200. } else
  201. if((ic8&0xfe)==0xc6) {
  202. names="ifnull\0ifnonnull\0";
  203. op=((ic8)&0x1);
  204. args[0]=disasm_arg_label;
  205. addr+=1;
  206. a0=(int64_t)(*((int16_t*)addr));addr+=2;
  207. } else
  208. if((ic8&0xfe)==0xc8) {
  209. names="goto_w\0jsr_w\0";
  210. op=((ic8)&0x1);
  211. args[0]=disasm_arg_label4;
  212. addr+=1;
  213. a0=(int64_t)(*((int32_t*)addr));addr+=4;
  214. } else
  215. {
  216. names="nop\0aconst_null\0iconst_m1\0iconst_0\0iconst_1\0iconst_2\0iconst_3\0iconst_4\0iconst_5\0lconst_0\0lconst_1\0fconst_0\0fconst_1\0fconst_2\0dconst_0\0dconst_1\0bipush\0sipush\0ldc\0ldc_w\0ldc2_w\0iload\0lload\0fload\0dload\0aload\0iload_0\0iload_1\0iload_2\0iload_3\0lload_0\0lload_1\0lload_2\0lload_3\0fload_0\0fload_1\0fload_2\0fload_3\0dload_0\0dload_1\0dload_2\0dload_3\0aload_0\0aload_1\0aload_2\0aload_3\0iaload\0laload\0faload\0daload\0aaload\0baload\0caload\0saload\0istore\0lstore\0fstore\0dstore\0astore\0istore_0\0istore_1\0istore_2\0istore_3\0lstore_0\0lstore_1\0lstore_2\0lstore_3\0fstore_0\0fstore_1\0fstore_2\0fstore_3\0dstore_0\0dstore_1\0dstore_2\0dstore_3\0astore_0\0astore_1\0astore_2\0astore_3\0iastore\0lastore\0fastore\0dastore\0aastore\0bastore\0castore\0sastore\0pop\0pop2\0dup\0dup_x1\0dup_x2\0dup2\0dup2_x1\0dup2_x2\0swap\0iadd\0ladd\0fadd\0dadd\0isub\0lsub\0fsub\0dsub\0imul\0lmul\0fmul\0dmul\0idiv\0ldiv\0fdiv\0ddiv\0irem\0lrem\0frem\0drem\0ineg\0lneg\0fneg\0dneg\0ishl\0lshl\0ishr\0lshr\0iushr\0lushr\0iand\0land\0ior\0lor\0ixor\0lxor\0iinc\0i2l\0i2f\0i2d\0l2i\0l2f\0l2d\0d2i\0f2l\0f2d\0d2i\0d2l\0d2f\0i2b\0i2c\0i2s\0lcmp\0fcmpl\0fcmpg\0dcmpl\0dcmpg\0ifeq\0ifne\0iflt\0ifge\0ifgt\0ifle\0if_icmpeq\0if_icmpne\0if_icmplt\0if_icmpge\0if_icmpgt\0if_icmple\0if_acmpeq\0if_acmpne\0goto\0jsr\0ret\0?\0?\0ireturn\0lreturn\0freturn\0dreturn\0areturn\0return\0getstatic\0putstatic\0getfield\0putfield\0invokevirtual\0invokespecial\0invokestatic\0invokeinterface\0invokedynamic\0new\0newarray\0anewarray\0arraylength\0athrow\0checkcast\0instanceof\0monitorenter\0monitorexit\0?\0multianewarray\0ifnull\0ifnonnull\0goto_w\0jsr_w\0breakpoint\0?\0?\0?\0?\0?\0?\0?\0?\0?\0?\0?\0?\0?\0?\0?\0?\0?\0?\0?\0?\0?\0?\0?\0?\0?\0?\0?\0?\0?\0?\0?\0?\0?\0?\0?\0?\0?\0?\0?\0?\0?\0?\0?\0?\0?\0?\0?\0?\0?\0?\0?\0impdep1\0impdep2\0";
  217. op=((ic8)&0xff);
  218. addr+=1;
  219. }
  220. if(str!=NULL) {
  221. str+=sprintf(str,disasm_str(names,op));
  222. if(str-olds<16)om=16-(str-olds);else om=1;for(op=0;op<om;op++) *str++=' ';
  223. for(op=0;op<sizeof(args) && args[op]!=disasm_arg_NONE;op++) {
  224. if(op) { *str++=','; *str++=' '; }
  225. switch(args[op]) {
  226. case disasm_arg_a0: str+=sprintf(str,"0x%lx", a0); break;
  227. case disasm_arg_label: str+=sprintf(str,"0x%lx", (int64_t)((uint16_t)a0)+((int)addr)); break;
  228. case disasm_arg_label4: str+=sprintf(str,"0x%lx", (int64_t)((uint32_t)a0)+((int)addr)); break;
  229. case disasm_arg_a1: str+=sprintf(str,"0x%lx", a1); break;
  230. case disasm_arg_a2: str+=sprintf(str,"0x%lx", a2); break;
  231. default: break;
  232. }
  233. if(*(str-2)==',')str-=2;
  234. }
  235. *str=0;
  236. }
  237. return addr;
  238. }
  239. #ifdef __cplusplus
  240. }
  241. #endif