z80.h 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663
  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 z80.txt
  29. */
  30. #ifdef __cplusplus
  31. extern "C" {
  32. #endif
  33. #define disasm_arch "z80"
  34. enum { disasm_arg_NONE,disasm_arg_ofs,disasm_arg_ofe, disasm_arg_r, disasm_arg_g, disasm_arg_n, disasm_arg_hlidx, disasm_arg_ixd, disasm_arg_iyd, disasm_arg_A, disasm_arg_bcidx, disasm_arg_deidx, disasm_arg_nidx, disasm_arg_I, disasm_arg_R, disasm_arg_r16, disasm_arg_sp, disasm_arg_de, disasm_arg_hl, disasm_arg_af, disasm_arg_afap, disasm_arg_spidx, disasm_arg_ix, disasm_arg_iy, disasm_arg_nd, disasm_arg_labeln, disasm_arg_c, disasm_arg_labeli, disasm_arg_ixidx, disasm_arg_iyidx, disasm_arg_n8, disasm_arg_Cidx };
  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, n=0;
  41. uint8_t r=0, g=0, d=0, c=0, i=0;
  42. uint8_t ic8, ic8_3, ic8_4;
  43. uint16_t ic16, ic16_11, ic16_12, ic16_8, ic16_10, ic16_3;
  44. uint32_t ic24, ic24_8, ic24_16;
  45. uint32_t ic32, ic32_27, ic32_16;
  46. char *names=NULL,*olds=str;
  47. char *regs="b\0c\0d\0e\0h\0l\0?\0a\0";
  48. char *reg16="bc\0de\0hl\0sp\0ix\0iy\0";
  49. char *conds="nz\0z\0nc\0c\0po\0pe\0p\0m\0";
  50. uint8_t args[3]={0,0,0};
  51. ic8=*((uint8_t*)addr);
  52. ic16=*((uint16_t*)addr);
  53. ic24=*((uint32_t*)addr);
  54. ic32=*((uint32_t*)addr);
  55. ic16_11=ic16>>11; ic16_12=ic16>>12; ic8_3=ic8>>3; ic8_4=ic8>>4; ic32_27=ic32>>27; ic32_16=ic32>>16; ic16_8=ic16>>8; ic16_10=ic16>>10; ic16_3=ic16>>3; ic24_8=ic24>>8; ic24_16=ic24>>16;
  56. /* handle multiple NOPs at once */
  57. if(ic8==0x0) {
  58. while(*((uint8_t*)addr)==ic8) { op++; addr+=1; }
  59. if(str!=NULL) str+=sprintf(str," %d x nop",op);
  60. *str=0;
  61. return addr;
  62. }
  63. /* decode instruction */
  64. if(ic8==0x2) {
  65. names="ld\0";
  66. args[0]=disasm_arg_bcidx; args[1]=disasm_arg_A;
  67. addr+=1;
  68. } else
  69. if(ic8==0x8) {
  70. names="ex\0";
  71. args[0]=disasm_arg_af; args[1]=disasm_arg_afap;
  72. addr+=1;
  73. } else
  74. if(ic8==0xa) {
  75. names="ld\0";
  76. args[0]=disasm_arg_A; args[1]=disasm_arg_bcidx;
  77. addr+=1;
  78. } else
  79. if(ic8==0x12) {
  80. names="ld\0";
  81. args[0]=disasm_arg_deidx; args[1]=disasm_arg_A;
  82. addr+=1;
  83. } else
  84. if(ic8==0x1a) {
  85. names="ld\0";
  86. args[0]=disasm_arg_A; args[1]=disasm_arg_deidx;
  87. addr+=1;
  88. } else
  89. if((ic16&0xf7ff)==0x23dd) {
  90. names="inc\0dec\0";
  91. op=((ic16_11)&0x1);
  92. args[0]=disasm_arg_ix;
  93. addr+=2;
  94. } else
  95. if((ic16&0xf7ff)==0x23fd) {
  96. names="inc\0dec\0";
  97. op=((ic16_11)&0x1);
  98. args[0]=disasm_arg_iy;
  99. addr+=2;
  100. } else
  101. if((ic8&0xfe)==0x34) {
  102. names="inc\0dec\0";
  103. op=((ic8)&0x1);
  104. args[0]=disasm_arg_hlidx;
  105. addr+=1;
  106. } else
  107. if((ic16&0xcfff)==0x9dd) {
  108. names="add\0";
  109. d=((ic16_12)&0x3);
  110. args[0]=disasm_arg_ix; args[1]=disasm_arg_r16;
  111. addr+=2;
  112. } else
  113. if((ic16&0xcfff)==0x9fd) {
  114. names="add\0";
  115. d=((ic16_12)&0x3);
  116. args[0]=disasm_arg_iy; args[1]=disasm_arg_r16;
  117. addr+=2;
  118. } else
  119. if((ic8&0xc7)==0x1) {
  120. names="sub\0add\0";
  121. op=((ic8_3)&0x1); d=((ic8_4)&0x3);
  122. args[0]=disasm_arg_hl; args[1]=disasm_arg_r16;
  123. addr+=1;
  124. } else
  125. if((ic8&0xc7)==0x3) {
  126. names="inc\0dec\0";
  127. op=((ic8_3)&0x1); d=((ic8_4)&0x3);
  128. args[0]=disasm_arg_r16;
  129. addr+=1;
  130. } else
  131. if((ic8&0xc6)==0x4) {
  132. names="inc\0dec\0";
  133. op=((ic8)&0x1); r=((ic8_3)&0x7);
  134. args[0]=disasm_arg_r;
  135. addr+=1;
  136. } else
  137. if((ic16&0xc7ff)==0x6cb) {
  138. names="rlc\0?\0rl\0rr\0sla\0sra\0srl\0";
  139. op=((ic16_11)&0x7);
  140. args[0]=disasm_arg_hlidx;
  141. addr+=2;
  142. } else
  143. if((ic32&0xc700ffff)==0x600cbdd) {
  144. names="rlc\0?\0rl\0rr\0sla\0sra\0srl\0";
  145. op=((ic32_27)&0x7); d=((ic32_16)&0xff);
  146. args[0]=disasm_arg_ixd;
  147. addr+=4;
  148. } else
  149. if((ic32&0xc700ffff)==0x600cbfd) {
  150. names="rlc\0?\0rl\0rr\0sla\0sra\0srl\0";
  151. op=((ic32_27)&0x7); d=((ic32_16)&0xff);
  152. args[0]=disasm_arg_iyd;
  153. addr+=4;
  154. } else
  155. if((ic8&0xc7)==0x7) {
  156. names="rlca\0rrca\0rla\0rra\0daa\0cpl\0scf\0ccf\0";
  157. op=((ic8_3)&0x7);
  158. addr+=1;
  159. } else
  160. if((ic16&0xc0ff)==0xcb) {
  161. names="rlc\0?\0rl\0rr\0sla\0sra\0srl\0";
  162. op=((ic16_11)&0x7); r=((ic16_8)&0x7);
  163. args[0]=disasm_arg_r;
  164. addr+=2;
  165. } else
  166. if(ic16==0x47ed) {
  167. names="ld\0";
  168. args[0]=disasm_arg_I; args[1]=disasm_arg_A;
  169. addr+=2;
  170. } else
  171. if(ic16==0x4fed) {
  172. names="ld\0";
  173. args[0]=disasm_arg_R; args[1]=disasm_arg_A;
  174. addr+=2;
  175. } else
  176. if((ic16&0xf6ff)==0x44ed) {
  177. names="neg\0retn\0?\0reti\0";
  178. op=((ic16_10)&0x2)|((ic16_8)&0x1);
  179. addr+=2;
  180. } else
  181. if(ic16==0x57ed) {
  182. names="ld\0";
  183. args[0]=disasm_arg_A; args[1]=disasm_arg_I;
  184. addr+=2;
  185. } else
  186. if(ic16==0x5fed) {
  187. names="ld\0";
  188. args[0]=disasm_arg_A; args[1]=disasm_arg_R;
  189. addr+=2;
  190. } else
  191. if((ic16&0xe7ff)==0x46ed) {
  192. names="im\0";
  193. n=((ic16_10)&0x2)|((ic16_12)&0x1);
  194. args[0]=disasm_arg_n;
  195. addr+=2;
  196. } else
  197. if((ic16&0xf7ff)==0x67ed) {
  198. names="rrd\0rld\0";
  199. op=((ic16_11)&0x1);
  200. addr+=2;
  201. } else
  202. if(ic8==0x76) {
  203. names="halt\0";
  204. addr+=1;
  205. } else
  206. if((ic8&0xf8)==0x70) {
  207. names="ld\0";
  208. r=((ic8)&0x7);
  209. args[0]=disasm_arg_hlidx; args[1]=disasm_arg_r;
  210. addr+=1;
  211. } else
  212. if((ic8&0xcf)==0x42) {
  213. names="sbc\0";
  214. d=((ic8_4)&0x3);
  215. args[0]=disasm_arg_hl; args[1]=disasm_arg_r16;
  216. addr+=1;
  217. } else
  218. if((ic16&0xcfff)==0x4aed) {
  219. names="adc\0";
  220. d=((ic16_12)&0x3);
  221. args[0]=disasm_arg_hl; args[1]=disasm_arg_r16;
  222. addr+=2;
  223. } else
  224. if((ic16&0xc7ff)==0x40ed) {
  225. names="in\0";
  226. r=((ic16_11)&0x7);
  227. args[0]=disasm_arg_r; args[1]=disasm_arg_Cidx;
  228. addr+=2;
  229. } else
  230. if((ic16&0xc7ff)==0x41ed) {
  231. names="out\0";
  232. r=((ic16_11)&0x7);
  233. args[0]=disasm_arg_Cidx; args[1]=disasm_arg_r;
  234. addr+=2;
  235. } else
  236. if((ic8&0xc7)==0x46) {
  237. names="ld\0";
  238. r=((ic8_3)&0x7);
  239. args[0]=disasm_arg_r; args[1]=disasm_arg_hlidx;
  240. addr+=1;
  241. } else
  242. if((ic8&0xc0)==0x40) {
  243. names="ld\0";
  244. r=((ic8_3)&0x7); g=((ic8)&0x7);
  245. args[0]=disasm_arg_r; args[1]=disasm_arg_g;
  246. addr+=1;
  247. } else
  248. if(ic8==0xb0) {
  249. names="ldir\0";
  250. addr+=1;
  251. } else
  252. if((ic16&0xe4ff)==0xa0ed) {
  253. names="ldi\0cpi\0ini\0outi\0ldd\0cpd\0ind\0outd\0?\0cpir\0inir\0otir\0lddr\0cpdr\0indr\0otdr\0";
  254. op=((ic16>>9)&0xc)|((ic16_8)&0x3);
  255. addr+=2;
  256. } else
  257. if((ic8&0xc7)==0x86) {
  258. names="add\0adc\0sub\0sbc\0and\0xor\0or\0cp\0";
  259. op=((ic8_3)&0x7);
  260. args[0]=disasm_arg_A; args[1]=disasm_arg_hlidx;
  261. addr+=1;
  262. } else
  263. if((ic8&0xc0)==0x80) {
  264. names="add\0adc\0sub\0sbc\0and\0xor\0or\0cp\0";
  265. op=((ic8_3)&0x7); r=((ic8)&0x7);
  266. args[0]=disasm_arg_A; args[1]=disasm_arg_r;
  267. addr+=1;
  268. } else
  269. if(ic8==0xc9) {
  270. names="ret\0";
  271. addr+=1;
  272. } else
  273. if(ic8==0xd8) {
  274. names="exx\0";
  275. addr+=1;
  276. } else
  277. if(ic8==0xe3) {
  278. names="ex\0";
  279. d=2;
  280. args[0]=disasm_arg_spidx; args[1]=disasm_arg_r16;
  281. addr+=1;
  282. } else
  283. if(ic16==0xe3dd) {
  284. names="ex\0";
  285. d=4;
  286. args[0]=disasm_arg_spidx; args[1]=disasm_arg_r16;
  287. addr+=2;
  288. } else
  289. if(ic16==0xe3fd) {
  290. names="ex\0";
  291. d=5;
  292. args[0]=disasm_arg_spidx; args[1]=disasm_arg_r16;
  293. addr+=2;
  294. } else
  295. if((ic16&0xfbff)==0xe1dd) {
  296. names="pop\0push\0";
  297. op=((ic16_10)&0x1);
  298. d=4;
  299. args[0]=disasm_arg_r16;
  300. addr+=2;
  301. } else
  302. if((ic16&0xfbff)==0xe1fd) {
  303. names="pop\0push\0";
  304. op=((ic16_10)&0x1);
  305. d=5;
  306. args[0]=disasm_arg_r16;
  307. addr+=2;
  308. } else
  309. if(ic8==0xe9) {
  310. names="jp\0";
  311. args[0]=disasm_arg_hlidx;
  312. addr+=1;
  313. } else
  314. if(ic16==0xe9dd) {
  315. names="jp\0";
  316. args[0]=disasm_arg_ixidx;
  317. addr+=2;
  318. } else
  319. if(ic16==0xe9fd) {
  320. names="jp\0";
  321. args[0]=disasm_arg_iyidx;
  322. addr+=2;
  323. } else
  324. if(ic8==0xeb) {
  325. names="ex\0";
  326. args[0]=disasm_arg_de; args[1]=disasm_arg_hl;
  327. addr+=1;
  328. } else
  329. if(ic8==0xf9) {
  330. names="ld\0";
  331. d=2;
  332. args[0]=disasm_arg_sp; args[1]=disasm_arg_r16;
  333. addr+=1;
  334. } else
  335. if(ic16==0xf9dd) {
  336. names="ld\0";
  337. d=4;
  338. args[0]=disasm_arg_sp; args[1]=disasm_arg_r16;
  339. addr+=2;
  340. } else
  341. if(ic16==0xf9fd) {
  342. names="ld\0";
  343. d=5;
  344. args[0]=disasm_arg_sp; args[1]=disasm_arg_r16;
  345. addr+=2;
  346. } else
  347. if((ic8&0xf7)==0xf3) {
  348. names="di\0ei\0";
  349. op=((ic8_3)&0x1);
  350. addr+=1;
  351. } else
  352. if((ic8&0xcb)==0xc1) {
  353. names="pop\0push\0";
  354. op=((ic8>>2)&0x1); d=((ic8_4)&0x3);
  355. args[0]=disasm_arg_r16;
  356. addr+=1;
  357. } else
  358. if((ic8&0xc7)==0xc0) {
  359. names="ret\0";
  360. c=((ic8_3)&0x7);
  361. args[0]=disasm_arg_c;
  362. addr+=1;
  363. } else
  364. if((ic8&0xc7)==0xc7) {
  365. names="rst\0";
  366. n=((ic8_3)&0x7);
  367. args[0]=disasm_arg_n8;
  368. addr+=1;
  369. } else
  370. if(ic16==0x6cb) {
  371. names="?\0bit\0res\0set\0";
  372. op=((ic16>>14)&0x3); n=((ic16_11)&0x7);
  373. args[0]=disasm_arg_nd; args[1]=disasm_arg_hlidx;
  374. addr+=2;
  375. } else
  376. if((ic32&0x700ffff)==0x600cbdd) {
  377. names="?\0bit\0res\0set\0";
  378. op=((ic32>>30)&0x3); n=((ic32_27)&0x7); d=((ic32_16)&0xff);
  379. args[0]=disasm_arg_nd; args[1]=disasm_arg_ixd;
  380. addr+=4;
  381. } else
  382. if((ic32&0x700ffff)==0x600cbfd) {
  383. names="?\0bit\0res\0set\0";
  384. op=((ic32>>30)&0x3); n=((ic32_27)&0x7); d=((ic32_16)&0xff);
  385. args[0]=disasm_arg_nd; args[1]=disasm_arg_iyd;
  386. addr+=4;
  387. } else
  388. if((ic16&0xf7)==0x10) {
  389. names="djnz\0jr\0";
  390. op=((ic16_3)&0x1); i=((ic16>>15)&1?(0xffffffff<<8):0)|((ic16_8)&0xff);
  391. args[0]=disasm_arg_labeli;
  392. addr+=2;
  393. } else
  394. if((ic24&0xfeff)==0x34dd) {
  395. names="inc\0dec\0";
  396. op=((ic24_8)&0x1); d=((ic24_16)&0xff);
  397. args[0]=disasm_arg_ixd;
  398. addr+=3;
  399. } else
  400. if((ic24&0xfeff)==0x34fd) {
  401. names="inc\0dec\0";
  402. op=((ic24_8)&0x1); d=((ic24_16)&0xff);
  403. args[0]=disasm_arg_iyd;
  404. addr+=3;
  405. } else
  406. if(ic16==0x36) {
  407. names="ld\0";
  408. n=((ic16_8)&0xff);
  409. args[0]=disasm_arg_hlidx; args[1]=disasm_arg_n;
  410. addr+=2;
  411. } else
  412. if((ic16&0xe7)==0x20) {
  413. names="jr\0";
  414. i=((ic16>>15)&1?(0xffffffff<<8):0)|((ic16_8)&0xff); c=((ic16_3)&0x3);
  415. args[0]=disasm_arg_c; args[1]=disasm_arg_labeli;
  416. addr+=2;
  417. } else
  418. if((ic16&0xc7)==0x6) {
  419. names="ld\0";
  420. n=((ic16_8)&0xff); r=((ic16_3)&0x7);
  421. args[0]=disasm_arg_r; args[1]=disasm_arg_n;
  422. addr+=2;
  423. } else
  424. if((ic24&0xf8ff)==0x70dd) {
  425. names="ld\0";
  426. d=((ic24_16)&0xff); r=((ic24_8)&0x7);
  427. args[0]=disasm_arg_ixd; args[1]=disasm_arg_r;
  428. addr+=3;
  429. } else
  430. if((ic24&0xf8ff)==0x70fd) {
  431. names="ld\0";
  432. d=((ic24_16)&0xff); r=((ic24_8)&0x7);
  433. args[0]=disasm_arg_iyd; args[1]=disasm_arg_r;
  434. addr+=3;
  435. } else
  436. if((ic24&0xc7ff)==0x46dd) {
  437. names="ld\0";
  438. d=((ic24_16)&0xff); r=((ic24>>11)&0x7);
  439. args[0]=disasm_arg_r; args[1]=disasm_arg_ixd;
  440. addr+=3;
  441. } else
  442. if((ic24&0xc7ff)==0x46fd) {
  443. names="ld\0";
  444. d=((ic24_16)&0xff); r=((ic24>>11)&0x7);
  445. args[0]=disasm_arg_r; args[1]=disasm_arg_iyd;
  446. addr+=3;
  447. } else
  448. if((ic24&0xc6ff)==0x86dd) {
  449. names="add\0?\0adc\0?\0sub\0sbc\0?\0?\0and\0?\0xor\0?\0or\0?\0cp\0";
  450. op=((ic24>>10)&0xe)|((ic24_8)&0x1); d=((ic24_16)&0xff);
  451. args[0]=disasm_arg_A; args[1]=disasm_arg_ixd;
  452. addr+=3;
  453. } else
  454. if((ic24&0xc6ff)==0x86fd) {
  455. names="add\0?\0adc\0?\0sub\0sbc\0?\0?\0and\0?\0xor\0?\0or\0?\0cp\0";
  456. op=((ic24>>10)&0xe)|((ic24_8)&0x1); d=((ic24_16)&0xff);
  457. args[0]=disasm_arg_A; args[1]=disasm_arg_iyd;
  458. addr+=3;
  459. } else
  460. if(ic16==0xcb) {
  461. names="?\0bit\0res\0set\0";
  462. op=((ic16>>14)&0x3); n=((ic16_11)&0x7); r=((ic16_8)&0x7);
  463. args[0]=disasm_arg_nd; args[1]=disasm_arg_r;
  464. addr+=2;
  465. } else
  466. if(ic16==0xd3) {
  467. names="out\0";
  468. n=((ic16_8)&0xff);
  469. args[0]=disasm_arg_nidx; args[1]=disasm_arg_A;
  470. addr+=2;
  471. } else
  472. if(ic16==0xdb) {
  473. names="in\0";
  474. n=((ic16_8)&0xff);
  475. args[0]=disasm_arg_A; args[1]=disasm_arg_nidx;
  476. addr+=2;
  477. } else
  478. if((ic16&0xc7)==0xc6) {
  479. names="add\0adc\0sub\0sbc\0and\0xor\0or\0cp\0";
  480. op=((ic16_3)&0x7); n=((ic16_8)&0xff);
  481. args[0]=disasm_arg_A; args[1]=disasm_arg_n;
  482. addr+=2;
  483. } else
  484. if(ic32==0x21dd) {
  485. names="ld\0";
  486. n=((ic32_16)&0xffff);
  487. d=4;
  488. args[0]=disasm_arg_r16; args[1]=disasm_arg_n;
  489. addr+=4;
  490. } else
  491. if(ic32==0x21fd) {
  492. names="ld\0";
  493. n=((ic32_16)&0xffff);
  494. d=5;
  495. args[0]=disasm_arg_r16; args[1]=disasm_arg_n;
  496. addr+=4;
  497. } else
  498. if((ic24&0xff)==0x22) {
  499. names="ld\0";
  500. n=((ic24_8)&0xffff);
  501. d=2;
  502. args[0]=disasm_arg_nidx; args[1]=disasm_arg_r16;
  503. addr+=3;
  504. } else
  505. if(ic32==0x22dd) {
  506. names="ld\0";
  507. n=((ic32_16)&0xffff);
  508. d=4;
  509. args[0]=disasm_arg_nidx; args[1]=disasm_arg_r16;
  510. addr+=4;
  511. } else
  512. if(ic32==0x22fd) {
  513. names="ld\0";
  514. n=((ic32_16)&0xffff);
  515. d=5;
  516. args[0]=disasm_arg_nidx; args[1]=disasm_arg_r16;
  517. addr+=4;
  518. } else
  519. if(ic32==0x29dd) {
  520. names="ld\0";
  521. n=((ic32_16)&0xffff);
  522. d=4;
  523. args[0]=disasm_arg_r16; args[1]=disasm_arg_nidx;
  524. addr+=4;
  525. } else
  526. if(ic32==0x29fd) {
  527. names="ld\0";
  528. n=((ic32_16)&0xffff);
  529. d=5;
  530. args[0]=disasm_arg_r16; args[1]=disasm_arg_nidx;
  531. addr+=4;
  532. } else
  533. if((ic24&0xff)==0x2a) {
  534. names="ld\0";
  535. n=((ic24_8)&0xffff);
  536. d=2;
  537. args[0]=disasm_arg_r16; args[1]=disasm_arg_nidx;
  538. addr+=3;
  539. } else
  540. if((ic24&0xff)==0x32) {
  541. names="ld\0";
  542. n=((ic24_8)&0xffff);
  543. args[0]=disasm_arg_nidx; args[1]=disasm_arg_A;
  544. addr+=3;
  545. } else
  546. if(ic32==0x36dd) {
  547. names="ld\0";
  548. n=((ic32>>24)&0xff); d=((ic32_16)&0xff);
  549. args[0]=disasm_arg_ixd; args[1]=disasm_arg_n;
  550. addr+=4;
  551. } else
  552. if(ic32==0x36fd) {
  553. names="ld\0";
  554. n=((ic32>>24)&0xff); d=((ic32_16)&0xff);
  555. args[0]=disasm_arg_iyd; args[1]=disasm_arg_n;
  556. addr+=4;
  557. } else
  558. if((ic24&0xff)==0x3a) {
  559. names="ld\0";
  560. n=((ic24_8)&0xffff);
  561. args[0]=disasm_arg_A; args[1]=disasm_arg_nidx;
  562. addr+=3;
  563. } else
  564. if((ic24&0xcf)==0x1) {
  565. names="ld\0";
  566. n=((ic24_8)&0xffff); d=((ic24>>4)&0x3);
  567. args[0]=disasm_arg_r16; args[1]=disasm_arg_n;
  568. addr+=3;
  569. } else
  570. if((ic24&0xcf)==0x43) {
  571. names="ld\0";
  572. n=((ic24_8)&0xffff); d=((ic24>>4)&0x3);
  573. args[0]=disasm_arg_nidx; args[1]=disasm_arg_r16;
  574. addr+=3;
  575. } else
  576. if((ic32&0xcfff)==0x4bed) {
  577. names="ld\0";
  578. n=((ic32_16)&0xffff); d=((ic32>>12)&0x3);
  579. args[0]=disasm_arg_r16; args[1]=disasm_arg_nidx;
  580. addr+=4;
  581. } else
  582. if((ic24&0xff)==0xc3) {
  583. names="jp\0";
  584. n=((ic24_8)&0xffff);
  585. args[0]=disasm_arg_labeln;
  586. addr+=3;
  587. } else
  588. if((ic24&0xff)==0xcd) {
  589. names="call\0";
  590. n=((ic24_8)&0xffff);
  591. args[0]=disasm_arg_labeln;
  592. addr+=3;
  593. } else
  594. if((ic24&0xc7)==0xc2) {
  595. names="jp\0";
  596. n=((ic24_8)&0xffff); c=((ic24>>3)&0x7);
  597. args[0]=disasm_arg_c; args[1]=disasm_arg_labeln;
  598. addr+=3;
  599. } else
  600. if((ic24&0xc7)==0xc4) {
  601. names="call\0";
  602. n=((ic24_8)&0xffff); c=((ic24>>3)&0x7);
  603. args[0]=disasm_arg_c; args[1]=disasm_arg_labeln;
  604. addr+=3;
  605. } else
  606. names=NULL;
  607. if(str!=NULL) {
  608. str+=sprintf(str,disasm_str(names,op),disasm_str(conds,c));
  609. if(str-olds<8)om=8-(str-olds);else om=1;for(op=0;op<om;op++) *str++=' ';
  610. for(op=0;op<sizeof(args) && args[op]!=disasm_arg_NONE;op++) {
  611. if(op) { *str++=','; *str++=' '; }
  612. switch(args[op]) {
  613. case disasm_arg_r: str+=sprintf(str,"%s", disasm_str(regs,r)); break;
  614. case disasm_arg_g: str+=sprintf(str,"%s", "%s'", disasm_str(regs,g)); break;
  615. case disasm_arg_n: str+=sprintf(str,"%xh", n); break;
  616. case disasm_arg_hlidx: str+=sprintf(str,"(hl)"); break;
  617. case disasm_arg_ixd: str+=sprintf(str,"(ix+%d)", d); break;
  618. case disasm_arg_iyd: str+=sprintf(str,"(iy+%d)", d); break;
  619. case disasm_arg_A: str+=sprintf(str,"a"); break;
  620. case disasm_arg_bcidx: str+=sprintf(str,"(bc)"); break;
  621. case disasm_arg_deidx: str+=sprintf(str,"(de)"); break;
  622. case disasm_arg_nidx: str+=sprintf(str,"(%xh)", n); break;
  623. case disasm_arg_I: str+=sprintf(str,"i"); break;
  624. case disasm_arg_R: str+=sprintf(str,"r"); break;
  625. case disasm_arg_r16: str+=sprintf(str,"%s", disasm_str(reg16,d)); break;
  626. case disasm_arg_sp: str+=sprintf(str,"sp"); break;
  627. case disasm_arg_de: str+=sprintf(str,"de"); break;
  628. case disasm_arg_hl: str+=sprintf(str,"hl"); break;
  629. case disasm_arg_af: str+=sprintf(str,"af"); break;
  630. case disasm_arg_afap: str+=sprintf(str,"af'"); break;
  631. case disasm_arg_spidx: str+=sprintf(str,"(sp)"); break;
  632. case disasm_arg_ix: str+=sprintf(str,"ix"); break;
  633. case disasm_arg_iy: str+=sprintf(str,"iy"); break;
  634. case disasm_arg_nd: str+=sprintf(str,"%d", n); break;
  635. case disasm_arg_labeln: str+=sprintf(str,"%xh", n); break;
  636. case disasm_arg_c: str+=sprintf(str,"%s", disasm_str(conds,c)); break;
  637. case disasm_arg_labeli: str+=sprintf(str,"%lxh", ((int)addr)+i); break;
  638. case disasm_arg_ixidx: str+=sprintf(str,"(ix)"); break;
  639. case disasm_arg_iyidx: str+=sprintf(str,"(iy)"); break;
  640. case disasm_arg_n8: str+=sprintf(str,"%xh", n<<3); break;
  641. case disasm_arg_Cidx: str+=sprintf(str,"(c)"); break;
  642. default: break;
  643. }
  644. if(*(str-2)==',')str-=2;
  645. }
  646. *str=0;
  647. }
  648. return addr;
  649. }
  650. #ifdef __cplusplus
  651. }
  652. #endif