z80.txt 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  1. /*
  2. * Copyright (C) 2017 bzt (bztsrc@gitlab)
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  17. *
  18. * @brief Instruction table for Zilog 80 architecture
  19. */
  20. @regs B C D E H L ? A
  21. @reg16 BC DE HL SP IX IY
  22. @conds NZ Z NC C PO PE P M
  23. <A> "a"
  24. <I> "i"
  25. <R> "r"
  26. <Cidx> "(c)"
  27. <r> @regs[r]
  28. <g> "%s'", @regs[g]
  29. <r16> @reg16[d]
  30. <c> @conds[c]
  31. <af> "af"
  32. <afap> "af'"
  33. <sp> "sp"
  34. <spidx> "(sp)"
  35. <n> "%xh", n
  36. <nd> "%d", n
  37. <nidx> "(%xh)", n
  38. <n8> "%xh", n<<3
  39. <hl> "hl"
  40. <hlidx> "(hl)"
  41. <bcidx> "(bc)"
  42. <de> "de"
  43. <deidx> "(de)"
  44. <ix> "ix"
  45. <ixidx> "(ix)"
  46. <ixd> "(ix+%d)", d
  47. <iy> "iy"
  48. <iyidx> "(iy)"
  49. <iyd> "(iy+%d)", d
  50. <labeln> "%xh", n
  51. <labeli> "%lxh", $+i
  52. 01rrrggg LD <r>, <g>
  53. nnnnnnnn00rrr110 LD <r>, <n>
  54. 01rrr110 LD <r>, <hlidx>
  55. dddddddd01rrr11011011101 LD <r>, <ixd>
  56. dddddddd01rrr11011111101 LD <r>, <iyd>
  57. 01110rrr LD <hlidx>, <r>
  58. dddddddd01110rrr11011101 LD <ixd>, <r>
  59. dddddddd01110rrr11111101 LD <iyd>, <r>
  60. nnnnnnnn00110110 LD <hlidx>, <n>
  61. nnnnnnnndddddddd0011011011011101 LD <ixd>, <n>
  62. nnnnnnnndddddddd0011011011111101 LD <iyd>, <n>
  63. 00001010 LD <A>, <bcidx>
  64. 00011010 LD <A>, <deidx>
  65. nnnnnnnnnnnnnnnn00111010 LD <A>, <nidx>
  66. 00000010 LD <bcidx>, <A>
  67. 00010010 LD <deidx>, <A>
  68. nnnnnnnnnnnnnnnn00110010 LD <nidx>, <A>
  69. 0101011111101101 LD <A>, <I>
  70. 0101111111101101 LD <A>, <R>
  71. 0100011111101101 LD <I>, <A>
  72. 0100111111101101 LD <R>, <A>
  73. nnnnnnnnnnnnnnnn00dd0001 LD <r16>, <n>
  74. nnnnnnnnnnnnnnnn0010000111011101 LD <r16>, <n> d=4
  75. nnnnnnnnnnnnnnnn0010000111111101 LD <r16>, <n> d=5
  76. nnnnnnnnnnnnnnnn00101010 LD <r16>, <nidx> d=2
  77. nnnnnnnnnnnnnnnn01dd101111101101 LD <r16>, <nidx>
  78. nnnnnnnnnnnnnnnn0010100111011101 LD <r16>, <nidx> d=4
  79. nnnnnnnnnnnnnnnn0010100111111101 LD <r16>, <nidx> d=5
  80. nnnnnnnnnnnnnnnn00100010 LD <nidx>, <r16> d=2
  81. nnnnnnnnnnnnnnnn01dd0011 LD <nidx>, <r16>
  82. nnnnnnnnnnnnnnnn0010001011011101 LD <nidx>, <r16> d=4
  83. nnnnnnnnnnnnnnnn0010001011111101 LD <nidx>, <r16> d=5
  84. 11111001 LD <sp>, <r16> d=2
  85. 1111100111011101 LD <sp>, <r16> d=4
  86. 1111100111111101 LD <sp>, <r16> d=5
  87. 11dd0101 PUSH <r16>
  88. 1110010111011101 PUSH <r16> d=4
  89. 1110010111111101 PUSH <r16> d=5
  90. 11dd0001 POP <r16>
  91. 1110000111011101 POP <r16> d=4
  92. 1110000111111101 POP <r16> d=5
  93. 11101011 EX <de>, <hl>
  94. 00001000 EX <af>, <afap>
  95. 11011000 EXX
  96. 11100011 EX <spidx>, <r16> d=2
  97. 1110001111011101 EX <spidx>, <r16> d=4
  98. 1110001111111101 EX <spidx>, <r16> d=5
  99. 1010000011101101 LDI
  100. 10110000 LDIR
  101. 1010100011101101 LDD
  102. 1011100011101101 LDDR
  103. 1010000111101101 CPI
  104. 1011000111101101 CPIR
  105. 1010100111101101 CPD
  106. 1011100111101101 CPDR
  107. 10000rrr ADD <A>, <r>
  108. nnnnnnnn11000110 ADD <A>, <n>
  109. 10000110 ADD <A>, <hlidx>
  110. dddddddd1000011011011101 ADD <A>, <ixd>
  111. dddddddd1000011011111101 ADD <A>, <iyd>
  112. 10001rrr ADC <A>, <r>
  113. nnnnnnnn11001110 ADC <A>, <n>
  114. 10001110 ADC <A>, <hlidx>
  115. dddddddd1000111011011101 ADC <A>, <ixd>
  116. dddddddd1000111011111101 ADC <A>, <iyd>
  117. 10010rrr SUB <A>, <r>
  118. nnnnnnnn11010110 SUB <A>, <n>
  119. 10010110 SUB <A>, <hlidx>
  120. dddddddd1001011011011101 SUB <A>, <ixd>
  121. dddddddd1001011011111101 SUB <A>, <iyd>
  122. 10011rrr SBC <A>, <r>
  123. nnnnnnnn11011110 SBC <A>, <n>
  124. 10011110 SBC <A>, <hlidx>
  125. dddddddd1001011111011101 SBC <A>, <ixd>
  126. dddddddd1001011111111101 SBC <A>, <iyd>
  127. 10100rrr AND <A>, <r>
  128. nnnnnnnn11100110 AND <A>, <n>
  129. 10100110 AND <A>, <hlidx>
  130. dddddddd1010011011011101 AND <A>, <ixd>
  131. dddddddd1010011011111101 AND <A>, <iyd>
  132. 10110rrr OR <A>, <r>
  133. nnnnnnnn11110110 OR <A>, <n>
  134. 10110110 OR <A>, <hlidx>
  135. dddddddd1011011011011101 OR <A>, <ixd>
  136. dddddddd1011011011111101 OR <A>, <iyd>
  137. 10101rrr XOR <A>, <r>
  138. nnnnnnnn11101110 XOR <A>, <n>
  139. 10101110 XOR <A>, <hlidx>
  140. dddddddd1010111011011101 XOR <A>, <ixd>
  141. dddddddd1010111011111101 XOR <A>, <iyd>
  142. 10111rrr CP <A>, <r>
  143. nnnnnnnn11111110 CP <A>, <n>
  144. 10111110 CP <A>, <hlidx>
  145. dddddddd1011111011011101 CP <A>, <ixd>
  146. dddddddd1011111011111101 CP <A>, <iyd>
  147. 00rrr100 INC <r>
  148. 00110100 INC <hlidx>
  149. dddddddd0011010011011101 INC <ixd>
  150. dddddddd0011010011111101 INC <iyd>
  151. 00rrr101 DEC <r>
  152. 00110101 DEC <hlidx>
  153. dddddddd0011010111011101 DEC <ixd>
  154. dddddddd0011010111111101 DEC <iyd>
  155. 00100111 DAA
  156. 00101111 CPL
  157. 0100010011101101 NEG
  158. 00111111 CCF
  159. 00110111 SCF
  160. 00000000 NOP
  161. 01110110 HALT
  162. 11110011 DI
  163. 11111011 EI
  164. 010nN11011101101 IM <n>
  165. 00dd1001 ADD <hl>, <r16>
  166. 01dd101011101101 ADC <hl>, <r16>
  167. 00dd0001 SUB <hl>, <r16>
  168. 01dd0010 SBC <hl>, <r16>
  169. 00dd100111011101 ADD <ix>, <r16>
  170. 00dd100111111101 ADD <iy>, <r16>
  171. 00dd0011 INC <r16>
  172. 0010001111011101 INC <ix>
  173. 0010001111111101 INC <iy>
  174. 00dd1011 DEC <r16>
  175. 0010101111011101 DEC <ix>
  176. 0010101111111101 DEC <iy>
  177. 00000111 RLCA
  178. 00010111 RLA
  179. 00001111 RRCA
  180. 00011111 RRA
  181. 00000rrr11001011 RLC <r>
  182. 0000011011001011 RLC <hlidx>
  183. 00000110dddddddd1100101111011101 RLC <ixd>
  184. 00000110dddddddd1100101111111101 RLC <iyd>
  185. 00010rrr11001011 RL <r>
  186. 0001011011001011 RL <hlidx>
  187. 00010110dddddddd1100101111011101 RL ixd>
  188. 00010110dddddddd1100101111111101 RL <iyd>
  189. 00011rrr11001011 RR <r>
  190. 0001111011001011 RR <hlidx>
  191. 00011110dddddddd1100101111011101 RR <ixd>
  192. 00011110dddddddd1100101111111101 RR <iyd>
  193. 00100rrr11001011 SLA <r>
  194. 0010011011001011 SLA <hlidx>
  195. 00100110dddddddd1100101111011101 SLA <ixd>
  196. 00100110dddddddd1100101111111101 SLA <iyd>
  197. 00101rrr11001011 SRA <r>
  198. 0010111011001011 SRA <hlidx>
  199. 00101110dddddddd1100101111011101 SRA <ixd>
  200. 00101110dddddddd1100101111111101 SRA <iyd>
  201. 00110rrr11001011 SRL <r>
  202. 0011011011001011 SRL <hlidx>
  203. 00110110dddddddd1100101111011101 SRL <ixd>
  204. 00110110dddddddd1100101111111101 SRL <iyd>
  205. 0110111111101101 RLD
  206. 0110011111101101 RRD
  207. 01nnnrrr11001011 BIT <nd>, <r>
  208. 01nnn11011001011 BIT <nd>, <hlidx>
  209. 01nnn110dddddddd1100101111011101 BIT <nd>, <ixd>
  210. 01nnn110dddddddd1100101111111101 BIT <nd>, <iyd>
  211. 11nnnrrr11001011 SET <nd>, <r>
  212. 11nnn11011001011 SET <nd>, <hlidx>
  213. 11nnn110dddddddd1100101111011101 SET <nd>, <ixd>
  214. 11nnn110dddddddd1100101111111101 SET <nd>, <iyd>
  215. 10nnnrrr11001011 RES <nd>, <r>
  216. 10nnn11011001011 RES <nd>, <hlidx>
  217. 10nnn110dddddddd1100101111011101 RES <nd>, <ixd>
  218. 10nnn110dddddddd1100101111111101 RES <nd>, <iyd>
  219. nnnnnnnnnnnnnnnn11000011 JP <labeln>
  220. nnnnnnnnnnnnnnnn11ccc010 JP <c>, <labeln>
  221. iiiiiiii00011000 JR <labeli>
  222. iiiiiiii001cc000 JR <c>, <labeli>
  223. 11101001 JP <hlidx>
  224. 1110100111011101 JP <ixidx>
  225. 1110100111111101 JP <iyidx>
  226. iiiiiiii00010000 DJNZ <labeli>
  227. nnnnnnnnnnnnnnnn11001101 CALL <labeln>
  228. nnnnnnnnnnnnnnnn11ccc100 CALL <c>, <labeln>
  229. 11001001 RET
  230. 11ccc000 RET <c>
  231. 0100110111101101 RETI
  232. 0100010111101101 RETN
  233. 11nnn111 RST <n8>
  234. nnnnnnnn11011011 IN <A>, <nidx>
  235. 01rrr00011101101 IN <r>, <Cidx>
  236. 1010001011101101 INI
  237. 1011001011101101 INIR
  238. 1010101011101101 IND
  239. 1011101011101101 INDR
  240. nnnnnnnn11010011 OUT <nidx>, <A>
  241. 01rrr00111101101 OUT <Cidx>, <r>
  242. 1010001111101101 OUTI
  243. 1011001111101101 OTIR
  244. 1010101111101101 OUTD
  245. 1011101111101101 OTDR