SoftCPU.cpp 49 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397
  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, typename U>
  33. inline constexpr T sign_extended_to(U value)
  34. {
  35. if (!(value & X86::TypeTrivia<U>::sign_bit))
  36. return value;
  37. return (X86::TypeTrivia<T>::mask & ~X86::TypeTrivia<U>::mask) | value;
  38. }
  39. SoftCPU::SoftCPU(Emulator& emulator)
  40. : m_emulator(emulator)
  41. {
  42. memset(m_gpr, 0, sizeof(m_gpr));
  43. m_segment[(int)X86::SegmentRegister::CS] = 0x18;
  44. m_segment[(int)X86::SegmentRegister::DS] = 0x20;
  45. m_segment[(int)X86::SegmentRegister::ES] = 0x20;
  46. m_segment[(int)X86::SegmentRegister::SS] = 0x20;
  47. }
  48. void SoftCPU::dump() const
  49. {
  50. printf("eax=%08x ebx=%08x ecx=%08x edx=%08x ", eax(), ebx(), ecx(), edx());
  51. printf("ebp=%08x esp=%08x esi=%08x edi=%08x ", ebp(), esp(), esi(), edi());
  52. printf("o=%u s=%u z=%u a=%u p=%u c=%u\n", of(), sf(), zf(), af(), pf(), cf());
  53. }
  54. u8 SoftCPU::read8()
  55. {
  56. auto value = read_memory8({ cs(), eip() });
  57. m_eip += 1;
  58. return value;
  59. }
  60. u16 SoftCPU::read16()
  61. {
  62. auto value = read_memory16({ cs(), eip() });
  63. m_eip += 2;
  64. return value;
  65. }
  66. u32 SoftCPU::read32()
  67. {
  68. auto value = read_memory32({ cs(), eip() });
  69. m_eip += 4;
  70. return value;
  71. }
  72. u8 SoftCPU::read_memory8(X86::LogicalAddress address)
  73. {
  74. ASSERT(address.selector() == 0x18 || address.selector() == 0x20);
  75. auto value = m_emulator.mmu().read8(address.offset());
  76. printf("\033[36;1mread_memory8: @%08x -> %02x\033[0m\n", address.offset(), value);
  77. return value;
  78. }
  79. u16 SoftCPU::read_memory16(X86::LogicalAddress address)
  80. {
  81. ASSERT(address.selector() == 0x18 || address.selector() == 0x20);
  82. auto value = m_emulator.mmu().read16(address.offset());
  83. printf("\033[36;1mread_memory16: @%08x -> %04x\033[0m\n", address.offset(), value);
  84. return value;
  85. }
  86. u32 SoftCPU::read_memory32(X86::LogicalAddress address)
  87. {
  88. ASSERT(address.selector() == 0x18 || address.selector() == 0x20);
  89. auto value = m_emulator.mmu().read32(address.offset());
  90. printf("\033[36;1mread_memory32: @%08x -> %08x\033[0m\n", address.offset(), value);
  91. return value;
  92. }
  93. void SoftCPU::write_memory8(X86::LogicalAddress address, u8 value)
  94. {
  95. ASSERT(address.selector() == 0x20);
  96. printf("\033[35;1mwrite_memory8: @%08x <- %02x\033[0m\n", address.offset(), value);
  97. m_emulator.mmu().write8(address.offset(), value);
  98. }
  99. void SoftCPU::write_memory16(X86::LogicalAddress address, u16 value)
  100. {
  101. ASSERT(address.selector() == 0x20);
  102. printf("\033[35;1mwrite_memory16: @%08x <- %04x\033[0m\n", address.offset(), value);
  103. m_emulator.mmu().write16(address.offset(), value);
  104. }
  105. void SoftCPU::write_memory32(X86::LogicalAddress address, u32 value)
  106. {
  107. ASSERT(address.selector() == 0x20);
  108. printf("\033[35;1mwrite_memory32: @%08x <- %08x\033[0m\n", address.offset(), value);
  109. m_emulator.mmu().write32(address.offset(), value);
  110. }
  111. void SoftCPU::push32(u32 value)
  112. {
  113. set_esp(esp() - sizeof(value));
  114. write_memory32({ ss(), esp() }, value);
  115. }
  116. u32 SoftCPU::pop32()
  117. {
  118. auto value = read_memory32({ ss(), esp() });
  119. set_esp(esp() + sizeof(value));
  120. return value;
  121. }
  122. template<bool check_zf, typename Callback>
  123. void SoftCPU::do_once_or_repeat(const X86::Instruction& insn, Callback callback)
  124. {
  125. if (!insn.has_rep_prefix())
  126. return callback();
  127. if (insn.has_address_size_override_prefix()) {
  128. while (cx()) {
  129. callback();
  130. set_cx(cx() - 1);
  131. if constexpr (check_zf) {
  132. if (insn.rep_prefix() == X86::Prefix::REPZ && !zf())
  133. break;
  134. if (insn.rep_prefix() == X86::Prefix::REPNZ && zf())
  135. break;
  136. }
  137. }
  138. return;
  139. }
  140. while (ecx()) {
  141. callback();
  142. set_ecx(ecx() - 1);
  143. if constexpr (check_zf) {
  144. if (insn.rep_prefix() == X86::Prefix::REPZ && !zf())
  145. break;
  146. if (insn.rep_prefix() == X86::Prefix::REPNZ && zf())
  147. break;
  148. }
  149. }
  150. }
  151. template<typename T>
  152. static T op_xor(SoftCPU& cpu, const T& dest, const T& src)
  153. {
  154. T result = 0;
  155. u32 new_flags = 0;
  156. if constexpr (sizeof(T) == 4) {
  157. asm volatile("xorl %%ecx, %%eax\n"
  158. : "=a"(result)
  159. : "a"(dest), "c"((u32)src));
  160. } else if constexpr (sizeof(T) == 2) {
  161. asm volatile("xor %%cx, %%ax\n"
  162. : "=a"(result)
  163. : "a"(dest), "c"((u16)src));
  164. } else if constexpr (sizeof(T) == 1) {
  165. asm volatile("xorb %%cl, %%al\n"
  166. : "=a"(result)
  167. : "a"(dest), "c"((u8)src));
  168. } else {
  169. ASSERT_NOT_REACHED();
  170. }
  171. asm volatile(
  172. "pushf\n"
  173. "pop %%ebx"
  174. : "=b"(new_flags));
  175. cpu.set_flags_oszpc(new_flags);
  176. return result;
  177. }
  178. template<typename T>
  179. static T op_or(SoftCPU& cpu, const T& dest, const T& src)
  180. {
  181. T result = 0;
  182. u32 new_flags = 0;
  183. if constexpr (sizeof(T) == 4) {
  184. asm volatile("orl %%ecx, %%eax\n"
  185. : "=a"(result)
  186. : "a"(dest), "c"((u32)src));
  187. } else if constexpr (sizeof(T) == 2) {
  188. asm volatile("or %%cx, %%ax\n"
  189. : "=a"(result)
  190. : "a"(dest), "c"((u16)src));
  191. } else if constexpr (sizeof(T) == 1) {
  192. asm volatile("orb %%cl, %%al\n"
  193. : "=a"(result)
  194. : "a"(dest), "c"((u8)src));
  195. } else {
  196. ASSERT_NOT_REACHED();
  197. }
  198. asm volatile(
  199. "pushf\n"
  200. "pop %%ebx"
  201. : "=b"(new_flags));
  202. cpu.set_flags_oszpc(new_flags);
  203. return result;
  204. }
  205. template<typename T>
  206. static T op_sub(SoftCPU& cpu, const T& dest, const T& src)
  207. {
  208. T result = 0;
  209. u32 new_flags = 0;
  210. if constexpr (sizeof(T) == 4) {
  211. asm volatile("subl %%ecx, %%eax\n"
  212. : "=a"(result)
  213. : "a"(dest), "c"((u32)src));
  214. } else if constexpr (sizeof(T) == 2) {
  215. asm volatile("subw %%cx, %%ax\n"
  216. : "=a"(result)
  217. : "a"(dest), "c"((u16)src));
  218. } else if constexpr (sizeof(T) == 1) {
  219. asm volatile("subb %%cl, %%al\n"
  220. : "=a"(result)
  221. : "a"(dest), "c"((u8)src));
  222. } else {
  223. ASSERT_NOT_REACHED();
  224. }
  225. asm volatile(
  226. "pushf\n"
  227. "pop %%ebx"
  228. : "=b"(new_flags));
  229. cpu.set_flags_oszapc(new_flags);
  230. return result;
  231. }
  232. template<typename T>
  233. static T op_add(SoftCPU& cpu, T& dest, const T& src)
  234. {
  235. T result = 0;
  236. u32 new_flags = 0;
  237. if constexpr (sizeof(T) == 4) {
  238. asm volatile("addl %%ecx, %%eax\n"
  239. : "=a"(result)
  240. : "a"(dest), "c"((u32)src));
  241. } else if constexpr (sizeof(T) == 2) {
  242. asm volatile("addw %%cx, %%ax\n"
  243. : "=a"(result)
  244. : "a"(dest), "c"((u16)src));
  245. } else if constexpr (sizeof(T) == 1) {
  246. asm volatile("addb %%cl, %%al\n"
  247. : "=a"(result)
  248. : "a"(dest), "c"((u8)src));
  249. } else {
  250. ASSERT_NOT_REACHED();
  251. }
  252. asm volatile(
  253. "pushf\n"
  254. "pop %%ebx"
  255. : "=b"(new_flags));
  256. cpu.set_flags_oszapc(new_flags);
  257. return result;
  258. }
  259. template<typename T>
  260. static T op_and(SoftCPU& cpu, const T& dest, const T& src)
  261. {
  262. T result = 0;
  263. u32 new_flags = 0;
  264. if constexpr (sizeof(T) == 4) {
  265. asm volatile("andl %%ecx, %%eax\n"
  266. : "=a"(result)
  267. : "a"(dest), "c"((u32)src));
  268. } else if constexpr (sizeof(T) == 2) {
  269. asm volatile("andw %%cx, %%ax\n"
  270. : "=a"(result)
  271. : "a"(dest), "c"((u16)src));
  272. } else if constexpr (sizeof(T) == 1) {
  273. asm volatile("andb %%cl, %%al\n"
  274. : "=a"(result)
  275. : "a"(dest), "c"((u8)src));
  276. } else {
  277. ASSERT_NOT_REACHED();
  278. }
  279. asm volatile(
  280. "pushf\n"
  281. "pop %%ebx"
  282. : "=b"(new_flags));
  283. cpu.set_flags_oszpc(new_flags);
  284. return result;
  285. }
  286. template<typename T>
  287. static T op_imul(SoftCPU& cpu, const T& dest, const T& src)
  288. {
  289. T result = 0;
  290. u32 new_flags = 0;
  291. if constexpr (sizeof(T) == 4) {
  292. asm volatile("imull %%ecx, %%eax\n"
  293. : "=a"(result)
  294. : "a"(dest), "c"((i32)src));
  295. } else if constexpr (sizeof(T) == 2) {
  296. asm volatile("imulw %%cx, %%ax\n"
  297. : "=a"(result)
  298. : "a"(dest), "c"((i16)src));
  299. } else {
  300. ASSERT_NOT_REACHED();
  301. }
  302. asm volatile(
  303. "pushf\n"
  304. "pop %%ebx"
  305. : "=b"(new_flags));
  306. cpu.set_flags_oszapc(new_flags);
  307. return result;
  308. }
  309. template<typename T>
  310. static T op_shr(SoftCPU& cpu, T data, u8 steps)
  311. {
  312. if (steps == 0)
  313. return data;
  314. u32 result = 0;
  315. u32 new_flags = 0;
  316. if constexpr (sizeof(T) == 4)
  317. asm volatile("shrl %%cl, %%eax\n" ::"a"(data), "c"(steps));
  318. else if constexpr (sizeof(T) == 2)
  319. asm volatile("shrw %%cl, %%ax\n" ::"a"(data), "c"(steps));
  320. else if constexpr (sizeof(T) == 1)
  321. asm volatile("shrb %%cl, %%al\n" ::"a"(data), "c"(steps));
  322. asm volatile(
  323. "mov %%eax, %%ebx\n"
  324. : "=b"(result));
  325. asm volatile(
  326. "pushf\n"
  327. "pop %%eax"
  328. : "=a"(new_flags));
  329. cpu.set_flags_oszapc(new_flags);
  330. return result;
  331. }
  332. template<typename T>
  333. static T op_shl(SoftCPU& cpu, T data, u8 steps)
  334. {
  335. if (steps == 0)
  336. return data;
  337. u32 result = 0;
  338. u32 new_flags = 0;
  339. if constexpr (sizeof(T) == 4)
  340. asm volatile("shll %%cl, %%eax\n" ::"a"(data), "c"(steps));
  341. else if constexpr (sizeof(T) == 2)
  342. asm volatile("shlw %%cl, %%ax\n" ::"a"(data), "c"(steps));
  343. else if constexpr (sizeof(T) == 1)
  344. asm volatile("shlb %%cl, %%al\n" ::"a"(data), "c"(steps));
  345. asm volatile(
  346. "mov %%eax, %%ebx\n"
  347. : "=b"(result));
  348. asm volatile(
  349. "pushf\n"
  350. "pop %%eax"
  351. : "=a"(new_flags));
  352. cpu.set_flags_oszapc(new_flags);
  353. return result;
  354. }
  355. template<bool update_dest, typename Op>
  356. void SoftCPU::generic_AL_imm8(Op op, const X86::Instruction& insn)
  357. {
  358. auto dest = al();
  359. auto src = insn.imm8();
  360. auto result = op(*this, dest, src);
  361. if (update_dest)
  362. set_al(result);
  363. }
  364. template<bool update_dest, typename Op>
  365. void SoftCPU::generic_AX_imm16(Op op, const X86::Instruction& insn)
  366. {
  367. auto dest = ax();
  368. auto src = insn.imm16();
  369. auto result = op(*this, dest, src);
  370. if (update_dest)
  371. set_ax(result);
  372. }
  373. template<bool update_dest, typename Op>
  374. void SoftCPU::generic_EAX_imm32(Op op, const X86::Instruction& insn)
  375. {
  376. auto dest = eax();
  377. auto src = insn.imm32();
  378. auto result = op(*this, dest, src);
  379. if (update_dest)
  380. set_eax(result);
  381. }
  382. template<bool update_dest, typename Op>
  383. void SoftCPU::generic_RM16_imm16(Op op, const X86::Instruction& insn)
  384. {
  385. auto dest = insn.modrm().read16(*this, insn);
  386. auto src = insn.imm16();
  387. auto result = op(*this, dest, src);
  388. if (update_dest)
  389. insn.modrm().write16(*this, insn, result);
  390. }
  391. template<bool update_dest, typename Op>
  392. void SoftCPU::generic_RM16_imm8(Op op, const X86::Instruction& insn)
  393. {
  394. auto dest = insn.modrm().read16(*this, insn);
  395. auto src = sign_extended_to<u16>(insn.imm8());
  396. auto result = op(*this, dest, src);
  397. if (update_dest)
  398. insn.modrm().write16(*this, insn, result);
  399. }
  400. template<bool update_dest, typename Op>
  401. void SoftCPU::generic_RM16_reg16(Op op, const X86::Instruction& insn)
  402. {
  403. auto dest = insn.modrm().read16(*this, insn);
  404. auto src = gpr16(insn.reg16());
  405. auto result = op(*this, dest, src);
  406. if (update_dest)
  407. insn.modrm().write16(*this, insn, result);
  408. }
  409. template<bool update_dest, typename Op>
  410. void SoftCPU::generic_RM32_imm32(Op op, const X86::Instruction& insn)
  411. {
  412. auto dest = insn.modrm().read32(*this, insn);
  413. auto src = insn.imm32();
  414. auto result = op(*this, dest, src);
  415. if (update_dest)
  416. insn.modrm().write32(*this, insn, result);
  417. }
  418. template<bool update_dest, typename Op>
  419. void SoftCPU::generic_RM32_imm8(Op op, const X86::Instruction& insn)
  420. {
  421. auto dest = insn.modrm().read32(*this, insn);
  422. auto src = sign_extended_to<u32>(insn.imm8());
  423. auto result = op(*this, dest, src);
  424. if (update_dest)
  425. insn.modrm().write32(*this, insn, result);
  426. }
  427. template<bool update_dest, typename Op>
  428. void SoftCPU::generic_RM32_reg32(Op op, const X86::Instruction& insn)
  429. {
  430. auto dest = insn.modrm().read32(*this, insn);
  431. auto src = gpr32(insn.reg32());
  432. auto result = op(*this, dest, src);
  433. if (update_dest)
  434. insn.modrm().write32(*this, insn, result);
  435. }
  436. template<bool update_dest, typename Op>
  437. void SoftCPU::generic_RM8_imm8(Op op, const X86::Instruction& insn)
  438. {
  439. auto dest = insn.modrm().read8(*this, insn);
  440. auto src = insn.imm8();
  441. auto result = op(*this, dest, src);
  442. if (update_dest)
  443. insn.modrm().write8(*this, insn, result);
  444. }
  445. template<bool update_dest, typename Op>
  446. void SoftCPU::generic_RM8_reg8(Op op, const X86::Instruction& insn)
  447. {
  448. auto dest = insn.modrm().read8(*this, insn);
  449. auto src = gpr8(insn.reg8());
  450. auto result = op(*this, dest, src);
  451. if (update_dest)
  452. insn.modrm().write8(*this, insn, result);
  453. }
  454. template<bool update_dest, typename Op>
  455. void SoftCPU::generic_reg16_RM16(Op op, const X86::Instruction& insn)
  456. {
  457. auto dest = gpr16(insn.reg16());
  458. auto src = insn.modrm().read16(*this, insn);
  459. auto result = op(*this, dest, src);
  460. if (update_dest)
  461. gpr16(insn.reg16()) = result;
  462. }
  463. template<bool update_dest, typename Op>
  464. void SoftCPU::generic_reg32_RM32(Op op, const X86::Instruction& insn)
  465. {
  466. auto dest = gpr32(insn.reg32());
  467. auto src = insn.modrm().read32(*this, insn);
  468. auto result = op(*this, dest, src);
  469. if (update_dest)
  470. gpr32(insn.reg32()) = result;
  471. }
  472. template<bool update_dest, typename Op>
  473. void SoftCPU::generic_reg8_RM8(Op op, const X86::Instruction& insn)
  474. {
  475. auto dest = gpr8(insn.reg8());
  476. auto src = insn.modrm().read8(*this, insn);
  477. auto result = op(*this, dest, src);
  478. if (update_dest)
  479. gpr8(insn.reg8()) = result;
  480. }
  481. void SoftCPU::AAA(const X86::Instruction&) { TODO(); }
  482. void SoftCPU::AAD(const X86::Instruction&) { TODO(); }
  483. void SoftCPU::AAM(const X86::Instruction&) { TODO(); }
  484. void SoftCPU::AAS(const X86::Instruction&) { TODO(); }
  485. void SoftCPU::ADC_AL_imm8(const X86::Instruction&) { TODO(); }
  486. void SoftCPU::ADC_AX_imm16(const X86::Instruction&) { TODO(); }
  487. void SoftCPU::ADC_EAX_imm32(const X86::Instruction&) { TODO(); }
  488. void SoftCPU::ADC_RM16_imm16(const X86::Instruction&) { TODO(); }
  489. void SoftCPU::ADC_RM16_imm8(const X86::Instruction&) { TODO(); }
  490. void SoftCPU::ADC_RM16_reg16(const X86::Instruction&) { TODO(); }
  491. void SoftCPU::ADC_RM32_imm32(const X86::Instruction&) { TODO(); }
  492. void SoftCPU::ADC_RM32_imm8(const X86::Instruction&) { TODO(); }
  493. void SoftCPU::ADC_RM32_reg32(const X86::Instruction&) { TODO(); }
  494. void SoftCPU::ADC_RM8_imm8(const X86::Instruction&) { TODO(); }
  495. void SoftCPU::ADC_RM8_reg8(const X86::Instruction&) { TODO(); }
  496. void SoftCPU::ADC_reg16_RM16(const X86::Instruction&) { TODO(); }
  497. void SoftCPU::ADC_reg32_RM32(const X86::Instruction&) { TODO(); }
  498. void SoftCPU::ADC_reg8_RM8(const X86::Instruction&) { TODO(); }
  499. void SoftCPU::ARPL(const X86::Instruction&) { TODO(); }
  500. void SoftCPU::BOUND(const X86::Instruction&) { TODO(); }
  501. void SoftCPU::BSF_reg16_RM16(const X86::Instruction&) { TODO(); }
  502. void SoftCPU::BSF_reg32_RM32(const X86::Instruction&) { TODO(); }
  503. void SoftCPU::BSR_reg16_RM16(const X86::Instruction&) { TODO(); }
  504. void SoftCPU::BSR_reg32_RM32(const X86::Instruction&) { TODO(); }
  505. void SoftCPU::BSWAP_reg32(const X86::Instruction&) { TODO(); }
  506. void SoftCPU::BTC_RM16_imm8(const X86::Instruction&) { TODO(); }
  507. void SoftCPU::BTC_RM16_reg16(const X86::Instruction&) { TODO(); }
  508. void SoftCPU::BTC_RM32_imm8(const X86::Instruction&) { TODO(); }
  509. void SoftCPU::BTC_RM32_reg32(const X86::Instruction&) { TODO(); }
  510. void SoftCPU::BTR_RM16_imm8(const X86::Instruction&) { TODO(); }
  511. void SoftCPU::BTR_RM16_reg16(const X86::Instruction&) { TODO(); }
  512. void SoftCPU::BTR_RM32_imm8(const X86::Instruction&) { TODO(); }
  513. void SoftCPU::BTR_RM32_reg32(const X86::Instruction&) { TODO(); }
  514. void SoftCPU::BTS_RM16_imm8(const X86::Instruction&) { TODO(); }
  515. void SoftCPU::BTS_RM16_reg16(const X86::Instruction&) { TODO(); }
  516. void SoftCPU::BTS_RM32_imm8(const X86::Instruction&) { TODO(); }
  517. void SoftCPU::BTS_RM32_reg32(const X86::Instruction&) { TODO(); }
  518. void SoftCPU::BT_RM16_imm8(const X86::Instruction&) { TODO(); }
  519. void SoftCPU::BT_RM16_reg16(const X86::Instruction&) { TODO(); }
  520. void SoftCPU::BT_RM32_imm8(const X86::Instruction&) { TODO(); }
  521. void SoftCPU::BT_RM32_reg32(const X86::Instruction&) { TODO(); }
  522. void SoftCPU::CALL_FAR_mem16(const X86::Instruction&) { TODO(); }
  523. void SoftCPU::CALL_FAR_mem32(const X86::Instruction&) { TODO(); }
  524. void SoftCPU::CALL_RM16(const X86::Instruction&) { TODO(); }
  525. void SoftCPU::CALL_RM32(const X86::Instruction& insn)
  526. {
  527. push32(eip());
  528. set_eip(insn.modrm().read32(*this, insn));
  529. }
  530. void SoftCPU::CALL_imm16(const X86::Instruction&) { TODO(); }
  531. void SoftCPU::CALL_imm16_imm16(const X86::Instruction&) { TODO(); }
  532. void SoftCPU::CALL_imm16_imm32(const X86::Instruction&) { TODO(); }
  533. void SoftCPU::CALL_imm32(const X86::Instruction& insn)
  534. {
  535. push32(eip());
  536. set_eip(eip() + (i32)insn.imm32());
  537. }
  538. void SoftCPU::CBW(const X86::Instruction&) { TODO(); }
  539. void SoftCPU::CDQ(const X86::Instruction&) { TODO(); }
  540. void SoftCPU::CLC(const X86::Instruction&) { TODO(); }
  541. void SoftCPU::CLD(const X86::Instruction&) { TODO(); }
  542. void SoftCPU::CLI(const X86::Instruction&) { TODO(); }
  543. void SoftCPU::CLTS(const X86::Instruction&) { TODO(); }
  544. void SoftCPU::CMC(const X86::Instruction&) { TODO(); }
  545. void SoftCPU::CMOVcc_reg16_RM16(const X86::Instruction&) { TODO(); }
  546. void SoftCPU::CMOVcc_reg32_RM32(const X86::Instruction&) { TODO(); }
  547. void SoftCPU::CMPSB(const X86::Instruction&) { TODO(); }
  548. void SoftCPU::CMPSD(const X86::Instruction&) { TODO(); }
  549. void SoftCPU::CMPSW(const X86::Instruction&) { TODO(); }
  550. void SoftCPU::CMPXCHG_RM16_reg16(const X86::Instruction&) { TODO(); }
  551. void SoftCPU::CMPXCHG_RM32_reg32(const X86::Instruction&) { TODO(); }
  552. void SoftCPU::CMPXCHG_RM8_reg8(const X86::Instruction&) { TODO(); }
  553. void SoftCPU::CPUID(const X86::Instruction&) { TODO(); }
  554. void SoftCPU::CWD(const X86::Instruction&) { TODO(); }
  555. void SoftCPU::CWDE(const X86::Instruction&) { TODO(); }
  556. void SoftCPU::DAA(const X86::Instruction&) { TODO(); }
  557. void SoftCPU::DAS(const X86::Instruction&) { TODO(); }
  558. void SoftCPU::DEC_RM16(const X86::Instruction&) { TODO(); }
  559. void SoftCPU::DEC_RM32(const X86::Instruction&) { TODO(); }
  560. void SoftCPU::DEC_RM8(const X86::Instruction&) { TODO(); }
  561. void SoftCPU::DEC_reg16(const X86::Instruction&) { TODO(); }
  562. void SoftCPU::DEC_reg32(const X86::Instruction&) { TODO(); }
  563. void SoftCPU::DIV_RM16(const X86::Instruction&) { TODO(); }
  564. void SoftCPU::DIV_RM32(const X86::Instruction&) { TODO(); }
  565. void SoftCPU::DIV_RM8(const X86::Instruction&) { TODO(); }
  566. void SoftCPU::ENTER16(const X86::Instruction&) { TODO(); }
  567. void SoftCPU::ENTER32(const X86::Instruction&) { TODO(); }
  568. void SoftCPU::ESCAPE(const X86::Instruction&) { TODO(); }
  569. void SoftCPU::HLT(const X86::Instruction&) { TODO(); }
  570. void SoftCPU::IDIV_RM16(const X86::Instruction&) { TODO(); }
  571. void SoftCPU::IDIV_RM32(const X86::Instruction&) { TODO(); }
  572. void SoftCPU::IDIV_RM8(const X86::Instruction&) { TODO(); }
  573. void SoftCPU::IMUL_RM16(const X86::Instruction&) { TODO(); }
  574. void SoftCPU::IMUL_RM32(const X86::Instruction&) { TODO(); }
  575. void SoftCPU::IMUL_RM8(const X86::Instruction&) { TODO(); }
  576. void SoftCPU::IMUL_reg16_RM16(const X86::Instruction& insn)
  577. {
  578. gpr16(insn.reg16()) = op_imul<i16>(*this, gpr16(insn.reg16()), insn.modrm().read16(*this, insn));
  579. }
  580. void SoftCPU::IMUL_reg16_RM16_imm16(const X86::Instruction& insn)
  581. {
  582. gpr16(insn.reg16()) = op_imul<i16>(*this, insn.modrm().read16(*this, insn), insn.imm16());
  583. }
  584. void SoftCPU::IMUL_reg16_RM16_imm8(const X86::Instruction& insn)
  585. {
  586. gpr16(insn.reg16()) = op_imul<i16>(*this, insn.modrm().read16(*this, insn), sign_extended_to<i16>(insn.imm8()));
  587. }
  588. void SoftCPU::IMUL_reg32_RM32(const X86::Instruction& insn)
  589. {
  590. gpr32(insn.reg32()) = op_imul<i32>(*this, gpr32(insn.reg32()), insn.modrm().read32(*this, insn));
  591. }
  592. void SoftCPU::IMUL_reg32_RM32_imm32(const X86::Instruction& insn)
  593. {
  594. gpr32(insn.reg32()) = op_imul<i32>(*this, insn.modrm().read32(*this, insn), insn.imm32());
  595. }
  596. void SoftCPU::IMUL_reg32_RM32_imm8(const X86::Instruction& insn)
  597. {
  598. gpr32(insn.reg32()) = op_imul<i32>(*this, insn.modrm().read32(*this, insn), sign_extended_to<i32>(insn.imm8()));
  599. }
  600. template<typename T>
  601. static T op_inc(SoftCPU& cpu, T data)
  602. {
  603. T result = 0;
  604. u32 new_flags = 0;
  605. if constexpr (sizeof(T) == 4) {
  606. asm volatile("incl %%eax\n"
  607. : "=a"(result)
  608. : "a"(data));
  609. } else if constexpr (sizeof(T) == 2) {
  610. asm volatile("incw %%ax\n"
  611. : "=a"(result)
  612. : "a"(data));
  613. } else if constexpr (sizeof(T) == 1) {
  614. asm volatile("incb %%al\n"
  615. : "=a"(result)
  616. : "a"(data));
  617. }
  618. asm volatile(
  619. "pushf\n"
  620. "pop %%ebx"
  621. : "=b"(new_flags));
  622. cpu.set_flags_oszap(new_flags);
  623. return result;
  624. }
  625. void SoftCPU::INC_RM16(const X86::Instruction& insn)
  626. {
  627. insn.modrm().write16(*this, insn, op_inc(*this, insn.modrm().read16(*this, insn)));
  628. }
  629. void SoftCPU::INC_RM32(const X86::Instruction& insn)
  630. {
  631. insn.modrm().write32(*this, insn, op_inc(*this, insn.modrm().read32(*this, insn)));
  632. }
  633. void SoftCPU::INC_RM8(const X86::Instruction& insn)
  634. {
  635. insn.modrm().write8(*this, insn, op_inc(*this, insn.modrm().read8(*this, insn)));
  636. }
  637. void SoftCPU::INC_reg16(const X86::Instruction& insn)
  638. {
  639. gpr16(insn.reg16()) = op_inc(*this, gpr16(insn.reg16()));
  640. }
  641. void SoftCPU::INC_reg32(const X86::Instruction& insn)
  642. {
  643. gpr32(insn.reg32()) = op_inc(*this, gpr32(insn.reg32()));
  644. }
  645. void SoftCPU::INSB(const X86::Instruction&) { TODO(); }
  646. void SoftCPU::INSD(const X86::Instruction&) { TODO(); }
  647. void SoftCPU::INSW(const X86::Instruction&) { TODO(); }
  648. void SoftCPU::INT3(const X86::Instruction&) { TODO(); }
  649. void SoftCPU::INTO(const X86::Instruction&) { TODO(); }
  650. void SoftCPU::INT_imm8(const X86::Instruction& insn)
  651. {
  652. ASSERT(insn.imm8() == 0x82);
  653. set_eax(m_emulator.virt_syscall(eax(), edx(), ecx(), ebx()));
  654. }
  655. void SoftCPU::INVLPG(const X86::Instruction&) { TODO(); }
  656. void SoftCPU::IN_AL_DX(const X86::Instruction&) { TODO(); }
  657. void SoftCPU::IN_AL_imm8(const X86::Instruction&) { TODO(); }
  658. void SoftCPU::IN_AX_DX(const X86::Instruction&) { TODO(); }
  659. void SoftCPU::IN_AX_imm8(const X86::Instruction&) { TODO(); }
  660. void SoftCPU::IN_EAX_DX(const X86::Instruction&) { TODO(); }
  661. void SoftCPU::IN_EAX_imm8(const X86::Instruction&) { TODO(); }
  662. void SoftCPU::IRET(const X86::Instruction&) { TODO(); }
  663. void SoftCPU::JCXZ_imm8(const X86::Instruction&) { TODO(); }
  664. void SoftCPU::JMP_FAR_mem16(const X86::Instruction&) { TODO(); }
  665. void SoftCPU::JMP_FAR_mem32(const X86::Instruction&) { TODO(); }
  666. void SoftCPU::JMP_RM16(const X86::Instruction&) { TODO(); }
  667. void SoftCPU::JMP_RM32(const X86::Instruction&) { TODO(); }
  668. void SoftCPU::JMP_imm16(const X86::Instruction& insn)
  669. {
  670. set_eip(eip() + (i16)insn.imm16());
  671. }
  672. void SoftCPU::JMP_imm16_imm16(const X86::Instruction&) { TODO(); }
  673. void SoftCPU::JMP_imm16_imm32(const X86::Instruction&) { TODO(); }
  674. void SoftCPU::JMP_imm32(const X86::Instruction& insn)
  675. {
  676. set_eip(eip() + (i32)insn.imm32());
  677. }
  678. void SoftCPU::JMP_short_imm8(const X86::Instruction& insn)
  679. {
  680. set_eip(eip() + (i8)insn.imm8());
  681. }
  682. void SoftCPU::Jcc_NEAR_imm(const X86::Instruction&) { TODO(); }
  683. void SoftCPU::Jcc_imm8(const X86::Instruction& insn)
  684. {
  685. if (evaluate_condition(insn.cc()))
  686. set_eip(eip() + (i8)insn.imm8());
  687. }
  688. void SoftCPU::LAHF(const X86::Instruction&) { TODO(); }
  689. void SoftCPU::LAR_reg16_RM16(const X86::Instruction&) { TODO(); }
  690. void SoftCPU::LAR_reg32_RM32(const X86::Instruction&) { TODO(); }
  691. void SoftCPU::LDS_reg16_mem16(const X86::Instruction&) { TODO(); }
  692. void SoftCPU::LDS_reg32_mem32(const X86::Instruction&) { TODO(); }
  693. void SoftCPU::LEAVE16(const X86::Instruction&) { TODO(); }
  694. void SoftCPU::LEAVE32(const X86::Instruction&)
  695. {
  696. u32 new_ebp = read_memory32({ ss(), ebp() });
  697. set_esp(ebp() + 4);
  698. set_ebp(new_ebp);
  699. }
  700. void SoftCPU::LEA_reg16_mem16(const X86::Instruction& insn)
  701. {
  702. gpr16(insn.reg16()) = insn.modrm().resolve(*this, insn.segment_prefix()).offset();
  703. }
  704. void SoftCPU::LEA_reg32_mem32(const X86::Instruction& insn)
  705. {
  706. gpr32(insn.reg32()) = insn.modrm().resolve(*this, insn.segment_prefix()).offset();
  707. }
  708. void SoftCPU::LES_reg16_mem16(const X86::Instruction&) { TODO(); }
  709. void SoftCPU::LES_reg32_mem32(const X86::Instruction&) { TODO(); }
  710. void SoftCPU::LFS_reg16_mem16(const X86::Instruction&) { TODO(); }
  711. void SoftCPU::LFS_reg32_mem32(const X86::Instruction&) { TODO(); }
  712. void SoftCPU::LGDT(const X86::Instruction&) { TODO(); }
  713. void SoftCPU::LGS_reg16_mem16(const X86::Instruction&) { TODO(); }
  714. void SoftCPU::LGS_reg32_mem32(const X86::Instruction&) { TODO(); }
  715. void SoftCPU::LIDT(const X86::Instruction&) { TODO(); }
  716. void SoftCPU::LLDT_RM16(const X86::Instruction&) { TODO(); }
  717. void SoftCPU::LMSW_RM16(const X86::Instruction&) { TODO(); }
  718. void SoftCPU::LODSB(const X86::Instruction&) { TODO(); }
  719. void SoftCPU::LODSD(const X86::Instruction&) { TODO(); }
  720. void SoftCPU::LODSW(const X86::Instruction&) { TODO(); }
  721. void SoftCPU::LOOPNZ_imm8(const X86::Instruction&) { TODO(); }
  722. void SoftCPU::LOOPZ_imm8(const X86::Instruction&) { TODO(); }
  723. void SoftCPU::LOOP_imm8(const X86::Instruction&) { TODO(); }
  724. void SoftCPU::LSL_reg16_RM16(const X86::Instruction&) { TODO(); }
  725. void SoftCPU::LSL_reg32_RM32(const X86::Instruction&) { TODO(); }
  726. void SoftCPU::LSS_reg16_mem16(const X86::Instruction&) { TODO(); }
  727. void SoftCPU::LSS_reg32_mem32(const X86::Instruction&) { TODO(); }
  728. void SoftCPU::LTR_RM16(const X86::Instruction&) { TODO(); }
  729. void SoftCPU::MOVSB(const X86::Instruction&) { TODO(); }
  730. void SoftCPU::MOVSD(const X86::Instruction&) { TODO(); }
  731. void SoftCPU::MOVSW(const X86::Instruction&) { TODO(); }
  732. void SoftCPU::MOVSX_reg16_RM8(const X86::Instruction&) { TODO(); }
  733. void SoftCPU::MOVSX_reg32_RM16(const X86::Instruction&) { TODO(); }
  734. void SoftCPU::MOVSX_reg32_RM8(const X86::Instruction&) { TODO(); }
  735. void SoftCPU::MOVZX_reg16_RM8(const X86::Instruction& insn)
  736. {
  737. gpr16(insn.reg16()) = insn.modrm().read8(*this, insn);
  738. }
  739. void SoftCPU::MOVZX_reg32_RM16(const X86::Instruction& insn)
  740. {
  741. gpr32(insn.reg32()) = insn.modrm().read16(*this, insn);
  742. }
  743. void SoftCPU::MOVZX_reg32_RM8(const X86::Instruction& insn)
  744. {
  745. gpr32(insn.reg32()) = insn.modrm().read8(*this, insn);
  746. }
  747. void SoftCPU::MOV_AL_moff8(const X86::Instruction&) { TODO(); }
  748. void SoftCPU::MOV_AX_moff16(const X86::Instruction&) { TODO(); }
  749. void SoftCPU::MOV_CR_reg32(const X86::Instruction&) { TODO(); }
  750. void SoftCPU::MOV_DR_reg32(const X86::Instruction&) { TODO(); }
  751. void SoftCPU::MOV_EAX_moff32(const X86::Instruction& insn)
  752. {
  753. set_eax(read_memory32({ segment(insn.segment_prefix().value_or(X86::SegmentRegister::DS)), insn.imm_address() }));
  754. }
  755. void SoftCPU::MOV_RM16_imm16(const X86::Instruction& insn)
  756. {
  757. insn.modrm().write16(*this, insn, insn.imm16());
  758. }
  759. void SoftCPU::MOV_RM16_reg16(const X86::Instruction& insn)
  760. {
  761. insn.modrm().write16(*this, insn, gpr16(insn.reg16()));
  762. }
  763. void SoftCPU::MOV_RM16_seg(const X86::Instruction&) { TODO(); }
  764. void SoftCPU::MOV_RM32_imm32(const X86::Instruction& insn)
  765. {
  766. insn.modrm().write32(*this, insn, insn.imm32());
  767. }
  768. void SoftCPU::MOV_RM32_reg32(const X86::Instruction& insn)
  769. {
  770. insn.modrm().write32(*this, insn, gpr32(insn.reg32()));
  771. }
  772. void SoftCPU::MOV_RM8_imm8(const X86::Instruction& insn)
  773. {
  774. insn.modrm().write8(*this, insn, insn.imm8());
  775. }
  776. void SoftCPU::MOV_RM8_reg8(const X86::Instruction& insn)
  777. {
  778. insn.modrm().write8(*this, insn, insn.modrm().read8(*this, insn));
  779. }
  780. void SoftCPU::MOV_moff16_AX(const X86::Instruction&) { TODO(); }
  781. void SoftCPU::MOV_moff32_EAX(const X86::Instruction&) { TODO(); }
  782. void SoftCPU::MOV_moff8_AL(const X86::Instruction&) { TODO(); }
  783. void SoftCPU::MOV_reg16_RM16(const X86::Instruction& insn)
  784. {
  785. gpr16(insn.reg16()) = insn.modrm().read16(*this, insn);
  786. }
  787. void SoftCPU::MOV_reg16_imm16(const X86::Instruction& insn)
  788. {
  789. gpr16(insn.reg16()) = insn.imm16();
  790. }
  791. void SoftCPU::MOV_reg32_CR(const X86::Instruction&) { TODO(); }
  792. void SoftCPU::MOV_reg32_DR(const X86::Instruction&) { TODO(); }
  793. void SoftCPU::MOV_reg32_RM32(const X86::Instruction& insn)
  794. {
  795. gpr32(insn.reg32()) = insn.modrm().read32(*this, insn);
  796. }
  797. void SoftCPU::MOV_reg32_imm32(const X86::Instruction& insn)
  798. {
  799. gpr32(insn.reg32()) = insn.imm32();
  800. }
  801. void SoftCPU::MOV_reg8_RM8(const X86::Instruction& insn)
  802. {
  803. gpr8(insn.reg8()) = insn.modrm().read8(*this, insn);
  804. }
  805. void SoftCPU::MOV_reg8_imm8(const X86::Instruction& insn)
  806. {
  807. gpr8(insn.reg8()) = insn.imm8();
  808. }
  809. void SoftCPU::MOV_seg_RM16(const X86::Instruction&) { TODO(); }
  810. void SoftCPU::MOV_seg_RM32(const X86::Instruction&) { TODO(); }
  811. void SoftCPU::MUL_RM16(const X86::Instruction&) { TODO(); }
  812. void SoftCPU::MUL_RM32(const X86::Instruction&) { TODO(); }
  813. void SoftCPU::MUL_RM8(const X86::Instruction&) { TODO(); }
  814. void SoftCPU::NEG_RM16(const X86::Instruction&) { TODO(); }
  815. void SoftCPU::NEG_RM32(const X86::Instruction&) { TODO(); }
  816. void SoftCPU::NEG_RM8(const X86::Instruction&) { TODO(); }
  817. void SoftCPU::NOP(const X86::Instruction&) { TODO(); }
  818. void SoftCPU::NOT_RM16(const X86::Instruction&) { TODO(); }
  819. void SoftCPU::NOT_RM32(const X86::Instruction&) { TODO(); }
  820. void SoftCPU::NOT_RM8(const X86::Instruction&) { TODO(); }
  821. void SoftCPU::OUTSB(const X86::Instruction&) { TODO(); }
  822. void SoftCPU::OUTSD(const X86::Instruction&) { TODO(); }
  823. void SoftCPU::OUTSW(const X86::Instruction&) { TODO(); }
  824. void SoftCPU::OUT_DX_AL(const X86::Instruction&) { TODO(); }
  825. void SoftCPU::OUT_DX_AX(const X86::Instruction&) { TODO(); }
  826. void SoftCPU::OUT_DX_EAX(const X86::Instruction&) { TODO(); }
  827. void SoftCPU::OUT_imm8_AL(const X86::Instruction&) { TODO(); }
  828. void SoftCPU::OUT_imm8_AX(const X86::Instruction&) { TODO(); }
  829. void SoftCPU::OUT_imm8_EAX(const X86::Instruction&) { TODO(); }
  830. void SoftCPU::PADDB_mm1_mm2m64(const X86::Instruction&) { TODO(); }
  831. void SoftCPU::PADDW_mm1_mm2m64(const X86::Instruction&) { TODO(); }
  832. void SoftCPU::PADDD_mm1_mm2m64(const X86::Instruction&) { TODO(); }
  833. void SoftCPU::POPA(const X86::Instruction&) { TODO(); }
  834. void SoftCPU::POPAD(const X86::Instruction&) { TODO(); }
  835. void SoftCPU::POPF(const X86::Instruction&) { TODO(); }
  836. void SoftCPU::POPFD(const X86::Instruction&) { TODO(); }
  837. void SoftCPU::POP_DS(const X86::Instruction&) { TODO(); }
  838. void SoftCPU::POP_ES(const X86::Instruction&) { TODO(); }
  839. void SoftCPU::POP_FS(const X86::Instruction&) { TODO(); }
  840. void SoftCPU::POP_GS(const X86::Instruction&) { TODO(); }
  841. void SoftCPU::POP_RM16(const X86::Instruction&) { TODO(); }
  842. void SoftCPU::POP_RM32(const X86::Instruction&) { TODO(); }
  843. void SoftCPU::POP_SS(const X86::Instruction&) { TODO(); }
  844. void SoftCPU::POP_reg16(const X86::Instruction&) { TODO(); }
  845. void SoftCPU::POP_reg32(const X86::Instruction& insn)
  846. {
  847. gpr32(insn.reg32()) = pop32();
  848. }
  849. void SoftCPU::PUSHA(const X86::Instruction&) { TODO(); }
  850. void SoftCPU::PUSHAD(const X86::Instruction&) { TODO(); }
  851. void SoftCPU::PUSHF(const X86::Instruction&) { TODO(); }
  852. void SoftCPU::PUSHFD(const X86::Instruction&) { TODO(); }
  853. void SoftCPU::PUSH_CS(const X86::Instruction&) { TODO(); }
  854. void SoftCPU::PUSH_DS(const X86::Instruction&) { TODO(); }
  855. void SoftCPU::PUSH_ES(const X86::Instruction&) { TODO(); }
  856. void SoftCPU::PUSH_FS(const X86::Instruction&) { TODO(); }
  857. void SoftCPU::PUSH_GS(const X86::Instruction&) { TODO(); }
  858. void SoftCPU::PUSH_RM16(const X86::Instruction&) { TODO(); }
  859. void SoftCPU::PUSH_RM32(const X86::Instruction& insn)
  860. {
  861. push32(insn.modrm().read32(*this, insn));
  862. }
  863. void SoftCPU::PUSH_SP_8086_80186(const X86::Instruction&) { TODO(); }
  864. void SoftCPU::PUSH_SS(const X86::Instruction&) { TODO(); }
  865. void SoftCPU::PUSH_imm16(const X86::Instruction&) { TODO(); }
  866. void SoftCPU::PUSH_imm32(const X86::Instruction& insn)
  867. {
  868. push32(insn.imm32());
  869. }
  870. void SoftCPU::PUSH_imm8(const X86::Instruction& insn)
  871. {
  872. ASSERT(!insn.has_operand_size_override_prefix());
  873. push32((i32)insn.imm8());
  874. }
  875. void SoftCPU::PUSH_reg16(const X86::Instruction&) { TODO(); }
  876. void SoftCPU::PUSH_reg32(const X86::Instruction& insn)
  877. {
  878. push32(gpr32(insn.reg32()));
  879. }
  880. void SoftCPU::RCL_RM16_1(const X86::Instruction&) { TODO(); }
  881. void SoftCPU::RCL_RM16_CL(const X86::Instruction&) { TODO(); }
  882. void SoftCPU::RCL_RM16_imm8(const X86::Instruction&) { TODO(); }
  883. void SoftCPU::RCL_RM32_1(const X86::Instruction&) { TODO(); }
  884. void SoftCPU::RCL_RM32_CL(const X86::Instruction&) { TODO(); }
  885. void SoftCPU::RCL_RM32_imm8(const X86::Instruction&) { TODO(); }
  886. void SoftCPU::RCL_RM8_1(const X86::Instruction&) { TODO(); }
  887. void SoftCPU::RCL_RM8_CL(const X86::Instruction&) { TODO(); }
  888. void SoftCPU::RCL_RM8_imm8(const X86::Instruction&) { TODO(); }
  889. void SoftCPU::RCR_RM16_1(const X86::Instruction&) { TODO(); }
  890. void SoftCPU::RCR_RM16_CL(const X86::Instruction&) { TODO(); }
  891. void SoftCPU::RCR_RM16_imm8(const X86::Instruction&) { TODO(); }
  892. void SoftCPU::RCR_RM32_1(const X86::Instruction&) { TODO(); }
  893. void SoftCPU::RCR_RM32_CL(const X86::Instruction&) { TODO(); }
  894. void SoftCPU::RCR_RM32_imm8(const X86::Instruction&) { TODO(); }
  895. void SoftCPU::RCR_RM8_1(const X86::Instruction&) { TODO(); }
  896. void SoftCPU::RCR_RM8_CL(const X86::Instruction&) { TODO(); }
  897. void SoftCPU::RCR_RM8_imm8(const X86::Instruction&) { TODO(); }
  898. void SoftCPU::RDTSC(const X86::Instruction&) { TODO(); }
  899. void SoftCPU::RET(const X86::Instruction& insn)
  900. {
  901. ASSERT(!insn.has_operand_size_override_prefix());
  902. set_eip(pop32());
  903. }
  904. void SoftCPU::RETF(const X86::Instruction&) { TODO(); }
  905. void SoftCPU::RETF_imm16(const X86::Instruction&) { TODO(); }
  906. void SoftCPU::RET_imm16(const X86::Instruction& insn)
  907. {
  908. ASSERT(!insn.has_operand_size_override_prefix());
  909. set_eip(pop32());
  910. set_esp(esp() + insn.imm16());
  911. }
  912. void SoftCPU::ROL_RM16_1(const X86::Instruction&) { TODO(); }
  913. void SoftCPU::ROL_RM16_CL(const X86::Instruction&) { TODO(); }
  914. void SoftCPU::ROL_RM16_imm8(const X86::Instruction&) { TODO(); }
  915. void SoftCPU::ROL_RM32_1(const X86::Instruction&) { TODO(); }
  916. void SoftCPU::ROL_RM32_CL(const X86::Instruction&) { TODO(); }
  917. void SoftCPU::ROL_RM32_imm8(const X86::Instruction&) { TODO(); }
  918. void SoftCPU::ROL_RM8_1(const X86::Instruction&) { TODO(); }
  919. void SoftCPU::ROL_RM8_CL(const X86::Instruction&) { TODO(); }
  920. void SoftCPU::ROL_RM8_imm8(const X86::Instruction&) { TODO(); }
  921. void SoftCPU::ROR_RM16_1(const X86::Instruction&) { TODO(); }
  922. void SoftCPU::ROR_RM16_CL(const X86::Instruction&) { TODO(); }
  923. void SoftCPU::ROR_RM16_imm8(const X86::Instruction&) { TODO(); }
  924. void SoftCPU::ROR_RM32_1(const X86::Instruction&) { TODO(); }
  925. void SoftCPU::ROR_RM32_CL(const X86::Instruction&) { TODO(); }
  926. void SoftCPU::ROR_RM32_imm8(const X86::Instruction&) { TODO(); }
  927. void SoftCPU::ROR_RM8_1(const X86::Instruction&) { TODO(); }
  928. void SoftCPU::ROR_RM8_CL(const X86::Instruction&) { TODO(); }
  929. void SoftCPU::ROR_RM8_imm8(const X86::Instruction&) { TODO(); }
  930. void SoftCPU::SAHF(const X86::Instruction&) { TODO(); }
  931. void SoftCPU::SALC(const X86::Instruction&) { TODO(); }
  932. template<typename T>
  933. static T op_sar(SoftCPU& cpu, T data, u8 steps)
  934. {
  935. if (steps == 0)
  936. return data;
  937. u32 result = 0;
  938. u32 new_flags = 0;
  939. if constexpr (sizeof(T) == 4)
  940. asm volatile("sarl %%cl, %%eax\n" ::"a"(data), "c"(steps));
  941. else if constexpr (sizeof(T) == 2)
  942. asm volatile("sarw %%cl, %%ax\n" ::"a"(data), "c"(steps));
  943. else if constexpr (sizeof(T) == 1)
  944. asm volatile("sarb %%cl, %%al\n" ::"a"(data), "c"(steps));
  945. asm volatile(
  946. "mov %%eax, %%ebx\n"
  947. : "=b"(result));
  948. asm volatile(
  949. "pushf\n"
  950. "pop %%eax"
  951. : "=a"(new_flags));
  952. cpu.set_flags_oszapc(new_flags);
  953. return result;
  954. }
  955. void SoftCPU::SAR_RM16_1(const X86::Instruction& insn)
  956. {
  957. auto data = insn.modrm().read16(*this, insn);
  958. insn.modrm().write16(*this, insn, op_sar(*this, data, 1));
  959. }
  960. void SoftCPU::SAR_RM16_CL(const X86::Instruction& insn)
  961. {
  962. auto data = insn.modrm().read16(*this, insn);
  963. insn.modrm().write16(*this, insn, op_sar(*this, data, cl()));
  964. }
  965. void SoftCPU::SAR_RM16_imm8(const X86::Instruction& insn)
  966. {
  967. auto data = insn.modrm().read16(*this, insn);
  968. insn.modrm().write16(*this, insn, op_sar(*this, data, insn.imm8()));
  969. }
  970. void SoftCPU::SAR_RM32_1(const X86::Instruction& insn)
  971. {
  972. auto data = insn.modrm().read32(*this, insn);
  973. insn.modrm().write32(*this, insn, op_sar(*this, data, 1));
  974. }
  975. void SoftCPU::SAR_RM32_CL(const X86::Instruction& insn)
  976. {
  977. auto data = insn.modrm().read32(*this, insn);
  978. insn.modrm().write32(*this, insn, op_sar(*this, data, cl()));
  979. }
  980. void SoftCPU::SAR_RM32_imm8(const X86::Instruction& insn)
  981. {
  982. auto data = insn.modrm().read32(*this, insn);
  983. insn.modrm().write32(*this, insn, op_sar(*this, data, insn.imm8()));
  984. }
  985. void SoftCPU::SAR_RM8_1(const X86::Instruction& insn)
  986. {
  987. auto data = insn.modrm().read8(*this, insn);
  988. insn.modrm().write8(*this, insn, op_sar(*this, data, 1));
  989. }
  990. void SoftCPU::SAR_RM8_CL(const X86::Instruction& insn)
  991. {
  992. auto data = insn.modrm().read8(*this, insn);
  993. insn.modrm().write8(*this, insn, op_sar(*this, data, cl()));
  994. }
  995. void SoftCPU::SAR_RM8_imm8(const X86::Instruction& insn)
  996. {
  997. auto data = insn.modrm().read8(*this, insn);
  998. insn.modrm().write8(*this, insn, op_sar(*this, data, insn.imm8()));
  999. }
  1000. void SoftCPU::SBB_AL_imm8(const X86::Instruction&) { TODO(); }
  1001. void SoftCPU::SBB_AX_imm16(const X86::Instruction&) { TODO(); }
  1002. void SoftCPU::SBB_EAX_imm32(const X86::Instruction&) { TODO(); }
  1003. void SoftCPU::SBB_RM16_imm16(const X86::Instruction&) { TODO(); }
  1004. void SoftCPU::SBB_RM16_imm8(const X86::Instruction&) { TODO(); }
  1005. void SoftCPU::SBB_RM16_reg16(const X86::Instruction&) { TODO(); }
  1006. void SoftCPU::SBB_RM32_imm32(const X86::Instruction&) { TODO(); }
  1007. void SoftCPU::SBB_RM32_imm8(const X86::Instruction&) { TODO(); }
  1008. void SoftCPU::SBB_RM32_reg32(const X86::Instruction&) { TODO(); }
  1009. void SoftCPU::SBB_RM8_imm8(const X86::Instruction&) { TODO(); }
  1010. void SoftCPU::SBB_RM8_reg8(const X86::Instruction&) { TODO(); }
  1011. void SoftCPU::SBB_reg16_RM16(const X86::Instruction&) { TODO(); }
  1012. void SoftCPU::SBB_reg32_RM32(const X86::Instruction&) { TODO(); }
  1013. void SoftCPU::SBB_reg8_RM8(const X86::Instruction&) { TODO(); }
  1014. void SoftCPU::SCASB(const X86::Instruction&) { TODO(); }
  1015. void SoftCPU::SCASD(const X86::Instruction&) { TODO(); }
  1016. void SoftCPU::SCASW(const X86::Instruction&) { TODO(); }
  1017. void SoftCPU::SETcc_RM8(const X86::Instruction&) { TODO(); }
  1018. void SoftCPU::SGDT(const X86::Instruction&) { TODO(); }
  1019. void SoftCPU::SHLD_RM16_reg16_CL(const X86::Instruction&) { TODO(); }
  1020. void SoftCPU::SHLD_RM16_reg16_imm8(const X86::Instruction&) { TODO(); }
  1021. void SoftCPU::SHLD_RM32_reg32_CL(const X86::Instruction&) { TODO(); }
  1022. void SoftCPU::SHLD_RM32_reg32_imm8(const X86::Instruction&) { TODO(); }
  1023. void SoftCPU::SHL_RM16_1(const X86::Instruction& insn)
  1024. {
  1025. auto data = insn.modrm().read16(*this, insn);
  1026. insn.modrm().write16(*this, insn, op_shl(*this, data, 1));
  1027. }
  1028. void SoftCPU::SHL_RM16_CL(const X86::Instruction& insn)
  1029. {
  1030. auto data = insn.modrm().read16(*this, insn);
  1031. insn.modrm().write16(*this, insn, op_shl(*this, data, cl()));
  1032. }
  1033. void SoftCPU::SHL_RM16_imm8(const X86::Instruction& insn)
  1034. {
  1035. auto data = insn.modrm().read16(*this, insn);
  1036. insn.modrm().write16(*this, insn, op_shl(*this, data, insn.imm8()));
  1037. }
  1038. void SoftCPU::SHL_RM32_1(const X86::Instruction& insn)
  1039. {
  1040. auto data = insn.modrm().read32(*this, insn);
  1041. insn.modrm().write32(*this, insn, op_shl(*this, data, 1));
  1042. }
  1043. void SoftCPU::SHL_RM32_CL(const X86::Instruction& insn)
  1044. {
  1045. auto data = insn.modrm().read32(*this, insn);
  1046. insn.modrm().write32(*this, insn, op_shl(*this, data, cl()));
  1047. }
  1048. void SoftCPU::SHL_RM32_imm8(const X86::Instruction& insn)
  1049. {
  1050. auto data = insn.modrm().read32(*this, insn);
  1051. insn.modrm().write32(*this, insn, op_shl(*this, data, insn.imm8()));
  1052. }
  1053. void SoftCPU::SHL_RM8_1(const X86::Instruction& insn)
  1054. {
  1055. auto data = insn.modrm().read8(*this, insn);
  1056. insn.modrm().write8(*this, insn, op_shl(*this, data, 1));
  1057. }
  1058. void SoftCPU::SHL_RM8_CL(const X86::Instruction& insn)
  1059. {
  1060. auto data = insn.modrm().read8(*this, insn);
  1061. insn.modrm().write8(*this, insn, op_shl(*this, data, cl()));
  1062. }
  1063. void SoftCPU::SHL_RM8_imm8(const X86::Instruction& insn)
  1064. {
  1065. auto data = insn.modrm().read8(*this, insn);
  1066. insn.modrm().write8(*this, insn, op_shl(*this, data, insn.imm8()));
  1067. }
  1068. void SoftCPU::SHRD_RM16_reg16_CL(const X86::Instruction&) { TODO(); }
  1069. void SoftCPU::SHRD_RM16_reg16_imm8(const X86::Instruction&) { TODO(); }
  1070. void SoftCPU::SHRD_RM32_reg32_CL(const X86::Instruction&) { TODO(); }
  1071. void SoftCPU::SHRD_RM32_reg32_imm8(const X86::Instruction&) { TODO(); }
  1072. void SoftCPU::SHR_RM16_1(const X86::Instruction& insn)
  1073. {
  1074. auto data = insn.modrm().read16(*this, insn);
  1075. insn.modrm().write16(*this, insn, op_shr(*this, data, 1));
  1076. }
  1077. void SoftCPU::SHR_RM16_CL(const X86::Instruction& insn)
  1078. {
  1079. auto data = insn.modrm().read16(*this, insn);
  1080. insn.modrm().write16(*this, insn, op_shr(*this, data, cl()));
  1081. }
  1082. void SoftCPU::SHR_RM16_imm8(const X86::Instruction& insn)
  1083. {
  1084. auto data = insn.modrm().read16(*this, insn);
  1085. insn.modrm().write16(*this, insn, op_shr(*this, data, insn.imm8()));
  1086. }
  1087. void SoftCPU::SHR_RM32_1(const X86::Instruction& insn)
  1088. {
  1089. auto data = insn.modrm().read32(*this, insn);
  1090. insn.modrm().write32(*this, insn, op_shr(*this, data, 1));
  1091. }
  1092. void SoftCPU::SHR_RM32_CL(const X86::Instruction& insn)
  1093. {
  1094. auto data = insn.modrm().read32(*this, insn);
  1095. insn.modrm().write32(*this, insn, op_shr(*this, data, cl()));
  1096. }
  1097. void SoftCPU::SHR_RM32_imm8(const X86::Instruction& insn)
  1098. {
  1099. auto data = insn.modrm().read32(*this, insn);
  1100. insn.modrm().write32(*this, insn, op_shr(*this, data, insn.imm8()));
  1101. }
  1102. void SoftCPU::SHR_RM8_1(const X86::Instruction& insn)
  1103. {
  1104. auto data = insn.modrm().read8(*this, insn);
  1105. insn.modrm().write8(*this, insn, op_shr(*this, data, 1));
  1106. }
  1107. void SoftCPU::SHR_RM8_CL(const X86::Instruction& insn)
  1108. {
  1109. auto data = insn.modrm().read8(*this, insn);
  1110. insn.modrm().write8(*this, insn, op_shr(*this, data, cl()));
  1111. }
  1112. void SoftCPU::SHR_RM8_imm8(const X86::Instruction& insn)
  1113. {
  1114. auto data = insn.modrm().read8(*this, insn);
  1115. insn.modrm().write8(*this, insn, op_shr(*this, data, insn.imm8()));
  1116. }
  1117. void SoftCPU::SIDT(const X86::Instruction&) { TODO(); }
  1118. void SoftCPU::SLDT_RM16(const X86::Instruction&) { TODO(); }
  1119. void SoftCPU::SMSW_RM16(const X86::Instruction&) { TODO(); }
  1120. void SoftCPU::STC(const X86::Instruction&) { TODO(); }
  1121. void SoftCPU::STD(const X86::Instruction&) { TODO(); }
  1122. void SoftCPU::STI(const X86::Instruction&) { TODO(); }
  1123. void SoftCPU::STOSB(const X86::Instruction& insn)
  1124. {
  1125. if (insn.has_address_size_override_prefix()) {
  1126. do_once_or_repeat<false>(insn, [&] {
  1127. write_memory8({ es(), di() }, al());
  1128. set_di(di() + (df() ? -1 : 1));
  1129. });
  1130. } else {
  1131. do_once_or_repeat<false>(insn, [&] {
  1132. write_memory8({ es(), edi() }, al());
  1133. set_edi(edi() + (df() ? -1 : 1));
  1134. });
  1135. }
  1136. }
  1137. void SoftCPU::STOSD(const X86::Instruction& insn)
  1138. {
  1139. if (insn.has_address_size_override_prefix()) {
  1140. do_once_or_repeat<false>(insn, [&] {
  1141. write_memory32({ es(), di() }, eax());
  1142. set_di(di() + (df() ? -4 : 4));
  1143. });
  1144. } else {
  1145. do_once_or_repeat<false>(insn, [&] {
  1146. write_memory32({ es(), edi() }, eax());
  1147. set_edi(edi() + (df() ? -4 : 4));
  1148. });
  1149. }
  1150. }
  1151. void SoftCPU::STOSW(const X86::Instruction& insn)
  1152. {
  1153. if (insn.has_address_size_override_prefix()) {
  1154. do_once_or_repeat<false>(insn, [&] {
  1155. write_memory16({ es(), di() }, ax());
  1156. set_di(di() + (df() ? -2 : 2));
  1157. });
  1158. } else {
  1159. do_once_or_repeat<false>(insn, [&] {
  1160. write_memory16({ es(), edi() }, ax());
  1161. set_edi(edi() + (df() ? -2 : 2));
  1162. });
  1163. }
  1164. }
  1165. void SoftCPU::STR_RM16(const X86::Instruction&) { TODO(); }
  1166. void SoftCPU::UD0(const X86::Instruction&) { TODO(); }
  1167. void SoftCPU::UD1(const X86::Instruction&) { TODO(); }
  1168. void SoftCPU::UD2(const X86::Instruction&) { TODO(); }
  1169. void SoftCPU::VERR_RM16(const X86::Instruction&) { TODO(); }
  1170. void SoftCPU::VERW_RM16(const X86::Instruction&) { TODO(); }
  1171. void SoftCPU::WAIT(const X86::Instruction&) { TODO(); }
  1172. void SoftCPU::WBINVD(const X86::Instruction&) { TODO(); }
  1173. void SoftCPU::XADD_RM16_reg16(const X86::Instruction&) { TODO(); }
  1174. void SoftCPU::XADD_RM32_reg32(const X86::Instruction&) { TODO(); }
  1175. void SoftCPU::XADD_RM8_reg8(const X86::Instruction&) { TODO(); }
  1176. void SoftCPU::XCHG_AX_reg16(const X86::Instruction&) { TODO(); }
  1177. void SoftCPU::XCHG_EAX_reg32(const X86::Instruction&) { TODO(); }
  1178. void SoftCPU::XCHG_reg16_RM16(const X86::Instruction&) { TODO(); }
  1179. void SoftCPU::XCHG_reg32_RM32(const X86::Instruction&) { TODO(); }
  1180. void SoftCPU::XCHG_reg8_RM8(const X86::Instruction&) { TODO(); }
  1181. void SoftCPU::XLAT(const X86::Instruction&) { TODO(); }
  1182. #define DEFINE_GENERIC_INSN_HANDLERS_PARTIAL(mnemonic, op, update_dest) \
  1183. void SoftCPU::mnemonic##_AL_imm8(const X86::Instruction& insn) { generic_AL_imm8<update_dest>(op<u8>, insn); } \
  1184. void SoftCPU::mnemonic##_AX_imm16(const X86::Instruction& insn) { generic_AX_imm16<update_dest>(op<u16>, insn); } \
  1185. void SoftCPU::mnemonic##_EAX_imm32(const X86::Instruction& insn) { generic_EAX_imm32<update_dest>(op<u32>, insn); } \
  1186. void SoftCPU::mnemonic##_RM16_imm16(const X86::Instruction& insn) { generic_RM16_imm16<update_dest>(op<u16>, insn); } \
  1187. void SoftCPU::mnemonic##_RM16_reg16(const X86::Instruction& insn) { generic_RM16_reg16<update_dest>(op<u16>, insn); } \
  1188. void SoftCPU::mnemonic##_RM32_imm32(const X86::Instruction& insn) { generic_RM32_imm32<update_dest>(op<u32>, insn); } \
  1189. void SoftCPU::mnemonic##_RM32_reg32(const X86::Instruction& insn) { generic_RM32_reg32<update_dest>(op<u32>, insn); } \
  1190. void SoftCPU::mnemonic##_RM8_imm8(const X86::Instruction& insn) { generic_RM8_imm8<update_dest>(op<u8>, insn); } \
  1191. void SoftCPU::mnemonic##_RM8_reg8(const X86::Instruction& insn) { generic_RM8_reg8<update_dest>(op<u8>, insn); }
  1192. #define DEFINE_GENERIC_INSN_HANDLERS(mnemonic, op, update_dest) \
  1193. DEFINE_GENERIC_INSN_HANDLERS_PARTIAL(mnemonic, op, update_dest) \
  1194. void SoftCPU::mnemonic##_RM16_imm8(const X86::Instruction& insn) { generic_RM16_imm8<update_dest>(op<u16>, insn); } \
  1195. void SoftCPU::mnemonic##_RM32_imm8(const X86::Instruction& insn) { generic_RM32_imm8<update_dest>(op<u32>, insn); } \
  1196. void SoftCPU::mnemonic##_reg16_RM16(const X86::Instruction& insn) { generic_reg16_RM16<update_dest>(op<u16>, insn); } \
  1197. void SoftCPU::mnemonic##_reg32_RM32(const X86::Instruction& insn) { generic_reg32_RM32<update_dest>(op<u32>, insn); } \
  1198. void SoftCPU::mnemonic##_reg8_RM8(const X86::Instruction& insn) { generic_reg8_RM8<update_dest>(op<u8>, insn); }
  1199. DEFINE_GENERIC_INSN_HANDLERS(XOR, op_xor, true)
  1200. DEFINE_GENERIC_INSN_HANDLERS(OR, op_or, true)
  1201. DEFINE_GENERIC_INSN_HANDLERS(ADD, op_add, true)
  1202. DEFINE_GENERIC_INSN_HANDLERS(SUB, op_sub, true)
  1203. DEFINE_GENERIC_INSN_HANDLERS(AND, op_and, true)
  1204. DEFINE_GENERIC_INSN_HANDLERS(CMP, op_sub, false)
  1205. DEFINE_GENERIC_INSN_HANDLERS_PARTIAL(TEST, op_and, false)
  1206. void SoftCPU::MOVQ_mm1_mm2m64(const X86::Instruction&) { TODO(); }
  1207. void SoftCPU::EMMS(const X86::Instruction&) { TODO(); }
  1208. void SoftCPU::MOVQ_mm1_m64_mm2(const X86::Instruction&) { TODO(); }
  1209. void SoftCPU::wrap_0xC0(const X86::Instruction&) { TODO(); }
  1210. void SoftCPU::wrap_0xC1_16(const X86::Instruction&) { TODO(); }
  1211. void SoftCPU::wrap_0xC1_32(const X86::Instruction&) { TODO(); }
  1212. void SoftCPU::wrap_0xD0(const X86::Instruction&) { TODO(); }
  1213. void SoftCPU::wrap_0xD1_16(const X86::Instruction&) { TODO(); }
  1214. void SoftCPU::wrap_0xD1_32(const X86::Instruction&) { TODO(); }
  1215. void SoftCPU::wrap_0xD2(const X86::Instruction&) { TODO(); }
  1216. void SoftCPU::wrap_0xD3_16(const X86::Instruction&) { TODO(); }
  1217. void SoftCPU::wrap_0xD3_32(const X86::Instruction&) { TODO(); }
  1218. }