An emulator, assembler, and disassembler for the Sega Game Gear
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

860 lines
20 KiB

  1. # Copyright (C) 2014-2015 Ben Kurtovic <ben.kurtovic@gmail.com>
  2. # Released under the terms of the MIT License. See LICENSE for details.
  3. # *** ASM Instruction Description File ***
  4. # This file is used to generate 'instructions.inc.c'.
  5. # `make` should trigger a rebuild when this file is modified; if not, use:
  6. # `python scripts/update_asm_instructions.py`.
  7. ---
  8. adc:
  9. args: yes
  10. cases:
  11. - type: [register, register]
  12. cases:
  13. - cond: [a, a]
  14. return: [0x8F]
  15. - cond: [a, b]
  16. return: [0x88]
  17. - cond: [a, c]
  18. return: [0x89]
  19. - cond: [a, d]
  20. return: [0x8A]
  21. - cond: [a, e]
  22. return: [0x8B]
  23. - cond: [a, h|ih]
  24. return: [0x8C]
  25. - cond: [a, l|il]
  26. return: [0x8D]
  27. - cond: [hl, bc]
  28. return: [0xED, 0x4A]
  29. - cond: [hl, de]
  30. return: [0xED, 0x5A]
  31. - cond: [hl, hl]
  32. return: [0xED, 0x6A]
  33. - cond: [hl, sp]
  34. return: [0xED, 0x7A]
  35. - type: [register, immediate]
  36. cases:
  37. - cond: [a, u8]
  38. return: [0xCE, u8]
  39. - type: [register, indirect_hl_or_indexed]
  40. cases:
  41. - cond: [a, _]
  42. return: [0x8E]
  43. add:
  44. args: yes
  45. cases:
  46. - type: [register, register]
  47. cases:
  48. - cond: [a, a]
  49. return: [0x87]
  50. - cond: [a, b]
  51. return: [0x80]
  52. - cond: [a, c]
  53. return: [0x81]
  54. - cond: [a, d]
  55. return: [0x82]
  56. - cond: [a, e]
  57. return: [0x83]
  58. - cond: [a, h|ih]
  59. return: [0x84]
  60. - cond: [a, l|il]
  61. return: [0x85]
  62. - cond: [hl|i, bc]
  63. return: [0x09]
  64. - cond: [hl|i, de]
  65. return: [0x19]
  66. - cond: [hl|i, hl|i]
  67. return: [0x29]
  68. - cond: [hl|i, sp]
  69. return: [0x39]
  70. - type: [register, immediate]
  71. cases:
  72. - cond: [a, u8]
  73. return: [0xC6, u8]
  74. - type: [register, indirect_hl_or_indexed]
  75. cases:
  76. - cond: [a, _]
  77. return: [0x86]
  78. and:
  79. args: yes
  80. cases:
  81. - type: [register]
  82. cases:
  83. - cond: [a]
  84. return: [0xA7]
  85. - cond: [b]
  86. return: [0xA0]
  87. - cond: [c]
  88. return: [0xA1]
  89. - cond: [d]
  90. return: [0xA2]
  91. - cond: [e]
  92. return: [0xA3]
  93. - cond: [h|ih]
  94. return: [0xA4]
  95. - cond: [l|il]
  96. return: [0xA5]
  97. - type: [immediate]
  98. cases:
  99. - cond: [u8]
  100. return: [0xE6, u8]
  101. - type: [indirect_hl_or_indexed]
  102. cases:
  103. - cond: [_]
  104. return: [0xA6]
  105. bit:
  106. args: yes
  107. cases:
  108. - type: [immediate, register]
  109. cases:
  110. - cond: [bit.0, a]
  111. return: [0xCB, 0x47]
  112. - cond: [bit.0, b]
  113. return: [0xCB, 0x40]
  114. - cond: [bit.0, c]
  115. return: [0xCB, 0x41]
  116. - cond: [bit.0, d]
  117. return: [0xCB, 0x42]
  118. - cond: [bit.0, e]
  119. return: [0xCB, 0x43]
  120. - cond: [bit.0, h]
  121. return: [0xCB, 0x44]
  122. - cond: [bit.0, l]
  123. return: [0xCB, 0x45]
  124. - cond: [bit.1, a]
  125. return: [0xCB, 0x4F]
  126. - cond: [bit.1, b]
  127. return: [0xCB, 0x48]
  128. - cond: [bit.1, c]
  129. return: [0xCB, 0x49]
  130. - cond: [bit.1, d]
  131. return: [0xCB, 0x4A]
  132. - cond: [bit.1, e]
  133. return: [0xCB, 0x4B]
  134. - cond: [bit.1, h]
  135. return: [0xCB, 0x4C]
  136. - cond: [bit.1, l]
  137. return: [0xCB, 0x4D]
  138. - cond: [bit.2, a]
  139. return: [0xCB, 0x57]
  140. - cond: [bit.2, b]
  141. return: [0xCB, 0x50]
  142. - cond: [bit.2, c]
  143. return: [0xCB, 0x51]
  144. - cond: [bit.2, d]
  145. return: [0xCB, 0x52]
  146. - cond: [bit.2, e]
  147. return: [0xCB, 0x53]
  148. - cond: [bit.2, h]
  149. return: [0xCB, 0x54]
  150. - cond: [bit.2, l]
  151. return: [0xCB, 0x55]
  152. - cond: [bit.3, a]
  153. return: [0xCB, 0x5F]
  154. - cond: [bit.3, b]
  155. return: [0xCB, 0x58]
  156. - cond: [bit.3, c]
  157. return: [0xCB, 0x59]
  158. - cond: [bit.3, d]
  159. return: [0xCB, 0x5A]
  160. - cond: [bit.3, e]
  161. return: [0xCB, 0x5B]
  162. - cond: [bit.3, h]
  163. return: [0xCB, 0x5C]
  164. - cond: [bit.3, l]
  165. return: [0xCB, 0x5D]
  166. - cond: [bit.4, a]
  167. return: [0xCB, 0x67]
  168. - cond: [bit.4, b]
  169. return: [0xCB, 0x60]
  170. - cond: [bit.4, c]
  171. return: [0xCB, 0x61]
  172. - cond: [bit.4, d]
  173. return: [0xCB, 0x62]
  174. - cond: [bit.4, e]
  175. return: [0xCB, 0x63]
  176. - cond: [bit.4, h]
  177. return: [0xCB, 0x64]
  178. - cond: [bit.4, l]
  179. return: [0xCB, 0x65]
  180. - cond: [bit.5, a]
  181. return: [0xCB, 0x6F]
  182. - cond: [bit.5, b]
  183. return: [0xCB, 0x68]
  184. - cond: [bit.5, c]
  185. return: [0xCB, 0x69]
  186. - cond: [bit.5, d]
  187. return: [0xCB, 0x6A]
  188. - cond: [bit.5, e]
  189. return: [0xCB, 0x6B]
  190. - cond: [bit.5, h]
  191. return: [0xCB, 0x6C]
  192. - cond: [bit.5, l]
  193. return: [0xCB, 0x6D]
  194. - cond: [bit.6, a]
  195. return: [0xCB, 0x77]
  196. - cond: [bit.6, b]
  197. return: [0xCB, 0x70]
  198. - cond: [bit.6, c]
  199. return: [0xCB, 0x71]
  200. - cond: [bit.6, d]
  201. return: [0xCB, 0x72]
  202. - cond: [bit.6, e]
  203. return: [0xCB, 0x73]
  204. - cond: [bit.6, h]
  205. return: [0xCB, 0x74]
  206. - cond: [bit.6, l]
  207. return: [0xCB, 0x75]
  208. - cond: [bit.7, a]
  209. return: [0xCB, 0x7F]
  210. - cond: [bit.7, b]
  211. return: [0xCB, 0x78]
  212. - cond: [bit.7, c]
  213. return: [0xCB, 0x79]
  214. - cond: [bit.7, d]
  215. return: [0xCB, 0x7A]
  216. - cond: [bit.7, e]
  217. return: [0xCB, 0x7B]
  218. - cond: [bit.7, h]
  219. return: [0xCB, 0x7C]
  220. - cond: [bit.7, l]
  221. return: [0xCB, 0x7D]
  222. - type: [immediate, indirect_hl_or_indexed]
  223. cases:
  224. - cond: [bit.0, _]
  225. return: [0xCB, 0x46]
  226. - cond: [bit.1, _]
  227. return: [0xCB, 0x4E]
  228. - cond: [bit.2, _]
  229. return: [0xCB, 0x56]
  230. - cond: [bit.3, _]
  231. return: [0xCB, 0x5E]
  232. - cond: [bit.4, _]
  233. return: [0xCB, 0x66]
  234. - cond: [bit.5, _]
  235. return: [0xCB, 0x6E]
  236. - cond: [bit.6, _]
  237. return: [0xCB, 0x76]
  238. - cond: [bit.7, _]
  239. return: [0xCB, 0x7E]
  240. call:
  241. args: yes
  242. cases:
  243. - type: [immediate]
  244. cases:
  245. - cond: [u16]
  246. return: [0xCD, u16]
  247. - type: [condition, immediate]
  248. cases:
  249. - cond: [nz, u16]
  250. return: [0xC4, u16]
  251. - cond: [z, u16]
  252. return: [0xCC, u16]
  253. - cond: [nc, u16]
  254. return: [0xD4, u16]
  255. - cond: [c, u16]
  256. return: [0xDC, u16]
  257. - cond: [po, u16]
  258. return: [0xE4, u16]
  259. - cond: [pe, u16]
  260. return: [0xEC, u16]
  261. - cond: [p, u16]
  262. return: [0xF4, u16]
  263. - cond: [m, u16]
  264. return: [0xFC, u16]
  265. ccf:
  266. args: no
  267. return: [0x3F]
  268. cp:
  269. args: yes
  270. cases:
  271. - type: [register]
  272. cases:
  273. - cond: [a]
  274. return: [0xBF]
  275. - cond: [b]
  276. return: [0xB8]
  277. - cond: [c]
  278. return: [0xB9]
  279. - cond: [d]
  280. return: [0xBA]
  281. - cond: [e]
  282. return: [0xBB]
  283. - cond: [h|ih]
  284. return: [0xBC]
  285. - cond: [l|il]
  286. return: [0xBD]
  287. - type: [indirect_hl_or_indexed]
  288. cases:
  289. - cond: [_]
  290. return: [0xBE]
  291. - type: [immediate]
  292. cases:
  293. - cond: [u8]
  294. return: [0xFE, u8]
  295. cpd:
  296. args: no
  297. return: [0xED, 0xA9]
  298. cpdr:
  299. args: no
  300. return: [0xED, 0xB9]
  301. cpi:
  302. args: no
  303. return: [0xED, 0xA1]
  304. cpir:
  305. args: no
  306. return: [0xED, 0xB1]
  307. cpl:
  308. args: no
  309. return: [0x2F]
  310. daa:
  311. args: no
  312. return: [0x27]
  313. dec:
  314. args: yes
  315. cases:
  316. - type: [register]
  317. cases:
  318. - cond: [a]
  319. return: [0x3D]
  320. - cond: [b]
  321. return: [0x05]
  322. - cond: [c]
  323. return: [0x0D]
  324. - cond: [d]
  325. return: [0x15]
  326. - cond: [e]
  327. return: [0x1D]
  328. - cond: [h|ih]
  329. return: [0x25]
  330. - cond: [l|il]
  331. return: [0x2D]
  332. - cond: [bc]
  333. return: [0x0B]
  334. - cond: [de]
  335. return: [0x1B]
  336. - cond: [hl|i]
  337. return: [0x2B]
  338. - cond: [sp]
  339. return: [0x3B]
  340. - type: [indirect_hl_or_indexed]
  341. cases:
  342. - cond: [_]
  343. return: [0x35]
  344. di:
  345. args: no
  346. return: [0xF3]
  347. djnz:
  348. args: yes
  349. cases:
  350. - type: [immediate]
  351. cases:
  352. - cond: [rel]
  353. return: [0x10, rel]
  354. ei:
  355. args: no
  356. return: [0xFB]
  357. ex:
  358. args: yes
  359. cases:
  360. - type: [register, register]
  361. cases:
  362. - cond: [af, af_]
  363. return: [0x08]
  364. - cond: [de, hl]
  365. return: [0xEB]
  366. - type: [indirect, register]
  367. cases:
  368. - cond: [reg.sp, hl|i]
  369. return: [0xE3]
  370. exx:
  371. args: no
  372. return: [0xD9]
  373. halt:
  374. args: no
  375. return: [0x76]
  376. im:
  377. args: yes
  378. cases:
  379. - type: [immediate]
  380. cases:
  381. - cond: [im.0]
  382. return: [0xED, 0x46]
  383. - cond: [im.1]
  384. return: [0xED, 0x56]
  385. - cond: [im.2]
  386. return: [0xED, 0x5E]
  387. in:
  388. args: yes
  389. cases:
  390. - type: [register, port]
  391. cases:
  392. - cond: [a, imm]
  393. return: [0xDB, u8]
  394. - cond: [a, reg.c]
  395. return: [0xED, 0x78]
  396. - cond: [b, reg.c]
  397. return: [0xED, 0x40]
  398. - cond: [c, reg.c]
  399. return: [0xED, 0x48]
  400. - cond: [d, reg.c]
  401. return: [0xED, 0x50]
  402. - cond: [e, reg.c]
  403. return: [0xED, 0x58]
  404. - cond: [h, reg.c]
  405. return: [0xED, 0x60]
  406. - cond: [l, reg.c]
  407. return: [0xED, 0x68]
  408. - type: [port]
  409. cases:
  410. - cond: [reg.c]
  411. return: [0xED, 0x70]
  412. inc:
  413. args: yes
  414. cases:
  415. - type: [register]
  416. cases:
  417. - cond: [a]
  418. return: [0x3C]
  419. - cond: [b]
  420. return: [0x04]
  421. - cond: [c]
  422. return: [0x0C]
  423. - cond: [d]
  424. return: [0x14]
  425. - cond: [e]
  426. return: [0x1C]
  427. - cond: [h|ih]
  428. return: [0x24]
  429. - cond: [l|il]
  430. return: [0x2C]
  431. - cond: [bc]
  432. return: [0x03]
  433. - cond: [de]
  434. return: [0x13]
  435. - cond: [hl|i]
  436. return: [0x23]
  437. - cond: [sp]
  438. return: [0x33]
  439. - type: [indirect_hl_or_indexed]
  440. cases:
  441. - cond: [_]
  442. return: [0x34]
  443. ind:
  444. args: no
  445. return: [0xED, 0xAA]
  446. indr:
  447. args: no
  448. return: [0xED, 0xBA]
  449. ini:
  450. args: no
  451. return: [0xED, 0xA2]
  452. inir:
  453. args: no
  454. return: [0xED, 0xB2]
  455. # jp:
  456. # args: yes
  457. # return: TODO
  458. # jr:
  459. # args: yes
  460. # return: TODO
  461. ld:
  462. args: yes
  463. cases:
  464. - type: [register, register]
  465. cases:
  466. - cond: [a, a]
  467. return: [0x7F]
  468. - cond: [a, b]
  469. return: [0x78]
  470. - cond: [a, c]
  471. return: [0x79]
  472. - cond: [a, d]
  473. return: [0x7A]
  474. - cond: [a, e]
  475. return: [0x7B]
  476. - cond: [a, h|ih]
  477. return: [0x7C]
  478. - cond: [a, l|il]
  479. return: [0x7D]
  480. - cond: [b, a]
  481. return: [0x47]
  482. - cond: [b, b]
  483. return: [0x40]
  484. - cond: [b, c]
  485. return: [0x41]
  486. - cond: [b, d]
  487. return: [0x42]
  488. - cond: [b, e]
  489. return: [0x43]
  490. - cond: [b, h|ih]
  491. return: [0x44]
  492. - cond: [b, l|il]
  493. return: [0x45]
  494. - cond: [c, a]
  495. return: [0x4F]
  496. - cond: [c, b]
  497. return: [0x48]
  498. - cond: [c, c]
  499. return: [0x49]
  500. - cond: [c, d]
  501. return: [0x4A]
  502. - cond: [c, e]
  503. return: [0x4B]
  504. - cond: [c, h|ih]
  505. return: [0x4C]
  506. - cond: [c, l|il]
  507. return: [0x4D]
  508. - cond: [d, a]
  509. return: [0x57]
  510. - cond: [d, b]
  511. return: [0x50]
  512. - cond: [d, c]
  513. return: [0x51]
  514. - cond: [d, d]
  515. return: [0x52]
  516. - cond: [d, e]
  517. return: [0x53]
  518. - cond: [d, h|ih]
  519. return: [0x54]
  520. - cond: [d, l|il]
  521. return: [0x55]
  522. - cond: [e, a]
  523. return: [0x5F]
  524. - cond: [e, b]
  525. return: [0x58]
  526. - cond: [e, c]
  527. return: [0x59]
  528. - cond: [e, d]
  529. return: [0x5A]
  530. - cond: [e, e]
  531. return: [0x5B]
  532. - cond: [e, h|ih]
  533. return: [0x5C]
  534. - cond: [e, l|il]
  535. return: [0x5D]
  536. - cond: [h|ih, a]
  537. return: [0x67]
  538. - cond: [h|ih, b]
  539. return: [0x60]
  540. - cond: [h|ih, c]
  541. return: [0x61]
  542. - cond: [h|ih, d]
  543. return: [0x62]
  544. - cond: [h|ih, e]
  545. return: [0x63]
  546. - cond: [h|ih, h|ih]
  547. return: [0x64]
  548. - cond: [h|ih, l|il]
  549. return: [0x65]
  550. - cond: [l|il, a]
  551. return: [0x6F]
  552. - cond: [l|il, b]
  553. return: [0x68]
  554. - cond: [l|il, c]
  555. return: [0x69]
  556. - cond: [l|il, d]
  557. return: [0x6A]
  558. - cond: [l|il, e]
  559. return: [0x6B]
  560. - cond: [l|il, h|ih]
  561. return: [0x6C]
  562. - cond: [l|il, l|il]
  563. return: [0x6D]
  564. - cond: [a, i]
  565. return: [0xED, 0x57]
  566. - cond: [i, a]
  567. return: [0xED, 0x47]
  568. - cond: [a, r]
  569. return: [0xED, 0x5F]
  570. - cond: [r, a]
  571. return: [0xED, 0x4F]
  572. - cond: [sp, hl|i]
  573. return: [0xF9]
  574. - type: [register, immediate]
  575. cases:
  576. - cond: [a, u8]
  577. return: [0x3E, u8]
  578. - cond: [b, u8]
  579. return: [0x06, u8]
  580. - cond: [c, u8]
  581. return: [0x0E, u8]
  582. - cond: [d, u8]
  583. return: [0x16, u8]
  584. - cond: [e, u8]
  585. return: [0x1E, u8]
  586. - cond: [h|ih, u8]
  587. return: [0x26, u8]
  588. - cond: [l|il, u8]
  589. return: [0x2E, u8]
  590. - cond: [bc, u16]
  591. return: [0x01, u16]
  592. - cond: [de, u16]
  593. return: [0x11, u16]
  594. - cond: [hl|i, u16]
  595. return: [0x21, u16]
  596. - cond: [sp, u16]
  597. return: [0x31, u16]
  598. - type: [register, indirect_hl_or_indexed]
  599. cases:
  600. - cond: [a, _]
  601. return: [0x7E]
  602. - cond: [b, _]
  603. return: [0x46]
  604. - cond: [c, _]
  605. return: [0x4E]
  606. - cond: [d, _]
  607. return: [0x56]
  608. - cond: [e, _]
  609. return: [0x5E]
  610. - cond: [h, _]
  611. return: [0x66]
  612. - cond: [l, _]
  613. return: [0x6E]
  614. - type: [register, indirect]
  615. cases:
  616. - cond: [a, reg.bc]
  617. return: [0x0A]
  618. - cond: [a, reg.de]
  619. return: [0x1A]
  620. - cond: [hl|i, imm]
  621. return: [0x2A, u16]
  622. - cond: [a, imm]
  623. return: [0x3A, u16]
  624. - cond: [bc, imm]
  625. return: [0xED, 0x4B, u16]
  626. - cond: [de, imm]
  627. return: [0xED, 0x5B, u16]
  628. - cond: [sp, imm]
  629. return: [0xED, 0x7B, u16]
  630. - type: [indirect_hl_or_indexed, register]
  631. cases:
  632. - cond: [_, a]
  633. return: [0x77]
  634. - cond: [_, b]
  635. return: [0x70]
  636. - cond: [_, c]
  637. return: [0x71]
  638. - cond: [_, d]
  639. return: [0x72]
  640. - cond: [_, e]
  641. return: [0x73]
  642. - cond: [_, h]
  643. return: [0x74]
  644. - cond: [_, l]
  645. return: [0x75]
  646. - type: [indirect_hl_or_indexed, immediate]
  647. cases:
  648. - cond: [_, u8]
  649. return: [0x36, u8]
  650. - type: [indirect, register]
  651. cases:
  652. - cond: [reg.bc, a]
  653. return: [0x02]
  654. - cond: [reg.de, a]
  655. return: [0x12]
  656. - cond: [imm, hl|i]
  657. return: [0x22, u16]
  658. - cond: [imm, a]
  659. return: [0x32, u16]
  660. - cond: [imm, bc]
  661. return: [0xED, 0x43, u16]
  662. - cond: [imm, de]
  663. return: [0xED, 0x53, u16]
  664. - cond: [imm, sp]
  665. return: [0xED, 0x73, u16]
  666. ldd:
  667. args: no
  668. return: [0xED, 0xA8]
  669. lddr:
  670. args: no
  671. return: [0xED, 0xB8]
  672. ldi:
  673. args: no
  674. return: [0xED, 0xA0]
  675. ldir:
  676. args: no
  677. return: [0xED, 0xB0]
  678. neg:
  679. args: no
  680. return: [0xED, 0x44]
  681. nop:
  682. args: no
  683. return: [0x00]
  684. # or:
  685. # args: yes
  686. # return: TODO
  687. otdr:
  688. args: no
  689. return: [0xED, 0xBB]
  690. otir:
  691. args: no
  692. return: [0xED, 0xB3]
  693. # out:
  694. # args: yes
  695. # return: TODO
  696. outd:
  697. args: no
  698. return: [0xED, 0xAB]
  699. outi:
  700. args: no
  701. return: [0xED, 0xA3]
  702. # pop:
  703. # args: yes
  704. # return: TODO
  705. # push:
  706. # args: yes
  707. # return: TODO
  708. # res:
  709. # args: yes
  710. # return: TODO
  711. # ret:
  712. # args: yes
  713. # return: TODO
  714. reti:
  715. args: no
  716. return: [0xED, 0x4D]
  717. retn:
  718. args: no
  719. return: [0xED, 0x45]
  720. # rl:
  721. # args: yes
  722. # return: TODO
  723. rla:
  724. args: no
  725. return: [0x17]
  726. # rlc:
  727. # args: yes
  728. # return: TODO
  729. rlca:
  730. args: no
  731. return: [0x07]
  732. rld:
  733. args: no
  734. return: [0xED, 0x6F]
  735. # rr:
  736. # args: yes
  737. # return: TODO
  738. rra:
  739. args: no
  740. return: [0x1F]
  741. # rrc:
  742. # args: yes
  743. # return: TODO
  744. rrca:
  745. args: no
  746. return: [0x0F]
  747. # rrd:
  748. # args: yes
  749. # return: TODO
  750. # rst:
  751. # args: yes
  752. # return: TODO
  753. # sbc:
  754. # args: yes
  755. # return: TODO
  756. scf:
  757. args: no
  758. return: [0x37]
  759. # set:
  760. # args: yes
  761. # return: TODO
  762. # sl1:
  763. # args: yes
  764. # return: TODO
  765. # sla:
  766. # args: yes
  767. # return: TODO
  768. # sll:
  769. # args: yes
  770. # return: TODO
  771. # sls:
  772. # args: yes
  773. # return: TODO
  774. # sra:
  775. # args: yes
  776. # return: TODO
  777. # srl:
  778. # args: yes
  779. # return: TODO
  780. # sub:
  781. # args: yes
  782. # return: TODO
  783. # xor:
  784. # args: yes
  785. # return: TODO