SoftCPU.cpp 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883
  1. /*
  2. * Copyright (c) 2020, Andreas Kling <kling@serenityos.org>
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. *
  8. * 1. Redistributions of source code must retain the above copyright notice, this
  9. * list of conditions and the following disclaimer.
  10. *
  11. * 2. Redistributions in binary form must reproduce the above copyright notice,
  12. * this list of conditions and the following disclaimer in the documentation
  13. * and/or other materials provided with the distribution.
  14. *
  15. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  16. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  17. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  18. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  19. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  20. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  21. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  22. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  23. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  24. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  25. */
  26. #include "SoftCPU.h"
  27. #include "Emulator.h"
  28. #include <AK/Assertions.h>
  29. #include <stdio.h>
  30. #include <string.h>
  31. namespace UserspaceEmulator {
  32. template<typename T>
  33. struct TypeDoubler {
  34. };
  35. template<>
  36. struct TypeDoubler<u8> {
  37. typedef u16 type;
  38. };
  39. template<>
  40. struct TypeDoubler<u16> {
  41. typedef u32 type;
  42. };
  43. template<>
  44. struct TypeDoubler<u32> {
  45. typedef u64 type;
  46. };
  47. template<>
  48. struct TypeDoubler<i8> {
  49. typedef i16 type;
  50. };
  51. template<>
  52. struct TypeDoubler<i16> {
  53. typedef i32 type;
  54. };
  55. template<>
  56. struct TypeDoubler<i32> {
  57. typedef i64 type;
  58. };
  59. SoftCPU::SoftCPU(Emulator& emulator)
  60. : m_emulator(emulator)
  61. {
  62. memset(m_gpr, 0, sizeof(m_gpr));
  63. m_segment[(int)X86::SegmentRegister::CS] = 0x18;
  64. m_segment[(int)X86::SegmentRegister::DS] = 0x20;
  65. m_segment[(int)X86::SegmentRegister::ES] = 0x20;
  66. m_segment[(int)X86::SegmentRegister::SS] = 0x20;
  67. }
  68. void SoftCPU::dump() const
  69. {
  70. printf("eax=%08x ebx=%08x ecx=%08x edx=%08x ", eax(), ebx(), ecx(), edx());
  71. printf("ebp=%08x esp=%08x esi=%08x edi=%08x ", ebp(), esp(), esi(), edi());
  72. printf("o=%u s=%u z=%u a=%u p=%u c=%u\n", of(), sf(), zf(), af(), pf(), cf());
  73. }
  74. u8 SoftCPU::read_memory8(X86::LogicalAddress address)
  75. {
  76. ASSERT(address.selector() == 0x20);
  77. auto value = m_emulator.mmu().read8(address.offset());
  78. printf("\033[36;1mread_memory8: @%08x -> %02x\033[0m\n", address.offset(), value);
  79. return value;
  80. }
  81. u16 SoftCPU::read_memory16(X86::LogicalAddress address)
  82. {
  83. ASSERT(address.selector() == 0x20);
  84. auto value = m_emulator.mmu().read16(address.offset());
  85. printf("\033[36;1mread_memory16: @%08x -> %04x\033[0m\n", address.offset(), value);
  86. return value;
  87. }
  88. u32 SoftCPU::read_memory32(X86::LogicalAddress address)
  89. {
  90. ASSERT(address.selector() == 0x20);
  91. auto value = m_emulator.mmu().read32(address.offset());
  92. printf("\033[36;1mread_memory32: @%08x -> %08x\033[0m\n", address.offset(), value);
  93. return value;
  94. }
  95. void SoftCPU::write_memory8(X86::LogicalAddress address, u8 value)
  96. {
  97. ASSERT(address.selector() == 0x20);
  98. printf("\033[35;1mwrite_memory8: @%08x <- %02x\033[0m\n", address.offset(), value);
  99. m_emulator.mmu().write8(address.offset(), value);
  100. }
  101. void SoftCPU::write_memory16(X86::LogicalAddress address, u16 value)
  102. {
  103. ASSERT(address.selector() == 0x20);
  104. printf("\033[35;1mwrite_memory16: @%08x <- %04x\033[0m\n", address.offset(), value);
  105. m_emulator.mmu().write16(address.offset(), value);
  106. }
  107. void SoftCPU::write_memory32(X86::LogicalAddress address, u32 value)
  108. {
  109. ASSERT(address.selector() == 0x20);
  110. printf("\033[35;1mwrite_memory32: @%08x <- %08x\033[0m\n", address.offset(), value);
  111. m_emulator.mmu().write32(address.offset(), value);
  112. }
  113. void SoftCPU::push32(u32 value)
  114. {
  115. set_esp(esp() - sizeof(value));
  116. write_memory32({ ss(), esp() }, value);
  117. }
  118. u32 SoftCPU::pop32()
  119. {
  120. auto value = read_memory32({ ss(), esp() });
  121. set_esp(esp() + sizeof(value));
  122. return value;
  123. }
  124. template<typename Destination, typename Source>
  125. static typename TypeDoubler<Destination>::type op_xor(SoftCPU& cpu, Destination& dest, const Source& src)
  126. {
  127. auto result = dest ^ src;
  128. cpu.set_zf(dest == 0);
  129. cpu.set_sf(dest & 0x80000000);
  130. // FIXME: set_pf
  131. cpu.set_of(false);
  132. cpu.set_cf(false);
  133. return result;
  134. }
  135. template<typename Destination, typename Source>
  136. static typename TypeDoubler<Destination>::type op_sub(SoftCPU& cpu, Destination& dest, const Source& src)
  137. {
  138. u64 result = (u64)dest - (u64)src;
  139. cpu.set_zf(result == 0);
  140. cpu.set_sf((result >> (X86::TypeTrivia<Destination>::bits - 1) & 1));
  141. cpu.set_af((((result ^ (src ^ dest)) & 0x10) >> 4) & 1);
  142. cpu.set_of((((result ^ dest) & (src ^ dest)) >> (X86::TypeTrivia<Destination>::bits - 1)) & 1);
  143. return result;
  144. }
  145. template<bool update_dest, typename Op>
  146. void SoftCPU::generic_AL_imm8(Op op, const X86::Instruction& insn)
  147. {
  148. auto dest = al();
  149. auto src = insn.imm8();
  150. auto result = op(*this, dest, src);
  151. if (update_dest)
  152. set_al(result);
  153. }
  154. template<bool update_dest, typename Op>
  155. void SoftCPU::generic_AX_imm16(Op op, const X86::Instruction& insn)
  156. {
  157. auto dest = ax();
  158. auto src = insn.imm16();
  159. auto result = op(*this, dest, src);
  160. if (update_dest)
  161. set_ax(result);
  162. }
  163. template<bool update_dest, typename Op>
  164. void SoftCPU::generic_EAX_imm32(Op op, const X86::Instruction& insn)
  165. {
  166. auto dest = eax();
  167. auto src = insn.imm32();
  168. auto result = op(*this, dest, src);
  169. if (update_dest)
  170. set_eax(result);
  171. }
  172. template<bool update_dest, typename Op>
  173. void SoftCPU::generic_RM16_imm16(Op op, const X86::Instruction& insn)
  174. {
  175. auto dest = insn.modrm().read16(*this, insn);
  176. auto src = insn.imm16();
  177. auto result = op(*this, dest, src);
  178. if (update_dest)
  179. insn.modrm().write16(*this, insn, result);
  180. }
  181. template<bool update_dest, typename Op>
  182. void SoftCPU::generic_RM16_imm8(Op op, const X86::Instruction& insn)
  183. {
  184. auto dest = insn.modrm().read16(*this, insn);
  185. auto src = insn.imm8();
  186. auto result = op(*this, dest, src);
  187. if (update_dest)
  188. insn.modrm().write16(*this, insn, result);
  189. }
  190. template<bool update_dest, typename Op>
  191. void SoftCPU::generic_RM16_reg16(Op op, const X86::Instruction& insn)
  192. {
  193. auto dest = insn.modrm().read16(*this, insn);
  194. auto src = gpr16(insn.reg16());
  195. auto result = op(*this, dest, src);
  196. if (update_dest)
  197. insn.modrm().write16(*this, insn, result);
  198. }
  199. template<bool update_dest, typename Op>
  200. void SoftCPU::generic_RM32_imm32(Op op, const X86::Instruction& insn)
  201. {
  202. auto dest = insn.modrm().read32(*this, insn);
  203. auto src = insn.imm32();
  204. auto result = op(*this, dest, src);
  205. if (update_dest)
  206. insn.modrm().write32(*this, insn, result);
  207. }
  208. template<bool update_dest, typename Op>
  209. void SoftCPU::generic_RM32_imm8(Op op, const X86::Instruction& insn)
  210. {
  211. auto dest = insn.modrm().read32(*this, insn);
  212. auto src = insn.imm8();
  213. auto result = op(*this, dest, src);
  214. if (update_dest)
  215. insn.modrm().write32(*this, insn, result);
  216. }
  217. template<bool update_dest, typename Op>
  218. void SoftCPU::generic_RM32_reg32(Op op, const X86::Instruction& insn)
  219. {
  220. auto dest = insn.modrm().read32(*this, insn);
  221. auto src = gpr32(insn.reg32());
  222. auto result = op(*this, dest, src);
  223. if (update_dest)
  224. insn.modrm().write32(*this, insn, result);
  225. }
  226. template<bool update_dest, typename Op>
  227. void SoftCPU::generic_RM8_imm8(Op op, const X86::Instruction& insn)
  228. {
  229. auto dest = insn.modrm().read8(*this, insn);
  230. auto src = insn.imm8();
  231. auto result = op(*this, dest, src);
  232. if (update_dest)
  233. insn.modrm().write8(*this, insn, result);
  234. }
  235. template<bool update_dest, typename Op>
  236. void SoftCPU::generic_RM8_reg8(Op op, const X86::Instruction& insn)
  237. {
  238. auto dest = insn.modrm().read8(*this, insn);
  239. auto src = gpr8(insn.reg8());
  240. auto result = op(*this, dest, src);
  241. if (update_dest)
  242. insn.modrm().write8(*this, insn, result);
  243. }
  244. template<bool update_dest, typename Op>
  245. void SoftCPU::generic_reg16_RM16(Op op, const X86::Instruction& insn)
  246. {
  247. auto dest = gpr16(insn.reg16());
  248. auto src = insn.modrm().read16(*this, insn);
  249. auto result = op(*this, dest, src);
  250. if (update_dest)
  251. gpr16(insn.reg16()) = result;
  252. }
  253. template<bool update_dest, typename Op>
  254. void SoftCPU::generic_reg32_RM32(Op op, const X86::Instruction& insn)
  255. {
  256. auto dest = gpr32(insn.reg32());
  257. auto src = insn.modrm().read32(*this, insn);
  258. auto result = op(*this, dest, src);
  259. if (update_dest)
  260. gpr32(insn.reg32()) = result;
  261. }
  262. template<bool update_dest, typename Op>
  263. void SoftCPU::generic_reg8_RM8(Op op, const X86::Instruction& insn)
  264. {
  265. auto dest = gpr8(insn.reg8());
  266. auto src = insn.modrm().read8(*this, insn);
  267. auto result = op(*this, dest, src);
  268. if (update_dest)
  269. gpr8(insn.reg8()) = result;
  270. }
  271. void SoftCPU::AAA(const X86::Instruction&) { TODO(); }
  272. void SoftCPU::AAD(const X86::Instruction&) { TODO(); }
  273. void SoftCPU::AAM(const X86::Instruction&) { TODO(); }
  274. void SoftCPU::AAS(const X86::Instruction&) { TODO(); }
  275. void SoftCPU::ADC_AL_imm8(const X86::Instruction&) { TODO(); }
  276. void SoftCPU::ADC_AX_imm16(const X86::Instruction&) { TODO(); }
  277. void SoftCPU::ADC_EAX_imm32(const X86::Instruction&) { TODO(); }
  278. void SoftCPU::ADC_RM16_imm16(const X86::Instruction&) { TODO(); }
  279. void SoftCPU::ADC_RM16_imm8(const X86::Instruction&) { TODO(); }
  280. void SoftCPU::ADC_RM16_reg16(const X86::Instruction&) { TODO(); }
  281. void SoftCPU::ADC_RM32_imm32(const X86::Instruction&) { TODO(); }
  282. void SoftCPU::ADC_RM32_imm8(const X86::Instruction&) { TODO(); }
  283. void SoftCPU::ADC_RM32_reg32(const X86::Instruction&) { TODO(); }
  284. void SoftCPU::ADC_RM8_imm8(const X86::Instruction&) { TODO(); }
  285. void SoftCPU::ADC_RM8_reg8(const X86::Instruction&) { TODO(); }
  286. void SoftCPU::ADC_reg16_RM16(const X86::Instruction&) { TODO(); }
  287. void SoftCPU::ADC_reg32_RM32(const X86::Instruction&) { TODO(); }
  288. void SoftCPU::ADC_reg8_RM8(const X86::Instruction&) { TODO(); }
  289. void SoftCPU::ADD_AL_imm8(const X86::Instruction&) { TODO(); }
  290. void SoftCPU::ADD_AX_imm16(const X86::Instruction&) { TODO(); }
  291. void SoftCPU::ADD_EAX_imm32(const X86::Instruction&) { TODO(); }
  292. void SoftCPU::ADD_RM16_imm16(const X86::Instruction&) { TODO(); }
  293. void SoftCPU::ADD_RM16_imm8(const X86::Instruction&) { TODO(); }
  294. void SoftCPU::ADD_RM16_reg16(const X86::Instruction&) { TODO(); }
  295. void SoftCPU::ADD_RM32_imm32(const X86::Instruction&) { TODO(); }
  296. void SoftCPU::ADD_RM32_imm8(const X86::Instruction&) { TODO(); }
  297. void SoftCPU::ADD_RM32_reg32(const X86::Instruction&) { TODO(); }
  298. void SoftCPU::ADD_RM8_imm8(const X86::Instruction&) { TODO(); }
  299. void SoftCPU::ADD_RM8_reg8(const X86::Instruction&) { TODO(); }
  300. void SoftCPU::ADD_reg16_RM16(const X86::Instruction&) { TODO(); }
  301. void SoftCPU::ADD_reg32_RM32(const X86::Instruction&) { TODO(); }
  302. void SoftCPU::ADD_reg8_RM8(const X86::Instruction&) { TODO(); }
  303. void SoftCPU::AND_AL_imm8(const X86::Instruction&) { TODO(); }
  304. void SoftCPU::AND_AX_imm16(const X86::Instruction&) { TODO(); }
  305. void SoftCPU::AND_EAX_imm32(const X86::Instruction&) { TODO(); }
  306. void SoftCPU::AND_RM16_imm16(const X86::Instruction&) { TODO(); }
  307. void SoftCPU::AND_RM16_imm8(const X86::Instruction&) { TODO(); }
  308. void SoftCPU::AND_RM16_reg16(const X86::Instruction&) { TODO(); }
  309. void SoftCPU::AND_RM32_imm32(const X86::Instruction&) { TODO(); }
  310. void SoftCPU::AND_RM32_imm8(const X86::Instruction&) { TODO(); }
  311. void SoftCPU::AND_RM32_reg32(const X86::Instruction&) { TODO(); }
  312. void SoftCPU::AND_RM8_imm8(const X86::Instruction&) { TODO(); }
  313. void SoftCPU::AND_RM8_reg8(const X86::Instruction&) { TODO(); }
  314. void SoftCPU::AND_reg16_RM16(const X86::Instruction&) { TODO(); }
  315. void SoftCPU::AND_reg32_RM32(const X86::Instruction&) { TODO(); }
  316. void SoftCPU::AND_reg8_RM8(const X86::Instruction&) { TODO(); }
  317. void SoftCPU::ARPL(const X86::Instruction&) { TODO(); }
  318. void SoftCPU::BOUND(const X86::Instruction&) { TODO(); }
  319. void SoftCPU::BSF_reg16_RM16(const X86::Instruction&) { TODO(); }
  320. void SoftCPU::BSF_reg32_RM32(const X86::Instruction&) { TODO(); }
  321. void SoftCPU::BSR_reg16_RM16(const X86::Instruction&) { TODO(); }
  322. void SoftCPU::BSR_reg32_RM32(const X86::Instruction&) { TODO(); }
  323. void SoftCPU::BSWAP_reg32(const X86::Instruction&) { TODO(); }
  324. void SoftCPU::BTC_RM16_imm8(const X86::Instruction&) { TODO(); }
  325. void SoftCPU::BTC_RM16_reg16(const X86::Instruction&) { TODO(); }
  326. void SoftCPU::BTC_RM32_imm8(const X86::Instruction&) { TODO(); }
  327. void SoftCPU::BTC_RM32_reg32(const X86::Instruction&) { TODO(); }
  328. void SoftCPU::BTR_RM16_imm8(const X86::Instruction&) { TODO(); }
  329. void SoftCPU::BTR_RM16_reg16(const X86::Instruction&) { TODO(); }
  330. void SoftCPU::BTR_RM32_imm8(const X86::Instruction&) { TODO(); }
  331. void SoftCPU::BTR_RM32_reg32(const X86::Instruction&) { TODO(); }
  332. void SoftCPU::BTS_RM16_imm8(const X86::Instruction&) { TODO(); }
  333. void SoftCPU::BTS_RM16_reg16(const X86::Instruction&) { TODO(); }
  334. void SoftCPU::BTS_RM32_imm8(const X86::Instruction&) { TODO(); }
  335. void SoftCPU::BTS_RM32_reg32(const X86::Instruction&) { TODO(); }
  336. void SoftCPU::BT_RM16_imm8(const X86::Instruction&) { TODO(); }
  337. void SoftCPU::BT_RM16_reg16(const X86::Instruction&) { TODO(); }
  338. void SoftCPU::BT_RM32_imm8(const X86::Instruction&) { TODO(); }
  339. void SoftCPU::BT_RM32_reg32(const X86::Instruction&) { TODO(); }
  340. void SoftCPU::CALL_FAR_mem16(const X86::Instruction&) { TODO(); }
  341. void SoftCPU::CALL_FAR_mem32(const X86::Instruction&) { TODO(); }
  342. void SoftCPU::CALL_RM16(const X86::Instruction&) { TODO(); }
  343. void SoftCPU::CALL_RM32(const X86::Instruction&) { TODO(); }
  344. void SoftCPU::CALL_imm16(const X86::Instruction&) { TODO(); }
  345. void SoftCPU::CALL_imm16_imm16(const X86::Instruction&) { TODO(); }
  346. void SoftCPU::CALL_imm16_imm32(const X86::Instruction&) { TODO(); }
  347. void SoftCPU::CALL_imm32(const X86::Instruction&) { TODO(); }
  348. void SoftCPU::CBW(const X86::Instruction&) { TODO(); }
  349. void SoftCPU::CDQ(const X86::Instruction&) { TODO(); }
  350. void SoftCPU::CLC(const X86::Instruction&) { TODO(); }
  351. void SoftCPU::CLD(const X86::Instruction&) { TODO(); }
  352. void SoftCPU::CLI(const X86::Instruction&) { TODO(); }
  353. void SoftCPU::CLTS(const X86::Instruction&) { TODO(); }
  354. void SoftCPU::CMC(const X86::Instruction&) { TODO(); }
  355. void SoftCPU::CMOVcc_reg16_RM16(const X86::Instruction&) { TODO(); }
  356. void SoftCPU::CMOVcc_reg32_RM32(const X86::Instruction&) { TODO(); }
  357. void SoftCPU::CMPSB(const X86::Instruction&) { TODO(); }
  358. void SoftCPU::CMPSD(const X86::Instruction&) { TODO(); }
  359. void SoftCPU::CMPSW(const X86::Instruction&) { TODO(); }
  360. void SoftCPU::CMPXCHG_RM16_reg16(const X86::Instruction&) { TODO(); }
  361. void SoftCPU::CMPXCHG_RM32_reg32(const X86::Instruction&) { TODO(); }
  362. void SoftCPU::CMPXCHG_RM8_reg8(const X86::Instruction&) { TODO(); }
  363. void SoftCPU::CPUID(const X86::Instruction&) { TODO(); }
  364. void SoftCPU::CWD(const X86::Instruction&) { TODO(); }
  365. void SoftCPU::CWDE(const X86::Instruction&) { TODO(); }
  366. void SoftCPU::DAA(const X86::Instruction&) { TODO(); }
  367. void SoftCPU::DAS(const X86::Instruction&) { TODO(); }
  368. void SoftCPU::DEC_RM16(const X86::Instruction&) { TODO(); }
  369. void SoftCPU::DEC_RM32(const X86::Instruction&) { TODO(); }
  370. void SoftCPU::DEC_RM8(const X86::Instruction&) { TODO(); }
  371. void SoftCPU::DEC_reg16(const X86::Instruction&) { TODO(); }
  372. void SoftCPU::DEC_reg32(const X86::Instruction&) { TODO(); }
  373. void SoftCPU::DIV_RM16(const X86::Instruction&) { TODO(); }
  374. void SoftCPU::DIV_RM32(const X86::Instruction&) { TODO(); }
  375. void SoftCPU::DIV_RM8(const X86::Instruction&) { TODO(); }
  376. void SoftCPU::ENTER16(const X86::Instruction&) { TODO(); }
  377. void SoftCPU::ENTER32(const X86::Instruction&) { TODO(); }
  378. void SoftCPU::ESCAPE(const X86::Instruction&) { TODO(); }
  379. void SoftCPU::HLT(const X86::Instruction&) { TODO(); }
  380. void SoftCPU::IDIV_RM16(const X86::Instruction&) { TODO(); }
  381. void SoftCPU::IDIV_RM32(const X86::Instruction&) { TODO(); }
  382. void SoftCPU::IDIV_RM8(const X86::Instruction&) { TODO(); }
  383. void SoftCPU::IMUL_RM16(const X86::Instruction&) { TODO(); }
  384. void SoftCPU::IMUL_RM32(const X86::Instruction&) { TODO(); }
  385. void SoftCPU::IMUL_RM8(const X86::Instruction&) { TODO(); }
  386. void SoftCPU::IMUL_reg16_RM16(const X86::Instruction&) { TODO(); }
  387. void SoftCPU::IMUL_reg16_RM16_imm16(const X86::Instruction&) { TODO(); }
  388. void SoftCPU::IMUL_reg16_RM16_imm8(const X86::Instruction&) { TODO(); }
  389. void SoftCPU::IMUL_reg32_RM32(const X86::Instruction&) { TODO(); }
  390. void SoftCPU::IMUL_reg32_RM32_imm32(const X86::Instruction&) { TODO(); }
  391. void SoftCPU::IMUL_reg32_RM32_imm8(const X86::Instruction&) { TODO(); }
  392. void SoftCPU::INC_RM16(const X86::Instruction&) { TODO(); }
  393. void SoftCPU::INC_RM32(const X86::Instruction&) { TODO(); }
  394. void SoftCPU::INC_RM8(const X86::Instruction&) { TODO(); }
  395. void SoftCPU::INC_reg16(const X86::Instruction&) { TODO(); }
  396. void SoftCPU::INC_reg32(const X86::Instruction&) { TODO(); }
  397. void SoftCPU::INSB(const X86::Instruction&) { TODO(); }
  398. void SoftCPU::INSD(const X86::Instruction&) { TODO(); }
  399. void SoftCPU::INSW(const X86::Instruction&) { TODO(); }
  400. void SoftCPU::INT3(const X86::Instruction&) { TODO(); }
  401. void SoftCPU::INTO(const X86::Instruction&) { TODO(); }
  402. void SoftCPU::INT_imm8(const X86::Instruction& insn)
  403. {
  404. ASSERT(insn.imm8() == 0x82);
  405. set_eax(m_emulator.virt_syscall(eax(), edx(), ecx(), ebx()));
  406. }
  407. void SoftCPU::INVLPG(const X86::Instruction&) { TODO(); }
  408. void SoftCPU::IN_AL_DX(const X86::Instruction&) { TODO(); }
  409. void SoftCPU::IN_AL_imm8(const X86::Instruction&) { TODO(); }
  410. void SoftCPU::IN_AX_DX(const X86::Instruction&) { TODO(); }
  411. void SoftCPU::IN_AX_imm8(const X86::Instruction&) { TODO(); }
  412. void SoftCPU::IN_EAX_DX(const X86::Instruction&) { TODO(); }
  413. void SoftCPU::IN_EAX_imm8(const X86::Instruction&) { TODO(); }
  414. void SoftCPU::IRET(const X86::Instruction&) { TODO(); }
  415. void SoftCPU::JCXZ_imm8(const X86::Instruction&) { TODO(); }
  416. void SoftCPU::JMP_FAR_mem16(const X86::Instruction&) { TODO(); }
  417. void SoftCPU::JMP_FAR_mem32(const X86::Instruction&) { TODO(); }
  418. void SoftCPU::JMP_RM16(const X86::Instruction&) { TODO(); }
  419. void SoftCPU::JMP_RM32(const X86::Instruction&) { TODO(); }
  420. void SoftCPU::JMP_imm16(const X86::Instruction&) { TODO(); }
  421. void SoftCPU::JMP_imm16_imm16(const X86::Instruction&) { TODO(); }
  422. void SoftCPU::JMP_imm16_imm32(const X86::Instruction&) { TODO(); }
  423. void SoftCPU::JMP_imm32(const X86::Instruction&) { TODO(); }
  424. void SoftCPU::JMP_short_imm8(const X86::Instruction&) { TODO(); }
  425. void SoftCPU::Jcc_NEAR_imm(const X86::Instruction&) { TODO(); }
  426. void SoftCPU::Jcc_imm8(const X86::Instruction&) { TODO(); }
  427. void SoftCPU::LAHF(const X86::Instruction&) { TODO(); }
  428. void SoftCPU::LAR_reg16_RM16(const X86::Instruction&) { TODO(); }
  429. void SoftCPU::LAR_reg32_RM32(const X86::Instruction&) { TODO(); }
  430. void SoftCPU::LDS_reg16_mem16(const X86::Instruction&) { TODO(); }
  431. void SoftCPU::LDS_reg32_mem32(const X86::Instruction&) { TODO(); }
  432. void SoftCPU::LEAVE16(const X86::Instruction&) { TODO(); }
  433. void SoftCPU::LEAVE32(const X86::Instruction&) { TODO(); }
  434. void SoftCPU::LEA_reg16_mem16(const X86::Instruction&) { TODO(); }
  435. void SoftCPU::LEA_reg32_mem32(const X86::Instruction&) { TODO(); }
  436. void SoftCPU::LES_reg16_mem16(const X86::Instruction&) { TODO(); }
  437. void SoftCPU::LES_reg32_mem32(const X86::Instruction&) { TODO(); }
  438. void SoftCPU::LFS_reg16_mem16(const X86::Instruction&) { TODO(); }
  439. void SoftCPU::LFS_reg32_mem32(const X86::Instruction&) { TODO(); }
  440. void SoftCPU::LGDT(const X86::Instruction&) { TODO(); }
  441. void SoftCPU::LGS_reg16_mem16(const X86::Instruction&) { TODO(); }
  442. void SoftCPU::LGS_reg32_mem32(const X86::Instruction&) { TODO(); }
  443. void SoftCPU::LIDT(const X86::Instruction&) { TODO(); }
  444. void SoftCPU::LLDT_RM16(const X86::Instruction&) { TODO(); }
  445. void SoftCPU::LMSW_RM16(const X86::Instruction&) { TODO(); }
  446. void SoftCPU::LODSB(const X86::Instruction&) { TODO(); }
  447. void SoftCPU::LODSD(const X86::Instruction&) { TODO(); }
  448. void SoftCPU::LODSW(const X86::Instruction&) { TODO(); }
  449. void SoftCPU::LOOPNZ_imm8(const X86::Instruction&) { TODO(); }
  450. void SoftCPU::LOOPZ_imm8(const X86::Instruction&) { TODO(); }
  451. void SoftCPU::LOOP_imm8(const X86::Instruction&) { TODO(); }
  452. void SoftCPU::LSL_reg16_RM16(const X86::Instruction&) { TODO(); }
  453. void SoftCPU::LSL_reg32_RM32(const X86::Instruction&) { TODO(); }
  454. void SoftCPU::LSS_reg16_mem16(const X86::Instruction&) { TODO(); }
  455. void SoftCPU::LSS_reg32_mem32(const X86::Instruction&) { TODO(); }
  456. void SoftCPU::LTR_RM16(const X86::Instruction&) { TODO(); }
  457. void SoftCPU::MOVSB(const X86::Instruction&) { TODO(); }
  458. void SoftCPU::MOVSD(const X86::Instruction&) { TODO(); }
  459. void SoftCPU::MOVSW(const X86::Instruction&) { TODO(); }
  460. void SoftCPU::MOVSX_reg16_RM8(const X86::Instruction&) { TODO(); }
  461. void SoftCPU::MOVSX_reg32_RM16(const X86::Instruction&) { TODO(); }
  462. void SoftCPU::MOVSX_reg32_RM8(const X86::Instruction&) { TODO(); }
  463. void SoftCPU::MOVZX_reg16_RM8(const X86::Instruction&) { TODO(); }
  464. void SoftCPU::MOVZX_reg32_RM16(const X86::Instruction&) { TODO(); }
  465. void SoftCPU::MOVZX_reg32_RM8(const X86::Instruction&) { TODO(); }
  466. void SoftCPU::MOV_AL_moff8(const X86::Instruction&) { TODO(); }
  467. void SoftCPU::MOV_AX_moff16(const X86::Instruction&) { TODO(); }
  468. void SoftCPU::MOV_CR_reg32(const X86::Instruction&) { TODO(); }
  469. void SoftCPU::MOV_DR_reg32(const X86::Instruction&) { TODO(); }
  470. void SoftCPU::MOV_EAX_moff32(const X86::Instruction&) { TODO(); }
  471. void SoftCPU::MOV_RM16_imm16(const X86::Instruction& insn)
  472. {
  473. insn.modrm().write16(*this, insn, insn.imm16());
  474. }
  475. void SoftCPU::MOV_RM16_reg16(const X86::Instruction& insn)
  476. {
  477. insn.modrm().write16(*this, insn, gpr16(insn.reg16()));
  478. }
  479. void SoftCPU::MOV_RM16_seg(const X86::Instruction&) { TODO(); }
  480. void SoftCPU::MOV_RM32_imm32(const X86::Instruction& insn)
  481. {
  482. gpr32(insn.reg32()) = insn.imm32();
  483. }
  484. void SoftCPU::MOV_RM32_reg32(const X86::Instruction& insn)
  485. {
  486. insn.modrm().write32(*this, insn, gpr32(insn.reg32()));
  487. }
  488. void SoftCPU::MOV_RM8_imm8(const X86::Instruction& insn)
  489. {
  490. insn.modrm().write8(*this, insn, insn.imm8());
  491. }
  492. void SoftCPU::MOV_RM8_reg8(const X86::Instruction& insn)
  493. {
  494. insn.modrm().write8(*this, insn, insn.modrm().read8(*this, insn));
  495. }
  496. void SoftCPU::MOV_moff16_AX(const X86::Instruction&) { TODO(); }
  497. void SoftCPU::MOV_moff32_EAX(const X86::Instruction&) { TODO(); }
  498. void SoftCPU::MOV_moff8_AL(const X86::Instruction&) { TODO(); }
  499. void SoftCPU::MOV_reg16_RM16(const X86::Instruction& insn)
  500. {
  501. gpr16(insn.reg16()) = insn.modrm().read16(*this, insn);
  502. }
  503. void SoftCPU::MOV_reg16_imm16(const X86::Instruction& insn)
  504. {
  505. gpr16(insn.reg16()) = insn.imm16();
  506. }
  507. void SoftCPU::MOV_reg32_CR(const X86::Instruction&) { TODO(); }
  508. void SoftCPU::MOV_reg32_DR(const X86::Instruction&) { TODO(); }
  509. void SoftCPU::MOV_reg32_RM32(const X86::Instruction& insn)
  510. {
  511. gpr32(insn.reg32()) = insn.modrm().read32(*this, insn);
  512. }
  513. void SoftCPU::MOV_reg32_imm32(const X86::Instruction& insn)
  514. {
  515. gpr32(insn.reg32()) = insn.imm32();
  516. }
  517. void SoftCPU::MOV_reg8_RM8(const X86::Instruction& insn)
  518. {
  519. gpr8(insn.reg8()) = insn.modrm().read8(*this, insn);
  520. }
  521. void SoftCPU::MOV_reg8_imm8(const X86::Instruction& insn)
  522. {
  523. gpr8(insn.reg8()) = insn.imm8();
  524. }
  525. void SoftCPU::MOV_seg_RM16(const X86::Instruction&) { TODO(); }
  526. void SoftCPU::MOV_seg_RM32(const X86::Instruction&) { TODO(); }
  527. void SoftCPU::MUL_RM16(const X86::Instruction&) { TODO(); }
  528. void SoftCPU::MUL_RM32(const X86::Instruction&) { TODO(); }
  529. void SoftCPU::MUL_RM8(const X86::Instruction&) { TODO(); }
  530. void SoftCPU::NEG_RM16(const X86::Instruction&) { TODO(); }
  531. void SoftCPU::NEG_RM32(const X86::Instruction&) { TODO(); }
  532. void SoftCPU::NEG_RM8(const X86::Instruction&) { TODO(); }
  533. void SoftCPU::NOP(const X86::Instruction&) { TODO(); }
  534. void SoftCPU::NOT_RM16(const X86::Instruction&) { TODO(); }
  535. void SoftCPU::NOT_RM32(const X86::Instruction&) { TODO(); }
  536. void SoftCPU::NOT_RM8(const X86::Instruction&) { TODO(); }
  537. void SoftCPU::OR_AL_imm8(const X86::Instruction&) { TODO(); }
  538. void SoftCPU::OR_AX_imm16(const X86::Instruction&) { TODO(); }
  539. void SoftCPU::OR_EAX_imm32(const X86::Instruction&) { TODO(); }
  540. void SoftCPU::OR_RM16_imm16(const X86::Instruction&) { TODO(); }
  541. void SoftCPU::OR_RM16_imm8(const X86::Instruction&) { TODO(); }
  542. void SoftCPU::OR_RM16_reg16(const X86::Instruction&) { TODO(); }
  543. void SoftCPU::OR_RM32_imm32(const X86::Instruction&) { TODO(); }
  544. void SoftCPU::OR_RM32_imm8(const X86::Instruction&) { TODO(); }
  545. void SoftCPU::OR_RM32_reg32(const X86::Instruction&) { TODO(); }
  546. void SoftCPU::OR_RM8_imm8(const X86::Instruction&) { TODO(); }
  547. void SoftCPU::OR_RM8_reg8(const X86::Instruction&) { TODO(); }
  548. void SoftCPU::OR_reg16_RM16(const X86::Instruction&) { TODO(); }
  549. void SoftCPU::OR_reg32_RM32(const X86::Instruction&) { TODO(); }
  550. void SoftCPU::OR_reg8_RM8(const X86::Instruction&) { TODO(); }
  551. void SoftCPU::OUTSB(const X86::Instruction&) { TODO(); }
  552. void SoftCPU::OUTSD(const X86::Instruction&) { TODO(); }
  553. void SoftCPU::OUTSW(const X86::Instruction&) { TODO(); }
  554. void SoftCPU::OUT_DX_AL(const X86::Instruction&) { TODO(); }
  555. void SoftCPU::OUT_DX_AX(const X86::Instruction&) { TODO(); }
  556. void SoftCPU::OUT_DX_EAX(const X86::Instruction&) { TODO(); }
  557. void SoftCPU::OUT_imm8_AL(const X86::Instruction&) { TODO(); }
  558. void SoftCPU::OUT_imm8_AX(const X86::Instruction&) { TODO(); }
  559. void SoftCPU::OUT_imm8_EAX(const X86::Instruction&) { TODO(); }
  560. void SoftCPU::PADDB_mm1_mm2m64(const X86::Instruction&) { TODO(); }
  561. void SoftCPU::PADDW_mm1_mm2m64(const X86::Instruction&) { TODO(); }
  562. void SoftCPU::PADDD_mm1_mm2m64(const X86::Instruction&) { TODO(); }
  563. void SoftCPU::POPA(const X86::Instruction&) { TODO(); }
  564. void SoftCPU::POPAD(const X86::Instruction&) { TODO(); }
  565. void SoftCPU::POPF(const X86::Instruction&) { TODO(); }
  566. void SoftCPU::POPFD(const X86::Instruction&) { TODO(); }
  567. void SoftCPU::POP_DS(const X86::Instruction&) { TODO(); }
  568. void SoftCPU::POP_ES(const X86::Instruction&) { TODO(); }
  569. void SoftCPU::POP_FS(const X86::Instruction&) { TODO(); }
  570. void SoftCPU::POP_GS(const X86::Instruction&) { TODO(); }
  571. void SoftCPU::POP_RM16(const X86::Instruction&) { TODO(); }
  572. void SoftCPU::POP_RM32(const X86::Instruction&) { TODO(); }
  573. void SoftCPU::POP_SS(const X86::Instruction&) { TODO(); }
  574. void SoftCPU::POP_reg16(const X86::Instruction&) { TODO(); }
  575. void SoftCPU::POP_reg32(const X86::Instruction& insn)
  576. {
  577. gpr32(insn.reg32()) = pop32();
  578. }
  579. void SoftCPU::PUSHA(const X86::Instruction&) { TODO(); }
  580. void SoftCPU::PUSHAD(const X86::Instruction&) { TODO(); }
  581. void SoftCPU::PUSHF(const X86::Instruction&) { TODO(); }
  582. void SoftCPU::PUSHFD(const X86::Instruction&) { TODO(); }
  583. void SoftCPU::PUSH_CS(const X86::Instruction&) { TODO(); }
  584. void SoftCPU::PUSH_DS(const X86::Instruction&) { TODO(); }
  585. void SoftCPU::PUSH_ES(const X86::Instruction&) { TODO(); }
  586. void SoftCPU::PUSH_FS(const X86::Instruction&) { TODO(); }
  587. void SoftCPU::PUSH_GS(const X86::Instruction&) { TODO(); }
  588. void SoftCPU::PUSH_RM16(const X86::Instruction&) { TODO(); }
  589. void SoftCPU::PUSH_RM32(const X86::Instruction&) { TODO(); }
  590. void SoftCPU::PUSH_SP_8086_80186(const X86::Instruction&) { TODO(); }
  591. void SoftCPU::PUSH_SS(const X86::Instruction&) { TODO(); }
  592. void SoftCPU::PUSH_imm16(const X86::Instruction&) { TODO(); }
  593. void SoftCPU::PUSH_imm32(const X86::Instruction&) { TODO(); }
  594. void SoftCPU::PUSH_imm8(const X86::Instruction&) { TODO(); }
  595. void SoftCPU::PUSH_reg16(const X86::Instruction&) { TODO(); }
  596. void SoftCPU::PUSH_reg32(const X86::Instruction& insn)
  597. {
  598. push32(gpr32(insn.reg32()));
  599. }
  600. void SoftCPU::RCL_RM16_1(const X86::Instruction&) { TODO(); }
  601. void SoftCPU::RCL_RM16_CL(const X86::Instruction&) { TODO(); }
  602. void SoftCPU::RCL_RM16_imm8(const X86::Instruction&) { TODO(); }
  603. void SoftCPU::RCL_RM32_1(const X86::Instruction&) { TODO(); }
  604. void SoftCPU::RCL_RM32_CL(const X86::Instruction&) { TODO(); }
  605. void SoftCPU::RCL_RM32_imm8(const X86::Instruction&) { TODO(); }
  606. void SoftCPU::RCL_RM8_1(const X86::Instruction&) { TODO(); }
  607. void SoftCPU::RCL_RM8_CL(const X86::Instruction&) { TODO(); }
  608. void SoftCPU::RCL_RM8_imm8(const X86::Instruction&) { TODO(); }
  609. void SoftCPU::RCR_RM16_1(const X86::Instruction&) { TODO(); }
  610. void SoftCPU::RCR_RM16_CL(const X86::Instruction&) { TODO(); }
  611. void SoftCPU::RCR_RM16_imm8(const X86::Instruction&) { TODO(); }
  612. void SoftCPU::RCR_RM32_1(const X86::Instruction&) { TODO(); }
  613. void SoftCPU::RCR_RM32_CL(const X86::Instruction&) { TODO(); }
  614. void SoftCPU::RCR_RM32_imm8(const X86::Instruction&) { TODO(); }
  615. void SoftCPU::RCR_RM8_1(const X86::Instruction&) { TODO(); }
  616. void SoftCPU::RCR_RM8_CL(const X86::Instruction&) { TODO(); }
  617. void SoftCPU::RCR_RM8_imm8(const X86::Instruction&) { TODO(); }
  618. void SoftCPU::RDTSC(const X86::Instruction&) { TODO(); }
  619. void SoftCPU::RET(const X86::Instruction&) { TODO(); }
  620. void SoftCPU::RETF(const X86::Instruction&) { TODO(); }
  621. void SoftCPU::RETF_imm16(const X86::Instruction&) { TODO(); }
  622. void SoftCPU::RET_imm16(const X86::Instruction&) { TODO(); }
  623. void SoftCPU::ROL_RM16_1(const X86::Instruction&) { TODO(); }
  624. void SoftCPU::ROL_RM16_CL(const X86::Instruction&) { TODO(); }
  625. void SoftCPU::ROL_RM16_imm8(const X86::Instruction&) { TODO(); }
  626. void SoftCPU::ROL_RM32_1(const X86::Instruction&) { TODO(); }
  627. void SoftCPU::ROL_RM32_CL(const X86::Instruction&) { TODO(); }
  628. void SoftCPU::ROL_RM32_imm8(const X86::Instruction&) { TODO(); }
  629. void SoftCPU::ROL_RM8_1(const X86::Instruction&) { TODO(); }
  630. void SoftCPU::ROL_RM8_CL(const X86::Instruction&) { TODO(); }
  631. void SoftCPU::ROL_RM8_imm8(const X86::Instruction&) { TODO(); }
  632. void SoftCPU::ROR_RM16_1(const X86::Instruction&) { TODO(); }
  633. void SoftCPU::ROR_RM16_CL(const X86::Instruction&) { TODO(); }
  634. void SoftCPU::ROR_RM16_imm8(const X86::Instruction&) { TODO(); }
  635. void SoftCPU::ROR_RM32_1(const X86::Instruction&) { TODO(); }
  636. void SoftCPU::ROR_RM32_CL(const X86::Instruction&) { TODO(); }
  637. void SoftCPU::ROR_RM32_imm8(const X86::Instruction&) { TODO(); }
  638. void SoftCPU::ROR_RM8_1(const X86::Instruction&) { TODO(); }
  639. void SoftCPU::ROR_RM8_CL(const X86::Instruction&) { TODO(); }
  640. void SoftCPU::ROR_RM8_imm8(const X86::Instruction&) { TODO(); }
  641. void SoftCPU::SAHF(const X86::Instruction&) { TODO(); }
  642. void SoftCPU::SALC(const X86::Instruction&) { TODO(); }
  643. template<typename T>
  644. T SoftCPU::sar_impl(T data, u8 steps)
  645. {
  646. if (steps == 0)
  647. return data;
  648. u32 result = 0;
  649. u32 new_flags = 0;
  650. asm("sarl %%cl, %%eax\n"
  651. "mov %%eax, %%ebx\n"
  652. "pushf\n"
  653. "pop %%eax\n"
  654. : "=a"(new_flags), "=b"(result)
  655. : "a"(data), "c"(steps));
  656. set_flags_oszapc(new_flags);
  657. return result;
  658. }
  659. void SoftCPU::SAR_RM16_1(const X86::Instruction& insn)
  660. {
  661. auto data = insn.modrm().read16(*this, insn);
  662. insn.modrm().write16(*this, insn, sar_impl(data, 1));
  663. }
  664. void SoftCPU::SAR_RM16_CL(const X86::Instruction& insn)
  665. {
  666. auto data = insn.modrm().read16(*this, insn);
  667. insn.modrm().write16(*this, insn, sar_impl(data, cl()));
  668. }
  669. void SoftCPU::SAR_RM16_imm8(const X86::Instruction& insn)
  670. {
  671. auto data = insn.modrm().read16(*this, insn);
  672. insn.modrm().write16(*this, insn, sar_impl(data, insn.imm8()));
  673. }
  674. void SoftCPU::SAR_RM32_1(const X86::Instruction& insn)
  675. {
  676. auto data = insn.modrm().read32(*this, insn);
  677. insn.modrm().write32(*this, insn, sar_impl(data, 1));
  678. }
  679. void SoftCPU::SAR_RM32_CL(const X86::Instruction& insn)
  680. {
  681. auto data = insn.modrm().read32(*this, insn);
  682. insn.modrm().write32(*this, insn, sar_impl(data, cl()));
  683. }
  684. void SoftCPU::SAR_RM32_imm8(const X86::Instruction& insn)
  685. {
  686. auto data = insn.modrm().read32(*this, insn);
  687. insn.modrm().write32(*this, insn, sar_impl(data, insn.imm8()));
  688. }
  689. void SoftCPU::SAR_RM8_1(const X86::Instruction& insn)
  690. {
  691. auto data = insn.modrm().read8(*this, insn);
  692. insn.modrm().write8(*this, insn, sar_impl(data, 1));
  693. }
  694. void SoftCPU::SAR_RM8_CL(const X86::Instruction& insn)
  695. {
  696. auto data = insn.modrm().read8(*this, insn);
  697. insn.modrm().write8(*this, insn, sar_impl(data, cl()));
  698. }
  699. void SoftCPU::SAR_RM8_imm8(const X86::Instruction& insn)
  700. {
  701. auto data = insn.modrm().read8(*this, insn);
  702. insn.modrm().write8(*this, insn, sar_impl(data, insn.imm8()));
  703. }
  704. void SoftCPU::SBB_AL_imm8(const X86::Instruction&) { TODO(); }
  705. void SoftCPU::SBB_AX_imm16(const X86::Instruction&) { TODO(); }
  706. void SoftCPU::SBB_EAX_imm32(const X86::Instruction&) { TODO(); }
  707. void SoftCPU::SBB_RM16_imm16(const X86::Instruction&) { TODO(); }
  708. void SoftCPU::SBB_RM16_imm8(const X86::Instruction&) { TODO(); }
  709. void SoftCPU::SBB_RM16_reg16(const X86::Instruction&) { TODO(); }
  710. void SoftCPU::SBB_RM32_imm32(const X86::Instruction&) { TODO(); }
  711. void SoftCPU::SBB_RM32_imm8(const X86::Instruction&) { TODO(); }
  712. void SoftCPU::SBB_RM32_reg32(const X86::Instruction&) { TODO(); }
  713. void SoftCPU::SBB_RM8_imm8(const X86::Instruction&) { TODO(); }
  714. void SoftCPU::SBB_RM8_reg8(const X86::Instruction&) { TODO(); }
  715. void SoftCPU::SBB_reg16_RM16(const X86::Instruction&) { TODO(); }
  716. void SoftCPU::SBB_reg32_RM32(const X86::Instruction&) { TODO(); }
  717. void SoftCPU::SBB_reg8_RM8(const X86::Instruction&) { TODO(); }
  718. void SoftCPU::SCASB(const X86::Instruction&) { TODO(); }
  719. void SoftCPU::SCASD(const X86::Instruction&) { TODO(); }
  720. void SoftCPU::SCASW(const X86::Instruction&) { TODO(); }
  721. void SoftCPU::SETcc_RM8(const X86::Instruction&) { TODO(); }
  722. void SoftCPU::SGDT(const X86::Instruction&) { TODO(); }
  723. void SoftCPU::SHLD_RM16_reg16_CL(const X86::Instruction&) { TODO(); }
  724. void SoftCPU::SHLD_RM16_reg16_imm8(const X86::Instruction&) { TODO(); }
  725. void SoftCPU::SHLD_RM32_reg32_CL(const X86::Instruction&) { TODO(); }
  726. void SoftCPU::SHLD_RM32_reg32_imm8(const X86::Instruction&) { TODO(); }
  727. void SoftCPU::SHL_RM16_1(const X86::Instruction&) { TODO(); }
  728. void SoftCPU::SHL_RM16_CL(const X86::Instruction&) { TODO(); }
  729. void SoftCPU::SHL_RM16_imm8(const X86::Instruction&) { TODO(); }
  730. void SoftCPU::SHL_RM32_1(const X86::Instruction&) { TODO(); }
  731. void SoftCPU::SHL_RM32_CL(const X86::Instruction&) { TODO(); }
  732. void SoftCPU::SHL_RM32_imm8(const X86::Instruction&) { TODO(); }
  733. void SoftCPU::SHL_RM8_1(const X86::Instruction&) { TODO(); }
  734. void SoftCPU::SHL_RM8_CL(const X86::Instruction&) { TODO(); }
  735. void SoftCPU::SHL_RM8_imm8(const X86::Instruction&) { TODO(); }
  736. void SoftCPU::SHRD_RM16_reg16_CL(const X86::Instruction&) { TODO(); }
  737. void SoftCPU::SHRD_RM16_reg16_imm8(const X86::Instruction&) { TODO(); }
  738. void SoftCPU::SHRD_RM32_reg32_CL(const X86::Instruction&) { TODO(); }
  739. void SoftCPU::SHRD_RM32_reg32_imm8(const X86::Instruction&) { TODO(); }
  740. void SoftCPU::SHR_RM16_1(const X86::Instruction&) { TODO(); }
  741. void SoftCPU::SHR_RM16_CL(const X86::Instruction&) { TODO(); }
  742. void SoftCPU::SHR_RM16_imm8(const X86::Instruction&) { TODO(); }
  743. void SoftCPU::SHR_RM32_1(const X86::Instruction&) { TODO(); }
  744. void SoftCPU::SHR_RM32_CL(const X86::Instruction&) { TODO(); }
  745. void SoftCPU::SHR_RM32_imm8(const X86::Instruction&) { TODO(); }
  746. void SoftCPU::SHR_RM8_1(const X86::Instruction&) { TODO(); }
  747. void SoftCPU::SHR_RM8_CL(const X86::Instruction&) { TODO(); }
  748. void SoftCPU::SHR_RM8_imm8(const X86::Instruction&) { TODO(); }
  749. void SoftCPU::SIDT(const X86::Instruction&) { TODO(); }
  750. void SoftCPU::SLDT_RM16(const X86::Instruction&) { TODO(); }
  751. void SoftCPU::SMSW_RM16(const X86::Instruction&) { TODO(); }
  752. void SoftCPU::STC(const X86::Instruction&) { TODO(); }
  753. void SoftCPU::STD(const X86::Instruction&) { TODO(); }
  754. void SoftCPU::STI(const X86::Instruction&) { TODO(); }
  755. void SoftCPU::STOSB(const X86::Instruction&) { TODO(); }
  756. void SoftCPU::STOSD(const X86::Instruction&) { TODO(); }
  757. void SoftCPU::STOSW(const X86::Instruction&) { TODO(); }
  758. void SoftCPU::STR_RM16(const X86::Instruction&) { TODO(); }
  759. void SoftCPU::TEST_AL_imm8(const X86::Instruction&) { TODO(); }
  760. void SoftCPU::TEST_AX_imm16(const X86::Instruction&) { TODO(); }
  761. void SoftCPU::TEST_EAX_imm32(const X86::Instruction&) { TODO(); }
  762. void SoftCPU::TEST_RM16_imm16(const X86::Instruction&) { TODO(); }
  763. void SoftCPU::TEST_RM16_reg16(const X86::Instruction&) { TODO(); }
  764. void SoftCPU::TEST_RM32_imm32(const X86::Instruction&) { TODO(); }
  765. void SoftCPU::TEST_RM32_reg32(const X86::Instruction&) { TODO(); }
  766. void SoftCPU::TEST_RM8_imm8(const X86::Instruction&) { TODO(); }
  767. void SoftCPU::TEST_RM8_reg8(const X86::Instruction&) { TODO(); }
  768. void SoftCPU::UD0(const X86::Instruction&) { TODO(); }
  769. void SoftCPU::UD1(const X86::Instruction&) { TODO(); }
  770. void SoftCPU::UD2(const X86::Instruction&) { TODO(); }
  771. void SoftCPU::VERR_RM16(const X86::Instruction&) { TODO(); }
  772. void SoftCPU::VERW_RM16(const X86::Instruction&) { TODO(); }
  773. void SoftCPU::WAIT(const X86::Instruction&) { TODO(); }
  774. void SoftCPU::WBINVD(const X86::Instruction&) { TODO(); }
  775. void SoftCPU::XADD_RM16_reg16(const X86::Instruction&) { TODO(); }
  776. void SoftCPU::XADD_RM32_reg32(const X86::Instruction&) { TODO(); }
  777. void SoftCPU::XADD_RM8_reg8(const X86::Instruction&) { TODO(); }
  778. void SoftCPU::XCHG_AX_reg16(const X86::Instruction&) { TODO(); }
  779. void SoftCPU::XCHG_EAX_reg32(const X86::Instruction&) { TODO(); }
  780. void SoftCPU::XCHG_reg16_RM16(const X86::Instruction&) { TODO(); }
  781. void SoftCPU::XCHG_reg32_RM32(const X86::Instruction&) { TODO(); }
  782. void SoftCPU::XCHG_reg8_RM8(const X86::Instruction&) { TODO(); }
  783. void SoftCPU::XLAT(const X86::Instruction&) { TODO(); }
  784. #define DEFINE_GENERIC_INSN_HANDLERS(mnemonic, op, update_dest) \
  785. void SoftCPU::mnemonic##_AL_imm8(const X86::Instruction& insn) { generic_AL_imm8<update_dest>(op<u8, u8>, insn); } \
  786. void SoftCPU::mnemonic##_AX_imm16(const X86::Instruction& insn) { generic_AX_imm16<update_dest>(op<u16, u16>, insn); } \
  787. void SoftCPU::mnemonic##_EAX_imm32(const X86::Instruction& insn) { generic_EAX_imm32<update_dest>(op<u32, u32>, insn); } \
  788. void SoftCPU::mnemonic##_RM16_imm16(const X86::Instruction& insn) { generic_RM16_imm16<update_dest>(op<u16, u16>, insn); } \
  789. void SoftCPU::mnemonic##_RM16_imm8(const X86::Instruction& insn) { generic_RM16_imm8<update_dest>(op<u16, u8>, insn); } \
  790. void SoftCPU::mnemonic##_RM16_reg16(const X86::Instruction& insn) { generic_RM16_reg16<update_dest>(op<u16, u16>, insn); } \
  791. void SoftCPU::mnemonic##_RM32_imm32(const X86::Instruction& insn) { generic_RM32_imm32<update_dest>(op<u32, u32>, insn); } \
  792. void SoftCPU::mnemonic##_RM32_imm8(const X86::Instruction& insn) { generic_RM32_imm8<update_dest>(op<u32, u8>, insn); } \
  793. void SoftCPU::mnemonic##_RM32_reg32(const X86::Instruction& insn) { generic_RM32_reg32<update_dest>(op<u32, u32>, insn); } \
  794. void SoftCPU::mnemonic##_RM8_imm8(const X86::Instruction& insn) { generic_RM8_imm8<update_dest>(op<u8, u8>, insn); } \
  795. void SoftCPU::mnemonic##_RM8_reg8(const X86::Instruction& insn) { generic_RM8_reg8<update_dest>(op<u8, u8>, insn); } \
  796. void SoftCPU::mnemonic##_reg16_RM16(const X86::Instruction& insn) { generic_reg16_RM16<update_dest>(op<u16, u16>, insn); } \
  797. void SoftCPU::mnemonic##_reg32_RM32(const X86::Instruction& insn) { generic_reg32_RM32<update_dest>(op<u32, u32>, insn); } \
  798. void SoftCPU::mnemonic##_reg8_RM8(const X86::Instruction& insn) { generic_reg8_RM8<update_dest>(op<u8, u8>, insn); }
  799. DEFINE_GENERIC_INSN_HANDLERS(XOR, op_xor, true)
  800. DEFINE_GENERIC_INSN_HANDLERS(SUB, op_sub, true)
  801. DEFINE_GENERIC_INSN_HANDLERS(CMP, op_sub, false)
  802. void SoftCPU::MOVQ_mm1_mm2m64(const X86::Instruction&) { TODO(); }
  803. void SoftCPU::EMMS(const X86::Instruction&) { TODO(); }
  804. void SoftCPU::MOVQ_mm1_m64_mm2(const X86::Instruction&) { TODO(); }
  805. void SoftCPU::wrap_0xC0(const X86::Instruction&) { TODO(); }
  806. void SoftCPU::wrap_0xC1_16(const X86::Instruction&) { TODO(); }
  807. void SoftCPU::wrap_0xC1_32(const X86::Instruction&) { TODO(); }
  808. void SoftCPU::wrap_0xD0(const X86::Instruction&) { TODO(); }
  809. void SoftCPU::wrap_0xD1_16(const X86::Instruction&) { TODO(); }
  810. void SoftCPU::wrap_0xD1_32(const X86::Instruction&) { TODO(); }
  811. void SoftCPU::wrap_0xD2(const X86::Instruction&) { TODO(); }
  812. void SoftCPU::wrap_0xD3_16(const X86::Instruction&) { TODO(); }
  813. void SoftCPU::wrap_0xD3_32(const X86::Instruction&) { TODO(); }
  814. }