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.
 
 
 
 
 

742 lines
17 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. # return: TODO
  243. ccf:
  244. args: no
  245. return: [0x3F]
  246. # cp:
  247. # args: yes
  248. # return: TODO
  249. cpd:
  250. args: no
  251. return: [0xED, 0xA9]
  252. cpdr:
  253. args: no
  254. return: [0xED, 0xB9]
  255. cpi:
  256. args: no
  257. return: [0xED, 0xA1]
  258. cpir:
  259. args: no
  260. return: [0xED, 0xB1]
  261. cpl:
  262. args: no
  263. return: [0x2F]
  264. daa:
  265. args: no
  266. return: [0x27]
  267. # dec:
  268. # args: yes
  269. # return: TODO
  270. di:
  271. args: no
  272. return: [0xF3]
  273. # djnz:
  274. # args: yes
  275. # return: TODO
  276. ei:
  277. args: no
  278. return: [0xFB]
  279. # ex:
  280. # args: yes
  281. # return: TODO
  282. exx:
  283. args: no
  284. return: [0xD9]
  285. halt:
  286. args: no
  287. return: [0x76]
  288. # im:
  289. # args: yes
  290. # return: TODO
  291. # in:
  292. # args: yes
  293. # return: TODO
  294. inc:
  295. args: yes
  296. cases:
  297. - type: [register]
  298. cases:
  299. - cond: [a]
  300. return: [0x3C]
  301. - cond: [b]
  302. return: [0x04]
  303. - cond: [c]
  304. return: [0x0C]
  305. - cond: [d]
  306. return: [0x14]
  307. - cond: [e]
  308. return: [0x1C]
  309. - cond: [h|ih]
  310. return: [0x24]
  311. - cond: [l|il]
  312. return: [0x2C]
  313. - cond: [bc]
  314. return: [0x03]
  315. - cond: [de]
  316. return: [0x13]
  317. - cond: [hl|i]
  318. return: [0x23]
  319. - cond: [sp]
  320. return: [0x33]
  321. - type: [indirect_hl_or_indexed]
  322. cases:
  323. - cond: [_]
  324. return: [0x34]
  325. ind:
  326. args: no
  327. return: [0xED, 0xAA]
  328. indr:
  329. args: no
  330. return: [0xED, 0xBA]
  331. ini:
  332. args: no
  333. return: [0xED, 0xA2]
  334. inir:
  335. args: no
  336. return: [0xED, 0xB2]
  337. # jp:
  338. # args: yes
  339. # return: TODO
  340. # jr:
  341. # args: yes
  342. # return: TODO
  343. ld:
  344. args: yes
  345. cases:
  346. - type: [register, register]
  347. cases:
  348. - cond: [a, a]
  349. return: [0x7F]
  350. - cond: [a, b]
  351. return: [0x78]
  352. - cond: [a, c]
  353. return: [0x79]
  354. - cond: [a, d]
  355. return: [0x7A]
  356. - cond: [a, e]
  357. return: [0x7B]
  358. - cond: [a, h|ih]
  359. return: [0x7C]
  360. - cond: [a, l|il]
  361. return: [0x7D]
  362. - cond: [b, a]
  363. return: [0x47]
  364. - cond: [b, b]
  365. return: [0x40]
  366. - cond: [b, c]
  367. return: [0x41]
  368. - cond: [b, d]
  369. return: [0x42]
  370. - cond: [b, e]
  371. return: [0x43]
  372. - cond: [b, h|ih]
  373. return: [0x44]
  374. - cond: [b, l|il]
  375. return: [0x45]
  376. - cond: [c, a]
  377. return: [0x4F]
  378. - cond: [c, b]
  379. return: [0x48]
  380. - cond: [c, c]
  381. return: [0x49]
  382. - cond: [c, d]
  383. return: [0x4A]
  384. - cond: [c, e]
  385. return: [0x4B]
  386. - cond: [c, h|ih]
  387. return: [0x4C]
  388. - cond: [c, l|il]
  389. return: [0x4D]
  390. - cond: [d, a]
  391. return: [0x57]
  392. - cond: [d, b]
  393. return: [0x50]
  394. - cond: [d, c]
  395. return: [0x51]
  396. - cond: [d, d]
  397. return: [0x52]
  398. - cond: [d, e]
  399. return: [0x53]
  400. - cond: [d, h|ih]
  401. return: [0x54]
  402. - cond: [d, l|il]
  403. return: [0x55]
  404. - cond: [e, a]
  405. return: [0x5F]
  406. - cond: [e, b]
  407. return: [0x58]
  408. - cond: [e, c]
  409. return: [0x59]
  410. - cond: [e, d]
  411. return: [0x5A]
  412. - cond: [e, e]
  413. return: [0x5B]
  414. - cond: [e, h|ih]
  415. return: [0x5C]
  416. - cond: [e, l|il]
  417. return: [0x5D]
  418. - cond: [h|ih, a]
  419. return: [0x67]
  420. - cond: [h|ih, b]
  421. return: [0x60]
  422. - cond: [h|ih, c]
  423. return: [0x61]
  424. - cond: [h|ih, d]
  425. return: [0x62]
  426. - cond: [h|ih, e]
  427. return: [0x63]
  428. - cond: [h|ih, h|ih]
  429. return: [0x64]
  430. - cond: [h|ih, l|il]
  431. return: [0x65]
  432. - cond: [l|il, a]
  433. return: [0x6F]
  434. - cond: [l|il, b]
  435. return: [0x68]
  436. - cond: [l|il, c]
  437. return: [0x69]
  438. - cond: [l|il, d]
  439. return: [0x6A]
  440. - cond: [l|il, e]
  441. return: [0x6B]
  442. - cond: [l|il, h|ih]
  443. return: [0x6C]
  444. - cond: [l|il, l|il]
  445. return: [0x6D]
  446. - cond: [a, i]
  447. return: [0xED, 0x57]
  448. - cond: [i, a]
  449. return: [0xED, 0x47]
  450. - cond: [a, r]
  451. return: [0xED, 0x5F]
  452. - cond: [r, a]
  453. return: [0xED, 0x4F]
  454. - cond: [sp, hl|i]
  455. return: [0xF9]
  456. - type: [register, immediate]
  457. cases:
  458. - cond: [a, u8]
  459. return: [0x3E, u8]
  460. - cond: [b, u8]
  461. return: [0x06, u8]
  462. - cond: [c, u8]
  463. return: [0x0E, u8]
  464. - cond: [d, u8]
  465. return: [0x16, u8]
  466. - cond: [e, u8]
  467. return: [0x1E, u8]
  468. - cond: [h|ih, u8]
  469. return: [0x26, u8]
  470. - cond: [l|il, u8]
  471. return: [0x2E, u8]
  472. - cond: [bc, u16]
  473. return: [0x01, u16]
  474. - cond: [de, u16]
  475. return: [0x11, u16]
  476. - cond: [hl|i, u16]
  477. return: [0x21, u16]
  478. - cond: [sp, u16]
  479. return: [0x31, u16]
  480. - type: [register, indirect_hl_or_indexed]
  481. cases:
  482. - cond: [a, _]
  483. return: [0x7E]
  484. - cond: [b, _]
  485. return: [0x46]
  486. - cond: [c, _]
  487. return: [0x4E]
  488. - cond: [d, _]
  489. return: [0x56]
  490. - cond: [e, _]
  491. return: [0x5E]
  492. - cond: [h, _]
  493. return: [0x66]
  494. - cond: [l, _]
  495. return: [0x6E]
  496. - type: [register, indirect]
  497. cases:
  498. - cond: [a, reg.bc]
  499. return: [0x0A]
  500. - cond: [a, reg.de]
  501. return: [0x1A]
  502. - cond: [hl|i, imm]
  503. return: [0x2A, u16]
  504. - cond: [a, imm]
  505. return: [0x3A, u16]
  506. - cond: [bc, imm]
  507. return: [0xED, 0x4B, u16]
  508. - cond: [de, imm]
  509. return: [0xED, 0x5B, u16]
  510. - cond: [sp, imm]
  511. return: [0xED, 0x7B, u16]
  512. - type: [indirect_hl_or_indexed, register]
  513. cases:
  514. - cond: [_, a]
  515. return: [0x77]
  516. - cond: [_, b]
  517. return: [0x70]
  518. - cond: [_, c]
  519. return: [0x71]
  520. - cond: [_, d]
  521. return: [0x72]
  522. - cond: [_, e]
  523. return: [0x73]
  524. - cond: [_, h]
  525. return: [0x74]
  526. - cond: [_, l]
  527. return: [0x75]
  528. - type: [indirect_hl_or_indexed, immediate]
  529. cases:
  530. - cond: [_, u8]
  531. return: [0x36, u8]
  532. - type: [indirect, register]
  533. cases:
  534. - cond: [reg.bc, a]
  535. return: [0x02]
  536. - cond: [reg.de, a]
  537. return: [0x12]
  538. - cond: [imm, hl|i]
  539. return: [0x22, u16]
  540. - cond: [imm, a]
  541. return: [0x32, u16]
  542. - cond: [imm, bc]
  543. return: [0xED, 0x43, u16]
  544. - cond: [imm, de]
  545. return: [0xED, 0x53, u16]
  546. - cond: [imm, sp]
  547. return: [0xED, 0x73, u16]
  548. ldd:
  549. args: no
  550. return: [0xED, 0xA8]
  551. lddr:
  552. args: no
  553. return: [0xED, 0xB8]
  554. ldi:
  555. args: no
  556. return: [0xED, 0xA0]
  557. ldir:
  558. args: no
  559. return: [0xED, 0xB0]
  560. neg:
  561. args: no
  562. return: [0xED, 0x44]
  563. nop:
  564. args: no
  565. return: [0x00]
  566. # or:
  567. # args: yes
  568. # return: TODO
  569. otdr:
  570. args: no
  571. return: [0xED, 0xBB]
  572. otir:
  573. args: no
  574. return: [0xED, 0xB3]
  575. # out:
  576. # args: yes
  577. # return: TODO
  578. outd:
  579. args: no
  580. return: [0xED, 0xAB]
  581. outi:
  582. args: no
  583. return: [0xED, 0xA3]
  584. # pop:
  585. # args: yes
  586. # return: TODO
  587. # push:
  588. # args: yes
  589. # return: TODO
  590. # res:
  591. # args: yes
  592. # return: TODO
  593. # ret:
  594. # args: yes
  595. # return: TODO
  596. reti:
  597. args: no
  598. return: [0xED, 0x4D]
  599. retn:
  600. args: no
  601. return: [0xED, 0x45]
  602. # rl:
  603. # args: yes
  604. # return: TODO
  605. rla:
  606. args: no
  607. return: [0x17]
  608. # rlc:
  609. # args: yes
  610. # return: TODO
  611. rlca:
  612. args: no
  613. return: [0x07]
  614. rld:
  615. args: no
  616. return: [0xED, 0x6F]
  617. # rr:
  618. # args: yes
  619. # return: TODO
  620. rra:
  621. args: no
  622. return: [0x1F]
  623. # rrc:
  624. # args: yes
  625. # return: TODO
  626. rrca:
  627. args: no
  628. return: [0x0F]
  629. # rrd:
  630. # args: yes
  631. # return: TODO
  632. # rst:
  633. # args: yes
  634. # return: TODO
  635. # sbc:
  636. # args: yes
  637. # return: TODO
  638. scf:
  639. args: no
  640. return: [0x37]
  641. # set:
  642. # args: yes
  643. # return: TODO
  644. # sl1:
  645. # args: yes
  646. # return: TODO
  647. # sla:
  648. # args: yes
  649. # return: TODO
  650. # sll:
  651. # args: yes
  652. # return: TODO
  653. # sls:
  654. # args: yes
  655. # return: TODO
  656. # sra:
  657. # args: yes
  658. # return: TODO
  659. # srl:
  660. # args: yes
  661. # return: TODO
  662. # sub:
  663. # args: yes
  664. # return: TODO
  665. # xor:
  666. # args: yes
  667. # return: TODO