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.
 
 
 
 
 

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