Mirror of CollapseOS
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

8805 line
147KB

  1. // Generated by libz80
  2. static void ADC_A_off_HL (Z80Context* ctx)
  3. {
  4. BR.A = doArithmetic(ctx, read8(ctx, WR.HL), F1_ADC, F2_ADC);
  5. }
  6. static void ADC_A_off_IX_d (Z80Context* ctx)
  7. {
  8. ctx->tstates += 5;
  9. signed char displacement = read8(ctx, ctx->PC++);
  10. BR.A = doArithmetic(ctx, read8(ctx, WR.IX + displacement), F1_ADC, F2_ADC);
  11. }
  12. static void ADC_A_off_IY_d (Z80Context* ctx)
  13. {
  14. ctx->tstates += 5;
  15. signed char displacement = read8(ctx, ctx->PC++);
  16. BR.A = doArithmetic(ctx, read8(ctx, WR.IY + displacement), F1_ADC, F2_ADC);
  17. }
  18. static void ADC_A_A (Z80Context* ctx)
  19. {
  20. BR.A = doArithmetic(ctx, BR.A, F1_ADC, F2_ADC);
  21. }
  22. static void ADC_A_B (Z80Context* ctx)
  23. {
  24. BR.A = doArithmetic(ctx, BR.B, F1_ADC, F2_ADC);
  25. }
  26. static void ADC_A_C (Z80Context* ctx)
  27. {
  28. BR.A = doArithmetic(ctx, BR.C, F1_ADC, F2_ADC);
  29. }
  30. static void ADC_A_D (Z80Context* ctx)
  31. {
  32. BR.A = doArithmetic(ctx, BR.D, F1_ADC, F2_ADC);
  33. }
  34. static void ADC_A_E (Z80Context* ctx)
  35. {
  36. BR.A = doArithmetic(ctx, BR.E, F1_ADC, F2_ADC);
  37. }
  38. static void ADC_A_H (Z80Context* ctx)
  39. {
  40. BR.A = doArithmetic(ctx, BR.H, F1_ADC, F2_ADC);
  41. }
  42. static void ADC_A_IXh (Z80Context* ctx)
  43. {
  44. BR.A = doArithmetic(ctx, BR.IXh, F1_ADC, F2_ADC);
  45. }
  46. static void ADC_A_IXl (Z80Context* ctx)
  47. {
  48. BR.A = doArithmetic(ctx, BR.IXl, F1_ADC, F2_ADC);
  49. }
  50. static void ADC_A_IYh (Z80Context* ctx)
  51. {
  52. BR.A = doArithmetic(ctx, BR.IYh, F1_ADC, F2_ADC);
  53. }
  54. static void ADC_A_IYl (Z80Context* ctx)
  55. {
  56. BR.A = doArithmetic(ctx, BR.IYl, F1_ADC, F2_ADC);
  57. }
  58. static void ADC_A_L (Z80Context* ctx)
  59. {
  60. BR.A = doArithmetic(ctx, BR.L, F1_ADC, F2_ADC);
  61. }
  62. static void ADC_A_n (Z80Context* ctx)
  63. {
  64. BR.A = doArithmetic(ctx, read8(ctx, ctx->PC++), F1_ADC, F2_ADC);
  65. }
  66. static void ADC_HL_BC (Z80Context* ctx)
  67. {
  68. ctx->tstates += 7;
  69. WR.HL = doAddWord(ctx, WR.HL, WR.BC, F1_ADC, F2_ADC);
  70. }
  71. static void ADC_HL_DE (Z80Context* ctx)
  72. {
  73. ctx->tstates += 7;
  74. WR.HL = doAddWord(ctx, WR.HL, WR.DE, F1_ADC, F2_ADC);
  75. }
  76. static void ADC_HL_HL (Z80Context* ctx)
  77. {
  78. ctx->tstates += 7;
  79. WR.HL = doAddWord(ctx, WR.HL, WR.HL, F1_ADC, F2_ADC);
  80. }
  81. static void ADC_HL_SP (Z80Context* ctx)
  82. {
  83. ctx->tstates += 7;
  84. WR.HL = doAddWord(ctx, WR.HL, WR.SP, F1_ADC, F2_ADC);
  85. }
  86. static void ADD_A_off_HL (Z80Context* ctx)
  87. {
  88. BR.A = doArithmetic(ctx, read8(ctx, WR.HL), F1_ADD, F2_ADD);
  89. }
  90. static void ADD_A_off_IX_d (Z80Context* ctx)
  91. {
  92. ctx->tstates += 5;
  93. signed char displacement = read8(ctx, ctx->PC++);
  94. BR.A = doArithmetic(ctx, read8(ctx, WR.IX + displacement), F1_ADD, F2_ADD);
  95. }
  96. static void ADD_A_off_IY_d (Z80Context* ctx)
  97. {
  98. ctx->tstates += 5;
  99. signed char displacement = read8(ctx, ctx->PC++);
  100. BR.A = doArithmetic(ctx, read8(ctx, WR.IY + displacement), F1_ADD, F2_ADD);
  101. }
  102. static void ADD_A_A (Z80Context* ctx)
  103. {
  104. BR.A = doArithmetic(ctx, BR.A, F1_ADD, F2_ADD);
  105. }
  106. static void ADD_A_B (Z80Context* ctx)
  107. {
  108. BR.A = doArithmetic(ctx, BR.B, F1_ADD, F2_ADD);
  109. }
  110. static void ADD_A_C (Z80Context* ctx)
  111. {
  112. BR.A = doArithmetic(ctx, BR.C, F1_ADD, F2_ADD);
  113. }
  114. static void ADD_A_D (Z80Context* ctx)
  115. {
  116. BR.A = doArithmetic(ctx, BR.D, F1_ADD, F2_ADD);
  117. }
  118. static void ADD_A_E (Z80Context* ctx)
  119. {
  120. BR.A = doArithmetic(ctx, BR.E, F1_ADD, F2_ADD);
  121. }
  122. static void ADD_A_H (Z80Context* ctx)
  123. {
  124. BR.A = doArithmetic(ctx, BR.H, F1_ADD, F2_ADD);
  125. }
  126. static void ADD_A_IXh (Z80Context* ctx)
  127. {
  128. BR.A = doArithmetic(ctx, BR.IXh, F1_ADD, F2_ADD);
  129. }
  130. static void ADD_A_IXl (Z80Context* ctx)
  131. {
  132. BR.A = doArithmetic(ctx, BR.IXl, F1_ADD, F2_ADD);
  133. }
  134. static void ADD_A_IYh (Z80Context* ctx)
  135. {
  136. BR.A = doArithmetic(ctx, BR.IYh, F1_ADD, F2_ADD);
  137. }
  138. static void ADD_A_IYl (Z80Context* ctx)
  139. {
  140. BR.A = doArithmetic(ctx, BR.IYl, F1_ADD, F2_ADD);
  141. }
  142. static void ADD_A_L (Z80Context* ctx)
  143. {
  144. BR.A = doArithmetic(ctx, BR.L, F1_ADD, F2_ADD);
  145. }
  146. static void ADD_A_n (Z80Context* ctx)
  147. {
  148. BR.A = doArithmetic(ctx, read8(ctx, ctx->PC++), F1_ADD, F2_ADD);
  149. }
  150. static void ADD_HL_BC (Z80Context* ctx)
  151. {
  152. ctx->tstates += 7;
  153. WR.HL = doAddWord(ctx, WR.HL, WR.BC, F1_ADD, F2_ADD);
  154. }
  155. static void ADD_HL_DE (Z80Context* ctx)
  156. {
  157. ctx->tstates += 7;
  158. WR.HL = doAddWord(ctx, WR.HL, WR.DE, F1_ADD, F2_ADD);
  159. }
  160. static void ADD_HL_HL (Z80Context* ctx)
  161. {
  162. ctx->tstates += 7;
  163. WR.HL = doAddWord(ctx, WR.HL, WR.HL, F1_ADD, F2_ADD);
  164. }
  165. static void ADD_HL_SP (Z80Context* ctx)
  166. {
  167. ctx->tstates += 7;
  168. WR.HL = doAddWord(ctx, WR.HL, WR.SP, F1_ADD, F2_ADD);
  169. }
  170. static void ADD_IX_BC (Z80Context* ctx)
  171. {
  172. ctx->tstates += 7;
  173. WR.IX = doAddWord(ctx, WR.IX, WR.BC, 0, 0);
  174. }
  175. static void ADD_IX_DE (Z80Context* ctx)
  176. {
  177. ctx->tstates += 7;
  178. WR.IX = doAddWord(ctx, WR.IX, WR.DE, 0, 0);
  179. }
  180. static void ADD_IX_IX (Z80Context* ctx)
  181. {
  182. ctx->tstates += 7;
  183. WR.IX = doAddWord(ctx, WR.IX, WR.IX, 0, 0);
  184. }
  185. static void ADD_IX_SP (Z80Context* ctx)
  186. {
  187. ctx->tstates += 7;
  188. WR.IX = doAddWord(ctx, WR.IX, WR.SP, 0, 0);
  189. }
  190. static void ADD_IY_BC (Z80Context* ctx)
  191. {
  192. ctx->tstates += 7;
  193. WR.IY = doAddWord(ctx, WR.IY, WR.BC, 0, 0);
  194. }
  195. static void ADD_IY_DE (Z80Context* ctx)
  196. {
  197. ctx->tstates += 7;
  198. WR.IY = doAddWord(ctx, WR.IY, WR.DE, 0, 0);
  199. }
  200. static void ADD_IY_IY (Z80Context* ctx)
  201. {
  202. ctx->tstates += 7;
  203. WR.IY = doAddWord(ctx, WR.IY, WR.IY, 0, 0);
  204. }
  205. static void ADD_IY_SP (Z80Context* ctx)
  206. {
  207. ctx->tstates += 7;
  208. WR.IY = doAddWord(ctx, WR.IY, WR.SP, 0, 0);
  209. }
  210. static void AND_off_HL (Z80Context* ctx)
  211. {
  212. doAND(ctx, read8(ctx, WR.HL));
  213. }
  214. static void AND_off_IX_d (Z80Context* ctx)
  215. {
  216. ctx->tstates += 5;
  217. doAND(ctx, read8(ctx, WR.IX + (signed char) read8(ctx, ctx->PC++)));
  218. }
  219. static void AND_off_IY_d (Z80Context* ctx)
  220. {
  221. ctx->tstates += 5;
  222. doAND(ctx, read8(ctx, WR.IY + (signed char) read8(ctx, ctx->PC++)));
  223. }
  224. static void AND_A (Z80Context* ctx)
  225. {
  226. doAND(ctx, BR.A);
  227. }
  228. static void AND_B (Z80Context* ctx)
  229. {
  230. doAND(ctx, BR.B);
  231. }
  232. static void AND_C (Z80Context* ctx)
  233. {
  234. doAND(ctx, BR.C);
  235. }
  236. static void AND_D (Z80Context* ctx)
  237. {
  238. doAND(ctx, BR.D);
  239. }
  240. static void AND_E (Z80Context* ctx)
  241. {
  242. doAND(ctx, BR.E);
  243. }
  244. static void AND_H (Z80Context* ctx)
  245. {
  246. doAND(ctx, BR.H);
  247. }
  248. static void AND_IXh (Z80Context* ctx)
  249. {
  250. doAND(ctx, BR.IXh);
  251. }
  252. static void AND_IXl (Z80Context* ctx)
  253. {
  254. doAND(ctx, BR.IXl);
  255. }
  256. static void AND_IYh (Z80Context* ctx)
  257. {
  258. doAND(ctx, BR.IYh);
  259. }
  260. static void AND_IYl (Z80Context* ctx)
  261. {
  262. doAND(ctx, BR.IYl);
  263. }
  264. static void AND_L (Z80Context* ctx)
  265. {
  266. doAND(ctx, BR.L);
  267. }
  268. static void AND_n (Z80Context* ctx)
  269. {
  270. doAND(ctx, read8(ctx, ctx->PC++));
  271. }
  272. static void BIT_0_off_HL (Z80Context* ctx)
  273. {
  274. ctx->tstates += 1;
  275. doBIT_r(ctx, 0, read8(ctx, WR.HL));
  276. }
  277. static void BIT_0_off_IX_d (Z80Context* ctx)
  278. {
  279. ctx->tstates += 2;
  280. ushort address = WR.IX + (signed char) read8(ctx, ctx->PC++);
  281. doBIT_indexed(ctx, 0, address);
  282. }
  283. static void BIT_0_off_IY_d (Z80Context* ctx)
  284. {
  285. ctx->tstates += 2;
  286. ushort address = WR.IY + (signed char) read8(ctx, ctx->PC++);
  287. doBIT_indexed(ctx, 0, address);
  288. }
  289. static void BIT_0_A (Z80Context* ctx)
  290. {
  291. doBIT_r(ctx, 0, BR.A);
  292. }
  293. static void BIT_0_B (Z80Context* ctx)
  294. {
  295. doBIT_r(ctx, 0, BR.B);
  296. }
  297. static void BIT_0_C (Z80Context* ctx)
  298. {
  299. doBIT_r(ctx, 0, BR.C);
  300. }
  301. static void BIT_0_D (Z80Context* ctx)
  302. {
  303. doBIT_r(ctx, 0, BR.D);
  304. }
  305. static void BIT_0_E (Z80Context* ctx)
  306. {
  307. doBIT_r(ctx, 0, BR.E);
  308. }
  309. static void BIT_0_H (Z80Context* ctx)
  310. {
  311. doBIT_r(ctx, 0, BR.H);
  312. }
  313. static void BIT_0_L (Z80Context* ctx)
  314. {
  315. doBIT_r(ctx, 0, BR.L);
  316. }
  317. static void BIT_1_off_HL (Z80Context* ctx)
  318. {
  319. ctx->tstates += 1;
  320. doBIT_r(ctx, 1, read8(ctx, WR.HL));
  321. }
  322. static void BIT_1_off_IX_d (Z80Context* ctx)
  323. {
  324. ctx->tstates += 2;
  325. ushort address = WR.IX + (signed char) read8(ctx, ctx->PC++);
  326. doBIT_indexed(ctx, 1, address);
  327. }
  328. static void BIT_1_off_IY_d (Z80Context* ctx)
  329. {
  330. ctx->tstates += 2;
  331. ushort address = WR.IY + (signed char) read8(ctx, ctx->PC++);
  332. doBIT_indexed(ctx, 1, address);
  333. }
  334. static void BIT_1_A (Z80Context* ctx)
  335. {
  336. doBIT_r(ctx, 1, BR.A);
  337. }
  338. static void BIT_1_B (Z80Context* ctx)
  339. {
  340. doBIT_r(ctx, 1, BR.B);
  341. }
  342. static void BIT_1_C (Z80Context* ctx)
  343. {
  344. doBIT_r(ctx, 1, BR.C);
  345. }
  346. static void BIT_1_D (Z80Context* ctx)
  347. {
  348. doBIT_r(ctx, 1, BR.D);
  349. }
  350. static void BIT_1_E (Z80Context* ctx)
  351. {
  352. doBIT_r(ctx, 1, BR.E);
  353. }
  354. static void BIT_1_H (Z80Context* ctx)
  355. {
  356. doBIT_r(ctx, 1, BR.H);
  357. }
  358. static void BIT_1_L (Z80Context* ctx)
  359. {
  360. doBIT_r(ctx, 1, BR.L);
  361. }
  362. static void BIT_2_off_HL (Z80Context* ctx)
  363. {
  364. ctx->tstates += 1;
  365. doBIT_r(ctx, 2, read8(ctx, WR.HL));
  366. }
  367. static void BIT_2_off_IX_d (Z80Context* ctx)
  368. {
  369. ctx->tstates += 2;
  370. ushort address = WR.IX + (signed char) read8(ctx, ctx->PC++);
  371. doBIT_indexed(ctx, 2, address);
  372. }
  373. static void BIT_2_off_IY_d (Z80Context* ctx)
  374. {
  375. ctx->tstates += 2;
  376. ushort address = WR.IY + (signed char) read8(ctx, ctx->PC++);
  377. doBIT_indexed(ctx, 2, address);
  378. }
  379. static void BIT_2_A (Z80Context* ctx)
  380. {
  381. doBIT_r(ctx, 2, BR.A);
  382. }
  383. static void BIT_2_B (Z80Context* ctx)
  384. {
  385. doBIT_r(ctx, 2, BR.B);
  386. }
  387. static void BIT_2_C (Z80Context* ctx)
  388. {
  389. doBIT_r(ctx, 2, BR.C);
  390. }
  391. static void BIT_2_D (Z80Context* ctx)
  392. {
  393. doBIT_r(ctx, 2, BR.D);
  394. }
  395. static void BIT_2_E (Z80Context* ctx)
  396. {
  397. doBIT_r(ctx, 2, BR.E);
  398. }
  399. static void BIT_2_H (Z80Context* ctx)
  400. {
  401. doBIT_r(ctx, 2, BR.H);
  402. }
  403. static void BIT_2_L (Z80Context* ctx)
  404. {
  405. doBIT_r(ctx, 2, BR.L);
  406. }
  407. static void BIT_3_off_HL (Z80Context* ctx)
  408. {
  409. ctx->tstates += 1;
  410. doBIT_r(ctx, 3, read8(ctx, WR.HL));
  411. }
  412. static void BIT_3_off_IX_d (Z80Context* ctx)
  413. {
  414. ctx->tstates += 2;
  415. ushort address = WR.IX + (signed char) read8(ctx, ctx->PC++);
  416. doBIT_indexed(ctx, 3, address);
  417. }
  418. static void BIT_3_off_IY_d (Z80Context* ctx)
  419. {
  420. ctx->tstates += 2;
  421. ushort address = WR.IY + (signed char) read8(ctx, ctx->PC++);
  422. doBIT_indexed(ctx, 3, address);
  423. }
  424. static void BIT_3_A (Z80Context* ctx)
  425. {
  426. doBIT_r(ctx, 3, BR.A);
  427. }
  428. static void BIT_3_B (Z80Context* ctx)
  429. {
  430. doBIT_r(ctx, 3, BR.B);
  431. }
  432. static void BIT_3_C (Z80Context* ctx)
  433. {
  434. doBIT_r(ctx, 3, BR.C);
  435. }
  436. static void BIT_3_D (Z80Context* ctx)
  437. {
  438. doBIT_r(ctx, 3, BR.D);
  439. }
  440. static void BIT_3_E (Z80Context* ctx)
  441. {
  442. doBIT_r(ctx, 3, BR.E);
  443. }
  444. static void BIT_3_H (Z80Context* ctx)
  445. {
  446. doBIT_r(ctx, 3, BR.H);
  447. }
  448. static void BIT_3_L (Z80Context* ctx)
  449. {
  450. doBIT_r(ctx, 3, BR.L);
  451. }
  452. static void BIT_4_off_HL (Z80Context* ctx)
  453. {
  454. ctx->tstates += 1;
  455. doBIT_r(ctx, 4, read8(ctx, WR.HL));
  456. }
  457. static void BIT_4_off_IX_d (Z80Context* ctx)
  458. {
  459. ctx->tstates += 2;
  460. ushort address = WR.IX + (signed char) read8(ctx, ctx->PC++);
  461. doBIT_indexed(ctx, 4, address);
  462. }
  463. static void BIT_4_off_IY_d (Z80Context* ctx)
  464. {
  465. ctx->tstates += 2;
  466. ushort address = WR.IY + (signed char) read8(ctx, ctx->PC++);
  467. doBIT_indexed(ctx, 4, address);
  468. }
  469. static void BIT_4_A (Z80Context* ctx)
  470. {
  471. doBIT_r(ctx, 4, BR.A);
  472. }
  473. static void BIT_4_B (Z80Context* ctx)
  474. {
  475. doBIT_r(ctx, 4, BR.B);
  476. }
  477. static void BIT_4_C (Z80Context* ctx)
  478. {
  479. doBIT_r(ctx, 4, BR.C);
  480. }
  481. static void BIT_4_D (Z80Context* ctx)
  482. {
  483. doBIT_r(ctx, 4, BR.D);
  484. }
  485. static void BIT_4_E (Z80Context* ctx)
  486. {
  487. doBIT_r(ctx, 4, BR.E);
  488. }
  489. static void BIT_4_H (Z80Context* ctx)
  490. {
  491. doBIT_r(ctx, 4, BR.H);
  492. }
  493. static void BIT_4_L (Z80Context* ctx)
  494. {
  495. doBIT_r(ctx, 4, BR.L);
  496. }
  497. static void BIT_5_off_HL (Z80Context* ctx)
  498. {
  499. ctx->tstates += 1;
  500. doBIT_r(ctx, 5, read8(ctx, WR.HL));
  501. }
  502. static void BIT_5_off_IX_d (Z80Context* ctx)
  503. {
  504. ctx->tstates += 2;
  505. ushort address = WR.IX + (signed char) read8(ctx, ctx->PC++);
  506. doBIT_indexed(ctx, 5, address);
  507. }
  508. static void BIT_5_off_IY_d (Z80Context* ctx)
  509. {
  510. ctx->tstates += 2;
  511. ushort address = WR.IY + (signed char) read8(ctx, ctx->PC++);
  512. doBIT_indexed(ctx, 5, address);
  513. }
  514. static void BIT_5_A (Z80Context* ctx)
  515. {
  516. doBIT_r(ctx, 5, BR.A);
  517. }
  518. static void BIT_5_B (Z80Context* ctx)
  519. {
  520. doBIT_r(ctx, 5, BR.B);
  521. }
  522. static void BIT_5_C (Z80Context* ctx)
  523. {
  524. doBIT_r(ctx, 5, BR.C);
  525. }
  526. static void BIT_5_D (Z80Context* ctx)
  527. {
  528. doBIT_r(ctx, 5, BR.D);
  529. }
  530. static void BIT_5_E (Z80Context* ctx)
  531. {
  532. doBIT_r(ctx, 5, BR.E);
  533. }
  534. static void BIT_5_H (Z80Context* ctx)
  535. {
  536. doBIT_r(ctx, 5, BR.H);
  537. }
  538. static void BIT_5_L (Z80Context* ctx)
  539. {
  540. doBIT_r(ctx, 5, BR.L);
  541. }
  542. static void BIT_6_off_HL (Z80Context* ctx)
  543. {
  544. ctx->tstates += 1;
  545. doBIT_r(ctx, 6, read8(ctx, WR.HL));
  546. }
  547. static void BIT_6_off_IX_d (Z80Context* ctx)
  548. {
  549. ctx->tstates += 2;
  550. ushort address = WR.IX + (signed char) read8(ctx, ctx->PC++);
  551. doBIT_indexed(ctx, 6, address);
  552. }
  553. static void BIT_6_off_IY_d (Z80Context* ctx)
  554. {
  555. ctx->tstates += 2;
  556. ushort address = WR.IY + (signed char) read8(ctx, ctx->PC++);
  557. doBIT_indexed(ctx, 6, address);
  558. }
  559. static void BIT_6_A (Z80Context* ctx)
  560. {
  561. doBIT_r(ctx, 6, BR.A);
  562. }
  563. static void BIT_6_B (Z80Context* ctx)
  564. {
  565. doBIT_r(ctx, 6, BR.B);
  566. }
  567. static void BIT_6_C (Z80Context* ctx)
  568. {
  569. doBIT_r(ctx, 6, BR.C);
  570. }
  571. static void BIT_6_D (Z80Context* ctx)
  572. {
  573. doBIT_r(ctx, 6, BR.D);
  574. }
  575. static void BIT_6_E (Z80Context* ctx)
  576. {
  577. doBIT_r(ctx, 6, BR.E);
  578. }
  579. static void BIT_6_H (Z80Context* ctx)
  580. {
  581. doBIT_r(ctx, 6, BR.H);
  582. }
  583. static void BIT_6_L (Z80Context* ctx)
  584. {
  585. doBIT_r(ctx, 6, BR.L);
  586. }
  587. static void BIT_7_off_HL (Z80Context* ctx)
  588. {
  589. ctx->tstates += 1;
  590. doBIT_r(ctx, 7, read8(ctx, WR.HL));
  591. }
  592. static void BIT_7_off_IX_d (Z80Context* ctx)
  593. {
  594. ctx->tstates += 2;
  595. ushort address = WR.IX + (signed char) read8(ctx, ctx->PC++);
  596. doBIT_indexed(ctx, 7, address);
  597. }
  598. static void BIT_7_off_IY_d (Z80Context* ctx)
  599. {
  600. ctx->tstates += 2;
  601. ushort address = WR.IY + (signed char) read8(ctx, ctx->PC++);
  602. doBIT_indexed(ctx, 7, address);
  603. }
  604. static void BIT_7_A (Z80Context* ctx)
  605. {
  606. doBIT_r(ctx, 7, BR.A);
  607. }
  608. static void BIT_7_B (Z80Context* ctx)
  609. {
  610. doBIT_r(ctx, 7, BR.B);
  611. }
  612. static void BIT_7_C (Z80Context* ctx)
  613. {
  614. doBIT_r(ctx, 7, BR.C);
  615. }
  616. static void BIT_7_D (Z80Context* ctx)
  617. {
  618. doBIT_r(ctx, 7, BR.D);
  619. }
  620. static void BIT_7_E (Z80Context* ctx)
  621. {
  622. doBIT_r(ctx, 7, BR.E);
  623. }
  624. static void BIT_7_H (Z80Context* ctx)
  625. {
  626. doBIT_r(ctx, 7, BR.H);
  627. }
  628. static void BIT_7_L (Z80Context* ctx)
  629. {
  630. doBIT_r(ctx, 7, BR.L);
  631. }
  632. static void CALL_off_nn (Z80Context* ctx)
  633. {
  634. ushort addr = read16(ctx, ctx->PC);
  635. ctx->PC += 2;
  636. if (condition(ctx, C_))
  637. {
  638. ctx->tstates += 1;
  639. doPush(ctx, ctx->PC);
  640. ctx->PC = addr;
  641. }
  642. }
  643. static void CALL_C_off_nn (Z80Context* ctx)
  644. {
  645. ushort addr = read16(ctx, ctx->PC);
  646. ctx->PC += 2;
  647. if (condition(ctx, C_C))
  648. {
  649. ctx->tstates += 1;
  650. doPush(ctx, ctx->PC);
  651. ctx->PC = addr;
  652. }
  653. }
  654. static void CALL_M_off_nn (Z80Context* ctx)
  655. {
  656. ushort addr = read16(ctx, ctx->PC);
  657. ctx->PC += 2;
  658. if (condition(ctx, C_M))
  659. {
  660. ctx->tstates += 1;
  661. doPush(ctx, ctx->PC);
  662. ctx->PC = addr;
  663. }
  664. }
  665. static void CALL_NC_off_nn (Z80Context* ctx)
  666. {
  667. ushort addr = read16(ctx, ctx->PC);
  668. ctx->PC += 2;
  669. if (condition(ctx, C_NC))
  670. {
  671. ctx->tstates += 1;
  672. doPush(ctx, ctx->PC);
  673. ctx->PC = addr;
  674. }
  675. }
  676. static void CALL_NZ_off_nn (Z80Context* ctx)
  677. {
  678. ushort addr = read16(ctx, ctx->PC);
  679. ctx->PC += 2;
  680. if (condition(ctx, C_NZ))
  681. {
  682. ctx->tstates += 1;
  683. doPush(ctx, ctx->PC);
  684. ctx->PC = addr;
  685. }
  686. }
  687. static void CALL_P_off_nn (Z80Context* ctx)
  688. {
  689. ushort addr = read16(ctx, ctx->PC);
  690. ctx->PC += 2;
  691. if (condition(ctx, C_P))
  692. {
  693. ctx->tstates += 1;
  694. doPush(ctx, ctx->PC);
  695. ctx->PC = addr;
  696. }
  697. }
  698. static void CALL_PE_off_nn (Z80Context* ctx)
  699. {
  700. ushort addr = read16(ctx, ctx->PC);
  701. ctx->PC += 2;
  702. if (condition(ctx, C_PE))
  703. {
  704. ctx->tstates += 1;
  705. doPush(ctx, ctx->PC);
  706. ctx->PC = addr;
  707. }
  708. }
  709. static void CALL_PO_off_nn (Z80Context* ctx)
  710. {
  711. ushort addr = read16(ctx, ctx->PC);
  712. ctx->PC += 2;
  713. if (condition(ctx, C_PO))
  714. {
  715. ctx->tstates += 1;
  716. doPush(ctx, ctx->PC);
  717. ctx->PC = addr;
  718. }
  719. }
  720. static void CALL_Z_off_nn (Z80Context* ctx)
  721. {
  722. ushort addr = read16(ctx, ctx->PC);
  723. ctx->PC += 2;
  724. if (condition(ctx, C_Z))
  725. {
  726. ctx->tstates += 1;
  727. doPush(ctx, ctx->PC);
  728. ctx->PC = addr;
  729. }
  730. }
  731. static void CCF (Z80Context* ctx)
  732. {
  733. VALFLAG(F_C, (1 - (byte)GETFLAG(F_C) != 0));
  734. RESFLAG(F_N);
  735. adjustFlags(ctx, BR.A);
  736. }
  737. static void CP_off_HL (Z80Context* ctx)
  738. {
  739. doCP_HL(ctx);
  740. }
  741. static void CP_off_IX_d (Z80Context* ctx)
  742. {
  743. ctx->tstates += 5;
  744. signed char displacement = read8(ctx, ctx->PC++);
  745. byte val = read8(ctx, WR.IX + displacement);
  746. doArithmetic(ctx, val, 0, 1);
  747. adjustFlags(ctx, val);
  748. }
  749. static void CP_off_IY_d (Z80Context* ctx)
  750. {
  751. ctx->tstates += 5;
  752. signed char displacement = read8(ctx, ctx->PC++);
  753. byte val = read8(ctx, WR.IY + displacement);
  754. doArithmetic(ctx, val, 0, 1);
  755. adjustFlags(ctx, val);
  756. }
  757. static void CP_A (Z80Context* ctx)
  758. {
  759. doArithmetic(ctx, BR.A, 0, 1);
  760. adjustFlags(ctx, BR.A);
  761. }
  762. static void CP_B (Z80Context* ctx)
  763. {
  764. doArithmetic(ctx, BR.B, 0, 1);
  765. adjustFlags(ctx, BR.B);
  766. }
  767. static void CP_C (Z80Context* ctx)
  768. {
  769. doArithmetic(ctx, BR.C, 0, 1);
  770. adjustFlags(ctx, BR.C);
  771. }
  772. static void CP_D (Z80Context* ctx)
  773. {
  774. doArithmetic(ctx, BR.D, 0, 1);
  775. adjustFlags(ctx, BR.D);
  776. }
  777. static void CP_E (Z80Context* ctx)
  778. {
  779. doArithmetic(ctx, BR.E, 0, 1);
  780. adjustFlags(ctx, BR.E);
  781. }
  782. static void CP_H (Z80Context* ctx)
  783. {
  784. doArithmetic(ctx, BR.H, 0, 1);
  785. adjustFlags(ctx, BR.H);
  786. }
  787. static void CP_IXh (Z80Context* ctx)
  788. {
  789. doArithmetic(ctx, BR.IXh, 0, 1);
  790. adjustFlags(ctx, BR.IXh);
  791. }
  792. static void CP_IXl (Z80Context* ctx)
  793. {
  794. doArithmetic(ctx, BR.IXl, 0, 1);
  795. adjustFlags(ctx, BR.IXl);
  796. }
  797. static void CP_IYh (Z80Context* ctx)
  798. {
  799. doArithmetic(ctx, BR.IYh, 0, 1);
  800. adjustFlags(ctx, BR.IYh);
  801. }
  802. static void CP_IYl (Z80Context* ctx)
  803. {
  804. doArithmetic(ctx, BR.IYl, 0, 1);
  805. adjustFlags(ctx, BR.IYl);
  806. }
  807. static void CP_L (Z80Context* ctx)
  808. {
  809. doArithmetic(ctx, BR.L, 0, 1);
  810. adjustFlags(ctx, BR.L);
  811. }
  812. static void CP_n (Z80Context* ctx)
  813. {
  814. byte val = read8(ctx, ctx->PC++);
  815. doArithmetic(ctx, val, 0, 1);
  816. adjustFlags(ctx, val);
  817. }
  818. static void CPD (Z80Context* ctx)
  819. {
  820. ctx->tstates += 5;
  821. int carry = GETFLAG(F_C);
  822. byte value = doCP_HL(ctx);
  823. if(GETFLAG(F_H))
  824. value--;
  825. WR.HL--;
  826. WR.BC--;
  827. VALFLAG(F_PV, WR.BC != 0);
  828. if(carry)
  829. SETFLAG(F_C);
  830. else
  831. RESFLAG(F_C);
  832. VALFLAG(F_5, value & (1 << 1));
  833. VALFLAG(F_3, value & (1 << 3));
  834. }
  835. static void CPDR (Z80Context* ctx)
  836. {
  837. CPD(ctx);
  838. if (WR.BC != 0 && !GETFLAG(F_Z))
  839. {
  840. ctx->tstates += 5;
  841. ctx->PC -= 2;
  842. }
  843. }
  844. static void CPI (Z80Context* ctx)
  845. {
  846. ctx->tstates += 5;
  847. int carry = GETFLAG(F_C);
  848. byte value = doCP_HL(ctx);
  849. if(GETFLAG(F_H))
  850. value--;
  851. WR.HL++;
  852. WR.BC--;
  853. VALFLAG(F_PV, WR.BC != 0);
  854. VALFLAG(F_C, carry);
  855. VALFLAG(F_5, value & (1 << 2));
  856. VALFLAG(F_3, value & (1 << 3));
  857. }
  858. static void CPIR (Z80Context* ctx)
  859. {
  860. CPI(ctx);
  861. if (WR.BC != 0 && !GETFLAG(F_Z))
  862. {
  863. ctx->tstates += 5;
  864. ctx->PC -= 2;
  865. }
  866. }
  867. static void CPL (Z80Context* ctx)
  868. {
  869. BR.A = ~BR.A;
  870. SETFLAG(F_H | F_N);
  871. adjustFlags(ctx, BR.A);
  872. }
  873. static void DAA (Z80Context* ctx)
  874. {
  875. doDAA(ctx);
  876. }
  877. static void DEC_off_HL (Z80Context* ctx)
  878. {
  879. ctx->tstates += 1;
  880. byte value = read8(ctx, WR.HL);
  881. write8(ctx, WR.HL, doIncDec(ctx, value, ID_DEC));
  882. }
  883. static void DEC_off_IX_d (Z80Context* ctx)
  884. {
  885. ctx->tstates += 6;
  886. signed char off = read8(ctx, ctx->PC++);
  887. byte value = read8(ctx, WR.IX + off);
  888. write8(ctx, WR.IX + off, doIncDec(ctx, value, ID_DEC));
  889. }
  890. static void DEC_off_IY_d (Z80Context* ctx)
  891. {
  892. ctx->tstates += 6;
  893. signed char off = read8(ctx, ctx->PC++);
  894. byte value = read8(ctx, WR.IY + off);
  895. write8(ctx, WR.IY + off, doIncDec(ctx, value, ID_DEC));
  896. }
  897. static void DEC_A (Z80Context* ctx)
  898. {
  899. BR.A = doIncDec(ctx, BR.A, ID_DEC);
  900. }
  901. static void DEC_B (Z80Context* ctx)
  902. {
  903. BR.B = doIncDec(ctx, BR.B, ID_DEC);
  904. }
  905. static void DEC_BC (Z80Context* ctx)
  906. {
  907. ctx->tstates += 2;
  908. WR.BC--;
  909. }
  910. static void DEC_C (Z80Context* ctx)
  911. {
  912. BR.C = doIncDec(ctx, BR.C, ID_DEC);
  913. }
  914. static void DEC_D (Z80Context* ctx)
  915. {
  916. BR.D = doIncDec(ctx, BR.D, ID_DEC);
  917. }
  918. static void DEC_DE (Z80Context* ctx)
  919. {
  920. ctx->tstates += 2;
  921. WR.DE--;
  922. }
  923. static void DEC_E (Z80Context* ctx)
  924. {
  925. BR.E = doIncDec(ctx, BR.E, ID_DEC);
  926. }
  927. static void DEC_H (Z80Context* ctx)
  928. {
  929. BR.H = doIncDec(ctx, BR.H, ID_DEC);
  930. }
  931. static void DEC_HL (Z80Context* ctx)
  932. {
  933. ctx->tstates += 2;
  934. WR.HL--;
  935. }
  936. static void DEC_IX (Z80Context* ctx)
  937. {
  938. ctx->tstates += 2;
  939. WR.IX--;
  940. }
  941. static void DEC_IXh (Z80Context* ctx)
  942. {
  943. BR.IXh = doIncDec(ctx, BR.IXh, ID_DEC);
  944. }
  945. static void DEC_IXl (Z80Context* ctx)
  946. {
  947. BR.IXl = doIncDec(ctx, BR.IXl, ID_DEC);
  948. }
  949. static void DEC_IY (Z80Context* ctx)
  950. {
  951. ctx->tstates += 2;
  952. WR.IY--;
  953. }
  954. static void DEC_IYh (Z80Context* ctx)
  955. {
  956. BR.IYh = doIncDec(ctx, BR.IYh, ID_DEC);
  957. }
  958. static void DEC_IYl (Z80Context* ctx)
  959. {
  960. BR.IYl = doIncDec(ctx, BR.IYl, ID_DEC);
  961. }
  962. static void DEC_L (Z80Context* ctx)
  963. {
  964. BR.L = doIncDec(ctx, BR.L, ID_DEC);
  965. }
  966. static void DEC_SP (Z80Context* ctx)
  967. {
  968. ctx->tstates += 2;
  969. WR.SP--;
  970. }
  971. static void DI (Z80Context* ctx)
  972. {
  973. ctx->IFF1 = ctx->IFF2 = IE_DI;
  974. ctx->defer_int = 1;
  975. }
  976. static void DJNZ_off_PC_e (Z80Context* ctx)
  977. {
  978. ctx->tstates += 1;
  979. signed char off = read8(ctx, ctx->PC++);
  980. BR.B--;
  981. if (BR.B)
  982. {
  983. ctx->tstates += 5;
  984. ctx->PC += off;
  985. }
  986. }
  987. static void EI (Z80Context* ctx)
  988. {
  989. ctx->IFF1 = ctx->IFF2 = IE_EI;
  990. ctx->defer_int = 1;
  991. }
  992. static void EX_off_SP_HL (Z80Context* ctx)
  993. {
  994. ctx->tstates += 3;
  995. ushort tmp = read16(ctx, WR.SP);
  996. write16(ctx, WR.SP, WR.HL);
  997. WR.HL = tmp;
  998. }
  999. static void EX_off_SP_IX (Z80Context* ctx)
  1000. {
  1001. ctx->tstates += 3;
  1002. ushort tmp = read16(ctx, WR.SP);
  1003. write16(ctx, WR.SP, WR.IX);
  1004. WR.IX = tmp;
  1005. }
  1006. static void EX_off_SP_IY (Z80Context* ctx)
  1007. {
  1008. ctx->tstates += 3;
  1009. ushort tmp = read16(ctx, WR.SP);
  1010. write16(ctx, WR.SP, WR.IY);
  1011. WR.IY = tmp;
  1012. }
  1013. static void EX_AF_AF_ (Z80Context* ctx)
  1014. {
  1015. ushort tmp = ctx->R1.wr.AF;
  1016. ctx->R1.wr.AF = ctx->R2.wr.AF;
  1017. ctx->R2.wr.AF = tmp;
  1018. }
  1019. static void EX_DE_HL (Z80Context* ctx)
  1020. {
  1021. ushort tmp = WR.DE;
  1022. WR.DE = WR.HL;
  1023. WR.HL = tmp;
  1024. }
  1025. static void EXX (Z80Context* ctx)
  1026. {
  1027. ushort tmp;
  1028. tmp = ctx->R1.wr.BC;
  1029. ctx->R1.wr.BC = ctx->R2.wr.BC;
  1030. ctx->R2.wr.BC = tmp;
  1031. tmp = ctx->R1.wr.DE;
  1032. ctx->R1.wr.DE = ctx->R2.wr.DE;
  1033. ctx->R2.wr.DE = tmp;
  1034. tmp = ctx->R1.wr.HL;
  1035. ctx->R1.wr.HL = ctx->R2.wr.HL;
  1036. ctx->R2.wr.HL = tmp;
  1037. }
  1038. static void HALT (Z80Context* ctx)
  1039. {
  1040. ctx->halted = 1;
  1041. ctx->PC--;
  1042. }
  1043. static void IM_0 (Z80Context* ctx)
  1044. {
  1045. ctx->IM = 0;
  1046. }
  1047. static void IM_1 (Z80Context* ctx)
  1048. {
  1049. ctx->IM = 1;
  1050. }
  1051. static void IM_2 (Z80Context* ctx)
  1052. {
  1053. ctx->IM = 2;
  1054. }
  1055. static void IN_A_off_C (Z80Context* ctx)
  1056. {
  1057. BR.A = ioRead(ctx, WR.BC);
  1058. RESFLAG(F_H | F_N);
  1059. adjustFlagSZP(ctx, BR.A);
  1060. adjustFlags(ctx, BR.A);
  1061. }
  1062. static void IN_A_off_n (Z80Context* ctx)
  1063. {
  1064. byte port = read8(ctx, ctx->PC++);
  1065. BR.A = ioRead(ctx, BR.A << 8 | port);
  1066. }
  1067. static void IN_B_off_C (Z80Context* ctx)
  1068. {
  1069. BR.B = ioRead(ctx, WR.BC);
  1070. RESFLAG(F_H | F_N);
  1071. adjustFlagSZP(ctx, BR.B);
  1072. adjustFlags(ctx, BR.B);
  1073. }
  1074. static void IN_C_off_C (Z80Context* ctx)
  1075. {
  1076. BR.C = ioRead(ctx, WR.BC);
  1077. RESFLAG(F_H | F_N);
  1078. adjustFlagSZP(ctx, BR.C);
  1079. adjustFlags(ctx, BR.C);
  1080. }
  1081. static void IN_D_off_C (Z80Context* ctx)
  1082. {
  1083. BR.D = ioRead(ctx, WR.BC);
  1084. RESFLAG(F_H | F_N);
  1085. adjustFlagSZP(ctx, BR.D);
  1086. adjustFlags(ctx, BR.D);
  1087. }
  1088. static void IN_E_off_C (Z80Context* ctx)
  1089. {
  1090. BR.E = ioRead(ctx, WR.BC);
  1091. RESFLAG(F_H | F_N);
  1092. adjustFlagSZP(ctx, BR.E);
  1093. adjustFlags(ctx, BR.E);
  1094. }
  1095. static void IN_F_off_C (Z80Context* ctx)
  1096. {
  1097. BR.F = ioRead(ctx, WR.BC);
  1098. RESFLAG(F_H | F_N);
  1099. adjustFlagSZP(ctx, BR.F);
  1100. adjustFlags(ctx, BR.F);
  1101. }
  1102. static void IN_H_off_C (Z80Context* ctx)
  1103. {
  1104. BR.H = ioRead(ctx, WR.BC);
  1105. RESFLAG(F_H | F_N);
  1106. adjustFlagSZP(ctx, BR.H);
  1107. adjustFlags(ctx, BR.H);
  1108. }
  1109. static void IN_L_off_C (Z80Context* ctx)
  1110. {
  1111. BR.L = ioRead(ctx, WR.BC);
  1112. RESFLAG(F_H | F_N);
  1113. adjustFlagSZP(ctx, BR.L);
  1114. adjustFlags(ctx, BR.L);
  1115. }
  1116. static void INC_off_HL (Z80Context* ctx)
  1117. {
  1118. ctx->tstates += 1;
  1119. byte value = read8(ctx, WR.HL);
  1120. write8(ctx, WR.HL, doIncDec(ctx, value, ID_INC));
  1121. }
  1122. static void INC_off_IX_d (Z80Context* ctx)
  1123. {
  1124. ctx->tstates += 6;
  1125. signed char off = read8(ctx, ctx->PC++);
  1126. byte value = read8(ctx, WR.IX + off);
  1127. write8(ctx, WR.IX + off, doIncDec(ctx, value, ID_INC));
  1128. }
  1129. static void INC_off_IY_d (Z80Context* ctx)
  1130. {
  1131. ctx->tstates += 6;
  1132. signed char off = read8(ctx, ctx->PC++);
  1133. byte value = read8(ctx, WR.IY + off);
  1134. write8(ctx, WR.IY + off, doIncDec(ctx, value, ID_INC));
  1135. }
  1136. static void INC_A (Z80Context* ctx)
  1137. {
  1138. BR.A = doIncDec(ctx, BR.A, ID_INC);
  1139. }
  1140. static void INC_B (Z80Context* ctx)
  1141. {
  1142. BR.B = doIncDec(ctx, BR.B, ID_INC);
  1143. }
  1144. static void INC_BC (Z80Context* ctx)
  1145. {
  1146. ctx->tstates += 2;
  1147. WR.BC++;
  1148. }
  1149. static void INC_C (Z80Context* ctx)
  1150. {
  1151. BR.C = doIncDec(ctx, BR.C, ID_INC);
  1152. }
  1153. static void INC_D (Z80Context* ctx)
  1154. {
  1155. BR.D = doIncDec(ctx, BR.D, ID_INC);
  1156. }
  1157. static void INC_DE (Z80Context* ctx)
  1158. {
  1159. ctx->tstates += 2;
  1160. WR.DE++;
  1161. }
  1162. static void INC_E (Z80Context* ctx)
  1163. {
  1164. BR.E = doIncDec(ctx, BR.E, ID_INC);
  1165. }
  1166. static void INC_H (Z80Context* ctx)
  1167. {
  1168. BR.H = doIncDec(ctx, BR.H, ID_INC);
  1169. }
  1170. static void INC_HL (Z80Context* ctx)
  1171. {
  1172. ctx->tstates += 2;
  1173. WR.HL++;
  1174. }
  1175. static void INC_IX (Z80Context* ctx)
  1176. {
  1177. ctx->tstates += 2;
  1178. WR.IX++;
  1179. }
  1180. static void INC_IXh (Z80Context* ctx)
  1181. {
  1182. BR.IXh = doIncDec(ctx, BR.IXh, ID_INC);
  1183. }
  1184. static void INC_IXl (Z80Context* ctx)
  1185. {
  1186. BR.IXl = doIncDec(ctx, BR.IXl, ID_INC);
  1187. }
  1188. static void INC_IY (Z80Context* ctx)
  1189. {
  1190. ctx->tstates += 2;
  1191. WR.IY++;
  1192. }
  1193. static void INC_IYh (Z80Context* ctx)
  1194. {
  1195. BR.IYh = doIncDec(ctx, BR.IYh, ID_INC);
  1196. }
  1197. static void INC_IYl (Z80Context* ctx)
  1198. {
  1199. BR.IYl = doIncDec(ctx, BR.IYl, ID_INC);
  1200. }
  1201. static void INC_L (Z80Context* ctx)
  1202. {
  1203. BR.L = doIncDec(ctx, BR.L, ID_INC);
  1204. }
  1205. static void INC_SP (Z80Context* ctx)
  1206. {
  1207. ctx->tstates += 2;
  1208. WR.SP++;
  1209. }
  1210. static void IND (Z80Context* ctx)
  1211. {
  1212. ctx->tstates += 1;
  1213. byte val = ioRead(ctx, WR.BC);
  1214. write8(ctx, WR.HL, val);
  1215. WR.HL--;
  1216. BR.B = doIncDec(ctx, BR.B, ID_DEC);
  1217. VALFLAG(F_N, (val & 0x80) != 0);
  1218. int flagval = val + ((BR.C - 1) & 0xff);
  1219. VALFLAG(F_H, flagval > 0xff);
  1220. VALFLAG(F_C, flagval > 0xff);
  1221. VALFLAG(F_PV, parityBit[(flagval & 7) ^ BR.B]);
  1222. }
  1223. static void INDR (Z80Context* ctx)
  1224. {
  1225. IND(ctx);
  1226. if (BR.B != 0)
  1227. {
  1228. ctx->tstates += 5;
  1229. ctx->PC -= 2;
  1230. }
  1231. }
  1232. static void INI (Z80Context* ctx)
  1233. {
  1234. ctx->tstates += 1;
  1235. byte val = ioRead(ctx, WR.BC);
  1236. write8(ctx, WR.HL, val);
  1237. WR.HL++;
  1238. BR.B = doIncDec(ctx, BR.B, ID_DEC);
  1239. VALFLAG(F_N, (val & 0x80) != 0);
  1240. int flagval = val + ((BR.C + 1) & 0xff);
  1241. VALFLAG(F_H, flagval > 0xff);
  1242. VALFLAG(F_C, flagval > 0xff);
  1243. VALFLAG(F_PV, parityBit[(flagval & 7) ^ BR.B]);
  1244. }
  1245. static void INIR (Z80Context* ctx)
  1246. {
  1247. INI(ctx);
  1248. if (BR.B != 0)
  1249. {
  1250. ctx->tstates += 5;
  1251. ctx->PC -= 2;
  1252. }
  1253. }
  1254. static void JP_off_HL (Z80Context* ctx)
  1255. {
  1256. ctx->PC = WR.HL;
  1257. }
  1258. static void JP_off_IX (Z80Context* ctx)
  1259. {
  1260. ctx->PC = WR.IX;
  1261. }
  1262. static void JP_off_IY (Z80Context* ctx)
  1263. {
  1264. ctx->PC = WR.IY;
  1265. }
  1266. static void JP_off_nn (Z80Context* ctx)
  1267. {
  1268. ushort addr = read16(ctx, ctx->PC);
  1269. ctx->PC += 2;
  1270. if (condition(ctx, C_))
  1271. ctx->PC = addr;
  1272. }
  1273. static void JP_C_off_nn (Z80Context* ctx)
  1274. {
  1275. ushort addr = read16(ctx, ctx->PC);
  1276. ctx->PC += 2;
  1277. if (condition(ctx, C_C))
  1278. ctx->PC = addr;
  1279. }
  1280. static void JP_M_off_nn (Z80Context* ctx)
  1281. {
  1282. ushort addr = read16(ctx, ctx->PC);
  1283. ctx->PC += 2;
  1284. if (condition(ctx, C_M))
  1285. ctx->PC = addr;
  1286. }
  1287. static void JP_NC_off_nn (Z80Context* ctx)
  1288. {
  1289. ushort addr = read16(ctx, ctx->PC);
  1290. ctx->PC += 2;
  1291. if (condition(ctx, C_NC))
  1292. ctx->PC = addr;
  1293. }
  1294. static void JP_NZ_off_nn (Z80Context* ctx)
  1295. {
  1296. ushort addr = read16(ctx, ctx->PC);
  1297. ctx->PC += 2;
  1298. if (condition(ctx, C_NZ))
  1299. ctx->PC = addr;
  1300. }
  1301. static void JP_P_off_nn (Z80Context* ctx)
  1302. {
  1303. ushort addr = read16(ctx, ctx->PC);
  1304. ctx->PC += 2;
  1305. if (condition(ctx, C_P))
  1306. ctx->PC = addr;
  1307. }
  1308. static void JP_PE_off_nn (Z80Context* ctx)
  1309. {
  1310. ushort addr = read16(ctx, ctx->PC);
  1311. ctx->PC += 2;
  1312. if (condition(ctx, C_PE))
  1313. ctx->PC = addr;
  1314. }
  1315. static void JP_PO_off_nn (Z80Context* ctx)
  1316. {
  1317. ushort addr = read16(ctx, ctx->PC);
  1318. ctx->PC += 2;
  1319. if (condition(ctx, C_PO))
  1320. ctx->PC = addr;
  1321. }
  1322. static void JP_Z_off_nn (Z80Context* ctx)
  1323. {
  1324. ushort addr = read16(ctx, ctx->PC);
  1325. ctx->PC += 2;
  1326. if (condition(ctx, C_Z))
  1327. ctx->PC = addr;
  1328. }
  1329. static void JR_off_PC_e (Z80Context* ctx)
  1330. {
  1331. int off = doComplement(read8(ctx, ctx->PC++));
  1332. if (condition(ctx, C_))
  1333. {
  1334. ctx->tstates += 5;
  1335. ctx->PC += off;
  1336. }
  1337. }
  1338. static void JR_C_off_PC_e (Z80Context* ctx)
  1339. {
  1340. int off = doComplement(read8(ctx, ctx->PC++));
  1341. if (condition(ctx, C_C))
  1342. {
  1343. ctx->tstates += 5;
  1344. ctx->PC += off;
  1345. }
  1346. }
  1347. static void JR_NC_off_PC_e (Z80Context* ctx)
  1348. {
  1349. int off = doComplement(read8(ctx, ctx->PC++));
  1350. if (condition(ctx, C_NC))
  1351. {
  1352. ctx->tstates += 5;
  1353. ctx->PC += off;
  1354. }
  1355. }
  1356. static void JR_NZ_off_PC_e (Z80Context* ctx)
  1357. {
  1358. int off = doComplement(read8(ctx, ctx->PC++));
  1359. if (condition(ctx, C_NZ))
  1360. {
  1361. ctx->tstates += 5;
  1362. ctx->PC += off;
  1363. }
  1364. }
  1365. static void JR_Z_off_PC_e (Z80Context* ctx)
  1366. {
  1367. int off = doComplement(read8(ctx, ctx->PC++));
  1368. if (condition(ctx, C_Z))
  1369. {
  1370. ctx->tstates += 5;
  1371. ctx->PC += off;
  1372. }
  1373. }
  1374. static void LD_off_BC_A (Z80Context* ctx)
  1375. {
  1376. write8(ctx, WR.BC, BR.A);
  1377. }
  1378. static void LD_off_DE_A (Z80Context* ctx)
  1379. {
  1380. write8(ctx, WR.DE, BR.A);
  1381. }
  1382. static void LD_off_HL_A (Z80Context* ctx)
  1383. {
  1384. write8(ctx, WR.HL, BR.A);
  1385. }
  1386. static void LD_off_HL_B (Z80Context* ctx)
  1387. {
  1388. write8(ctx, WR.HL, BR.B);
  1389. }
  1390. static void LD_off_HL_C (Z80Context* ctx)
  1391. {
  1392. write8(ctx, WR.HL, BR.C);
  1393. }
  1394. static void LD_off_HL_D (Z80Context* ctx)
  1395. {
  1396. write8(ctx, WR.HL, BR.D);
  1397. }
  1398. static void LD_off_HL_E (Z80Context* ctx)
  1399. {
  1400. write8(ctx, WR.HL, BR.E);
  1401. }
  1402. static void LD_off_HL_H (Z80Context* ctx)
  1403. {
  1404. write8(ctx, WR.HL, BR.H);
  1405. }
  1406. static void LD_off_HL_L (Z80Context* ctx)
  1407. {
  1408. write8(ctx, WR.HL, BR.L);
  1409. }
  1410. static void LD_off_HL_n (Z80Context* ctx)
  1411. {
  1412. write8(ctx, WR.HL, read8(ctx, ctx->PC++));
  1413. }
  1414. static void LD_off_IX_d_A (Z80Context* ctx)
  1415. {
  1416. ctx->tstates += 5;
  1417. write8(ctx, WR.IX + (signed char) read8(ctx, ctx->PC++), BR.A);
  1418. }
  1419. static void LD_off_IX_d_B (Z80Context* ctx)
  1420. {
  1421. ctx->tstates += 5;
  1422. write8(ctx, WR.IX + (signed char) read8(ctx, ctx->PC++), BR.B);
  1423. }
  1424. static void LD_off_IX_d_C (Z80Context* ctx)
  1425. {
  1426. ctx->tstates += 5;
  1427. write8(ctx, WR.IX + (signed char) read8(ctx, ctx->PC++), BR.C);
  1428. }
  1429. static void LD_off_IX_d_D (Z80Context* ctx)
  1430. {
  1431. ctx->tstates += 5;
  1432. write8(ctx, WR.IX + (signed char) read8(ctx, ctx->PC++), BR.D);
  1433. }
  1434. static void LD_off_IX_d_E (Z80Context* ctx)
  1435. {
  1436. ctx->tstates += 5;
  1437. write8(ctx, WR.IX + (signed char) read8(ctx, ctx->PC++), BR.E);
  1438. }
  1439. static void LD_off_IX_d_H (Z80Context* ctx)
  1440. {
  1441. ctx->tstates += 5;
  1442. write8(ctx, WR.IX + (signed char) read8(ctx, ctx->PC++), BR.H);
  1443. }
  1444. static void LD_off_IX_d_L (Z80Context* ctx)
  1445. {
  1446. ctx->tstates += 5;
  1447. write8(ctx, WR.IX + (signed char) read8(ctx, ctx->PC++), BR.L);
  1448. }
  1449. static void LD_off_IX_d_n (Z80Context* ctx)
  1450. {
  1451. ctx->tstates += 2;
  1452. signed char offset = read8(ctx, ctx->PC++);
  1453. byte n = read8(ctx, ctx->PC++);
  1454. write8(ctx, WR.IX + offset, n);
  1455. }
  1456. static void LD_off_IY_d_A (Z80Context* ctx)
  1457. {
  1458. ctx->tstates += 5;
  1459. write8(ctx, WR.IY + (signed char) read8(ctx, ctx->PC++), BR.A);
  1460. }
  1461. static void LD_off_IY_d_B (Z80Context* ctx)
  1462. {
  1463. ctx->tstates += 5;
  1464. write8(ctx, WR.IY + (signed char) read8(ctx, ctx->PC++), BR.B);
  1465. }
  1466. static void LD_off_IY_d_C (Z80Context* ctx)
  1467. {
  1468. ctx->tstates += 5;
  1469. write8(ctx, WR.IY + (signed char) read8(ctx, ctx->PC++), BR.C);
  1470. }
  1471. static void LD_off_IY_d_D (Z80Context* ctx)
  1472. {
  1473. ctx->tstates += 5;
  1474. write8(ctx, WR.IY + (signed char) read8(ctx, ctx->PC++), BR.D);
  1475. }
  1476. static void LD_off_IY_d_E (Z80Context* ctx)
  1477. {
  1478. ctx->tstates += 5;
  1479. write8(ctx, WR.IY + (signed char) read8(ctx, ctx->PC++), BR.E);
  1480. }
  1481. static void LD_off_IY_d_H (Z80Context* ctx)
  1482. {
  1483. ctx->tstates += 5;
  1484. write8(ctx, WR.IY + (signed char) read8(ctx, ctx->PC++), BR.H);
  1485. }
  1486. static void LD_off_IY_d_L (Z80Context* ctx)
  1487. {
  1488. ctx->tstates += 5;
  1489. write8(ctx, WR.IY + (signed char) read8(ctx, ctx->PC++), BR.L);
  1490. }
  1491. static void LD_off_IY_d_n (Z80Context* ctx)
  1492. {
  1493. ctx->tstates += 2;
  1494. signed char offset = read8(ctx, ctx->PC++);
  1495. byte n = read8(ctx, ctx->PC++);
  1496. write8(ctx, WR.IY + offset, n);
  1497. }
  1498. static void LD_off_nn_A (Z80Context* ctx)
  1499. {
  1500. write8(ctx, read16(ctx, ctx->PC), BR.A);
  1501. ctx->PC += 2;
  1502. }
  1503. static void LD_off_nn_BC (Z80Context* ctx)
  1504. {
  1505. write16(ctx, read16(ctx, ctx->PC), WR.BC);
  1506. ctx->PC += 2;
  1507. }
  1508. static void LD_off_nn_DE (Z80Context* ctx)
  1509. {
  1510. write16(ctx, read16(ctx, ctx->PC), WR.DE);
  1511. ctx->PC += 2;
  1512. }
  1513. static void LD_off_nn_HL (Z80Context* ctx)
  1514. {
  1515. write16(ctx, read16(ctx, ctx->PC), WR.HL);
  1516. ctx->PC += 2;
  1517. }
  1518. static void LD_off_nn_IX (Z80Context* ctx)
  1519. {
  1520. write16(ctx, read16(ctx, ctx->PC), WR.IX);
  1521. ctx->PC += 2;
  1522. }
  1523. static void LD_off_nn_IY (Z80Context* ctx)
  1524. {
  1525. write16(ctx, read16(ctx, ctx->PC), WR.IY);
  1526. ctx->PC += 2;
  1527. }
  1528. static void LD_off_nn_SP (Z80Context* ctx)
  1529. {
  1530. write16(ctx, read16(ctx, ctx->PC), WR.SP);
  1531. ctx->PC += 2;
  1532. }
  1533. static void LD_A_off_BC (Z80Context* ctx)
  1534. {
  1535. BR.A = read8(ctx, WR.BC);
  1536. }
  1537. static void LD_A_off_DE (Z80Context* ctx)
  1538. {
  1539. BR.A = read8(ctx, WR.DE);
  1540. }
  1541. static void LD_A_off_HL (Z80Context* ctx)
  1542. {
  1543. BR.A = read8(ctx, WR.HL);
  1544. }
  1545. static void LD_A_off_IX_d (Z80Context* ctx)
  1546. {
  1547. ctx->tstates += 5;
  1548. BR.A = read8(ctx, WR.IX + (signed char) read8(ctx, ctx->PC++));
  1549. }
  1550. static void LD_A_off_IY_d (Z80Context* ctx)
  1551. {
  1552. ctx->tstates += 5;
  1553. BR.A = read8(ctx, WR.IY + (signed char) read8(ctx, ctx->PC++));
  1554. }
  1555. static void LD_A_off_nn (Z80Context* ctx)
  1556. {
  1557. BR.A = read8(ctx, read16(ctx, ctx->PC));
  1558. ctx->PC += 2;
  1559. }
  1560. static void LD_A_A (Z80Context* ctx)
  1561. {
  1562. BR.A = BR.A;
  1563. }
  1564. static void LD_A_B (Z80Context* ctx)
  1565. {
  1566. BR.A = BR.B;
  1567. }
  1568. static void LD_A_C (Z80Context* ctx)
  1569. {
  1570. BR.A = BR.C;
  1571. }
  1572. static void LD_A_D (Z80Context* ctx)
  1573. {
  1574. BR.A = BR.D;
  1575. }
  1576. static void LD_A_E (Z80Context* ctx)
  1577. {
  1578. BR.A = BR.E;
  1579. }
  1580. static void LD_A_H (Z80Context* ctx)
  1581. {
  1582. BR.A = BR.H;
  1583. }
  1584. static void LD_A_I (Z80Context* ctx)
  1585. {
  1586. ctx->tstates += 1;
  1587. BR.A = ctx->I;
  1588. adjustFlags(ctx, BR.A);
  1589. RESFLAG(F_H | F_N);
  1590. VALFLAG(F_PV, ctx->IFF2);
  1591. VALFLAG(F_S, (BR.A & 0x80) != 0);
  1592. VALFLAG(F_Z, (BR.A == 0));
  1593. }
  1594. static void LD_A_IXh (Z80Context* ctx)
  1595. {
  1596. BR.A = BR.IXh;
  1597. }
  1598. static void LD_A_IXl (Z80Context* ctx)
  1599. {
  1600. BR.A = BR.IXl;
  1601. }
  1602. static void LD_A_IYh (Z80Context* ctx)
  1603. {
  1604. BR.A = BR.IYh;
  1605. }
  1606. static void LD_A_IYl (Z80Context* ctx)
  1607. {
  1608. BR.A = BR.IYl;
  1609. }
  1610. static void LD_A_L (Z80Context* ctx)
  1611. {
  1612. BR.A = BR.L;
  1613. }
  1614. static void LD_A_n (Z80Context* ctx)
  1615. {
  1616. BR.A = read8(ctx, ctx->PC++);
  1617. }
  1618. static void LD_A_R (Z80Context* ctx)
  1619. {
  1620. ctx->tstates += 1;
  1621. BR.A = ctx->R;
  1622. adjustFlags(ctx, BR.A);
  1623. RESFLAG(F_H | F_N);
  1624. VALFLAG(F_PV, ctx->IFF2);
  1625. VALFLAG(F_S, (BR.A & 0x80) != 0);
  1626. VALFLAG(F_Z, (BR.A == 0));
  1627. }
  1628. static void LD_A_RES_0_off_IX_d (Z80Context* ctx)
  1629. {
  1630. ctx->tstates += 2;
  1631. signed char off = read8(ctx, ctx->PC++);
  1632. BR.A = doSetRes(ctx, SR_RES, 0, read8(ctx, WR.IX + off));
  1633. write8(ctx, WR.IX + off, BR.A);
  1634. }
  1635. static void LD_A_RES_0_off_IY_d (Z80Context* ctx)
  1636. {
  1637. ctx->tstates += 2;
  1638. signed char off = read8(ctx, ctx->PC++);
  1639. BR.A = doSetRes(ctx, SR_RES, 0, read8(ctx, WR.IY + off));
  1640. write8(ctx, WR.IY + off, BR.A);
  1641. }
  1642. static void LD_A_RES_1_off_IX_d (Z80Context* ctx)
  1643. {
  1644. ctx->tstates += 2;
  1645. signed char off = read8(ctx, ctx->PC++);
  1646. BR.A = doSetRes(ctx, SR_RES, 1, read8(ctx, WR.IX + off));
  1647. write8(ctx, WR.IX + off, BR.A);
  1648. }
  1649. static void LD_A_RES_1_off_IY_d (Z80Context* ctx)
  1650. {
  1651. ctx->tstates += 2;
  1652. signed char off = read8(ctx, ctx->PC++);
  1653. BR.A = doSetRes(ctx, SR_RES, 1, read8(ctx, WR.IY + off));
  1654. write8(ctx, WR.IY + off, BR.A);
  1655. }
  1656. static void LD_A_RES_2_off_IX_d (Z80Context* ctx)
  1657. {
  1658. ctx->tstates += 2;
  1659. signed char off = read8(ctx, ctx->PC++);
  1660. BR.A = doSetRes(ctx, SR_RES, 2, read8(ctx, WR.IX + off));
  1661. write8(ctx, WR.IX + off, BR.A);
  1662. }
  1663. static void LD_A_RES_2_off_IY_d (Z80Context* ctx)
  1664. {
  1665. ctx->tstates += 2;
  1666. signed char off = read8(ctx, ctx->PC++);
  1667. BR.A = doSetRes(ctx, SR_RES, 2, read8(ctx, WR.IY + off));
  1668. write8(ctx, WR.IY + off, BR.A);
  1669. }
  1670. static void LD_A_RES_3_off_IX_d (Z80Context* ctx)
  1671. {
  1672. ctx->tstates += 2;
  1673. signed char off = read8(ctx, ctx->PC++);
  1674. BR.A = doSetRes(ctx, SR_RES, 3, read8(ctx, WR.IX + off));
  1675. write8(ctx, WR.IX + off, BR.A);
  1676. }
  1677. static void LD_A_RES_3_off_IY_d (Z80Context* ctx)
  1678. {
  1679. ctx->tstates += 2;
  1680. signed char off = read8(ctx, ctx->PC++);
  1681. BR.A = doSetRes(ctx, SR_RES, 3, read8(ctx, WR.IY + off));
  1682. write8(ctx, WR.IY + off, BR.A);
  1683. }
  1684. static void LD_A_RES_4_off_IX_d (Z80Context* ctx)
  1685. {
  1686. ctx->tstates += 2;
  1687. signed char off = read8(ctx, ctx->PC++);
  1688. BR.A = doSetRes(ctx, SR_RES, 4, read8(ctx, WR.IX + off));
  1689. write8(ctx, WR.IX + off, BR.A);
  1690. }
  1691. static void LD_A_RES_4_off_IY_d (Z80Context* ctx)
  1692. {
  1693. ctx->tstates += 2;
  1694. signed char off = read8(ctx, ctx->PC++);
  1695. BR.A = doSetRes(ctx, SR_RES, 4, read8(ctx, WR.IY + off));
  1696. write8(ctx, WR.IY + off, BR.A);
  1697. }
  1698. static void LD_A_RES_5_off_IX_d (Z80Context* ctx)
  1699. {
  1700. ctx->tstates += 2;
  1701. signed char off = read8(ctx, ctx->PC++);
  1702. BR.A = doSetRes(ctx, SR_RES, 5, read8(ctx, WR.IX + off));
  1703. write8(ctx, WR.IX + off, BR.A);
  1704. }
  1705. static void LD_A_RES_5_off_IY_d (Z80Context* ctx)
  1706. {
  1707. ctx->tstates += 2;
  1708. signed char off = read8(ctx, ctx->PC++);
  1709. BR.A = doSetRes(ctx, SR_RES, 5, read8(ctx, WR.IY + off));
  1710. write8(ctx, WR.IY + off, BR.A);
  1711. }
  1712. static void LD_A_RES_6_off_IX_d (Z80Context* ctx)
  1713. {
  1714. ctx->tstates += 2;
  1715. signed char off = read8(ctx, ctx->PC++);
  1716. BR.A = doSetRes(ctx, SR_RES, 6, read8(ctx, WR.IX + off));
  1717. write8(ctx, WR.IX + off, BR.A);
  1718. }
  1719. static void LD_A_RES_6_off_IY_d (Z80Context* ctx)
  1720. {
  1721. ctx->tstates += 2;
  1722. signed char off = read8(ctx, ctx->PC++);
  1723. BR.A = doSetRes(ctx, SR_RES, 6, read8(ctx, WR.IY + off));
  1724. write8(ctx, WR.IY + off, BR.A);
  1725. }
  1726. static void LD_A_RES_7_off_IX_d (Z80Context* ctx)
  1727. {
  1728. ctx->tstates += 2;
  1729. signed char off = read8(ctx, ctx->PC++);
  1730. BR.A = doSetRes(ctx, SR_RES, 7, read8(ctx, WR.IX + off));
  1731. write8(ctx, WR.IX + off, BR.A);
  1732. }
  1733. static void LD_A_RES_7_off_IY_d (Z80Context* ctx)
  1734. {
  1735. ctx->tstates += 2;
  1736. signed char off = read8(ctx, ctx->PC++);
  1737. BR.A = doSetRes(ctx, SR_RES, 7, read8(ctx, WR.IY + off));
  1738. write8(ctx, WR.IY + off, BR.A);
  1739. }
  1740. static void LD_A_RL_off_IX_d (Z80Context* ctx)
  1741. {
  1742. ctx->tstates += 2;
  1743. signed char off = read8(ctx, ctx->PC++);
  1744. BR.A = doRL(ctx, 1, read8(ctx, WR.IX + off));
  1745. write8(ctx, WR.IX + off, BR.A);
  1746. }
  1747. static void LD_A_RL_off_IY_d (Z80Context* ctx)
  1748. {
  1749. ctx->tstates += 2;
  1750. signed char off = read8(ctx, ctx->PC++);
  1751. BR.A = doRL(ctx, 1, read8(ctx, WR.IY + off));
  1752. write8(ctx, WR.IY + off, BR.A);
  1753. }
  1754. static void LD_A_RLC_off_IX_d (Z80Context* ctx)
  1755. {
  1756. ctx->tstates += 2;
  1757. signed char off = read8(ctx, ctx->PC++);
  1758. BR.A = doRLC(ctx, 1, read8(ctx, WR.IX + off));
  1759. write8(ctx, WR.IX + off, BR.A);
  1760. }
  1761. static void LD_A_RLC_off_IY_d (Z80Context* ctx)
  1762. {
  1763. ctx->tstates += 2;
  1764. signed char off = read8(ctx, ctx->PC++);
  1765. BR.A = doRLC(ctx, 1, read8(ctx, WR.IY + off));
  1766. write8(ctx, WR.IY + off, BR.A);
  1767. }
  1768. static void LD_A_RR_off_IX_d (Z80Context* ctx)
  1769. {
  1770. ctx->tstates += 2;
  1771. signed char off = read8(ctx, ctx->PC++);
  1772. BR.A = doRR(ctx, 1, read8(ctx, WR.IX + off));
  1773. write8(ctx, WR.IX + off, BR.A);
  1774. }
  1775. static void LD_A_RR_off_IY_d (Z80Context* ctx)
  1776. {
  1777. ctx->tstates += 2;
  1778. signed char off = read8(ctx, ctx->PC++);
  1779. BR.A = doRR(ctx, 1, read8(ctx, WR.IY + off));
  1780. write8(ctx, WR.IY + off, BR.A);
  1781. }
  1782. static void LD_A_RRC_off_IX_d (Z80Context* ctx)
  1783. {
  1784. ctx->tstates += 2;
  1785. signed char off = read8(ctx, ctx->PC++);
  1786. BR.A = doRRC(ctx, 1, read8(ctx, WR.IX + off));
  1787. write8(ctx, WR.IX + off, BR.A);
  1788. }
  1789. static void LD_A_RRC_off_IY_d (Z80Context* ctx)
  1790. {
  1791. ctx->tstates += 2;
  1792. signed char off = read8(ctx, ctx->PC++);
  1793. BR.A = doRRC(ctx, 1, read8(ctx, WR.IY + off));
  1794. write8(ctx, WR.IY + off, BR.A);
  1795. }
  1796. static void LD_A_SET_0_off_IX_d (Z80Context* ctx)
  1797. {
  1798. ctx->tstates += 2;
  1799. signed char off = read8(ctx, ctx->PC++);
  1800. BR.A = doSetRes(ctx, SR_SET, 0, read8(ctx, WR.IX + off));
  1801. write8(ctx, WR.IX + off, BR.A);
  1802. }
  1803. static void LD_A_SET_0_off_IY_d (Z80Context* ctx)
  1804. {
  1805. ctx->tstates += 2;
  1806. signed char off = read8(ctx, ctx->PC++);
  1807. BR.A = doSetRes(ctx, SR_SET, 0, read8(ctx, WR.IY + off));
  1808. write8(ctx, WR.IY + off, BR.A);
  1809. }
  1810. static void LD_A_SET_1_off_IX_d (Z80Context* ctx)
  1811. {
  1812. ctx->tstates += 2;
  1813. signed char off = read8(ctx, ctx->PC++);
  1814. BR.A = doSetRes(ctx, SR_SET, 1, read8(ctx, WR.IX + off));
  1815. write8(ctx, WR.IX + off, BR.A);
  1816. }
  1817. static void LD_A_SET_1_off_IY_d (Z80Context* ctx)
  1818. {
  1819. ctx->tstates += 2;
  1820. signed char off = read8(ctx, ctx->PC++);
  1821. BR.A = doSetRes(ctx, SR_SET, 1, read8(ctx, WR.IY + off));
  1822. write8(ctx, WR.IY + off, BR.A);
  1823. }
  1824. static void LD_A_SET_2_off_IX_d (Z80Context* ctx)
  1825. {
  1826. ctx->tstates += 2;
  1827. signed char off = read8(ctx, ctx->PC++);
  1828. BR.A = doSetRes(ctx, SR_SET, 2, read8(ctx, WR.IX + off));
  1829. write8(ctx, WR.IX + off, BR.A);
  1830. }
  1831. static void LD_A_SET_2_off_IY_d (Z80Context* ctx)
  1832. {
  1833. ctx->tstates += 2;
  1834. signed char off = read8(ctx, ctx->PC++);
  1835. BR.A = doSetRes(ctx, SR_SET, 2, read8(ctx, WR.IY + off));
  1836. write8(ctx, WR.IY + off, BR.A);
  1837. }
  1838. static void LD_A_SET_3_off_IX_d (Z80Context* ctx)
  1839. {
  1840. ctx->tstates += 2;
  1841. signed char off = read8(ctx, ctx->PC++);
  1842. BR.A = doSetRes(ctx, SR_SET, 3, read8(ctx, WR.IX + off));
  1843. write8(ctx, WR.IX + off, BR.A);
  1844. }
  1845. static void LD_A_SET_3_off_IY_d (Z80Context* ctx)
  1846. {
  1847. ctx->tstates += 2;
  1848. signed char off = read8(ctx, ctx->PC++);
  1849. BR.A = doSetRes(ctx, SR_SET, 3, read8(ctx, WR.IY + off));
  1850. write8(ctx, WR.IY + off, BR.A);
  1851. }
  1852. static void LD_A_SET_4_off_IX_d (Z80Context* ctx)
  1853. {
  1854. ctx->tstates += 2;
  1855. signed char off = read8(ctx, ctx->PC++);
  1856. BR.A = doSetRes(ctx, SR_SET, 4, read8(ctx, WR.IX + off));
  1857. write8(ctx, WR.IX + off, BR.A);
  1858. }
  1859. static void LD_A_SET_4_off_IY_d (Z80Context* ctx)
  1860. {
  1861. ctx->tstates += 2;
  1862. signed char off = read8(ctx, ctx->PC++);
  1863. BR.A = doSetRes(ctx, SR_SET, 4, read8(ctx, WR.IY + off));
  1864. write8(ctx, WR.IY + off, BR.A);
  1865. }
  1866. static void LD_A_SET_5_off_IX_d (Z80Context* ctx)
  1867. {
  1868. ctx->tstates += 2;
  1869. signed char off = read8(ctx, ctx->PC++);
  1870. BR.A = doSetRes(ctx, SR_SET, 5, read8(ctx, WR.IX + off));
  1871. write8(ctx, WR.IX + off, BR.A);
  1872. }
  1873. static void LD_A_SET_5_off_IY_d (Z80Context* ctx)
  1874. {
  1875. ctx->tstates += 2;
  1876. signed char off = read8(ctx, ctx->PC++);
  1877. BR.A = doSetRes(ctx, SR_SET, 5, read8(ctx, WR.IY + off));
  1878. write8(ctx, WR.IY + off, BR.A);
  1879. }
  1880. static void LD_A_SET_6_off_IX_d (Z80Context* ctx)
  1881. {
  1882. ctx->tstates += 2;
  1883. signed char off = read8(ctx, ctx->PC++);
  1884. BR.A = doSetRes(ctx, SR_SET, 6, read8(ctx, WR.IX + off));
  1885. write8(ctx, WR.IX + off, BR.A);
  1886. }
  1887. static void LD_A_SET_6_off_IY_d (Z80Context* ctx)
  1888. {
  1889. ctx->tstates += 2;
  1890. signed char off = read8(ctx, ctx->PC++);
  1891. BR.A = doSetRes(ctx, SR_SET, 6, read8(ctx, WR.IY + off));
  1892. write8(ctx, WR.IY + off, BR.A);
  1893. }
  1894. static void LD_A_SET_7_off_IX_d (Z80Context* ctx)
  1895. {
  1896. ctx->tstates += 2;
  1897. signed char off = read8(ctx, ctx->PC++);
  1898. BR.A = doSetRes(ctx, SR_SET, 7, read8(ctx, WR.IX + off));
  1899. write8(ctx, WR.IX + off, BR.A);
  1900. }
  1901. static void LD_A_SET_7_off_IY_d (Z80Context* ctx)
  1902. {
  1903. ctx->tstates += 2;
  1904. signed char off = read8(ctx, ctx->PC++);
  1905. BR.A = doSetRes(ctx, SR_SET, 7, read8(ctx, WR.IY + off));
  1906. write8(ctx, WR.IY + off, BR.A);
  1907. }
  1908. static void LD_A_SLA_off_IX_d (Z80Context* ctx)
  1909. {
  1910. ctx->tstates += 2;
  1911. signed char off = read8(ctx, ctx->PC++);
  1912. BR.A = doSL(ctx, read8(ctx, WR.IX + off), 1);
  1913. write8(ctx, WR.IX + off, BR.A);
  1914. }
  1915. static void LD_A_SLA_off_IY_d (Z80Context* ctx)
  1916. {
  1917. ctx->tstates += 2;
  1918. signed char off = read8(ctx, ctx->PC++);
  1919. BR.A = doSL(ctx, read8(ctx, WR.IY + off), 1);
  1920. write8(ctx, WR.IY + off, BR.A);
  1921. }
  1922. static void LD_A_SLL_off_IX_d (Z80Context* ctx)
  1923. {
  1924. ctx->tstates += 2;
  1925. signed char off = read8(ctx, ctx->PC++);
  1926. BR.A = doSL(ctx, read8(ctx, WR.IX + off), 0);
  1927. write8(ctx, WR.IX + off, BR.A);
  1928. }
  1929. static void LD_A_SLL_off_IY_d (Z80Context* ctx)
  1930. {
  1931. ctx->tstates += 2;
  1932. signed char off = read8(ctx, ctx->PC++);
  1933. BR.A = doSL(ctx, read8(ctx, WR.IY + off), 0);
  1934. write8(ctx, WR.IY + off, BR.A);
  1935. }
  1936. static void LD_A_SRA_off_IX_d (Z80Context* ctx)
  1937. {
  1938. ctx->tstates += 2;
  1939. signed char off = read8(ctx, ctx->PC++);
  1940. BR.A = doSR(ctx, read8(ctx, WR.IX + off), 1);
  1941. write8(ctx, WR.IX + off, BR.A);
  1942. }
  1943. static void LD_A_SRA_off_IY_d (Z80Context* ctx)
  1944. {
  1945. ctx->tstates += 2;
  1946. signed char off = read8(ctx, ctx->PC++);
  1947. BR.A = doSR(ctx, read8(ctx, WR.IY + off), 1);
  1948. write8(ctx, WR.IY + off, BR.A);
  1949. }
  1950. static void LD_A_SRL_off_IX_d (Z80Context* ctx)
  1951. {
  1952. ctx->tstates += 2;
  1953. signed char off = read8(ctx, ctx->PC++);
  1954. BR.A = doSR(ctx, read8(ctx, WR.IX + off), 0);
  1955. write8(ctx, WR.IX + off, BR.A);
  1956. }
  1957. static void LD_A_SRL_off_IY_d (Z80Context* ctx)
  1958. {
  1959. ctx->tstates += 2;
  1960. signed char off = read8(ctx, ctx->PC++);
  1961. BR.A = doSR(ctx, read8(ctx, WR.IY + off), 0);
  1962. write8(ctx, WR.IY + off, BR.A);
  1963. }
  1964. static void LD_B_off_HL (Z80Context* ctx)
  1965. {
  1966. BR.B = read8(ctx, WR.HL);
  1967. }
  1968. static void LD_B_off_IX_d (Z80Context* ctx)
  1969. {
  1970. ctx->tstates += 5;
  1971. BR.B = read8(ctx, WR.IX + (signed char) read8(ctx, ctx->PC++));
  1972. }
  1973. static void LD_B_off_IY_d (Z80Context* ctx)
  1974. {
  1975. ctx->tstates += 5;
  1976. BR.B = read8(ctx, WR.IY + (signed char) read8(ctx, ctx->PC++));
  1977. }
  1978. static void LD_B_A (Z80Context* ctx)
  1979. {
  1980. BR.B = BR.A;
  1981. }
  1982. static void LD_B_B (Z80Context* ctx)
  1983. {
  1984. BR.B = BR.B;
  1985. }
  1986. static void LD_B_C (Z80Context* ctx)
  1987. {
  1988. BR.B = BR.C;
  1989. }
  1990. static void LD_B_D (Z80Context* ctx)
  1991. {
  1992. BR.B = BR.D;
  1993. }
  1994. static void LD_B_E (Z80Context* ctx)
  1995. {
  1996. BR.B = BR.E;
  1997. }
  1998. static void LD_B_H (Z80Context* ctx)
  1999. {
  2000. BR.B = BR.H;
  2001. }
  2002. static void LD_B_IXh (Z80Context* ctx)
  2003. {
  2004. BR.B = BR.IXh;
  2005. }
  2006. static void LD_B_IXl (Z80Context* ctx)
  2007. {
  2008. BR.B = BR.IXl;
  2009. }
  2010. static void LD_B_IYh (Z80Context* ctx)
  2011. {
  2012. BR.B = BR.IYh;
  2013. }
  2014. static void LD_B_IYl (Z80Context* ctx)
  2015. {
  2016. BR.B = BR.IYl;
  2017. }
  2018. static void LD_B_L (Z80Context* ctx)
  2019. {
  2020. BR.B = BR.L;
  2021. }
  2022. static void LD_B_n (Z80Context* ctx)
  2023. {
  2024. BR.B = read8(ctx, ctx->PC++);
  2025. }
  2026. static void LD_B_RES_0_off_IX_d (Z80Context* ctx)
  2027. {
  2028. ctx->tstates += 2;
  2029. signed char off = read8(ctx, ctx->PC++);
  2030. BR.B = doSetRes(ctx, SR_RES, 0, read8(ctx, WR.IX + off));
  2031. write8(ctx, WR.IX + off, BR.B);
  2032. }
  2033. static void LD_B_RES_0_off_IY_d (Z80Context* ctx)
  2034. {
  2035. ctx->tstates += 2;
  2036. signed char off = read8(ctx, ctx->PC++);
  2037. BR.B = doSetRes(ctx, SR_RES, 0, read8(ctx, WR.IY + off));
  2038. write8(ctx, WR.IY + off, BR.B);
  2039. }
  2040. static void LD_B_RES_1_off_IX_d (Z80Context* ctx)
  2041. {
  2042. ctx->tstates += 2;
  2043. signed char off = read8(ctx, ctx->PC++);
  2044. BR.B = doSetRes(ctx, SR_RES, 1, read8(ctx, WR.IX + off));
  2045. write8(ctx, WR.IX + off, BR.B);
  2046. }
  2047. static void LD_B_RES_1_off_IY_d (Z80Context* ctx)
  2048. {
  2049. ctx->tstates += 2;
  2050. signed char off = read8(ctx, ctx->PC++);
  2051. BR.B = doSetRes(ctx, SR_RES, 1, read8(ctx, WR.IY + off));
  2052. write8(ctx, WR.IY + off, BR.B);
  2053. }
  2054. static void LD_B_RES_2_off_IX_d (Z80Context* ctx)
  2055. {
  2056. ctx->tstates += 2;
  2057. signed char off = read8(ctx, ctx->PC++);
  2058. BR.B = doSetRes(ctx, SR_RES, 2, read8(ctx, WR.IX + off));
  2059. write8(ctx, WR.IX + off, BR.B);
  2060. }
  2061. static void LD_B_RES_2_off_IY_d (Z80Context* ctx)
  2062. {
  2063. ctx->tstates += 2;
  2064. signed char off = read8(ctx, ctx->PC++);
  2065. BR.B = doSetRes(ctx, SR_RES, 2, read8(ctx, WR.IY + off));
  2066. write8(ctx, WR.IY + off, BR.B);
  2067. }
  2068. static void LD_B_RES_3_off_IX_d (Z80Context* ctx)
  2069. {
  2070. ctx->tstates += 2;
  2071. signed char off = read8(ctx, ctx->PC++);
  2072. BR.B = doSetRes(ctx, SR_RES, 3, read8(ctx, WR.IX + off));
  2073. write8(ctx, WR.IX + off, BR.B);
  2074. }
  2075. static void LD_B_RES_3_off_IY_d (Z80Context* ctx)
  2076. {
  2077. ctx->tstates += 2;
  2078. signed char off = read8(ctx, ctx->PC++);
  2079. BR.B = doSetRes(ctx, SR_RES, 3, read8(ctx, WR.IY + off));
  2080. write8(ctx, WR.IY + off, BR.B);
  2081. }
  2082. static void LD_B_RES_4_off_IX_d (Z80Context* ctx)
  2083. {
  2084. ctx->tstates += 2;
  2085. signed char off = read8(ctx, ctx->PC++);
  2086. BR.B = doSetRes(ctx, SR_RES, 4, read8(ctx, WR.IX + off));
  2087. write8(ctx, WR.IX + off, BR.B);
  2088. }
  2089. static void LD_B_RES_4_off_IY_d (Z80Context* ctx)
  2090. {
  2091. ctx->tstates += 2;
  2092. signed char off = read8(ctx, ctx->PC++);
  2093. BR.B = doSetRes(ctx, SR_RES, 4, read8(ctx, WR.IY + off));
  2094. write8(ctx, WR.IY + off, BR.B);
  2095. }
  2096. static void LD_B_RES_5_off_IX_d (Z80Context* ctx)
  2097. {
  2098. ctx->tstates += 2;
  2099. signed char off = read8(ctx, ctx->PC++);
  2100. BR.B = doSetRes(ctx, SR_RES, 5, read8(ctx, WR.IX + off));
  2101. write8(ctx, WR.IX + off, BR.B);
  2102. }
  2103. static void LD_B_RES_5_off_IY_d (Z80Context* ctx)
  2104. {
  2105. ctx->tstates += 2;
  2106. signed char off = read8(ctx, ctx->PC++);
  2107. BR.B = doSetRes(ctx, SR_RES, 5, read8(ctx, WR.IY + off));
  2108. write8(ctx, WR.IY + off, BR.B);
  2109. }
  2110. static void LD_B_RES_6_off_IX_d (Z80Context* ctx)
  2111. {
  2112. ctx->tstates += 2;
  2113. signed char off = read8(ctx, ctx->PC++);
  2114. BR.B = doSetRes(ctx, SR_RES, 6, read8(ctx, WR.IX + off));
  2115. write8(ctx, WR.IX + off, BR.B);
  2116. }
  2117. static void LD_B_RES_6_off_IY_d (Z80Context* ctx)
  2118. {
  2119. ctx->tstates += 2;
  2120. signed char off = read8(ctx, ctx->PC++);
  2121. BR.B = doSetRes(ctx, SR_RES, 6, read8(ctx, WR.IY + off));
  2122. write8(ctx, WR.IY + off, BR.B);
  2123. }
  2124. static void LD_B_RES_7_off_IX_d (Z80Context* ctx)
  2125. {
  2126. ctx->tstates += 2;
  2127. signed char off = read8(ctx, ctx->PC++);
  2128. BR.B = doSetRes(ctx, SR_RES, 7, read8(ctx, WR.IX + off));
  2129. write8(ctx, WR.IX + off, BR.B);
  2130. }
  2131. static void LD_B_RES_7_off_IY_d (Z80Context* ctx)
  2132. {
  2133. ctx->tstates += 2;
  2134. signed char off = read8(ctx, ctx->PC++);
  2135. BR.B = doSetRes(ctx, SR_RES, 7, read8(ctx, WR.IY + off));
  2136. write8(ctx, WR.IY + off, BR.B);
  2137. }
  2138. static void LD_B_RL_off_IX_d (Z80Context* ctx)
  2139. {
  2140. ctx->tstates += 2;
  2141. signed char off = read8(ctx, ctx->PC++);
  2142. BR.B = doRL(ctx, 1, read8(ctx, WR.IX + off));
  2143. write8(ctx, WR.IX + off, BR.B);
  2144. }
  2145. static void LD_B_RL_off_IY_d (Z80Context* ctx)
  2146. {
  2147. ctx->tstates += 2;
  2148. signed char off = read8(ctx, ctx->PC++);
  2149. BR.B = doRL(ctx, 1, read8(ctx, WR.IY + off));
  2150. write8(ctx, WR.IY + off, BR.B);
  2151. }
  2152. static void LD_B_RLC_off_IX_d (Z80Context* ctx)
  2153. {
  2154. ctx->tstates += 2;
  2155. signed char off = read8(ctx, ctx->PC++);
  2156. BR.B = doRLC(ctx, 1, read8(ctx, WR.IX + off));
  2157. write8(ctx, WR.IX + off, BR.B);
  2158. }
  2159. static void LD_B_RLC_off_IY_d (Z80Context* ctx)
  2160. {
  2161. ctx->tstates += 2;
  2162. signed char off = read8(ctx, ctx->PC++);
  2163. BR.B = doRLC(ctx, 1, read8(ctx, WR.IY + off));
  2164. write8(ctx, WR.IY + off, BR.B);
  2165. }
  2166. static void LD_B_RR_off_IX_d (Z80Context* ctx)
  2167. {
  2168. ctx->tstates += 2;
  2169. signed char off = read8(ctx, ctx->PC++);
  2170. BR.B = doRR(ctx, 1, read8(ctx, WR.IX + off));
  2171. write8(ctx, WR.IX + off, BR.B);
  2172. }
  2173. static void LD_B_RR_off_IY_d (Z80Context* ctx)
  2174. {
  2175. ctx->tstates += 2;
  2176. signed char off = read8(ctx, ctx->PC++);
  2177. BR.B = doRR(ctx, 1, read8(ctx, WR.IY + off));
  2178. write8(ctx, WR.IY + off, BR.B);
  2179. }
  2180. static void LD_B_RRC_off_IX_d (Z80Context* ctx)
  2181. {
  2182. ctx->tstates += 2;
  2183. signed char off = read8(ctx, ctx->PC++);
  2184. BR.B = doRRC(ctx, 1, read8(ctx, WR.IX + off));
  2185. write8(ctx, WR.IX + off, BR.B);
  2186. }
  2187. static void LD_B_RRC_off_IY_d (Z80Context* ctx)
  2188. {
  2189. ctx->tstates += 2;
  2190. signed char off = read8(ctx, ctx->PC++);
  2191. BR.B = doRRC(ctx, 1, read8(ctx, WR.IY + off));
  2192. write8(ctx, WR.IY + off, BR.B);
  2193. }
  2194. static void LD_B_SET_0_off_IX_d (Z80Context* ctx)
  2195. {
  2196. ctx->tstates += 2;
  2197. signed char off = read8(ctx, ctx->PC++);
  2198. BR.B = doSetRes(ctx, SR_SET, 0, read8(ctx, WR.IX + off));
  2199. write8(ctx, WR.IX + off, BR.B);
  2200. }
  2201. static void LD_B_SET_0_off_IY_d (Z80Context* ctx)
  2202. {
  2203. ctx->tstates += 2;
  2204. signed char off = read8(ctx, ctx->PC++);
  2205. BR.B = doSetRes(ctx, SR_SET, 0, read8(ctx, WR.IY + off));
  2206. write8(ctx, WR.IY + off, BR.B);
  2207. }
  2208. static void LD_B_SET_1_off_IX_d (Z80Context* ctx)
  2209. {
  2210. ctx->tstates += 2;
  2211. signed char off = read8(ctx, ctx->PC++);
  2212. BR.B = doSetRes(ctx, SR_SET, 1, read8(ctx, WR.IX + off));
  2213. write8(ctx, WR.IX + off, BR.B);
  2214. }
  2215. static void LD_B_SET_1_off_IY_d (Z80Context* ctx)
  2216. {
  2217. ctx->tstates += 2;
  2218. signed char off = read8(ctx, ctx->PC++);
  2219. BR.B = doSetRes(ctx, SR_SET, 1, read8(ctx, WR.IY + off));
  2220. write8(ctx, WR.IY + off, BR.B);
  2221. }
  2222. static void LD_B_SET_2_off_IX_d (Z80Context* ctx)
  2223. {
  2224. ctx->tstates += 2;
  2225. signed char off = read8(ctx, ctx->PC++);
  2226. BR.B = doSetRes(ctx, SR_SET, 2, read8(ctx, WR.IX + off));
  2227. write8(ctx, WR.IX + off, BR.B);
  2228. }
  2229. static void LD_B_SET_2_off_IY_d (Z80Context* ctx)
  2230. {
  2231. ctx->tstates += 2;
  2232. signed char off = read8(ctx, ctx->PC++);
  2233. BR.B = doSetRes(ctx, SR_SET, 2, read8(ctx, WR.IY + off));
  2234. write8(ctx, WR.IY + off, BR.B);
  2235. }
  2236. static void LD_B_SET_3_off_IX_d (Z80Context* ctx)
  2237. {
  2238. ctx->tstates += 2;
  2239. signed char off = read8(ctx, ctx->PC++);
  2240. BR.B = doSetRes(ctx, SR_SET, 3, read8(ctx, WR.IX + off));
  2241. write8(ctx, WR.IX + off, BR.B);
  2242. }
  2243. static void LD_B_SET_3_off_IY_d (Z80Context* ctx)
  2244. {
  2245. ctx->tstates += 2;
  2246. signed char off = read8(ctx, ctx->PC++);
  2247. BR.B = doSetRes(ctx, SR_SET, 3, read8(ctx, WR.IY + off));
  2248. write8(ctx, WR.IY + off, BR.B);
  2249. }
  2250. static void LD_B_SET_4_off_IX_d (Z80Context* ctx)
  2251. {
  2252. ctx->tstates += 2;
  2253. signed char off = read8(ctx, ctx->PC++);
  2254. BR.B = doSetRes(ctx, SR_SET, 4, read8(ctx, WR.IX + off));
  2255. write8(ctx, WR.IX + off, BR.B);
  2256. }
  2257. static void LD_B_SET_4_off_IY_d (Z80Context* ctx)
  2258. {
  2259. ctx->tstates += 2;
  2260. signed char off = read8(ctx, ctx->PC++);
  2261. BR.B = doSetRes(ctx, SR_SET, 4, read8(ctx, WR.IY + off));
  2262. write8(ctx, WR.IY + off, BR.B);
  2263. }
  2264. static void LD_B_SET_5_off_IX_d (Z80Context* ctx)
  2265. {
  2266. ctx->tstates += 2;
  2267. signed char off = read8(ctx, ctx->PC++);
  2268. BR.B = doSetRes(ctx, SR_SET, 5, read8(ctx, WR.IX + off));
  2269. write8(ctx, WR.IX + off, BR.B);
  2270. }
  2271. static void LD_B_SET_5_off_IY_d (Z80Context* ctx)
  2272. {
  2273. ctx->tstates += 2;
  2274. signed char off = read8(ctx, ctx->PC++);
  2275. BR.B = doSetRes(ctx, SR_SET, 5, read8(ctx, WR.IY + off));
  2276. write8(ctx, WR.IY + off, BR.B);
  2277. }
  2278. static void LD_B_SET_6_off_IX_d (Z80Context* ctx)
  2279. {
  2280. ctx->tstates += 2;
  2281. signed char off = read8(ctx, ctx->PC++);
  2282. BR.B = doSetRes(ctx, SR_SET, 6, read8(ctx, WR.IX + off));
  2283. write8(ctx, WR.IX + off, BR.B);
  2284. }
  2285. static void LD_B_SET_6_off_IY_d (Z80Context* ctx)
  2286. {
  2287. ctx->tstates += 2;
  2288. signed char off = read8(ctx, ctx->PC++);
  2289. BR.B = doSetRes(ctx, SR_SET, 6, read8(ctx, WR.IY + off));
  2290. write8(ctx, WR.IY + off, BR.B);
  2291. }
  2292. static void LD_B_SET_7_off_IX_d (Z80Context* ctx)
  2293. {
  2294. ctx->tstates += 2;
  2295. signed char off = read8(ctx, ctx->PC++);
  2296. BR.B = doSetRes(ctx, SR_SET, 7, read8(ctx, WR.IX + off));
  2297. write8(ctx, WR.IX + off, BR.B);
  2298. }
  2299. static void LD_B_SET_7_off_IY_d (Z80Context* ctx)
  2300. {
  2301. ctx->tstates += 2;
  2302. signed char off = read8(ctx, ctx->PC++);
  2303. BR.B = doSetRes(ctx, SR_SET, 7, read8(ctx, WR.IY + off));
  2304. write8(ctx, WR.IY + off, BR.B);
  2305. }
  2306. static void LD_B_SLA_off_IX_d (Z80Context* ctx)
  2307. {
  2308. ctx->tstates += 2;
  2309. signed char off = read8(ctx, ctx->PC++);
  2310. BR.B = doSL(ctx, read8(ctx, WR.IX + off), 1);
  2311. write8(ctx, WR.IX + off, BR.B);
  2312. }
  2313. static void LD_B_SLA_off_IY_d (Z80Context* ctx)
  2314. {
  2315. ctx->tstates += 2;
  2316. signed char off = read8(ctx, ctx->PC++);
  2317. BR.B = doSL(ctx, read8(ctx, WR.IY + off), 1);
  2318. write8(ctx, WR.IY + off, BR.B);
  2319. }
  2320. static void LD_B_SLL_off_IX_d (Z80Context* ctx)
  2321. {
  2322. ctx->tstates += 2;
  2323. signed char off = read8(ctx, ctx->PC++);
  2324. BR.B = doSL(ctx, read8(ctx, WR.IX + off), 0);
  2325. write8(ctx, WR.IX + off, BR.B);
  2326. }
  2327. static void LD_B_SLL_off_IY_d (Z80Context* ctx)
  2328. {
  2329. ctx->tstates += 2;
  2330. signed char off = read8(ctx, ctx->PC++);
  2331. BR.B = doSL(ctx, read8(ctx, WR.IY + off), 0);
  2332. write8(ctx, WR.IY + off, BR.B);
  2333. }
  2334. static void LD_B_SRA_off_IX_d (Z80Context* ctx)
  2335. {
  2336. ctx->tstates += 2;
  2337. signed char off = read8(ctx, ctx->PC++);
  2338. BR.B = doSR(ctx, read8(ctx, WR.IX + off), 1);
  2339. write8(ctx, WR.IX + off, BR.B);
  2340. }
  2341. static void LD_B_SRA_off_IY_d (Z80Context* ctx)
  2342. {
  2343. ctx->tstates += 2;
  2344. signed char off = read8(ctx, ctx->PC++);
  2345. BR.B = doSR(ctx, read8(ctx, WR.IY + off), 1);
  2346. write8(ctx, WR.IY + off, BR.B);
  2347. }
  2348. static void LD_B_SRL_off_IX_d (Z80Context* ctx)
  2349. {
  2350. ctx->tstates += 2;
  2351. signed char off = read8(ctx, ctx->PC++);
  2352. BR.B = doSR(ctx, read8(ctx, WR.IX + off), 0);
  2353. write8(ctx, WR.IX + off, BR.B);
  2354. }
  2355. static void LD_B_SRL_off_IY_d (Z80Context* ctx)
  2356. {
  2357. ctx->tstates += 2;
  2358. signed char off = read8(ctx, ctx->PC++);
  2359. BR.B = doSR(ctx, read8(ctx, WR.IY + off), 0);
  2360. write8(ctx, WR.IY + off, BR.B);
  2361. }
  2362. static void LD_BC_off_nn (Z80Context* ctx)
  2363. {
  2364. ushort addr = read16(ctx, ctx->PC);
  2365. ctx->PC += 2;
  2366. WR.BC = read16(ctx, addr);
  2367. }
  2368. static void LD_BC_nn (Z80Context* ctx)
  2369. {
  2370. WR.BC = read16(ctx, ctx->PC);
  2371. ctx->PC += 2;
  2372. }
  2373. static void LD_C_off_HL (Z80Context* ctx)
  2374. {
  2375. BR.C = read8(ctx, WR.HL);
  2376. }
  2377. static void LD_C_off_IX_d (Z80Context* ctx)
  2378. {
  2379. ctx->tstates += 5;
  2380. BR.C = read8(ctx, WR.IX + (signed char) read8(ctx, ctx->PC++));
  2381. }
  2382. static void LD_C_off_IY_d (Z80Context* ctx)
  2383. {
  2384. ctx->tstates += 5;
  2385. BR.C = read8(ctx, WR.IY + (signed char) read8(ctx, ctx->PC++));
  2386. }
  2387. static void LD_C_A (Z80Context* ctx)
  2388. {
  2389. BR.C = BR.A;
  2390. }
  2391. static void LD_C_B (Z80Context* ctx)
  2392. {
  2393. BR.C = BR.B;
  2394. }
  2395. static void LD_C_C (Z80Context* ctx)
  2396. {
  2397. BR.C = BR.C;
  2398. }
  2399. static void LD_C_D (Z80Context* ctx)
  2400. {
  2401. BR.C = BR.D;
  2402. }
  2403. static void LD_C_E (Z80Context* ctx)
  2404. {
  2405. BR.C = BR.E;
  2406. }
  2407. static void LD_C_H (Z80Context* ctx)
  2408. {
  2409. BR.C = BR.H;
  2410. }
  2411. static void LD_C_IXh (Z80Context* ctx)
  2412. {
  2413. BR.C = BR.IXh;
  2414. }
  2415. static void LD_C_IXl (Z80Context* ctx)
  2416. {
  2417. BR.C = BR.IXl;
  2418. }
  2419. static void LD_C_IYh (Z80Context* ctx)
  2420. {
  2421. BR.C = BR.IYh;
  2422. }
  2423. static void LD_C_IYl (Z80Context* ctx)
  2424. {
  2425. BR.C = BR.IYl;
  2426. }
  2427. static void LD_C_L (Z80Context* ctx)
  2428. {
  2429. BR.C = BR.L;
  2430. }
  2431. static void LD_C_n (Z80Context* ctx)
  2432. {
  2433. BR.C = read8(ctx, ctx->PC++);
  2434. }
  2435. static void LD_C_RES_0_off_IX_d (Z80Context* ctx)
  2436. {
  2437. ctx->tstates += 2;
  2438. signed char off = read8(ctx, ctx->PC++);
  2439. BR.C = doSetRes(ctx, SR_RES, 0, read8(ctx, WR.IX + off));
  2440. write8(ctx, WR.IX + off, BR.C);
  2441. }
  2442. static void LD_C_RES_0_off_IY_d (Z80Context* ctx)
  2443. {
  2444. ctx->tstates += 2;
  2445. signed char off = read8(ctx, ctx->PC++);
  2446. BR.C = doSetRes(ctx, SR_RES, 0, read8(ctx, WR.IY + off));
  2447. write8(ctx, WR.IY + off, BR.C);
  2448. }
  2449. static void LD_C_RES_1_off_IX_d (Z80Context* ctx)
  2450. {
  2451. ctx->tstates += 2;
  2452. signed char off = read8(ctx, ctx->PC++);
  2453. BR.C = doSetRes(ctx, SR_RES, 1, read8(ctx, WR.IX + off));
  2454. write8(ctx, WR.IX + off, BR.C);
  2455. }
  2456. static void LD_C_RES_1_off_IY_d (Z80Context* ctx)
  2457. {
  2458. ctx->tstates += 2;
  2459. signed char off = read8(ctx, ctx->PC++);
  2460. BR.C = doSetRes(ctx, SR_RES, 1, read8(ctx, WR.IY + off));
  2461. write8(ctx, WR.IY + off, BR.C);
  2462. }
  2463. static void LD_C_RES_2_off_IX_d (Z80Context* ctx)
  2464. {
  2465. ctx->tstates += 2;
  2466. signed char off = read8(ctx, ctx->PC++);
  2467. BR.C = doSetRes(ctx, SR_RES, 2, read8(ctx, WR.IX + off));
  2468. write8(ctx, WR.IX + off, BR.C);
  2469. }
  2470. static void LD_C_RES_2_off_IY_d (Z80Context* ctx)
  2471. {
  2472. ctx->tstates += 2;
  2473. signed char off = read8(ctx, ctx->PC++);
  2474. BR.C = doSetRes(ctx, SR_RES, 2, read8(ctx, WR.IY + off));
  2475. write8(ctx, WR.IY + off, BR.C);
  2476. }
  2477. static void LD_C_RES_3_off_IX_d (Z80Context* ctx)
  2478. {
  2479. ctx->tstates += 2;
  2480. signed char off = read8(ctx, ctx->PC++);
  2481. BR.C = doSetRes(ctx, SR_RES, 3, read8(ctx, WR.IX + off));
  2482. write8(ctx, WR.IX + off, BR.C);
  2483. }
  2484. static void LD_C_RES_3_off_IY_d (Z80Context* ctx)
  2485. {
  2486. ctx->tstates += 2;
  2487. signed char off = read8(ctx, ctx->PC++);
  2488. BR.C = doSetRes(ctx, SR_RES, 3, read8(ctx, WR.IY + off));
  2489. write8(ctx, WR.IY + off, BR.C);
  2490. }
  2491. static void LD_C_RES_4_off_IX_d (Z80Context* ctx)
  2492. {
  2493. ctx->tstates += 2;
  2494. signed char off = read8(ctx, ctx->PC++);
  2495. BR.C = doSetRes(ctx, SR_RES, 4, read8(ctx, WR.IX + off));
  2496. write8(ctx, WR.IX + off, BR.C);
  2497. }
  2498. static void LD_C_RES_4_off_IY_d (Z80Context* ctx)
  2499. {
  2500. ctx->tstates += 2;
  2501. signed char off = read8(ctx, ctx->PC++);
  2502. BR.C = doSetRes(ctx, SR_RES, 4, read8(ctx, WR.IY + off));
  2503. write8(ctx, WR.IY + off, BR.C);
  2504. }
  2505. static void LD_C_RES_5_off_IX_d (Z80Context* ctx)
  2506. {
  2507. ctx->tstates += 2;
  2508. signed char off = read8(ctx, ctx->PC++);
  2509. BR.C = doSetRes(ctx, SR_RES, 5, read8(ctx, WR.IX + off));
  2510. write8(ctx, WR.IX + off, BR.C);
  2511. }
  2512. static void LD_C_RES_5_off_IY_d (Z80Context* ctx)
  2513. {
  2514. ctx->tstates += 2;
  2515. signed char off = read8(ctx, ctx->PC++);
  2516. BR.C = doSetRes(ctx, SR_RES, 5, read8(ctx, WR.IY + off));
  2517. write8(ctx, WR.IY + off, BR.C);
  2518. }
  2519. static void LD_C_RES_6_off_IX_d (Z80Context* ctx)
  2520. {
  2521. ctx->tstates += 2;
  2522. signed char off = read8(ctx, ctx->PC++);
  2523. BR.C = doSetRes(ctx, SR_RES, 6, read8(ctx, WR.IX + off));
  2524. write8(ctx, WR.IX + off, BR.C);
  2525. }
  2526. static void LD_C_RES_6_off_IY_d (Z80Context* ctx)
  2527. {
  2528. ctx->tstates += 2;
  2529. signed char off = read8(ctx, ctx->PC++);
  2530. BR.C = doSetRes(ctx, SR_RES, 6, read8(ctx, WR.IY + off));
  2531. write8(ctx, WR.IY + off, BR.C);
  2532. }
  2533. static void LD_C_RES_7_off_IX_d (Z80Context* ctx)
  2534. {
  2535. ctx->tstates += 2;
  2536. signed char off = read8(ctx, ctx->PC++);
  2537. BR.C = doSetRes(ctx, SR_RES, 7, read8(ctx, WR.IX + off));
  2538. write8(ctx, WR.IX + off, BR.C);
  2539. }
  2540. static void LD_C_RES_7_off_IY_d (Z80Context* ctx)
  2541. {
  2542. ctx->tstates += 2;
  2543. signed char off = read8(ctx, ctx->PC++);
  2544. BR.C = doSetRes(ctx, SR_RES, 7, read8(ctx, WR.IY + off));
  2545. write8(ctx, WR.IY + off, BR.C);
  2546. }
  2547. static void LD_C_RL_off_IX_d (Z80Context* ctx)
  2548. {
  2549. ctx->tstates += 2;
  2550. signed char off = read8(ctx, ctx->PC++);
  2551. BR.C = doRL(ctx, 1, read8(ctx, WR.IX + off));
  2552. write8(ctx, WR.IX + off, BR.C);
  2553. }
  2554. static void LD_C_RL_off_IY_d (Z80Context* ctx)
  2555. {
  2556. ctx->tstates += 2;
  2557. signed char off = read8(ctx, ctx->PC++);
  2558. BR.C = doRL(ctx, 1, read8(ctx, WR.IY + off));
  2559. write8(ctx, WR.IY + off, BR.C);
  2560. }
  2561. static void LD_C_RLC_off_IX_d (Z80Context* ctx)
  2562. {
  2563. ctx->tstates += 2;
  2564. signed char off = read8(ctx, ctx->PC++);
  2565. BR.C = doRLC(ctx, 1, read8(ctx, WR.IX + off));
  2566. write8(ctx, WR.IX + off, BR.C);
  2567. }
  2568. static void LD_C_RLC_off_IY_d (Z80Context* ctx)
  2569. {
  2570. ctx->tstates += 2;
  2571. signed char off = read8(ctx, ctx->PC++);
  2572. BR.C = doRLC(ctx, 1, read8(ctx, WR.IY + off));
  2573. write8(ctx, WR.IY + off, BR.C);
  2574. }
  2575. static void LD_C_RR_off_IX_d (Z80Context* ctx)
  2576. {
  2577. ctx->tstates += 2;
  2578. signed char off = read8(ctx, ctx->PC++);
  2579. BR.C = doRR(ctx, 1, read8(ctx, WR.IX + off));
  2580. write8(ctx, WR.IX + off, BR.C);
  2581. }
  2582. static void LD_C_RR_off_IY_d (Z80Context* ctx)
  2583. {
  2584. ctx->tstates += 2;
  2585. signed char off = read8(ctx, ctx->PC++);
  2586. BR.C = doRR(ctx, 1, read8(ctx, WR.IY + off));
  2587. write8(ctx, WR.IY + off, BR.C);
  2588. }
  2589. static void LD_C_RRC_off_IX_d (Z80Context* ctx)
  2590. {
  2591. ctx->tstates += 2;
  2592. signed char off = read8(ctx, ctx->PC++);
  2593. BR.C = doRRC(ctx, 1, read8(ctx, WR.IX + off));
  2594. write8(ctx, WR.IX + off, BR.C);
  2595. }
  2596. static void LD_C_RRC_off_IY_d (Z80Context* ctx)
  2597. {
  2598. ctx->tstates += 2;
  2599. signed char off = read8(ctx, ctx->PC++);
  2600. BR.C = doRRC(ctx, 1, read8(ctx, WR.IY + off));
  2601. write8(ctx, WR.IY + off, BR.C);
  2602. }
  2603. static void LD_C_SET_0_off_IX_d (Z80Context* ctx)
  2604. {
  2605. ctx->tstates += 2;
  2606. signed char off = read8(ctx, ctx->PC++);
  2607. BR.C = doSetRes(ctx, SR_SET, 0, read8(ctx, WR.IX + off));
  2608. write8(ctx, WR.IX + off, BR.C);
  2609. }
  2610. static void LD_C_SET_0_off_IY_d (Z80Context* ctx)
  2611. {
  2612. ctx->tstates += 2;
  2613. signed char off = read8(ctx, ctx->PC++);
  2614. BR.C = doSetRes(ctx, SR_SET, 0, read8(ctx, WR.IY + off));
  2615. write8(ctx, WR.IY + off, BR.C);
  2616. }
  2617. static void LD_C_SET_1_off_IX_d (Z80Context* ctx)
  2618. {
  2619. ctx->tstates += 2;
  2620. signed char off = read8(ctx, ctx->PC++);
  2621. BR.C = doSetRes(ctx, SR_SET, 1, read8(ctx, WR.IX + off));
  2622. write8(ctx, WR.IX + off, BR.C);
  2623. }
  2624. static void LD_C_SET_1_off_IY_d (Z80Context* ctx)
  2625. {
  2626. ctx->tstates += 2;
  2627. signed char off = read8(ctx, ctx->PC++);
  2628. BR.C = doSetRes(ctx, SR_SET, 1, read8(ctx, WR.IY + off));
  2629. write8(ctx, WR.IY + off, BR.C);
  2630. }
  2631. static void LD_C_SET_2_off_IX_d (Z80Context* ctx)
  2632. {
  2633. ctx->tstates += 2;
  2634. signed char off = read8(ctx, ctx->PC++);
  2635. BR.C = doSetRes(ctx, SR_SET, 2, read8(ctx, WR.IX + off));
  2636. write8(ctx, WR.IX + off, BR.C);
  2637. }
  2638. static void LD_C_SET_2_off_IY_d (Z80Context* ctx)
  2639. {
  2640. ctx->tstates += 2;
  2641. signed char off = read8(ctx, ctx->PC++);
  2642. BR.C = doSetRes(ctx, SR_SET, 2, read8(ctx, WR.IY + off));
  2643. write8(ctx, WR.IY + off, BR.C);
  2644. }
  2645. static void LD_C_SET_3_off_IX_d (Z80Context* ctx)
  2646. {
  2647. ctx->tstates += 2;
  2648. signed char off = read8(ctx, ctx->PC++);
  2649. BR.C = doSetRes(ctx, SR_SET, 3, read8(ctx, WR.IX + off));
  2650. write8(ctx, WR.IX + off, BR.C);
  2651. }
  2652. static void LD_C_SET_3_off_IY_d (Z80Context* ctx)
  2653. {
  2654. ctx->tstates += 2;
  2655. signed char off = read8(ctx, ctx->PC++);
  2656. BR.C = doSetRes(ctx, SR_SET, 3, read8(ctx, WR.IY + off));
  2657. write8(ctx, WR.IY + off, BR.C);
  2658. }
  2659. static void LD_C_SET_4_off_IX_d (Z80Context* ctx)
  2660. {
  2661. ctx->tstates += 2;
  2662. signed char off = read8(ctx, ctx->PC++);
  2663. BR.C = doSetRes(ctx, SR_SET, 4, read8(ctx, WR.IX + off));
  2664. write8(ctx, WR.IX + off, BR.C);
  2665. }
  2666. static void LD_C_SET_4_off_IY_d (Z80Context* ctx)
  2667. {
  2668. ctx->tstates += 2;
  2669. signed char off = read8(ctx, ctx->PC++);
  2670. BR.C = doSetRes(ctx, SR_SET, 4, read8(ctx, WR.IY + off));
  2671. write8(ctx, WR.IY + off, BR.C);
  2672. }
  2673. static void LD_C_SET_5_off_IX_d (Z80Context* ctx)
  2674. {
  2675. ctx->tstates += 2;
  2676. signed char off = read8(ctx, ctx->PC++);
  2677. BR.C = doSetRes(ctx, SR_SET, 5, read8(ctx, WR.IX + off));
  2678. write8(ctx, WR.IX + off, BR.C);
  2679. }
  2680. static void LD_C_SET_5_off_IY_d (Z80Context* ctx)
  2681. {
  2682. ctx->tstates += 2;
  2683. signed char off = read8(ctx, ctx->PC++);
  2684. BR.C = doSetRes(ctx, SR_SET, 5, read8(ctx, WR.IY + off));
  2685. write8(ctx, WR.IY + off, BR.C);
  2686. }
  2687. static void LD_C_SET_6_off_IX_d (Z80Context* ctx)
  2688. {
  2689. ctx->tstates += 2;
  2690. signed char off = read8(ctx, ctx->PC++);
  2691. BR.C = doSetRes(ctx, SR_SET, 6, read8(ctx, WR.IX + off));
  2692. write8(ctx, WR.IX + off, BR.C);
  2693. }
  2694. static void LD_C_SET_6_off_IY_d (Z80Context* ctx)
  2695. {
  2696. ctx->tstates += 2;
  2697. signed char off = read8(ctx, ctx->PC++);
  2698. BR.C = doSetRes(ctx, SR_SET, 6, read8(ctx, WR.IY + off));
  2699. write8(ctx, WR.IY + off, BR.C);
  2700. }
  2701. static void LD_C_SET_7_off_IX_d (Z80Context* ctx)
  2702. {
  2703. ctx->tstates += 2;
  2704. signed char off = read8(ctx, ctx->PC++);
  2705. BR.C = doSetRes(ctx, SR_SET, 7, read8(ctx, WR.IX + off));
  2706. write8(ctx, WR.IX + off, BR.C);
  2707. }
  2708. static void LD_C_SET_7_off_IY_d (Z80Context* ctx)
  2709. {
  2710. ctx->tstates += 2;
  2711. signed char off = read8(ctx, ctx->PC++);
  2712. BR.C = doSetRes(ctx, SR_SET, 7, read8(ctx, WR.IY + off));
  2713. write8(ctx, WR.IY + off, BR.C);
  2714. }
  2715. static void LD_C_SLA_off_IX_d (Z80Context* ctx)
  2716. {
  2717. ctx->tstates += 2;
  2718. signed char off = read8(ctx, ctx->PC++);
  2719. BR.C = doSL(ctx, read8(ctx, WR.IX + off), 1);
  2720. write8(ctx, WR.IX + off, BR.C);
  2721. }
  2722. static void LD_C_SLA_off_IY_d (Z80Context* ctx)
  2723. {
  2724. ctx->tstates += 2;
  2725. signed char off = read8(ctx, ctx->PC++);
  2726. BR.C = doSL(ctx, read8(ctx, WR.IY + off), 1);
  2727. write8(ctx, WR.IY + off, BR.C);
  2728. }
  2729. static void LD_C_SLL_off_IX_d (Z80Context* ctx)
  2730. {
  2731. ctx->tstates += 2;
  2732. signed char off = read8(ctx, ctx->PC++);
  2733. BR.C = doSL(ctx, read8(ctx, WR.IX + off), 0);
  2734. write8(ctx, WR.IX + off, BR.C);
  2735. }
  2736. static void LD_C_SLL_off_IY_d (Z80Context* ctx)
  2737. {
  2738. ctx->tstates += 2;
  2739. signed char off = read8(ctx, ctx->PC++);
  2740. BR.C = doSL(ctx, read8(ctx, WR.IY + off), 0);
  2741. write8(ctx, WR.IY + off, BR.C);
  2742. }
  2743. static void LD_C_SRA_off_IX_d (Z80Context* ctx)
  2744. {
  2745. ctx->tstates += 2;
  2746. signed char off = read8(ctx, ctx->PC++);
  2747. BR.C = doSR(ctx, read8(ctx, WR.IX + off), 1);
  2748. write8(ctx, WR.IX + off, BR.C);
  2749. }
  2750. static void LD_C_SRA_off_IY_d (Z80Context* ctx)
  2751. {
  2752. ctx->tstates += 2;
  2753. signed char off = read8(ctx, ctx->PC++);
  2754. BR.C = doSR(ctx, read8(ctx, WR.IY + off), 1);
  2755. write8(ctx, WR.IY + off, BR.C);
  2756. }
  2757. static void LD_C_SRL_off_IX_d (Z80Context* ctx)
  2758. {
  2759. ctx->tstates += 2;
  2760. signed char off = read8(ctx, ctx->PC++);
  2761. BR.C = doSR(ctx, read8(ctx, WR.IX + off), 0);
  2762. write8(ctx, WR.IX + off, BR.C);
  2763. }
  2764. static void LD_C_SRL_off_IY_d (Z80Context* ctx)
  2765. {
  2766. ctx->tstates += 2;
  2767. signed char off = read8(ctx, ctx->PC++);
  2768. BR.C = doSR(ctx, read8(ctx, WR.IY + off), 0);
  2769. write8(ctx, WR.IY + off, BR.C);
  2770. }
  2771. static void LD_D_off_HL (Z80Context* ctx)
  2772. {
  2773. BR.D = read8(ctx, WR.HL);
  2774. }
  2775. static void LD_D_off_IX_d (Z80Context* ctx)
  2776. {
  2777. ctx->tstates += 5;
  2778. BR.D = read8(ctx, WR.IX + (signed char) read8(ctx, ctx->PC++));
  2779. }
  2780. static void LD_D_off_IY_d (Z80Context* ctx)
  2781. {
  2782. ctx->tstates += 5;
  2783. BR.D = read8(ctx, WR.IY + (signed char) read8(ctx, ctx->PC++));
  2784. }
  2785. static void LD_D_A (Z80Context* ctx)
  2786. {
  2787. BR.D = BR.A;
  2788. }
  2789. static void LD_D_B (Z80Context* ctx)
  2790. {
  2791. BR.D = BR.B;
  2792. }
  2793. static void LD_D_C (Z80Context* ctx)
  2794. {
  2795. BR.D = BR.C;
  2796. }
  2797. static void LD_D_D (Z80Context* ctx)
  2798. {
  2799. BR.D = BR.D;
  2800. }
  2801. static void LD_D_E (Z80Context* ctx)
  2802. {
  2803. BR.D = BR.E;
  2804. }
  2805. static void LD_D_H (Z80Context* ctx)
  2806. {
  2807. BR.D = BR.H;
  2808. }
  2809. static void LD_D_IXh (Z80Context* ctx)
  2810. {
  2811. BR.D = BR.IXh;
  2812. }
  2813. static void LD_D_IXl (Z80Context* ctx)
  2814. {
  2815. BR.D = BR.IXl;
  2816. }
  2817. static void LD_D_IYh (Z80Context* ctx)
  2818. {
  2819. BR.D = BR.IYh;
  2820. }
  2821. static void LD_D_IYl (Z80Context* ctx)
  2822. {
  2823. BR.D = BR.IYl;
  2824. }
  2825. static void LD_D_L (Z80Context* ctx)
  2826. {
  2827. BR.D = BR.L;
  2828. }
  2829. static void LD_D_n (Z80Context* ctx)
  2830. {
  2831. BR.D = read8(ctx, ctx->PC++);
  2832. }
  2833. static void LD_D_RES_0_off_IX_d (Z80Context* ctx)
  2834. {
  2835. ctx->tstates += 2;
  2836. signed char off = read8(ctx, ctx->PC++);
  2837. BR.D = doSetRes(ctx, SR_RES, 0, read8(ctx, WR.IX + off));
  2838. write8(ctx, WR.IX + off, BR.D);
  2839. }
  2840. static void LD_D_RES_0_off_IY_d (Z80Context* ctx)
  2841. {
  2842. ctx->tstates += 2;
  2843. signed char off = read8(ctx, ctx->PC++);
  2844. BR.D = doSetRes(ctx, SR_RES, 0, read8(ctx, WR.IY + off));
  2845. write8(ctx, WR.IY + off, BR.D);
  2846. }
  2847. static void LD_D_RES_1_off_IX_d (Z80Context* ctx)
  2848. {
  2849. ctx->tstates += 2;
  2850. signed char off = read8(ctx, ctx->PC++);
  2851. BR.D = doSetRes(ctx, SR_RES, 1, read8(ctx, WR.IX + off));
  2852. write8(ctx, WR.IX + off, BR.D);
  2853. }
  2854. static void LD_D_RES_1_off_IY_d (Z80Context* ctx)
  2855. {
  2856. ctx->tstates += 2;
  2857. signed char off = read8(ctx, ctx->PC++);
  2858. BR.D = doSetRes(ctx, SR_RES, 1, read8(ctx, WR.IY + off));
  2859. write8(ctx, WR.IY + off, BR.D);
  2860. }
  2861. static void LD_D_RES_2_off_IX_d (Z80Context* ctx)
  2862. {
  2863. ctx->tstates += 2;
  2864. signed char off = read8(ctx, ctx->PC++);
  2865. BR.D = doSetRes(ctx, SR_RES, 2, read8(ctx, WR.IX + off));
  2866. write8(ctx, WR.IX + off, BR.D);
  2867. }
  2868. static void LD_D_RES_2_off_IY_d (Z80Context* ctx)
  2869. {
  2870. ctx->tstates += 2;
  2871. signed char off = read8(ctx, ctx->PC++);
  2872. BR.D = doSetRes(ctx, SR_RES, 2, read8(ctx, WR.IY + off));
  2873. write8(ctx, WR.IY + off, BR.D);
  2874. }
  2875. static void LD_D_RES_3_off_IX_d (Z80Context* ctx)
  2876. {
  2877. ctx->tstates += 2;
  2878. signed char off = read8(ctx, ctx->PC++);
  2879. BR.D = doSetRes(ctx, SR_RES, 3, read8(ctx, WR.IX + off));
  2880. write8(ctx, WR.IX + off, BR.D);
  2881. }
  2882. static void LD_D_RES_3_off_IY_d (Z80Context* ctx)
  2883. {
  2884. ctx->tstates += 2;
  2885. signed char off = read8(ctx, ctx->PC++);
  2886. BR.D = doSetRes(ctx, SR_RES, 3, read8(ctx, WR.IY + off));
  2887. write8(ctx, WR.IY + off, BR.D);
  2888. }
  2889. static void LD_D_RES_4_off_IX_d (Z80Context* ctx)
  2890. {
  2891. ctx->tstates += 2;
  2892. signed char off = read8(ctx, ctx->PC++);
  2893. BR.D = doSetRes(ctx, SR_RES, 4, read8(ctx, WR.IX + off));
  2894. write8(ctx, WR.IX + off, BR.D);
  2895. }
  2896. static void LD_D_RES_4_off_IY_d (Z80Context* ctx)
  2897. {
  2898. ctx->tstates += 2;
  2899. signed char off = read8(ctx, ctx->PC++);
  2900. BR.D = doSetRes(ctx, SR_RES, 4, read8(ctx, WR.IY + off));
  2901. write8(ctx, WR.IY + off, BR.D);
  2902. }
  2903. static void LD_D_RES_5_off_IX_d (Z80Context* ctx)
  2904. {
  2905. ctx->tstates += 2;
  2906. signed char off = read8(ctx, ctx->PC++);
  2907. BR.D = doSetRes(ctx, SR_RES, 5, read8(ctx, WR.IX + off));
  2908. write8(ctx, WR.IX + off, BR.D);
  2909. }
  2910. static void LD_D_RES_5_off_IY_d (Z80Context* ctx)
  2911. {
  2912. ctx->tstates += 2;
  2913. signed char off = read8(ctx, ctx->PC++);
  2914. BR.D = doSetRes(ctx, SR_RES, 5, read8(ctx, WR.IY + off));
  2915. write8(ctx, WR.IY + off, BR.D);
  2916. }
  2917. static void LD_D_RES_6_off_IX_d (Z80Context* ctx)
  2918. {
  2919. ctx->tstates += 2;
  2920. signed char off = read8(ctx, ctx->PC++);
  2921. BR.D = doSetRes(ctx, SR_RES, 6, read8(ctx, WR.IX + off));
  2922. write8(ctx, WR.IX + off, BR.D);
  2923. }
  2924. static void LD_D_RES_6_off_IY_d (Z80Context* ctx)
  2925. {
  2926. ctx->tstates += 2;
  2927. signed char off = read8(ctx, ctx->PC++);
  2928. BR.D = doSetRes(ctx, SR_RES, 6, read8(ctx, WR.IY + off));
  2929. write8(ctx, WR.IY + off, BR.D);
  2930. }
  2931. static void LD_D_RES_7_off_IX_d (Z80Context* ctx)
  2932. {
  2933. ctx->tstates += 2;
  2934. signed char off = read8(ctx, ctx->PC++);
  2935. BR.D = doSetRes(ctx, SR_RES, 7, read8(ctx, WR.IX + off));
  2936. write8(ctx, WR.IX + off, BR.D);
  2937. }
  2938. static void LD_D_RES_7_off_IY_d (Z80Context* ctx)
  2939. {
  2940. ctx->tstates += 2;
  2941. signed char off = read8(ctx, ctx->PC++);
  2942. BR.D = doSetRes(ctx, SR_RES, 7, read8(ctx, WR.IY + off));
  2943. write8(ctx, WR.IY + off, BR.D);
  2944. }
  2945. static void LD_D_RL_off_IX_d (Z80Context* ctx)
  2946. {
  2947. ctx->tstates += 2;
  2948. signed char off = read8(ctx, ctx->PC++);
  2949. BR.D = doRL(ctx, 1, read8(ctx, WR.IX + off));
  2950. write8(ctx, WR.IX + off, BR.D);
  2951. }
  2952. static void LD_D_RL_off_IY_d (Z80Context* ctx)
  2953. {
  2954. ctx->tstates += 2;
  2955. signed char off = read8(ctx, ctx->PC++);
  2956. BR.D = doRL(ctx, 1, read8(ctx, WR.IY + off));
  2957. write8(ctx, WR.IY + off, BR.D);
  2958. }
  2959. static void LD_D_RLC_off_IX_d (Z80Context* ctx)
  2960. {
  2961. ctx->tstates += 2;
  2962. signed char off = read8(ctx, ctx->PC++);
  2963. BR.D = doRLC(ctx, 1, read8(ctx, WR.IX + off));
  2964. write8(ctx, WR.IX + off, BR.D);
  2965. }
  2966. static void LD_D_RLC_off_IY_d (Z80Context* ctx)
  2967. {
  2968. ctx->tstates += 2;
  2969. signed char off = read8(ctx, ctx->PC++);
  2970. BR.D = doRLC(ctx, 1, read8(ctx, WR.IY + off));
  2971. write8(ctx, WR.IY + off, BR.D);
  2972. }
  2973. static void LD_D_RR_off_IX_d (Z80Context* ctx)
  2974. {
  2975. ctx->tstates += 2;
  2976. signed char off = read8(ctx, ctx->PC++);
  2977. BR.D = doRR(ctx, 1, read8(ctx, WR.IX + off));
  2978. write8(ctx, WR.IX + off, BR.D);
  2979. }
  2980. static void LD_D_RR_off_IY_d (Z80Context* ctx)
  2981. {
  2982. ctx->tstates += 2;
  2983. signed char off = read8(ctx, ctx->PC++);
  2984. BR.D = doRR(ctx, 1, read8(ctx, WR.IY + off));
  2985. write8(ctx, WR.IY + off, BR.D);
  2986. }
  2987. static void LD_D_RRC_off_IX_d (Z80Context* ctx)
  2988. {
  2989. ctx->tstates += 2;
  2990. signed char off = read8(ctx, ctx->PC++);
  2991. BR.D = doRRC(ctx, 1, read8(ctx, WR.IX + off));
  2992. write8(ctx, WR.IX + off, BR.D);
  2993. }
  2994. static void LD_D_RRC_off_IY_d (Z80Context* ctx)
  2995. {
  2996. ctx->tstates += 2;
  2997. signed char off = read8(ctx, ctx->PC++);
  2998. BR.D = doRRC(ctx, 1, read8(ctx, WR.IY + off));
  2999. write8(ctx, WR.IY + off, BR.D);
  3000. }
  3001. static void LD_D_SET_0_off_IX_d (Z80Context* ctx)
  3002. {
  3003. ctx->tstates += 2;
  3004. signed char off = read8(ctx, ctx->PC++);
  3005. BR.D = doSetRes(ctx, SR_SET, 0, read8(ctx, WR.IX + off));
  3006. write8(ctx, WR.IX + off, BR.D);
  3007. }
  3008. static void LD_D_SET_0_off_IY_d (Z80Context* ctx)
  3009. {
  3010. ctx->tstates += 2;
  3011. signed char off = read8(ctx, ctx->PC++);
  3012. BR.D = doSetRes(ctx, SR_SET, 0, read8(ctx, WR.IY + off));
  3013. write8(ctx, WR.IY + off, BR.D);
  3014. }
  3015. static void LD_D_SET_1_off_IX_d (Z80Context* ctx)
  3016. {
  3017. ctx->tstates += 2;
  3018. signed char off = read8(ctx, ctx->PC++);
  3019. BR.D = doSetRes(ctx, SR_SET, 1, read8(ctx, WR.IX + off));
  3020. write8(ctx, WR.IX + off, BR.D);
  3021. }
  3022. static void LD_D_SET_1_off_IY_d (Z80Context* ctx)
  3023. {
  3024. ctx->tstates += 2;
  3025. signed char off = read8(ctx, ctx->PC++);
  3026. BR.D = doSetRes(ctx, SR_SET, 1, read8(ctx, WR.IY + off));
  3027. write8(ctx, WR.IY + off, BR.D);
  3028. }
  3029. static void LD_D_SET_2_off_IX_d (Z80Context* ctx)
  3030. {
  3031. ctx->tstates += 2;
  3032. signed char off = read8(ctx, ctx->PC++);
  3033. BR.D = doSetRes(ctx, SR_SET, 2, read8(ctx, WR.IX + off));
  3034. write8(ctx, WR.IX + off, BR.D);
  3035. }
  3036. static void LD_D_SET_2_off_IY_d (Z80Context* ctx)
  3037. {
  3038. ctx->tstates += 2;
  3039. signed char off = read8(ctx, ctx->PC++);
  3040. BR.D = doSetRes(ctx, SR_SET, 2, read8(ctx, WR.IY + off));
  3041. write8(ctx, WR.IY + off, BR.D);
  3042. }
  3043. static void LD_D_SET_3_off_IX_d (Z80Context* ctx)
  3044. {
  3045. ctx->tstates += 2;
  3046. signed char off = read8(ctx, ctx->PC++);
  3047. BR.D = doSetRes(ctx, SR_SET, 3, read8(ctx, WR.IX + off));
  3048. write8(ctx, WR.IX + off, BR.D);
  3049. }
  3050. static void LD_D_SET_3_off_IY_d (Z80Context* ctx)
  3051. {
  3052. ctx->tstates += 2;
  3053. signed char off = read8(ctx, ctx->PC++);
  3054. BR.D = doSetRes(ctx, SR_SET, 3, read8(ctx, WR.IY + off));
  3055. write8(ctx, WR.IY + off, BR.D);
  3056. }
  3057. static void LD_D_SET_4_off_IX_d (Z80Context* ctx)
  3058. {
  3059. ctx->tstates += 2;
  3060. signed char off = read8(ctx, ctx->PC++);
  3061. BR.D = doSetRes(ctx, SR_SET, 4, read8(ctx, WR.IX + off));
  3062. write8(ctx, WR.IX + off, BR.D);
  3063. }
  3064. static void LD_D_SET_4_off_IY_d (Z80Context* ctx)
  3065. {
  3066. ctx->tstates += 2;
  3067. signed char off = read8(ctx, ctx->PC++);
  3068. BR.D = doSetRes(ctx, SR_SET, 4, read8(ctx, WR.IY + off));
  3069. write8(ctx, WR.IY + off, BR.D);
  3070. }
  3071. static void LD_D_SET_5_off_IX_d (Z80Context* ctx)
  3072. {
  3073. ctx->tstates += 2;
  3074. signed char off = read8(ctx, ctx->PC++);
  3075. BR.D = doSetRes(ctx, SR_SET, 5, read8(ctx, WR.IX + off));
  3076. write8(ctx, WR.IX + off, BR.D);
  3077. }
  3078. static void LD_D_SET_5_off_IY_d (Z80Context* ctx)
  3079. {
  3080. ctx->tstates += 2;
  3081. signed char off = read8(ctx, ctx->PC++);
  3082. BR.D = doSetRes(ctx, SR_SET, 5, read8(ctx, WR.IY + off));
  3083. write8(ctx, WR.IY + off, BR.D);
  3084. }
  3085. static void LD_D_SET_6_off_IX_d (Z80Context* ctx)
  3086. {
  3087. ctx->tstates += 2;
  3088. signed char off = read8(ctx, ctx->PC++);
  3089. BR.D = doSetRes(ctx, SR_SET, 6, read8(ctx, WR.IX + off));
  3090. write8(ctx, WR.IX + off, BR.D);
  3091. }
  3092. static void LD_D_SET_6_off_IY_d (Z80Context* ctx)
  3093. {
  3094. ctx->tstates += 2;
  3095. signed char off = read8(ctx, ctx->PC++);
  3096. BR.D = doSetRes(ctx, SR_SET, 6, read8(ctx, WR.IY + off));
  3097. write8(ctx, WR.IY + off, BR.D);
  3098. }
  3099. static void LD_D_SET_7_off_IX_d (Z80Context* ctx)
  3100. {
  3101. ctx->tstates += 2;
  3102. signed char off = read8(ctx, ctx->PC++);
  3103. BR.D = doSetRes(ctx, SR_SET, 7, read8(ctx, WR.IX + off));
  3104. write8(ctx, WR.IX + off, BR.D);
  3105. }
  3106. static void LD_D_SET_7_off_IY_d (Z80Context* ctx)
  3107. {
  3108. ctx->tstates += 2;
  3109. signed char off = read8(ctx, ctx->PC++);
  3110. BR.D = doSetRes(ctx, SR_SET, 7, read8(ctx, WR.IY + off));
  3111. write8(ctx, WR.IY + off, BR.D);
  3112. }
  3113. static void LD_D_SLA_off_IX_d (Z80Context* ctx)
  3114. {
  3115. ctx->tstates += 2;
  3116. signed char off = read8(ctx, ctx->PC++);
  3117. BR.D = doSL(ctx, read8(ctx, WR.IX + off), 1);
  3118. write8(ctx, WR.IX + off, BR.D);
  3119. }
  3120. static void LD_D_SLA_off_IY_d (Z80Context* ctx)
  3121. {
  3122. ctx->tstates += 2;
  3123. signed char off = read8(ctx, ctx->PC++);
  3124. BR.D = doSL(ctx, read8(ctx, WR.IY + off), 1);
  3125. write8(ctx, WR.IY + off, BR.D);
  3126. }
  3127. static void LD_D_SLL_off_IX_d (Z80Context* ctx)
  3128. {
  3129. ctx->tstates += 2;
  3130. signed char off = read8(ctx, ctx->PC++);
  3131. BR.D = doSL(ctx, read8(ctx, WR.IX + off), 0);
  3132. write8(ctx, WR.IX + off, BR.D);
  3133. }
  3134. static void LD_D_SLL_off_IY_d (Z80Context* ctx)
  3135. {
  3136. ctx->tstates += 2;
  3137. signed char off = read8(ctx, ctx->PC++);
  3138. BR.D = doSL(ctx, read8(ctx, WR.IY + off), 0);
  3139. write8(ctx, WR.IY + off, BR.D);
  3140. }
  3141. static void LD_D_SRA_off_IX_d (Z80Context* ctx)
  3142. {
  3143. ctx->tstates += 2;
  3144. signed char off = read8(ctx, ctx->PC++);
  3145. BR.D = doSR(ctx, read8(ctx, WR.IX + off), 1);
  3146. write8(ctx, WR.IX + off, BR.D);
  3147. }
  3148. static void LD_D_SRA_off_IY_d (Z80Context* ctx)
  3149. {
  3150. ctx->tstates += 2;
  3151. signed char off = read8(ctx, ctx->PC++);
  3152. BR.D = doSR(ctx, read8(ctx, WR.IY + off), 1);
  3153. write8(ctx, WR.IY + off, BR.D);
  3154. }
  3155. static void LD_D_SRL_off_IX_d (Z80Context* ctx)
  3156. {
  3157. ctx->tstates += 2;
  3158. signed char off = read8(ctx, ctx->PC++);
  3159. BR.D = doSR(ctx, read8(ctx, WR.IX + off), 0);
  3160. write8(ctx, WR.IX + off, BR.D);
  3161. }
  3162. static void LD_D_SRL_off_IY_d (Z80Context* ctx)
  3163. {
  3164. ctx->tstates += 2;
  3165. signed char off = read8(ctx, ctx->PC++);
  3166. BR.D = doSR(ctx, read8(ctx, WR.IY + off), 0);
  3167. write8(ctx, WR.IY + off, BR.D);
  3168. }
  3169. static void LD_DE_off_nn (Z80Context* ctx)
  3170. {
  3171. ushort addr = read16(ctx, ctx->PC);
  3172. ctx->PC += 2;
  3173. WR.DE = read16(ctx, addr);
  3174. }
  3175. static void LD_DE_nn (Z80Context* ctx)
  3176. {
  3177. WR.DE = read16(ctx, ctx->PC);
  3178. ctx->PC += 2;
  3179. }
  3180. static void LD_E_off_HL (Z80Context* ctx)
  3181. {
  3182. BR.E = read8(ctx, WR.HL);
  3183. }
  3184. static void LD_E_off_IX_d (Z80Context* ctx)
  3185. {
  3186. ctx->tstates += 5;
  3187. BR.E = read8(ctx, WR.IX + (signed char) read8(ctx, ctx->PC++));
  3188. }
  3189. static void LD_E_off_IY_d (Z80Context* ctx)
  3190. {
  3191. ctx->tstates += 5;
  3192. BR.E = read8(ctx, WR.IY + (signed char) read8(ctx, ctx->PC++));
  3193. }
  3194. static void LD_E_A (Z80Context* ctx)
  3195. {
  3196. BR.E = BR.A;
  3197. }
  3198. static void LD_E_B (Z80Context* ctx)
  3199. {
  3200. BR.E = BR.B;
  3201. }
  3202. static void LD_E_C (Z80Context* ctx)
  3203. {
  3204. BR.E = BR.C;
  3205. }
  3206. static void LD_E_D (Z80Context* ctx)
  3207. {
  3208. BR.E = BR.D;
  3209. }
  3210. static void LD_E_E (Z80Context* ctx)
  3211. {
  3212. BR.E = BR.E;
  3213. }
  3214. static void LD_E_H (Z80Context* ctx)
  3215. {
  3216. BR.E = BR.H;
  3217. }
  3218. static void LD_E_IXh (Z80Context* ctx)
  3219. {
  3220. BR.E = BR.IXh;
  3221. }
  3222. static void LD_E_IXl (Z80Context* ctx)
  3223. {
  3224. BR.E = BR.IXl;
  3225. }
  3226. static void LD_E_IYh (Z80Context* ctx)
  3227. {
  3228. BR.E = BR.IYh;
  3229. }
  3230. static void LD_E_IYl (Z80Context* ctx)
  3231. {
  3232. BR.E = BR.IYl;
  3233. }
  3234. static void LD_E_L (Z80Context* ctx)
  3235. {
  3236. BR.E = BR.L;
  3237. }
  3238. static void LD_E_n (Z80Context* ctx)
  3239. {
  3240. BR.E = read8(ctx, ctx->PC++);
  3241. }
  3242. static void LD_E_RES_0_off_IX_d (Z80Context* ctx)
  3243. {
  3244. ctx->tstates += 2;
  3245. signed char off = read8(ctx, ctx->PC++);
  3246. BR.E = doSetRes(ctx, SR_RES, 0, read8(ctx, WR.IX + off));
  3247. write8(ctx, WR.IX + off, BR.E);
  3248. }
  3249. static void LD_E_RES_0_off_IY_d (Z80Context* ctx)
  3250. {
  3251. ctx->tstates += 2;
  3252. signed char off = read8(ctx, ctx->PC++);
  3253. BR.E = doSetRes(ctx, SR_RES, 0, read8(ctx, WR.IY + off));
  3254. write8(ctx, WR.IY + off, BR.E);
  3255. }
  3256. static void LD_E_RES_1_off_IX_d (Z80Context* ctx)
  3257. {
  3258. ctx->tstates += 2;
  3259. signed char off = read8(ctx, ctx->PC++);
  3260. BR.E = doSetRes(ctx, SR_RES, 1, read8(ctx, WR.IX + off));
  3261. write8(ctx, WR.IX + off, BR.E);
  3262. }
  3263. static void LD_E_RES_1_off_IY_d (Z80Context* ctx)
  3264. {
  3265. ctx->tstates += 2;
  3266. signed char off = read8(ctx, ctx->PC++);
  3267. BR.E = doSetRes(ctx, SR_RES, 1, read8(ctx, WR.IY + off));
  3268. write8(ctx, WR.IY + off, BR.E);
  3269. }
  3270. static void LD_E_RES_2_off_IX_d (Z80Context* ctx)
  3271. {
  3272. ctx->tstates += 2;
  3273. signed char off = read8(ctx, ctx->PC++);
  3274. BR.E = doSetRes(ctx, SR_RES, 2, read8(ctx, WR.IX + off));
  3275. write8(ctx, WR.IX + off, BR.E);
  3276. }
  3277. static void LD_E_RES_2_off_IY_d (Z80Context* ctx)
  3278. {
  3279. ctx->tstates += 2;
  3280. signed char off = read8(ctx, ctx->PC++);
  3281. BR.E = doSetRes(ctx, SR_RES, 2, read8(ctx, WR.IY + off));
  3282. write8(ctx, WR.IY + off, BR.E);
  3283. }
  3284. static void LD_E_RES_3_off_IX_d (Z80Context* ctx)
  3285. {
  3286. ctx->tstates += 2;
  3287. signed char off = read8(ctx, ctx->PC++);
  3288. BR.E = doSetRes(ctx, SR_RES, 3, read8(ctx, WR.IX + off));
  3289. write8(ctx, WR.IX + off, BR.E);
  3290. }
  3291. static void LD_E_RES_3_off_IY_d (Z80Context* ctx)
  3292. {
  3293. ctx->tstates += 2;
  3294. signed char off = read8(ctx, ctx->PC++);
  3295. BR.E = doSetRes(ctx, SR_RES, 3, read8(ctx, WR.IY + off));
  3296. write8(ctx, WR.IY + off, BR.E);
  3297. }
  3298. static void LD_E_RES_4_off_IX_d (Z80Context* ctx)
  3299. {
  3300. ctx->tstates += 2;
  3301. signed char off = read8(ctx, ctx->PC++);
  3302. BR.E = doSetRes(ctx, SR_RES, 4, read8(ctx, WR.IX + off));
  3303. write8(ctx, WR.IX + off, BR.E);
  3304. }
  3305. static void LD_E_RES_4_off_IY_d (Z80Context* ctx)
  3306. {
  3307. ctx->tstates += 2;
  3308. signed char off = read8(ctx, ctx->PC++);
  3309. BR.E = doSetRes(ctx, SR_RES, 4, read8(ctx, WR.IY + off));
  3310. write8(ctx, WR.IY + off, BR.E);
  3311. }
  3312. static void LD_E_RES_5_off_IX_d (Z80Context* ctx)
  3313. {
  3314. ctx->tstates += 2;
  3315. signed char off = read8(ctx, ctx->PC++);
  3316. BR.E = doSetRes(ctx, SR_RES, 5, read8(ctx, WR.IX + off));
  3317. write8(ctx, WR.IX + off, BR.E);
  3318. }
  3319. static void LD_E_RES_5_off_IY_d (Z80Context* ctx)
  3320. {
  3321. ctx->tstates += 2;
  3322. signed char off = read8(ctx, ctx->PC++);
  3323. BR.E = doSetRes(ctx, SR_RES, 5, read8(ctx, WR.IY + off));
  3324. write8(ctx, WR.IY + off, BR.E);
  3325. }
  3326. static void LD_E_RES_6_off_IX_d (Z80Context* ctx)
  3327. {
  3328. ctx->tstates += 2;
  3329. signed char off = read8(ctx, ctx->PC++);
  3330. BR.E = doSetRes(ctx, SR_RES, 6, read8(ctx, WR.IX + off));
  3331. write8(ctx, WR.IX + off, BR.E);
  3332. }
  3333. static void LD_E_RES_6_off_IY_d (Z80Context* ctx)
  3334. {
  3335. ctx->tstates += 2;
  3336. signed char off = read8(ctx, ctx->PC++);
  3337. BR.E = doSetRes(ctx, SR_RES, 6, read8(ctx, WR.IY + off));
  3338. write8(ctx, WR.IY + off, BR.E);
  3339. }
  3340. static void LD_E_RES_7_off_IX_d (Z80Context* ctx)
  3341. {
  3342. ctx->tstates += 2;
  3343. signed char off = read8(ctx, ctx->PC++);
  3344. BR.E = doSetRes(ctx, SR_RES, 7, read8(ctx, WR.IX + off));
  3345. write8(ctx, WR.IX + off, BR.E);
  3346. }
  3347. static void LD_E_RES_7_off_IY_d (Z80Context* ctx)
  3348. {
  3349. ctx->tstates += 2;
  3350. signed char off = read8(ctx, ctx->PC++);
  3351. BR.E = doSetRes(ctx, SR_RES, 7, read8(ctx, WR.IY + off));
  3352. write8(ctx, WR.IY + off, BR.E);
  3353. }
  3354. static void LD_E_RL_off_IX_d (Z80Context* ctx)
  3355. {
  3356. ctx->tstates += 2;
  3357. signed char off = read8(ctx, ctx->PC++);
  3358. BR.E = doRL(ctx, 1, read8(ctx, WR.IX + off));
  3359. write8(ctx, WR.IX + off, BR.E);
  3360. }
  3361. static void LD_E_RL_off_IY_d (Z80Context* ctx)
  3362. {
  3363. ctx->tstates += 2;
  3364. signed char off = read8(ctx, ctx->PC++);
  3365. BR.E = doRL(ctx, 1, read8(ctx, WR.IY + off));
  3366. write8(ctx, WR.IY + off, BR.E);
  3367. }
  3368. static void LD_E_RLC_off_IX_d (Z80Context* ctx)
  3369. {
  3370. ctx->tstates += 2;
  3371. signed char off = read8(ctx, ctx->PC++);
  3372. BR.E = doRLC(ctx, 1, read8(ctx, WR.IX + off));
  3373. write8(ctx, WR.IX + off, BR.E);
  3374. }
  3375. static void LD_E_RLC_off_IY_d (Z80Context* ctx)
  3376. {
  3377. ctx->tstates += 2;
  3378. signed char off = read8(ctx, ctx->PC++);
  3379. BR.E = doRLC(ctx, 1, read8(ctx, WR.IY + off));
  3380. write8(ctx, WR.IY + off, BR.E);
  3381. }
  3382. static void LD_E_RR_off_IX_d (Z80Context* ctx)
  3383. {
  3384. ctx->tstates += 2;
  3385. signed char off = read8(ctx, ctx->PC++);
  3386. BR.E = doRR(ctx, 1, read8(ctx, WR.IX + off));
  3387. write8(ctx, WR.IX + off, BR.E);
  3388. }
  3389. static void LD_E_RR_off_IY_d (Z80Context* ctx)
  3390. {
  3391. ctx->tstates += 2;
  3392. signed char off = read8(ctx, ctx->PC++);
  3393. BR.E = doRR(ctx, 1, read8(ctx, WR.IY + off));
  3394. write8(ctx, WR.IY + off, BR.E);
  3395. }
  3396. static void LD_E_RRC_off_IX_d (Z80Context* ctx)
  3397. {
  3398. ctx->tstates += 2;
  3399. signed char off = read8(ctx, ctx->PC++);
  3400. BR.E = doRRC(ctx, 1, read8(ctx, WR.IX + off));
  3401. write8(ctx, WR.IX + off, BR.E);
  3402. }
  3403. static void LD_E_RRC_off_IY_d (Z80Context* ctx)
  3404. {
  3405. ctx->tstates += 2;
  3406. signed char off = read8(ctx, ctx->PC++);
  3407. BR.E = doRRC(ctx, 1, read8(ctx, WR.IY + off));
  3408. write8(ctx, WR.IY + off, BR.E);
  3409. }
  3410. static void LD_E_SET_0_off_IX_d (Z80Context* ctx)
  3411. {
  3412. ctx->tstates += 2;
  3413. signed char off = read8(ctx, ctx->PC++);
  3414. BR.E = doSetRes(ctx, SR_SET, 0, read8(ctx, WR.IX + off));
  3415. write8(ctx, WR.IX + off, BR.E);
  3416. }
  3417. static void LD_E_SET_0_off_IY_d (Z80Context* ctx)
  3418. {
  3419. ctx->tstates += 2;
  3420. signed char off = read8(ctx, ctx->PC++);
  3421. BR.E = doSetRes(ctx, SR_SET, 0, read8(ctx, WR.IY + off));
  3422. write8(ctx, WR.IY + off, BR.E);
  3423. }
  3424. static void LD_E_SET_1_off_IX_d (Z80Context* ctx)
  3425. {
  3426. ctx->tstates += 2;
  3427. signed char off = read8(ctx, ctx->PC++);
  3428. BR.E = doSetRes(ctx, SR_SET, 1, read8(ctx, WR.IX + off));
  3429. write8(ctx, WR.IX + off, BR.E);
  3430. }
  3431. static void LD_E_SET_1_off_IY_d (Z80Context* ctx)
  3432. {
  3433. ctx->tstates += 2;
  3434. signed char off = read8(ctx, ctx->PC++);
  3435. BR.E = doSetRes(ctx, SR_SET, 1, read8(ctx, WR.IY + off));
  3436. write8(ctx, WR.IY + off, BR.E);
  3437. }
  3438. static void LD_E_SET_2_off_IX_d (Z80Context* ctx)
  3439. {
  3440. ctx->tstates += 2;
  3441. signed char off = read8(ctx, ctx->PC++);
  3442. BR.E = doSetRes(ctx, SR_SET, 2, read8(ctx, WR.IX + off));
  3443. write8(ctx, WR.IX + off, BR.E);
  3444. }
  3445. static void LD_E_SET_2_off_IY_d (Z80Context* ctx)
  3446. {
  3447. ctx->tstates += 2;
  3448. signed char off = read8(ctx, ctx->PC++);
  3449. BR.E = doSetRes(ctx, SR_SET, 2, read8(ctx, WR.IY + off));
  3450. write8(ctx, WR.IY + off, BR.E);
  3451. }
  3452. static void LD_E_SET_3_off_IX_d (Z80Context* ctx)
  3453. {
  3454. ctx->tstates += 2;
  3455. signed char off = read8(ctx, ctx->PC++);
  3456. BR.E = doSetRes(ctx, SR_SET, 3, read8(ctx, WR.IX + off));
  3457. write8(ctx, WR.IX + off, BR.E);
  3458. }
  3459. static void LD_E_SET_3_off_IY_d (Z80Context* ctx)
  3460. {
  3461. ctx->tstates += 2;
  3462. signed char off = read8(ctx, ctx->PC++);
  3463. BR.E = doSetRes(ctx, SR_SET, 3, read8(ctx, WR.IY + off));
  3464. write8(ctx, WR.IY + off, BR.E);
  3465. }
  3466. static void LD_E_SET_4_off_IX_d (Z80Context* ctx)
  3467. {
  3468. ctx->tstates += 2;
  3469. signed char off = read8(ctx, ctx->PC++);
  3470. BR.E = doSetRes(ctx, SR_SET, 4, read8(ctx, WR.IX + off));
  3471. write8(ctx, WR.IX + off, BR.E);
  3472. }
  3473. static void LD_E_SET_4_off_IY_d (Z80Context* ctx)
  3474. {
  3475. ctx->tstates += 2;
  3476. signed char off = read8(ctx, ctx->PC++);
  3477. BR.E = doSetRes(ctx, SR_SET, 4, read8(ctx, WR.IY + off));
  3478. write8(ctx, WR.IY + off, BR.E);
  3479. }
  3480. static void LD_E_SET_5_off_IX_d (Z80Context* ctx)
  3481. {
  3482. ctx->tstates += 2;
  3483. signed char off = read8(ctx, ctx->PC++);
  3484. BR.E = doSetRes(ctx, SR_SET, 5, read8(ctx, WR.IX + off));
  3485. write8(ctx, WR.IX + off, BR.E);
  3486. }
  3487. static void LD_E_SET_5_off_IY_d (Z80Context* ctx)
  3488. {
  3489. ctx->tstates += 2;
  3490. signed char off = read8(ctx, ctx->PC++);
  3491. BR.E = doSetRes(ctx, SR_SET, 5, read8(ctx, WR.IY + off));
  3492. write8(ctx, WR.IY + off, BR.E);
  3493. }
  3494. static void LD_E_SET_6_off_IX_d (Z80Context* ctx)
  3495. {
  3496. ctx->tstates += 2;
  3497. signed char off = read8(ctx, ctx->PC++);
  3498. BR.E = doSetRes(ctx, SR_SET, 6, read8(ctx, WR.IX + off));
  3499. write8(ctx, WR.IX + off, BR.E);
  3500. }
  3501. static void LD_E_SET_6_off_IY_d (Z80Context* ctx)
  3502. {
  3503. ctx->tstates += 2;
  3504. signed char off = read8(ctx, ctx->PC++);
  3505. BR.E = doSetRes(ctx, SR_SET, 6, read8(ctx, WR.IY + off));
  3506. write8(ctx, WR.IY + off, BR.E);
  3507. }
  3508. static void LD_E_SET_7_off_IX_d (Z80Context* ctx)
  3509. {
  3510. ctx->tstates += 2;
  3511. signed char off = read8(ctx, ctx->PC++);
  3512. BR.E = doSetRes(ctx, SR_SET, 7, read8(ctx, WR.IX + off));
  3513. write8(ctx, WR.IX + off, BR.E);
  3514. }
  3515. static void LD_E_SET_7_off_IY_d (Z80Context* ctx)
  3516. {
  3517. ctx->tstates += 2;
  3518. signed char off = read8(ctx, ctx->PC++);
  3519. BR.E = doSetRes(ctx, SR_SET, 7, read8(ctx, WR.IY + off));
  3520. write8(ctx, WR.IY + off, BR.E);
  3521. }
  3522. static void LD_E_SLA_off_IX_d (Z80Context* ctx)
  3523. {
  3524. ctx->tstates += 2;
  3525. signed char off = read8(ctx, ctx->PC++);
  3526. BR.E = doSL(ctx, read8(ctx, WR.IX + off), 1);
  3527. write8(ctx, WR.IX + off, BR.E);
  3528. }
  3529. static void LD_E_SLA_off_IY_d (Z80Context* ctx)
  3530. {
  3531. ctx->tstates += 2;
  3532. signed char off = read8(ctx, ctx->PC++);
  3533. BR.E = doSL(ctx, read8(ctx, WR.IY + off), 1);
  3534. write8(ctx, WR.IY + off, BR.E);
  3535. }
  3536. static void LD_E_SLL_off_IX_d (Z80Context* ctx)
  3537. {
  3538. ctx->tstates += 2;
  3539. signed char off = read8(ctx, ctx->PC++);
  3540. BR.E = doSL(ctx, read8(ctx, WR.IX + off), 0);
  3541. write8(ctx, WR.IX + off, BR.E);
  3542. }
  3543. static void LD_E_SLL_off_IY_d (Z80Context* ctx)
  3544. {
  3545. ctx->tstates += 2;
  3546. signed char off = read8(ctx, ctx->PC++);
  3547. BR.E = doSL(ctx, read8(ctx, WR.IY + off), 0);
  3548. write8(ctx, WR.IY + off, BR.E);
  3549. }
  3550. static void LD_E_SRA_off_IX_d (Z80Context* ctx)
  3551. {
  3552. ctx->tstates += 2;
  3553. signed char off = read8(ctx, ctx->PC++);
  3554. BR.E = doSR(ctx, read8(ctx, WR.IX + off), 1);
  3555. write8(ctx, WR.IX + off, BR.E);
  3556. }
  3557. static void LD_E_SRA_off_IY_d (Z80Context* ctx)
  3558. {
  3559. ctx->tstates += 2;
  3560. signed char off = read8(ctx, ctx->PC++);
  3561. BR.E = doSR(ctx, read8(ctx, WR.IY + off), 1);
  3562. write8(ctx, WR.IY + off, BR.E);
  3563. }
  3564. static void LD_E_SRL_off_IX_d (Z80Context* ctx)
  3565. {
  3566. ctx->tstates += 2;
  3567. signed char off = read8(ctx, ctx->PC++);
  3568. BR.E = doSR(ctx, read8(ctx, WR.IX + off), 0);
  3569. write8(ctx, WR.IX + off, BR.E);
  3570. }
  3571. static void LD_E_SRL_off_IY_d (Z80Context* ctx)
  3572. {
  3573. ctx->tstates += 2;
  3574. signed char off = read8(ctx, ctx->PC++);
  3575. BR.E = doSR(ctx, read8(ctx, WR.IY + off), 0);
  3576. write8(ctx, WR.IY + off, BR.E);
  3577. }
  3578. static void LD_H_off_HL (Z80Context* ctx)
  3579. {
  3580. BR.H = read8(ctx, WR.HL);
  3581. }
  3582. static void LD_H_off_IX_d (Z80Context* ctx)
  3583. {
  3584. ctx->tstates += 5;
  3585. BR.H = read8(ctx, WR.IX + (signed char) read8(ctx, ctx->PC++));
  3586. }
  3587. static void LD_H_off_IY_d (Z80Context* ctx)
  3588. {
  3589. ctx->tstates += 5;
  3590. BR.H = read8(ctx, WR.IY + (signed char) read8(ctx, ctx->PC++));
  3591. }
  3592. static void LD_H_A (Z80Context* ctx)
  3593. {
  3594. BR.H = BR.A;
  3595. }
  3596. static void LD_H_B (Z80Context* ctx)
  3597. {
  3598. BR.H = BR.B;
  3599. }
  3600. static void LD_H_C (Z80Context* ctx)
  3601. {
  3602. BR.H = BR.C;
  3603. }
  3604. static void LD_H_D (Z80Context* ctx)
  3605. {
  3606. BR.H = BR.D;
  3607. }
  3608. static void LD_H_E (Z80Context* ctx)
  3609. {
  3610. BR.H = BR.E;
  3611. }
  3612. static void LD_H_H (Z80Context* ctx)
  3613. {
  3614. BR.H = BR.H;
  3615. }
  3616. static void LD_H_L (Z80Context* ctx)
  3617. {
  3618. BR.H = BR.L;
  3619. }
  3620. static void LD_H_n (Z80Context* ctx)
  3621. {
  3622. BR.H = read8(ctx, ctx->PC++);
  3623. }
  3624. static void LD_H_RES_0_off_IX_d (Z80Context* ctx)
  3625. {
  3626. ctx->tstates += 2;
  3627. signed char off = read8(ctx, ctx->PC++);
  3628. BR.H = doSetRes(ctx, SR_RES, 0, read8(ctx, WR.IX + off));
  3629. write8(ctx, WR.IX + off, BR.H);
  3630. }
  3631. static void LD_H_RES_0_off_IY_d (Z80Context* ctx)
  3632. {
  3633. ctx->tstates += 2;
  3634. signed char off = read8(ctx, ctx->PC++);
  3635. BR.H = doSetRes(ctx, SR_RES, 0, read8(ctx, WR.IY + off));
  3636. write8(ctx, WR.IY + off, BR.H);
  3637. }
  3638. static void LD_H_RES_1_off_IX_d (Z80Context* ctx)
  3639. {
  3640. ctx->tstates += 2;
  3641. signed char off = read8(ctx, ctx->PC++);
  3642. BR.H = doSetRes(ctx, SR_RES, 1, read8(ctx, WR.IX + off));
  3643. write8(ctx, WR.IX + off, BR.H);
  3644. }
  3645. static void LD_H_RES_1_off_IY_d (Z80Context* ctx)
  3646. {
  3647. ctx->tstates += 2;
  3648. signed char off = read8(ctx, ctx->PC++);
  3649. BR.H = doSetRes(ctx, SR_RES, 1, read8(ctx, WR.IY + off));
  3650. write8(ctx, WR.IY + off, BR.H);
  3651. }
  3652. static void LD_H_RES_2_off_IX_d (Z80Context* ctx)
  3653. {
  3654. ctx->tstates += 2;
  3655. signed char off = read8(ctx, ctx->PC++);
  3656. BR.H = doSetRes(ctx, SR_RES, 2, read8(ctx, WR.IX + off));
  3657. write8(ctx, WR.IX + off, BR.H);
  3658. }
  3659. static void LD_H_RES_2_off_IY_d (Z80Context* ctx)
  3660. {
  3661. ctx->tstates += 2;
  3662. signed char off = read8(ctx, ctx->PC++);
  3663. BR.H = doSetRes(ctx, SR_RES, 2, read8(ctx, WR.IY + off));
  3664. write8(ctx, WR.IY + off, BR.H);
  3665. }
  3666. static void LD_H_RES_3_off_IX_d (Z80Context* ctx)
  3667. {
  3668. ctx->tstates += 2;
  3669. signed char off = read8(ctx, ctx->PC++);
  3670. BR.H = doSetRes(ctx, SR_RES, 3, read8(ctx, WR.IX + off));
  3671. write8(ctx, WR.IX + off, BR.H);
  3672. }
  3673. static void LD_H_RES_3_off_IY_d (Z80Context* ctx)
  3674. {
  3675. ctx->tstates += 2;
  3676. signed char off = read8(ctx, ctx->PC++);
  3677. BR.H = doSetRes(ctx, SR_RES, 3, read8(ctx, WR.IY + off));
  3678. write8(ctx, WR.IY + off, BR.H);
  3679. }
  3680. static void LD_H_RES_4_off_IX_d (Z80Context* ctx)
  3681. {
  3682. ctx->tstates += 2;
  3683. signed char off = read8(ctx, ctx->PC++);
  3684. BR.H = doSetRes(ctx, SR_RES, 4, read8(ctx, WR.IX + off));
  3685. write8(ctx, WR.IX + off, BR.H);
  3686. }
  3687. static void LD_H_RES_4_off_IY_d (Z80Context* ctx)
  3688. {
  3689. ctx->tstates += 2;
  3690. signed char off = read8(ctx, ctx->PC++);
  3691. BR.H = doSetRes(ctx, SR_RES, 4, read8(ctx, WR.IY + off));
  3692. write8(ctx, WR.IY + off, BR.H);
  3693. }
  3694. static void LD_H_RES_5_off_IX_d (Z80Context* ctx)
  3695. {
  3696. ctx->tstates += 2;
  3697. signed char off = read8(ctx, ctx->PC++);
  3698. BR.H = doSetRes(ctx, SR_RES, 5, read8(ctx, WR.IX + off));
  3699. write8(ctx, WR.IX + off, BR.H);
  3700. }
  3701. static void LD_H_RES_5_off_IY_d (Z80Context* ctx)
  3702. {
  3703. ctx->tstates += 2;
  3704. signed char off = read8(ctx, ctx->PC++);
  3705. BR.H = doSetRes(ctx, SR_RES, 5, read8(ctx, WR.IY + off));
  3706. write8(ctx, WR.IY + off, BR.H);
  3707. }
  3708. static void LD_H_RES_6_off_IX_d (Z80Context* ctx)
  3709. {
  3710. ctx->tstates += 2;
  3711. signed char off = read8(ctx, ctx->PC++);
  3712. BR.H = doSetRes(ctx, SR_RES, 6, read8(ctx, WR.IX + off));
  3713. write8(ctx, WR.IX + off, BR.H);
  3714. }
  3715. static void LD_H_RES_6_off_IY_d (Z80Context* ctx)
  3716. {
  3717. ctx->tstates += 2;
  3718. signed char off = read8(ctx, ctx->PC++);
  3719. BR.H = doSetRes(ctx, SR_RES, 6, read8(ctx, WR.IY + off));
  3720. write8(ctx, WR.IY + off, BR.H);
  3721. }
  3722. static void LD_H_RES_7_off_IX_d (Z80Context* ctx)
  3723. {
  3724. ctx->tstates += 2;
  3725. signed char off = read8(ctx, ctx->PC++);
  3726. BR.H = doSetRes(ctx, SR_RES, 7, read8(ctx, WR.IX + off));
  3727. write8(ctx, WR.IX + off, BR.H);
  3728. }
  3729. static void LD_H_RES_7_off_IY_d (Z80Context* ctx)
  3730. {
  3731. ctx->tstates += 2;
  3732. signed char off = read8(ctx, ctx->PC++);
  3733. BR.H = doSetRes(ctx, SR_RES, 7, read8(ctx, WR.IY + off));
  3734. write8(ctx, WR.IY + off, BR.H);
  3735. }
  3736. static void LD_H_RL_off_IX_d (Z80Context* ctx)
  3737. {
  3738. ctx->tstates += 2;
  3739. signed char off = read8(ctx, ctx->PC++);
  3740. BR.H = doRL(ctx, 1, read8(ctx, WR.IX + off));
  3741. write8(ctx, WR.IX + off, BR.H);
  3742. }
  3743. static void LD_H_RL_off_IY_d (Z80Context* ctx)
  3744. {
  3745. ctx->tstates += 2;
  3746. signed char off = read8(ctx, ctx->PC++);
  3747. BR.H = doRL(ctx, 1, read8(ctx, WR.IY + off));
  3748. write8(ctx, WR.IY + off, BR.H);
  3749. }
  3750. static void LD_H_RLC_off_IX_d (Z80Context* ctx)
  3751. {
  3752. ctx->tstates += 2;
  3753. signed char off = read8(ctx, ctx->PC++);
  3754. BR.H = doRLC(ctx, 1, read8(ctx, WR.IX + off));
  3755. write8(ctx, WR.IX + off, BR.H);
  3756. }
  3757. static void LD_H_RLC_off_IY_d (Z80Context* ctx)
  3758. {
  3759. ctx->tstates += 2;
  3760. signed char off = read8(ctx, ctx->PC++);
  3761. BR.H = doRLC(ctx, 1, read8(ctx, WR.IY + off));
  3762. write8(ctx, WR.IY + off, BR.H);
  3763. }
  3764. static void LD_H_RR_off_IX_d (Z80Context* ctx)
  3765. {
  3766. ctx->tstates += 2;
  3767. signed char off = read8(ctx, ctx->PC++);
  3768. BR.H = doRR(ctx, 1, read8(ctx, WR.IX + off));
  3769. write8(ctx, WR.IX + off, BR.H);
  3770. }
  3771. static void LD_H_RR_off_IY_d (Z80Context* ctx)
  3772. {
  3773. ctx->tstates += 2;
  3774. signed char off = read8(ctx, ctx->PC++);
  3775. BR.H = doRR(ctx, 1, read8(ctx, WR.IY + off));
  3776. write8(ctx, WR.IY + off, BR.H);
  3777. }
  3778. static void LD_H_RRC_off_IX_d (Z80Context* ctx)
  3779. {
  3780. ctx->tstates += 2;
  3781. signed char off = read8(ctx, ctx->PC++);
  3782. BR.H = doRRC(ctx, 1, read8(ctx, WR.IX + off));
  3783. write8(ctx, WR.IX + off, BR.H);
  3784. }
  3785. static void LD_H_RRC_off_IY_d (Z80Context* ctx)
  3786. {
  3787. ctx->tstates += 2;
  3788. signed char off = read8(ctx, ctx->PC++);
  3789. BR.H = doRRC(ctx, 1, read8(ctx, WR.IY + off));
  3790. write8(ctx, WR.IY + off, BR.H);
  3791. }
  3792. static void LD_H_SET_0_off_IX_d (Z80Context* ctx)
  3793. {
  3794. ctx->tstates += 2;
  3795. signed char off = read8(ctx, ctx->PC++);
  3796. BR.H = doSetRes(ctx, SR_SET, 0, read8(ctx, WR.IX + off));
  3797. write8(ctx, WR.IX + off, BR.H);
  3798. }
  3799. static void LD_H_SET_0_off_IY_d (Z80Context* ctx)
  3800. {
  3801. ctx->tstates += 2;
  3802. signed char off = read8(ctx, ctx->PC++);
  3803. BR.H = doSetRes(ctx, SR_SET, 0, read8(ctx, WR.IY + off));
  3804. write8(ctx, WR.IY + off, BR.H);
  3805. }
  3806. static void LD_H_SET_1_off_IX_d (Z80Context* ctx)
  3807. {
  3808. ctx->tstates += 2;
  3809. signed char off = read8(ctx, ctx->PC++);
  3810. BR.H = doSetRes(ctx, SR_SET, 1, read8(ctx, WR.IX + off));
  3811. write8(ctx, WR.IX + off, BR.H);
  3812. }
  3813. static void LD_H_SET_1_off_IY_d (Z80Context* ctx)
  3814. {
  3815. ctx->tstates += 2;
  3816. signed char off = read8(ctx, ctx->PC++);
  3817. BR.H = doSetRes(ctx, SR_SET, 1, read8(ctx, WR.IY + off));
  3818. write8(ctx, WR.IY + off, BR.H);
  3819. }
  3820. static void LD_H_SET_2_off_IX_d (Z80Context* ctx)
  3821. {
  3822. ctx->tstates += 2;
  3823. signed char off = read8(ctx, ctx->PC++);
  3824. BR.H = doSetRes(ctx, SR_SET, 2, read8(ctx, WR.IX + off));
  3825. write8(ctx, WR.IX + off, BR.H);
  3826. }
  3827. static void LD_H_SET_2_off_IY_d (Z80Context* ctx)
  3828. {
  3829. ctx->tstates += 2;
  3830. signed char off = read8(ctx, ctx->PC++);
  3831. BR.H = doSetRes(ctx, SR_SET, 2, read8(ctx, WR.IY + off));
  3832. write8(ctx, WR.IY + off, BR.H);
  3833. }
  3834. static void LD_H_SET_3_off_IX_d (Z80Context* ctx)
  3835. {
  3836. ctx->tstates += 2;
  3837. signed char off = read8(ctx, ctx->PC++);
  3838. BR.H = doSetRes(ctx, SR_SET, 3, read8(ctx, WR.IX + off));
  3839. write8(ctx, WR.IX + off, BR.H);
  3840. }
  3841. static void LD_H_SET_3_off_IY_d (Z80Context* ctx)
  3842. {
  3843. ctx->tstates += 2;
  3844. signed char off = read8(ctx, ctx->PC++);
  3845. BR.H = doSetRes(ctx, SR_SET, 3, read8(ctx, WR.IY + off));
  3846. write8(ctx, WR.IY + off, BR.H);
  3847. }
  3848. static void LD_H_SET_4_off_IX_d (Z80Context* ctx)
  3849. {
  3850. ctx->tstates += 2;
  3851. signed char off = read8(ctx, ctx->PC++);
  3852. BR.H = doSetRes(ctx, SR_SET, 4, read8(ctx, WR.IX + off));
  3853. write8(ctx, WR.IX + off, BR.H);
  3854. }
  3855. static void LD_H_SET_4_off_IY_d (Z80Context* ctx)
  3856. {
  3857. ctx->tstates += 2;
  3858. signed char off = read8(ctx, ctx->PC++);
  3859. BR.H = doSetRes(ctx, SR_SET, 4, read8(ctx, WR.IY + off));
  3860. write8(ctx, WR.IY + off, BR.H);
  3861. }
  3862. static void LD_H_SET_5_off_IX_d (Z80Context* ctx)
  3863. {
  3864. ctx->tstates += 2;
  3865. signed char off = read8(ctx, ctx->PC++);
  3866. BR.H = doSetRes(ctx, SR_SET, 5, read8(ctx, WR.IX + off));
  3867. write8(ctx, WR.IX + off, BR.H);
  3868. }
  3869. static void LD_H_SET_5_off_IY_d (Z80Context* ctx)
  3870. {
  3871. ctx->tstates += 2;
  3872. signed char off = read8(ctx, ctx->PC++);
  3873. BR.H = doSetRes(ctx, SR_SET, 5, read8(ctx, WR.IY + off));
  3874. write8(ctx, WR.IY + off, BR.H);
  3875. }
  3876. static void LD_H_SET_6_off_IX_d (Z80Context* ctx)
  3877. {
  3878. ctx->tstates += 2;
  3879. signed char off = read8(ctx, ctx->PC++);
  3880. BR.H = doSetRes(ctx, SR_SET, 6, read8(ctx, WR.IX + off));
  3881. write8(ctx, WR.IX + off, BR.H);
  3882. }
  3883. static void LD_H_SET_6_off_IY_d (Z80Context* ctx)
  3884. {
  3885. ctx->tstates += 2;
  3886. signed char off = read8(ctx, ctx->PC++);
  3887. BR.H = doSetRes(ctx, SR_SET, 6, read8(ctx, WR.IY + off));
  3888. write8(ctx, WR.IY + off, BR.H);
  3889. }
  3890. static void LD_H_SET_7_off_IX_d (Z80Context* ctx)
  3891. {
  3892. ctx->tstates += 2;
  3893. signed char off = read8(ctx, ctx->PC++);
  3894. BR.H = doSetRes(ctx, SR_SET, 7, read8(ctx, WR.IX + off));
  3895. write8(ctx, WR.IX + off, BR.H);
  3896. }
  3897. static void LD_H_SET_7_off_IY_d (Z80Context* ctx)
  3898. {
  3899. ctx->tstates += 2;
  3900. signed char off = read8(ctx, ctx->PC++);
  3901. BR.H = doSetRes(ctx, SR_SET, 7, read8(ctx, WR.IY + off));
  3902. write8(ctx, WR.IY + off, BR.H);
  3903. }
  3904. static void LD_H_SLA_off_IX_d (Z80Context* ctx)
  3905. {
  3906. ctx->tstates += 2;
  3907. signed char off = read8(ctx, ctx->PC++);
  3908. BR.H = doSL(ctx, read8(ctx, WR.IX + off), 1);
  3909. write8(ctx, WR.IX + off, BR.H);
  3910. }
  3911. static void LD_H_SLA_off_IY_d (Z80Context* ctx)
  3912. {
  3913. ctx->tstates += 2;
  3914. signed char off = read8(ctx, ctx->PC++);
  3915. BR.H = doSL(ctx, read8(ctx, WR.IY + off), 1);
  3916. write8(ctx, WR.IY + off, BR.H);
  3917. }
  3918. static void LD_H_SLL_off_IX_d (Z80Context* ctx)
  3919. {
  3920. ctx->tstates += 2;
  3921. signed char off = read8(ctx, ctx->PC++);
  3922. BR.H = doSL(ctx, read8(ctx, WR.IX + off), 0);
  3923. write8(ctx, WR.IX + off, BR.H);
  3924. }
  3925. static void LD_H_SLL_off_IY_d (Z80Context* ctx)
  3926. {
  3927. ctx->tstates += 2;
  3928. signed char off = read8(ctx, ctx->PC++);
  3929. BR.H = doSL(ctx, read8(ctx, WR.IY + off), 0);
  3930. write8(ctx, WR.IY + off, BR.H);
  3931. }
  3932. static void LD_H_SRA_off_IX_d (Z80Context* ctx)
  3933. {
  3934. ctx->tstates += 2;
  3935. signed char off = read8(ctx, ctx->PC++);
  3936. BR.H = doSR(ctx, read8(ctx, WR.IX + off), 1);
  3937. write8(ctx, WR.IX + off, BR.H);
  3938. }
  3939. static void LD_H_SRA_off_IY_d (Z80Context* ctx)
  3940. {
  3941. ctx->tstates += 2;
  3942. signed char off = read8(ctx, ctx->PC++);
  3943. BR.H = doSR(ctx, read8(ctx, WR.IY + off), 1);
  3944. write8(ctx, WR.IY + off, BR.H);
  3945. }
  3946. static void LD_H_SRL_off_IX_d (Z80Context* ctx)
  3947. {
  3948. ctx->tstates += 2;
  3949. signed char off = read8(ctx, ctx->PC++);
  3950. BR.H = doSR(ctx, read8(ctx, WR.IX + off), 0);
  3951. write8(ctx, WR.IX + off, BR.H);
  3952. }
  3953. static void LD_H_SRL_off_IY_d (Z80Context* ctx)
  3954. {
  3955. ctx->tstates += 2;
  3956. signed char off = read8(ctx, ctx->PC++);
  3957. BR.H = doSR(ctx, read8(ctx, WR.IY + off), 0);
  3958. write8(ctx, WR.IY + off, BR.H);
  3959. }
  3960. static void LD_HL_off_nn (Z80Context* ctx)
  3961. {
  3962. ushort addr = read16(ctx, ctx->PC);
  3963. ctx->PC += 2;
  3964. WR.HL = read16(ctx, addr);
  3965. }
  3966. static void LD_HL_nn (Z80Context* ctx)
  3967. {
  3968. WR.HL = read16(ctx, ctx->PC);
  3969. ctx->PC += 2;
  3970. }
  3971. static void LD_I_A (Z80Context* ctx)
  3972. {
  3973. ctx->tstates += 1;
  3974. ctx->I = BR.A;
  3975. }
  3976. static void LD_IX_off_nn (Z80Context* ctx)
  3977. {
  3978. ushort addr = read16(ctx, ctx->PC);
  3979. ctx->PC += 2;
  3980. WR.IX = read16(ctx, addr);
  3981. }
  3982. static void LD_IX_nn (Z80Context* ctx)
  3983. {
  3984. WR.IX = read16(ctx, ctx->PC);
  3985. ctx->PC += 2;
  3986. }
  3987. static void LD_IXh_A (Z80Context* ctx)
  3988. {
  3989. BR.IXh = BR.A;
  3990. }
  3991. static void LD_IXh_B (Z80Context* ctx)
  3992. {
  3993. BR.IXh = BR.B;
  3994. }
  3995. static void LD_IXh_C (Z80Context* ctx)
  3996. {
  3997. BR.IXh = BR.C;
  3998. }
  3999. static void LD_IXh_D (Z80Context* ctx)
  4000. {
  4001. BR.IXh = BR.D;
  4002. }
  4003. static void LD_IXh_E (Z80Context* ctx)
  4004. {
  4005. BR.IXh = BR.E;
  4006. }
  4007. static void LD_IXh_IXh (Z80Context* ctx)
  4008. {
  4009. BR.IXh = BR.IXh;
  4010. }
  4011. static void LD_IXh_IXl (Z80Context* ctx)
  4012. {
  4013. BR.IXh = BR.IXl;
  4014. }
  4015. static void LD_IXh_n (Z80Context* ctx)
  4016. {
  4017. BR.IXh = read8(ctx, ctx->PC++);
  4018. }
  4019. static void LD_IXl_A (Z80Context* ctx)
  4020. {
  4021. BR.IXl = BR.A;
  4022. }
  4023. static void LD_IXl_B (Z80Context* ctx)
  4024. {
  4025. BR.IXl = BR.B;
  4026. }
  4027. static void LD_IXl_C (Z80Context* ctx)
  4028. {
  4029. BR.IXl = BR.C;
  4030. }
  4031. static void LD_IXl_D (Z80Context* ctx)
  4032. {
  4033. BR.IXl = BR.D;
  4034. }
  4035. static void LD_IXl_E (Z80Context* ctx)
  4036. {
  4037. BR.IXl = BR.E;
  4038. }
  4039. static void LD_IXl_IXh (Z80Context* ctx)
  4040. {
  4041. BR.IXl = BR.IXh;
  4042. }
  4043. static void LD_IXl_IXl (Z80Context* ctx)
  4044. {
  4045. BR.IXl = BR.IXl;
  4046. }
  4047. static void LD_IXl_n (Z80Context* ctx)
  4048. {
  4049. BR.IXl = read8(ctx, ctx->PC++);
  4050. }
  4051. static void LD_IY_off_nn (Z80Context* ctx)
  4052. {
  4053. ushort addr = read16(ctx, ctx->PC);
  4054. ctx->PC += 2;
  4055. WR.IY = read16(ctx, addr);
  4056. }
  4057. static void LD_IY_nn (Z80Context* ctx)
  4058. {
  4059. WR.IY = read16(ctx, ctx->PC);
  4060. ctx->PC += 2;
  4061. }
  4062. static void LD_IYh_A (Z80Context* ctx)
  4063. {
  4064. BR.IYh = BR.A;
  4065. }
  4066. static void LD_IYh_B (Z80Context* ctx)
  4067. {
  4068. BR.IYh = BR.B;
  4069. }
  4070. static void LD_IYh_C (Z80Context* ctx)
  4071. {
  4072. BR.IYh = BR.C;
  4073. }
  4074. static void LD_IYh_D (Z80Context* ctx)
  4075. {
  4076. BR.IYh = BR.D;
  4077. }
  4078. static void LD_IYh_E (Z80Context* ctx)
  4079. {
  4080. BR.IYh = BR.E;
  4081. }
  4082. static void LD_IYh_IYh (Z80Context* ctx)
  4083. {
  4084. BR.IYh = BR.IYh;
  4085. }
  4086. static void LD_IYh_IYl (Z80Context* ctx)
  4087. {
  4088. BR.IYh = BR.IYl;
  4089. }
  4090. static void LD_IYh_n (Z80Context* ctx)
  4091. {
  4092. BR.IYh = read8(ctx, ctx->PC++);
  4093. }
  4094. static void LD_IYl_A (Z80Context* ctx)
  4095. {
  4096. BR.IYl = BR.A;
  4097. }
  4098. static void LD_IYl_B (Z80Context* ctx)
  4099. {
  4100. BR.IYl = BR.B;
  4101. }
  4102. static void LD_IYl_C (Z80Context* ctx)
  4103. {
  4104. BR.IYl = BR.C;
  4105. }
  4106. static void LD_IYl_D (Z80Context* ctx)
  4107. {
  4108. BR.IYl = BR.D;
  4109. }
  4110. static void LD_IYl_E (Z80Context* ctx)
  4111. {
  4112. BR.IYl = BR.E;
  4113. }
  4114. static void LD_IYl_IYh (Z80Context* ctx)
  4115. {
  4116. BR.IYl = BR.IYh;
  4117. }
  4118. static void LD_IYl_IYl (Z80Context* ctx)
  4119. {
  4120. BR.IYl = BR.IYl;
  4121. }
  4122. static void LD_IYl_n (Z80Context* ctx)
  4123. {
  4124. BR.IYl = read8(ctx, ctx->PC++);
  4125. }
  4126. static void LD_L_off_HL (Z80Context* ctx)
  4127. {
  4128. BR.L = read8(ctx, WR.HL);
  4129. }
  4130. static void LD_L_off_IX_d (Z80Context* ctx)
  4131. {
  4132. ctx->tstates += 5;
  4133. BR.L = read8(ctx, WR.IX + (signed char) read8(ctx, ctx->PC++));
  4134. }
  4135. static void LD_L_off_IY_d (Z80Context* ctx)
  4136. {
  4137. ctx->tstates += 5;
  4138. BR.L = read8(ctx, WR.IY + (signed char) read8(ctx, ctx->PC++));
  4139. }
  4140. static void LD_L_A (Z80Context* ctx)
  4141. {
  4142. BR.L = BR.A;
  4143. }
  4144. static void LD_L_B (Z80Context* ctx)
  4145. {
  4146. BR.L = BR.B;
  4147. }
  4148. static void LD_L_C (Z80Context* ctx)
  4149. {
  4150. BR.L = BR.C;
  4151. }
  4152. static void LD_L_D (Z80Context* ctx)
  4153. {
  4154. BR.L = BR.D;
  4155. }
  4156. static void LD_L_E (Z80Context* ctx)
  4157. {
  4158. BR.L = BR.E;
  4159. }
  4160. static void LD_L_H (Z80Context* ctx)
  4161. {
  4162. BR.L = BR.H;
  4163. }
  4164. static void LD_L_L (Z80Context* ctx)
  4165. {
  4166. BR.L = BR.L;
  4167. }
  4168. static void LD_L_n (Z80Context* ctx)
  4169. {
  4170. BR.L = read8(ctx, ctx->PC++);
  4171. }
  4172. static void LD_L_RES_0_off_IX_d (Z80Context* ctx)
  4173. {
  4174. ctx->tstates += 2;
  4175. signed char off = read8(ctx, ctx->PC++);
  4176. BR.L = doSetRes(ctx, SR_RES, 0, read8(ctx, WR.IX + off));
  4177. write8(ctx, WR.IX + off, BR.L);
  4178. }
  4179. static void LD_L_RES_0_off_IY_d (Z80Context* ctx)
  4180. {
  4181. ctx->tstates += 2;
  4182. signed char off = read8(ctx, ctx->PC++);
  4183. BR.L = doSetRes(ctx, SR_RES, 0, read8(ctx, WR.IY + off));
  4184. write8(ctx, WR.IY + off, BR.L);
  4185. }
  4186. static void LD_L_RES_1_off_IX_d (Z80Context* ctx)
  4187. {
  4188. ctx->tstates += 2;
  4189. signed char off = read8(ctx, ctx->PC++);
  4190. BR.L = doSetRes(ctx, SR_RES, 1, read8(ctx, WR.IX + off));
  4191. write8(ctx, WR.IX + off, BR.L);
  4192. }
  4193. static void LD_L_RES_1_off_IY_d (Z80Context* ctx)
  4194. {
  4195. ctx->tstates += 2;
  4196. signed char off = read8(ctx, ctx->PC++);
  4197. BR.L = doSetRes(ctx, SR_RES, 1, read8(ctx, WR.IY + off));
  4198. write8(ctx, WR.IY + off, BR.L);
  4199. }
  4200. static void LD_L_RES_2_off_IX_d (Z80Context* ctx)
  4201. {
  4202. ctx->tstates += 2;
  4203. signed char off = read8(ctx, ctx->PC++);
  4204. BR.L = doSetRes(ctx, SR_RES, 2, read8(ctx, WR.IX + off));
  4205. write8(ctx, WR.IX + off, BR.L);
  4206. }
  4207. static void LD_L_RES_2_off_IY_d (Z80Context* ctx)
  4208. {
  4209. ctx->tstates += 2;
  4210. signed char off = read8(ctx, ctx->PC++);
  4211. BR.L = doSetRes(ctx, SR_RES, 2, read8(ctx, WR.IY + off));
  4212. write8(ctx, WR.IY + off, BR.L);
  4213. }
  4214. static void LD_L_RES_3_off_IX_d (Z80Context* ctx)
  4215. {
  4216. ctx->tstates += 2;
  4217. signed char off = read8(ctx, ctx->PC++);
  4218. BR.L = doSetRes(ctx, SR_RES, 3, read8(ctx, WR.IX + off));
  4219. write8(ctx, WR.IX + off, BR.L);
  4220. }
  4221. static void LD_L_RES_3_off_IY_d (Z80Context* ctx)
  4222. {
  4223. ctx->tstates += 2;
  4224. signed char off = read8(ctx, ctx->PC++);
  4225. BR.L = doSetRes(ctx, SR_RES, 3, read8(ctx, WR.IY + off));
  4226. write8(ctx, WR.IY + off, BR.L);
  4227. }
  4228. static void LD_L_RES_4_off_IX_d (Z80Context* ctx)
  4229. {
  4230. ctx->tstates += 2;
  4231. signed char off = read8(ctx, ctx->PC++);
  4232. BR.L = doSetRes(ctx, SR_RES, 4, read8(ctx, WR.IX + off));
  4233. write8(ctx, WR.IX + off, BR.L);
  4234. }
  4235. static void LD_L_RES_4_off_IY_d (Z80Context* ctx)
  4236. {
  4237. ctx->tstates += 2;
  4238. signed char off = read8(ctx, ctx->PC++);
  4239. BR.L = doSetRes(ctx, SR_RES, 4, read8(ctx, WR.IY + off));
  4240. write8(ctx, WR.IY + off, BR.L);
  4241. }
  4242. static void LD_L_RES_5_off_IX_d (Z80Context* ctx)
  4243. {
  4244. ctx->tstates += 2;
  4245. signed char off = read8(ctx, ctx->PC++);
  4246. BR.L = doSetRes(ctx, SR_RES, 5, read8(ctx, WR.IX + off));
  4247. write8(ctx, WR.IX + off, BR.L);
  4248. }
  4249. static void LD_L_RES_5_off_IY_d (Z80Context* ctx)
  4250. {
  4251. ctx->tstates += 2;
  4252. signed char off = read8(ctx, ctx->PC++);
  4253. BR.L = doSetRes(ctx, SR_RES, 5, read8(ctx, WR.IY + off));
  4254. write8(ctx, WR.IY + off, BR.L);
  4255. }
  4256. static void LD_L_RES_6_off_IX_d (Z80Context* ctx)
  4257. {
  4258. ctx->tstates += 2;
  4259. signed char off = read8(ctx, ctx->PC++);
  4260. BR.L = doSetRes(ctx, SR_RES, 6, read8(ctx, WR.IX + off));
  4261. write8(ctx, WR.IX + off, BR.L);
  4262. }
  4263. static void LD_L_RES_6_off_IY_d (Z80Context* ctx)
  4264. {
  4265. ctx->tstates += 2;
  4266. signed char off = read8(ctx, ctx->PC++);
  4267. BR.L = doSetRes(ctx, SR_RES, 6, read8(ctx, WR.IY + off));
  4268. write8(ctx, WR.IY + off, BR.L);
  4269. }
  4270. static void LD_L_RES_7_off_IX_d (Z80Context* ctx)
  4271. {
  4272. ctx->tstates += 2;
  4273. signed char off = read8(ctx, ctx->PC++);
  4274. BR.L = doSetRes(ctx, SR_RES, 7, read8(ctx, WR.IX + off));
  4275. write8(ctx, WR.IX + off, BR.L);
  4276. }
  4277. static void LD_L_RES_7_off_IY_d (Z80Context* ctx)
  4278. {
  4279. ctx->tstates += 2;
  4280. signed char off = read8(ctx, ctx->PC++);
  4281. BR.L = doSetRes(ctx, SR_RES, 7, read8(ctx, WR.IY + off));
  4282. write8(ctx, WR.IY + off, BR.L);
  4283. }
  4284. static void LD_L_RL_off_IX_d (Z80Context* ctx)
  4285. {
  4286. ctx->tstates += 2;
  4287. signed char off = read8(ctx, ctx->PC++);
  4288. BR.L = doRL(ctx, 1, read8(ctx, WR.IX + off));
  4289. write8(ctx, WR.IX + off, BR.L);
  4290. }
  4291. static void LD_L_RL_off_IY_d (Z80Context* ctx)
  4292. {
  4293. ctx->tstates += 2;
  4294. signed char off = read8(ctx, ctx->PC++);
  4295. BR.L = doRL(ctx, 1, read8(ctx, WR.IY + off));
  4296. write8(ctx, WR.IY + off, BR.L);
  4297. }
  4298. static void LD_L_RLC_off_IX_d (Z80Context* ctx)
  4299. {
  4300. ctx->tstates += 2;
  4301. signed char off = read8(ctx, ctx->PC++);
  4302. BR.L = doRLC(ctx, 1, read8(ctx, WR.IX + off));
  4303. write8(ctx, WR.IX + off, BR.L);
  4304. }
  4305. static void LD_L_RLC_off_IY_d (Z80Context* ctx)
  4306. {
  4307. ctx->tstates += 2;
  4308. signed char off = read8(ctx, ctx->PC++);
  4309. BR.L = doRLC(ctx, 1, read8(ctx, WR.IY + off));
  4310. write8(ctx, WR.IY + off, BR.L);
  4311. }
  4312. static void LD_L_RR_off_IX_d (Z80Context* ctx)
  4313. {
  4314. ctx->tstates += 2;
  4315. signed char off = read8(ctx, ctx->PC++);
  4316. BR.L = doRR(ctx, 1, read8(ctx, WR.IX + off));
  4317. write8(ctx, WR.IX + off, BR.L);
  4318. }
  4319. static void LD_L_RR_off_IY_d (Z80Context* ctx)
  4320. {
  4321. ctx->tstates += 2;
  4322. signed char off = read8(ctx, ctx->PC++);
  4323. BR.L = doRR(ctx, 1, read8(ctx, WR.IY + off));
  4324. write8(ctx, WR.IY + off, BR.L);
  4325. }
  4326. static void LD_L_RRC_off_IX_d (Z80Context* ctx)
  4327. {
  4328. ctx->tstates += 2;
  4329. signed char off = read8(ctx, ctx->PC++);
  4330. BR.L = doRRC(ctx, 1, read8(ctx, WR.IX + off));
  4331. write8(ctx, WR.IX + off, BR.L);
  4332. }
  4333. static void LD_L_RRC_off_IY_d (Z80Context* ctx)
  4334. {
  4335. ctx->tstates += 2;
  4336. signed char off = read8(ctx, ctx->PC++);
  4337. BR.L = doRRC(ctx, 1, read8(ctx, WR.IY + off));
  4338. write8(ctx, WR.IY + off, BR.L);
  4339. }
  4340. static void LD_L_SET_0_off_IX_d (Z80Context* ctx)
  4341. {
  4342. ctx->tstates += 2;
  4343. signed char off = read8(ctx, ctx->PC++);
  4344. BR.L = doSetRes(ctx, SR_SET, 0, read8(ctx, WR.IX + off));
  4345. write8(ctx, WR.IX + off, BR.L);
  4346. }
  4347. static void LD_L_SET_0_off_IY_d (Z80Context* ctx)
  4348. {
  4349. ctx->tstates += 2;
  4350. signed char off = read8(ctx, ctx->PC++);
  4351. BR.L = doSetRes(ctx, SR_SET, 0, read8(ctx, WR.IY + off));
  4352. write8(ctx, WR.IY + off, BR.L);
  4353. }
  4354. static void LD_L_SET_1_off_IX_d (Z80Context* ctx)
  4355. {
  4356. ctx->tstates += 2;
  4357. signed char off = read8(ctx, ctx->PC++);
  4358. BR.L = doSetRes(ctx, SR_SET, 1, read8(ctx, WR.IX + off));
  4359. write8(ctx, WR.IX + off, BR.L);
  4360. }
  4361. static void LD_L_SET_1_off_IY_d (Z80Context* ctx)
  4362. {
  4363. ctx->tstates += 2;
  4364. signed char off = read8(ctx, ctx->PC++);
  4365. BR.L = doSetRes(ctx, SR_SET, 1, read8(ctx, WR.IY + off));
  4366. write8(ctx, WR.IY + off, BR.L);
  4367. }
  4368. static void LD_L_SET_2_off_IX_d (Z80Context* ctx)
  4369. {
  4370. ctx->tstates += 2;
  4371. signed char off = read8(ctx, ctx->PC++);
  4372. BR.L = doSetRes(ctx, SR_SET, 2, read8(ctx, WR.IX + off));
  4373. write8(ctx, WR.IX + off, BR.L);
  4374. }
  4375. static void LD_L_SET_2_off_IY_d (Z80Context* ctx)
  4376. {
  4377. ctx->tstates += 2;
  4378. signed char off = read8(ctx, ctx->PC++);
  4379. BR.L = doSetRes(ctx, SR_SET, 2, read8(ctx, WR.IY + off));
  4380. write8(ctx, WR.IY + off, BR.L);
  4381. }
  4382. static void LD_L_SET_3_off_IX_d (Z80Context* ctx)
  4383. {
  4384. ctx->tstates += 2;
  4385. signed char off = read8(ctx, ctx->PC++);
  4386. BR.L = doSetRes(ctx, SR_SET, 3, read8(ctx, WR.IX + off));
  4387. write8(ctx, WR.IX + off, BR.L);
  4388. }
  4389. static void LD_L_SET_3_off_IY_d (Z80Context* ctx)
  4390. {
  4391. ctx->tstates += 2;
  4392. signed char off = read8(ctx, ctx->PC++);
  4393. BR.L = doSetRes(ctx, SR_SET, 3, read8(ctx, WR.IY + off));
  4394. write8(ctx, WR.IY + off, BR.L);
  4395. }
  4396. static void LD_L_SET_4_off_IX_d (Z80Context* ctx)
  4397. {
  4398. ctx->tstates += 2;
  4399. signed char off = read8(ctx, ctx->PC++);
  4400. BR.L = doSetRes(ctx, SR_SET, 4, read8(ctx, WR.IX + off));
  4401. write8(ctx, WR.IX + off, BR.L);
  4402. }
  4403. static void LD_L_SET_4_off_IY_d (Z80Context* ctx)
  4404. {
  4405. ctx->tstates += 2;
  4406. signed char off = read8(ctx, ctx->PC++);
  4407. BR.L = doSetRes(ctx, SR_SET, 4, read8(ctx, WR.IY + off));
  4408. write8(ctx, WR.IY + off, BR.L);
  4409. }
  4410. static void LD_L_SET_5_off_IX_d (Z80Context* ctx)
  4411. {
  4412. ctx->tstates += 2;
  4413. signed char off = read8(ctx, ctx->PC++);
  4414. BR.L = doSetRes(ctx, SR_SET, 5, read8(ctx, WR.IX + off));
  4415. write8(ctx, WR.IX + off, BR.L);
  4416. }
  4417. static void LD_L_SET_5_off_IY_d (Z80Context* ctx)
  4418. {
  4419. ctx->tstates += 2;
  4420. signed char off = read8(ctx, ctx->PC++);
  4421. BR.L = doSetRes(ctx, SR_SET, 5, read8(ctx, WR.IY + off));
  4422. write8(ctx, WR.IY + off, BR.L);
  4423. }
  4424. static void LD_L_SET_6_off_IX_d (Z80Context* ctx)
  4425. {
  4426. ctx->tstates += 2;
  4427. signed char off = read8(ctx, ctx->PC++);
  4428. BR.L = doSetRes(ctx, SR_SET, 6, read8(ctx, WR.IX + off));
  4429. write8(ctx, WR.IX + off, BR.L);
  4430. }
  4431. static void LD_L_SET_6_off_IY_d (Z80Context* ctx)
  4432. {
  4433. ctx->tstates += 2;
  4434. signed char off = read8(ctx, ctx->PC++);
  4435. BR.L = doSetRes(ctx, SR_SET, 6, read8(ctx, WR.IY + off));
  4436. write8(ctx, WR.IY + off, BR.L);
  4437. }
  4438. static void LD_L_SET_7_off_IX_d (Z80Context* ctx)
  4439. {
  4440. ctx->tstates += 2;
  4441. signed char off = read8(ctx, ctx->PC++);
  4442. BR.L = doSetRes(ctx, SR_SET, 7, read8(ctx, WR.IX + off));
  4443. write8(ctx, WR.IX + off, BR.L);
  4444. }
  4445. static void LD_L_SET_7_off_IY_d (Z80Context* ctx)
  4446. {
  4447. ctx->tstates += 2;
  4448. signed char off = read8(ctx, ctx->PC++);
  4449. BR.L = doSetRes(ctx, SR_SET, 7, read8(ctx, WR.IY + off));
  4450. write8(ctx, WR.IY + off, BR.L);
  4451. }
  4452. static void LD_L_SLA_off_IX_d (Z80Context* ctx)
  4453. {
  4454. ctx->tstates += 2;
  4455. signed char off = read8(ctx, ctx->PC++);
  4456. BR.L = doSL(ctx, read8(ctx, WR.IX + off), 1);
  4457. write8(ctx, WR.IX + off, BR.L);
  4458. }
  4459. static void LD_L_SLA_off_IY_d (Z80Context* ctx)
  4460. {
  4461. ctx->tstates += 2;
  4462. signed char off = read8(ctx, ctx->PC++);
  4463. BR.L = doSL(ctx, read8(ctx, WR.IY + off), 1);
  4464. write8(ctx, WR.IY + off, BR.L);
  4465. }
  4466. static void LD_L_SLL_off_IX_d (Z80Context* ctx)
  4467. {
  4468. ctx->tstates += 2;
  4469. signed char off = read8(ctx, ctx->PC++);
  4470. BR.L = doSL(ctx, read8(ctx, WR.IX + off), 0);
  4471. write8(ctx, WR.IX + off, BR.L);
  4472. }
  4473. static void LD_L_SLL_off_IY_d (Z80Context* ctx)
  4474. {
  4475. ctx->tstates += 2;
  4476. signed char off = read8(ctx, ctx->PC++);
  4477. BR.L = doSL(ctx, read8(ctx, WR.IY + off), 0);
  4478. write8(ctx, WR.IY + off, BR.L);
  4479. }
  4480. static void LD_L_SRA_off_IX_d (Z80Context* ctx)
  4481. {
  4482. ctx->tstates += 2;
  4483. signed char off = read8(ctx, ctx->PC++);
  4484. BR.L = doSR(ctx, read8(ctx, WR.IX + off), 1);
  4485. write8(ctx, WR.IX + off, BR.L);
  4486. }
  4487. static void LD_L_SRA_off_IY_d (Z80Context* ctx)
  4488. {
  4489. ctx->tstates += 2;
  4490. signed char off = read8(ctx, ctx->PC++);
  4491. BR.L = doSR(ctx, read8(ctx, WR.IY + off), 1);
  4492. write8(ctx, WR.IY + off, BR.L);
  4493. }
  4494. static void LD_L_SRL_off_IX_d (Z80Context* ctx)
  4495. {
  4496. ctx->tstates += 2;
  4497. signed char off = read8(ctx, ctx->PC++);
  4498. BR.L = doSR(ctx, read8(ctx, WR.IX + off), 0);
  4499. write8(ctx, WR.IX + off, BR.L);
  4500. }
  4501. static void LD_L_SRL_off_IY_d (Z80Context* ctx)
  4502. {
  4503. ctx->tstates += 2;
  4504. signed char off = read8(ctx, ctx->PC++);
  4505. BR.L = doSR(ctx, read8(ctx, WR.IY + off), 0);
  4506. write8(ctx, WR.IY + off, BR.L);
  4507. }
  4508. static void LD_R_A (Z80Context* ctx)
  4509. {
  4510. ctx->tstates += 1;
  4511. ctx->R = BR.A;
  4512. }
  4513. static void LD_SP_off_nn (Z80Context* ctx)
  4514. {
  4515. ushort addr = read16(ctx, ctx->PC);
  4516. ctx->PC += 2;
  4517. WR.SP = read16(ctx, addr);
  4518. }
  4519. static void LD_SP_HL (Z80Context* ctx)
  4520. {
  4521. ctx->tstates += 2;
  4522. WR.SP = WR.HL;
  4523. }
  4524. static void LD_SP_IX (Z80Context* ctx)
  4525. {
  4526. ctx->tstates += 2;
  4527. WR.SP = WR.IX;
  4528. }
  4529. static void LD_SP_IY (Z80Context* ctx)
  4530. {
  4531. ctx->tstates += 2;
  4532. WR.SP = WR.IY;
  4533. }
  4534. static void LD_SP_nn (Z80Context* ctx)
  4535. {
  4536. WR.SP = read16(ctx, ctx->PC);
  4537. ctx->PC += 2;
  4538. }
  4539. static void LDD (Z80Context* ctx)
  4540. {
  4541. ctx->tstates += 2;
  4542. byte val = read8(ctx, WR.HL);
  4543. write8(ctx, WR.DE, val);
  4544. WR.DE--;
  4545. WR.HL--;
  4546. WR.BC--;
  4547. VALFLAG(F_5, ((BR.A + val) & 0x02) != 0);
  4548. VALFLAG(F_3, ((BR.A + val) & F_3) != 0);
  4549. RESFLAG(F_H | F_N);
  4550. VALFLAG(F_PV, WR.BC != 0);
  4551. }
  4552. static void LDDR (Z80Context* ctx)
  4553. {
  4554. LDD(ctx);
  4555. if (WR.BC != 0)
  4556. {
  4557. ctx->tstates += 5;
  4558. ctx->PC -= 2;
  4559. }
  4560. }
  4561. static void LDI (Z80Context* ctx)
  4562. {
  4563. ctx->tstates += 2;
  4564. byte val = read8(ctx, WR.HL);
  4565. write8(ctx, WR.DE, val);
  4566. WR.DE++;
  4567. WR.HL++;
  4568. WR.BC--;
  4569. VALFLAG(F_5, (BR.A + val) & 0x02);
  4570. VALFLAG(F_3, ((BR.A + val) & F_3) != 0);
  4571. RESFLAG(F_H | F_N);
  4572. VALFLAG(F_PV, WR.BC != 0);
  4573. }
  4574. static void LDIR (Z80Context* ctx)
  4575. {
  4576. LDI(ctx);
  4577. if (WR.BC != 0)
  4578. {
  4579. ctx->tstates += 5;
  4580. ctx->PC -= 2;
  4581. }
  4582. }
  4583. static void NEG (Z80Context* ctx)
  4584. {
  4585. int temp = BR.A;
  4586. BR.A = 0;
  4587. BR.A = doArithmetic(ctx, temp, 0, 1);
  4588. SETFLAG(F_N);
  4589. }
  4590. static void NOP (Z80Context* ctx)
  4591. {
  4592. /* NOP */
  4593. }
  4594. static void OR_off_HL (Z80Context* ctx)
  4595. {
  4596. doOR(ctx, read8(ctx, WR.HL));
  4597. }
  4598. static void OR_off_IX_d (Z80Context* ctx)
  4599. {
  4600. ctx->tstates += 5;
  4601. doOR(ctx, read8(ctx, WR.IX + (signed char) read8(ctx, ctx->PC++)));
  4602. }
  4603. static void OR_off_IY_d (Z80Context* ctx)
  4604. {
  4605. ctx->tstates += 5;
  4606. doOR(ctx, read8(ctx, WR.IY + (signed char) read8(ctx, ctx->PC++)));
  4607. }
  4608. static void OR_A (Z80Context* ctx)
  4609. {
  4610. doOR(ctx, BR.A);
  4611. }
  4612. static void OR_B (Z80Context* ctx)
  4613. {
  4614. doOR(ctx, BR.B);
  4615. }
  4616. static void OR_C (Z80Context* ctx)
  4617. {
  4618. doOR(ctx, BR.C);
  4619. }
  4620. static void OR_D (Z80Context* ctx)
  4621. {
  4622. doOR(ctx, BR.D);
  4623. }
  4624. static void OR_E (Z80Context* ctx)
  4625. {
  4626. doOR(ctx, BR.E);
  4627. }
  4628. static void OR_H (Z80Context* ctx)
  4629. {
  4630. doOR(ctx, BR.H);
  4631. }
  4632. static void OR_IXh (Z80Context* ctx)
  4633. {
  4634. doOR(ctx, BR.IXh);
  4635. }
  4636. static void OR_IXl (Z80Context* ctx)
  4637. {
  4638. doOR(ctx, BR.IXl);
  4639. }
  4640. static void OR_IYh (Z80Context* ctx)
  4641. {
  4642. doOR(ctx, BR.IYh);
  4643. }
  4644. static void OR_IYl (Z80Context* ctx)
  4645. {
  4646. doOR(ctx, BR.IYl);
  4647. }
  4648. static void OR_L (Z80Context* ctx)
  4649. {
  4650. doOR(ctx, BR.L);
  4651. }
  4652. static void OR_n (Z80Context* ctx)
  4653. {
  4654. doOR(ctx, read8(ctx, ctx->PC++));
  4655. }
  4656. static void OTDR (Z80Context* ctx)
  4657. {
  4658. OUTD(ctx);
  4659. if (BR.B != 0)
  4660. {
  4661. ctx->tstates += 5;
  4662. ctx->PC -= 2;
  4663. }
  4664. }
  4665. static void OTIR (Z80Context* ctx)
  4666. {
  4667. OUTI(ctx);
  4668. if (BR.B != 0)
  4669. {
  4670. ctx->tstates += 5;
  4671. ctx->PC -= 2;
  4672. }
  4673. }
  4674. static void OUT_off_C_0 (Z80Context* ctx)
  4675. {
  4676. ioWrite(ctx, WR.BC, 0);
  4677. }
  4678. static void OUT_off_C_A (Z80Context* ctx)
  4679. {
  4680. ioWrite(ctx, WR.BC, BR.A);
  4681. }
  4682. static void OUT_off_C_B (Z80Context* ctx)
  4683. {
  4684. ioWrite(ctx, WR.BC, BR.B);
  4685. }
  4686. static void OUT_off_C_C (Z80Context* ctx)
  4687. {
  4688. ioWrite(ctx, WR.BC, BR.C);
  4689. }
  4690. static void OUT_off_C_D (Z80Context* ctx)
  4691. {
  4692. ioWrite(ctx, WR.BC, BR.D);
  4693. }
  4694. static void OUT_off_C_E (Z80Context* ctx)
  4695. {
  4696. ioWrite(ctx, WR.BC, BR.E);
  4697. }
  4698. static void OUT_off_C_H (Z80Context* ctx)
  4699. {
  4700. ioWrite(ctx, WR.BC, BR.H);
  4701. }
  4702. static void OUT_off_C_L (Z80Context* ctx)
  4703. {
  4704. ioWrite(ctx, WR.BC, BR.L);
  4705. }
  4706. static void OUT_off_n_A (Z80Context* ctx)
  4707. {
  4708. ioWrite(ctx, BR.A << 8 | read8(ctx, ctx->PC++), BR.A);
  4709. }
  4710. static void OUTD (Z80Context* ctx)
  4711. {
  4712. ctx->tstates += 1;
  4713. byte value = read8(ctx, WR.HL);
  4714. BR.B = doIncDec(ctx, BR.B, 1);
  4715. ioWrite(ctx, WR.BC, value);
  4716. WR.HL--;
  4717. int flag_value = value + BR.L;
  4718. VALFLAG(F_N, value & 0x80);
  4719. VALFLAG(F_H, flag_value > 0xff);
  4720. VALFLAG(F_C, flag_value > 0xff);
  4721. VALFLAG(F_PV, parityBit[(flag_value & 7) ^ BR.B]);
  4722. adjustFlags(ctx, BR.B);
  4723. }
  4724. static void OUTI (Z80Context* ctx)
  4725. {
  4726. ctx->tstates += 1;
  4727. byte value = read8(ctx, WR.HL);
  4728. BR.B = doIncDec(ctx, BR.B, 1);
  4729. ioWrite(ctx, WR.BC, value);
  4730. WR.HL++;
  4731. int flag_value = value + BR.L;
  4732. VALFLAG(F_N, value & 0x80);
  4733. VALFLAG(F_H, flag_value > 0xff);
  4734. VALFLAG(F_C, flag_value > 0xff);
  4735. VALFLAG(F_PV, parityBit[(flag_value & 7) ^ BR.B]);
  4736. adjustFlags(ctx, BR.B);
  4737. }
  4738. static void POP_AF (Z80Context* ctx)
  4739. {
  4740. WR.AF = doPop(ctx);
  4741. }
  4742. static void POP_BC (Z80Context* ctx)
  4743. {
  4744. WR.BC = doPop(ctx);
  4745. }
  4746. static void POP_DE (Z80Context* ctx)
  4747. {
  4748. WR.DE = doPop(ctx);
  4749. }
  4750. static void POP_HL (Z80Context* ctx)
  4751. {
  4752. WR.HL = doPop(ctx);
  4753. }
  4754. static void POP_IX (Z80Context* ctx)
  4755. {
  4756. WR.IX = doPop(ctx);
  4757. }
  4758. static void POP_IY (Z80Context* ctx)
  4759. {
  4760. WR.IY = doPop(ctx);
  4761. }
  4762. static void PUSH_AF (Z80Context* ctx)
  4763. {
  4764. ctx->tstates += 1;
  4765. doPush(ctx, WR.AF);
  4766. }
  4767. static void PUSH_BC (Z80Context* ctx)
  4768. {
  4769. ctx->tstates += 1;
  4770. doPush(ctx, WR.BC);
  4771. }
  4772. static void PUSH_DE (Z80Context* ctx)
  4773. {
  4774. ctx->tstates += 1;
  4775. doPush(ctx, WR.DE);
  4776. }
  4777. static void PUSH_HL (Z80Context* ctx)
  4778. {
  4779. ctx->tstates += 1;
  4780. doPush(ctx, WR.HL);
  4781. }
  4782. static void PUSH_IX (Z80Context* ctx)
  4783. {
  4784. ctx->tstates += 1;
  4785. doPush(ctx, WR.IX);
  4786. }
  4787. static void PUSH_IY (Z80Context* ctx)
  4788. {
  4789. ctx->tstates += 1;
  4790. doPush(ctx, WR.IY);
  4791. }
  4792. static void RES_0_off_HL (Z80Context* ctx)
  4793. {
  4794. ctx->tstates += 1;
  4795. write8(ctx, WR.HL, doSetRes(ctx, SR_RES, 0, read8(ctx, WR.HL)));
  4796. }
  4797. static void RES_0_off_IX_d (Z80Context* ctx)
  4798. {
  4799. ctx->tstates += 2;
  4800. signed char off = read8(ctx, ctx->PC++);
  4801. write8(ctx, WR.IX + off, doSetRes(ctx, SR_RES, 0, read8(ctx, WR.IX + off)));
  4802. }
  4803. static void RES_0_off_IY_d (Z80Context* ctx)
  4804. {
  4805. ctx->tstates += 2;
  4806. signed char off = read8(ctx, ctx->PC++);
  4807. write8(ctx, WR.IY + off, doSetRes(ctx, SR_RES, 0, read8(ctx, WR.IY + off)));
  4808. }
  4809. static void RES_0_A (Z80Context* ctx)
  4810. {
  4811. BR.A = doSetRes(ctx, SR_RES, 0, BR.A);
  4812. }
  4813. static void RES_0_B (Z80Context* ctx)
  4814. {
  4815. BR.B = doSetRes(ctx, SR_RES, 0, BR.B);
  4816. }
  4817. static void RES_0_C (Z80Context* ctx)
  4818. {
  4819. BR.C = doSetRes(ctx, SR_RES, 0, BR.C);
  4820. }
  4821. static void RES_0_D (Z80Context* ctx)
  4822. {
  4823. BR.D = doSetRes(ctx, SR_RES, 0, BR.D);
  4824. }
  4825. static void RES_0_E (Z80Context* ctx)
  4826. {
  4827. BR.E = doSetRes(ctx, SR_RES, 0, BR.E);
  4828. }
  4829. static void RES_0_H (Z80Context* ctx)
  4830. {
  4831. BR.H = doSetRes(ctx, SR_RES, 0, BR.H);
  4832. }
  4833. static void RES_0_L (Z80Context* ctx)
  4834. {
  4835. BR.L = doSetRes(ctx, SR_RES, 0, BR.L);
  4836. }
  4837. static void RES_1_off_HL (Z80Context* ctx)
  4838. {
  4839. ctx->tstates += 1;
  4840. write8(ctx, WR.HL, doSetRes(ctx, SR_RES, 1, read8(ctx, WR.HL)));
  4841. }
  4842. static void RES_1_off_IX_d (Z80Context* ctx)
  4843. {
  4844. ctx->tstates += 2;
  4845. signed char off = read8(ctx, ctx->PC++);
  4846. write8(ctx, WR.IX + off, doSetRes(ctx, SR_RES, 1, read8(ctx, WR.IX + off)));
  4847. }
  4848. static void RES_1_off_IY_d (Z80Context* ctx)
  4849. {
  4850. ctx->tstates += 2;
  4851. signed char off = read8(ctx, ctx->PC++);
  4852. write8(ctx, WR.IY + off, doSetRes(ctx, SR_RES, 1, read8(ctx, WR.IY + off)));
  4853. }
  4854. static void RES_1_A (Z80Context* ctx)
  4855. {
  4856. BR.A = doSetRes(ctx, SR_RES, 1, BR.A);
  4857. }
  4858. static void RES_1_B (Z80Context* ctx)
  4859. {
  4860. BR.B = doSetRes(ctx, SR_RES, 1, BR.B);
  4861. }
  4862. static void RES_1_C (Z80Context* ctx)
  4863. {
  4864. BR.C = doSetRes(ctx, SR_RES, 1, BR.C);
  4865. }
  4866. static void RES_1_D (Z80Context* ctx)
  4867. {
  4868. BR.D = doSetRes(ctx, SR_RES, 1, BR.D);
  4869. }
  4870. static void RES_1_E (Z80Context* ctx)
  4871. {
  4872. BR.E = doSetRes(ctx, SR_RES, 1, BR.E);
  4873. }
  4874. static void RES_1_H (Z80Context* ctx)
  4875. {
  4876. BR.H = doSetRes(ctx, SR_RES, 1, BR.H);
  4877. }
  4878. static void RES_1_L (Z80Context* ctx)
  4879. {
  4880. BR.L = doSetRes(ctx, SR_RES, 1, BR.L);
  4881. }
  4882. static void RES_2_off_HL (Z80Context* ctx)
  4883. {
  4884. ctx->tstates += 1;
  4885. write8(ctx, WR.HL, doSetRes(ctx, SR_RES, 2, read8(ctx, WR.HL)));
  4886. }
  4887. static void RES_2_off_IX_d (Z80Context* ctx)
  4888. {
  4889. ctx->tstates += 2;
  4890. signed char off = read8(ctx, ctx->PC++);
  4891. write8(ctx, WR.IX + off, doSetRes(ctx, SR_RES, 2, read8(ctx, WR.IX + off)));
  4892. }
  4893. static void RES_2_off_IY_d (Z80Context* ctx)
  4894. {
  4895. ctx->tstates += 2;
  4896. signed char off = read8(ctx, ctx->PC++);
  4897. write8(ctx, WR.IY + off, doSetRes(ctx, SR_RES, 2, read8(ctx, WR.IY + off)));
  4898. }
  4899. static void RES_2_A (Z80Context* ctx)
  4900. {
  4901. BR.A = doSetRes(ctx, SR_RES, 2, BR.A);
  4902. }
  4903. static void RES_2_B (Z80Context* ctx)
  4904. {
  4905. BR.B = doSetRes(ctx, SR_RES, 2, BR.B);
  4906. }
  4907. static void RES_2_C (Z80Context* ctx)
  4908. {
  4909. BR.C = doSetRes(ctx, SR_RES, 2, BR.C);
  4910. }
  4911. static void RES_2_D (Z80Context* ctx)
  4912. {
  4913. BR.D = doSetRes(ctx, SR_RES, 2, BR.D);
  4914. }
  4915. static void RES_2_E (Z80Context* ctx)
  4916. {
  4917. BR.E = doSetRes(ctx, SR_RES, 2, BR.E);
  4918. }
  4919. static void RES_2_H (Z80Context* ctx)
  4920. {
  4921. BR.H = doSetRes(ctx, SR_RES, 2, BR.H);
  4922. }
  4923. static void RES_2_L (Z80Context* ctx)
  4924. {
  4925. BR.L = doSetRes(ctx, SR_RES, 2, BR.L);
  4926. }
  4927. static void RES_3_off_HL (Z80Context* ctx)
  4928. {
  4929. ctx->tstates += 1;
  4930. write8(ctx, WR.HL, doSetRes(ctx, SR_RES, 3, read8(ctx, WR.HL)));
  4931. }
  4932. static void RES_3_off_IX_d (Z80Context* ctx)
  4933. {
  4934. ctx->tstates += 2;
  4935. signed char off = read8(ctx, ctx->PC++);
  4936. write8(ctx, WR.IX + off, doSetRes(ctx, SR_RES, 3, read8(ctx, WR.IX + off)));
  4937. }
  4938. static void RES_3_off_IY_d (Z80Context* ctx)
  4939. {
  4940. ctx->tstates += 2;
  4941. signed char off = read8(ctx, ctx->PC++);
  4942. write8(ctx, WR.IY + off, doSetRes(ctx, SR_RES, 3, read8(ctx, WR.IY + off)));
  4943. }
  4944. static void RES_3_A (Z80Context* ctx)
  4945. {
  4946. BR.A = doSetRes(ctx, SR_RES, 3, BR.A);
  4947. }
  4948. static void RES_3_B (Z80Context* ctx)
  4949. {
  4950. BR.B = doSetRes(ctx, SR_RES, 3, BR.B);
  4951. }
  4952. static void RES_3_C (Z80Context* ctx)
  4953. {
  4954. BR.C = doSetRes(ctx, SR_RES, 3, BR.C);
  4955. }
  4956. static void RES_3_D (Z80Context* ctx)
  4957. {
  4958. BR.D = doSetRes(ctx, SR_RES, 3, BR.D);
  4959. }
  4960. static void RES_3_E (Z80Context* ctx)
  4961. {
  4962. BR.E = doSetRes(ctx, SR_RES, 3, BR.E);
  4963. }
  4964. static void RES_3_H (Z80Context* ctx)
  4965. {
  4966. BR.H = doSetRes(ctx, SR_RES, 3, BR.H);
  4967. }
  4968. static void RES_3_L (Z80Context* ctx)
  4969. {
  4970. BR.L = doSetRes(ctx, SR_RES, 3, BR.L);
  4971. }
  4972. static void RES_4_off_HL (Z80Context* ctx)
  4973. {
  4974. ctx->tstates += 1;
  4975. write8(ctx, WR.HL, doSetRes(ctx, SR_RES, 4, read8(ctx, WR.HL)));
  4976. }
  4977. static void RES_4_off_IX_d (Z80Context* ctx)
  4978. {
  4979. ctx->tstates += 2;
  4980. signed char off = read8(ctx, ctx->PC++);
  4981. write8(ctx, WR.IX + off, doSetRes(ctx, SR_RES, 4, read8(ctx, WR.IX + off)));
  4982. }
  4983. static void RES_4_off_IY_d (Z80Context* ctx)
  4984. {
  4985. ctx->tstates += 2;
  4986. signed char off = read8(ctx, ctx->PC++);
  4987. write8(ctx, WR.IY + off, doSetRes(ctx, SR_RES, 4, read8(ctx, WR.IY + off)));
  4988. }
  4989. static void RES_4_A (Z80Context* ctx)
  4990. {
  4991. BR.A = doSetRes(ctx, SR_RES, 4, BR.A);
  4992. }
  4993. static void RES_4_B (Z80Context* ctx)
  4994. {
  4995. BR.B = doSetRes(ctx, SR_RES, 4, BR.B);
  4996. }
  4997. static void RES_4_C (Z80Context* ctx)
  4998. {
  4999. BR.C = doSetRes(ctx, SR_RES, 4, BR.C);
  5000. }
  5001. static void RES_4_D (Z80Context* ctx)
  5002. {
  5003. BR.D = doSetRes(ctx, SR_RES, 4, BR.D);
  5004. }
  5005. static void RES_4_E (Z80Context* ctx)
  5006. {
  5007. BR.E = doSetRes(ctx, SR_RES, 4, BR.E);
  5008. }
  5009. static void RES_4_H (Z80Context* ctx)
  5010. {
  5011. BR.H = doSetRes(ctx, SR_RES, 4, BR.H);
  5012. }
  5013. static void RES_4_L (Z80Context* ctx)
  5014. {
  5015. BR.L = doSetRes(ctx, SR_RES, 4, BR.L);
  5016. }
  5017. static void RES_5_off_HL (Z80Context* ctx)
  5018. {
  5019. ctx->tstates += 1;
  5020. write8(ctx, WR.HL, doSetRes(ctx, SR_RES, 5, read8(ctx, WR.HL)));
  5021. }
  5022. static void RES_5_off_IX_d (Z80Context* ctx)
  5023. {
  5024. ctx->tstates += 2;
  5025. signed char off = read8(ctx, ctx->PC++);
  5026. write8(ctx, WR.IX + off, doSetRes(ctx, SR_RES, 5, read8(ctx, WR.IX + off)));
  5027. }
  5028. static void RES_5_off_IY_d (Z80Context* ctx)
  5029. {
  5030. ctx->tstates += 2;
  5031. signed char off = read8(ctx, ctx->PC++);
  5032. write8(ctx, WR.IY + off, doSetRes(ctx, SR_RES, 5, read8(ctx, WR.IY + off)));
  5033. }
  5034. static void RES_5_A (Z80Context* ctx)
  5035. {
  5036. BR.A = doSetRes(ctx, SR_RES, 5, BR.A);
  5037. }
  5038. static void RES_5_B (Z80Context* ctx)
  5039. {
  5040. BR.B = doSetRes(ctx, SR_RES, 5, BR.B);
  5041. }
  5042. static void RES_5_C (Z80Context* ctx)
  5043. {
  5044. BR.C = doSetRes(ctx, SR_RES, 5, BR.C);
  5045. }
  5046. static void RES_5_D (Z80Context* ctx)
  5047. {
  5048. BR.D = doSetRes(ctx, SR_RES, 5, BR.D);
  5049. }
  5050. static void RES_5_E (Z80Context* ctx)
  5051. {
  5052. BR.E = doSetRes(ctx, SR_RES, 5, BR.E);
  5053. }
  5054. static void RES_5_H (Z80Context* ctx)
  5055. {
  5056. BR.H = doSetRes(ctx, SR_RES, 5, BR.H);
  5057. }
  5058. static void RES_5_L (Z80Context* ctx)
  5059. {
  5060. BR.L = doSetRes(ctx, SR_RES, 5, BR.L);
  5061. }
  5062. static void RES_6_off_HL (Z80Context* ctx)
  5063. {
  5064. ctx->tstates += 1;
  5065. write8(ctx, WR.HL, doSetRes(ctx, SR_RES, 6, read8(ctx, WR.HL)));
  5066. }
  5067. static void RES_6_off_IX_d (Z80Context* ctx)
  5068. {
  5069. ctx->tstates += 2;
  5070. signed char off = read8(ctx, ctx->PC++);
  5071. write8(ctx, WR.IX + off, doSetRes(ctx, SR_RES, 6, read8(ctx, WR.IX + off)));
  5072. }
  5073. static void RES_6_off_IY_d (Z80Context* ctx)
  5074. {
  5075. ctx->tstates += 2;
  5076. signed char off = read8(ctx, ctx->PC++);
  5077. write8(ctx, WR.IY + off, doSetRes(ctx, SR_RES, 6, read8(ctx, WR.IY + off)));
  5078. }
  5079. static void RES_6_A (Z80Context* ctx)
  5080. {
  5081. BR.A = doSetRes(ctx, SR_RES, 6, BR.A);
  5082. }
  5083. static void RES_6_B (Z80Context* ctx)
  5084. {
  5085. BR.B = doSetRes(ctx, SR_RES, 6, BR.B);
  5086. }
  5087. static void RES_6_C (Z80Context* ctx)
  5088. {
  5089. BR.C = doSetRes(ctx, SR_RES, 6, BR.C);
  5090. }
  5091. static void RES_6_D (Z80Context* ctx)
  5092. {
  5093. BR.D = doSetRes(ctx, SR_RES, 6, BR.D);
  5094. }
  5095. static void RES_6_E (Z80Context* ctx)
  5096. {
  5097. BR.E = doSetRes(ctx, SR_RES, 6, BR.E);
  5098. }
  5099. static void RES_6_H (Z80Context* ctx)
  5100. {
  5101. BR.H = doSetRes(ctx, SR_RES, 6, BR.H);
  5102. }
  5103. static void RES_6_L (Z80Context* ctx)
  5104. {
  5105. BR.L = doSetRes(ctx, SR_RES, 6, BR.L);
  5106. }
  5107. static void RES_7_off_HL (Z80Context* ctx)
  5108. {
  5109. ctx->tstates += 1;
  5110. write8(ctx, WR.HL, doSetRes(ctx, SR_RES, 7, read8(ctx, WR.HL)));
  5111. }
  5112. static void RES_7_off_IX_d (Z80Context* ctx)
  5113. {
  5114. ctx->tstates += 2;
  5115. signed char off = read8(ctx, ctx->PC++);
  5116. write8(ctx, WR.IX + off, doSetRes(ctx, SR_RES, 7, read8(ctx, WR.IX + off)));
  5117. }
  5118. static void RES_7_off_IY_d (Z80Context* ctx)
  5119. {
  5120. ctx->tstates += 2;
  5121. signed char off = read8(ctx, ctx->PC++);
  5122. write8(ctx, WR.IY + off, doSetRes(ctx, SR_RES, 7, read8(ctx, WR.IY + off)));
  5123. }
  5124. static void RES_7_A (Z80Context* ctx)
  5125. {
  5126. BR.A = doSetRes(ctx, SR_RES, 7, BR.A);
  5127. }
  5128. static void RES_7_B (Z80Context* ctx)
  5129. {
  5130. BR.B = doSetRes(ctx, SR_RES, 7, BR.B);
  5131. }
  5132. static void RES_7_C (Z80Context* ctx)
  5133. {
  5134. BR.C = doSetRes(ctx, SR_RES, 7, BR.C);
  5135. }
  5136. static void RES_7_D (Z80Context* ctx)
  5137. {
  5138. BR.D = doSetRes(ctx, SR_RES, 7, BR.D);
  5139. }
  5140. static void RES_7_E (Z80Context* ctx)
  5141. {
  5142. BR.E = doSetRes(ctx, SR_RES, 7, BR.E);
  5143. }
  5144. static void RES_7_H (Z80Context* ctx)
  5145. {
  5146. BR.H = doSetRes(ctx, SR_RES, 7, BR.H);
  5147. }
  5148. static void RES_7_L (Z80Context* ctx)
  5149. {
  5150. BR.L = doSetRes(ctx, SR_RES, 7, BR.L);
  5151. }
  5152. static void RET (Z80Context* ctx)
  5153. {
  5154. ctx->PC = doPop(ctx);
  5155. }
  5156. static void RET_C (Z80Context* ctx)
  5157. {
  5158. ctx->tstates += 1;
  5159. if (condition(ctx, C_C))
  5160. ctx->PC = doPop(ctx);
  5161. }
  5162. static void RET_M (Z80Context* ctx)
  5163. {
  5164. ctx->tstates += 1;
  5165. if (condition(ctx, C_M))
  5166. ctx->PC = doPop(ctx);
  5167. }
  5168. static void RET_NC (Z80Context* ctx)
  5169. {
  5170. ctx->tstates += 1;
  5171. if (condition(ctx, C_NC))
  5172. ctx->PC = doPop(ctx);
  5173. }
  5174. static void RET_NZ (Z80Context* ctx)
  5175. {
  5176. ctx->tstates += 1;
  5177. if (condition(ctx, C_NZ))
  5178. ctx->PC = doPop(ctx);
  5179. }
  5180. static void RET_P (Z80Context* ctx)
  5181. {
  5182. ctx->tstates += 1;
  5183. if (condition(ctx, C_P))
  5184. ctx->PC = doPop(ctx);
  5185. }
  5186. static void RET_PE (Z80Context* ctx)
  5187. {
  5188. ctx->tstates += 1;
  5189. if (condition(ctx, C_PE))
  5190. ctx->PC = doPop(ctx);
  5191. }
  5192. static void RET_PO (Z80Context* ctx)
  5193. {
  5194. ctx->tstates += 1;
  5195. if (condition(ctx, C_PO))
  5196. ctx->PC = doPop(ctx);
  5197. }
  5198. static void RET_Z (Z80Context* ctx)
  5199. {
  5200. ctx->tstates += 1;
  5201. if (condition(ctx, C_Z))
  5202. ctx->PC = doPop(ctx);
  5203. }
  5204. static void RETI (Z80Context* ctx)
  5205. {
  5206. ctx->IFF1 = ctx->IFF2;
  5207. RET (ctx);
  5208. }
  5209. static void RETN (Z80Context* ctx)
  5210. {
  5211. ctx->IFF1 = ctx->IFF2;
  5212. RET(ctx);
  5213. }
  5214. static void RL_off_HL (Z80Context* ctx)
  5215. {
  5216. ctx->tstates += 1;
  5217. write8(ctx, WR.HL, doRL(ctx, 1, read8(ctx, WR.HL)));
  5218. }
  5219. static void RL_off_IX_d (Z80Context* ctx)
  5220. {
  5221. ctx->tstates += 2;
  5222. signed char off = read8(ctx, ctx->PC++);
  5223. write8(ctx, WR.IX + off, doRL(ctx, 1, read8(ctx, WR.IX + off)));
  5224. }
  5225. static void RL_off_IY_d (Z80Context* ctx)
  5226. {
  5227. ctx->tstates += 2;
  5228. signed char off = read8(ctx, ctx->PC++);
  5229. write8(ctx, WR.IY + off, doRL(ctx, 1, read8(ctx, WR.IY + off)));
  5230. }
  5231. static void RL_A (Z80Context* ctx)
  5232. {
  5233. BR.A = doRL(ctx, 1, BR.A);
  5234. }
  5235. static void RL_B (Z80Context* ctx)
  5236. {
  5237. BR.B = doRL(ctx, 1, BR.B);
  5238. }
  5239. static void RL_C (Z80Context* ctx)
  5240. {
  5241. BR.C = doRL(ctx, 1, BR.C);
  5242. }
  5243. static void RL_D (Z80Context* ctx)
  5244. {
  5245. BR.D = doRL(ctx, 1, BR.D);
  5246. }
  5247. static void RL_E (Z80Context* ctx)
  5248. {
  5249. BR.E = doRL(ctx, 1, BR.E);
  5250. }
  5251. static void RL_H (Z80Context* ctx)
  5252. {
  5253. BR.H = doRL(ctx, 1, BR.H);
  5254. }
  5255. static void RL_L (Z80Context* ctx)
  5256. {
  5257. BR.L = doRL(ctx, 1, BR.L);
  5258. }
  5259. static void RLA (Z80Context* ctx)
  5260. {
  5261. BR.A = doRL(ctx, 0, BR.A);
  5262. }
  5263. static void RLC_off_HL (Z80Context* ctx)
  5264. {
  5265. ctx->tstates += 1;
  5266. write8(ctx, WR.HL, doRLC(ctx, 1, read8(ctx, WR.HL)));
  5267. }
  5268. static void RLC_off_IX_d (Z80Context* ctx)
  5269. {
  5270. ctx->tstates += 2;
  5271. signed char off = read8(ctx, ctx->PC++);
  5272. write8(ctx, WR.IX + off, doRLC(ctx, 1, read8(ctx, WR.IX + off)));
  5273. }
  5274. static void RLC_off_IY_d (Z80Context* ctx)
  5275. {
  5276. ctx->tstates += 2;
  5277. signed char off = read8(ctx, ctx->PC++);
  5278. write8(ctx, WR.IY + off, doRLC(ctx, 1, read8(ctx, WR.IY + off)));
  5279. }
  5280. static void RLC_A (Z80Context* ctx)
  5281. {
  5282. BR.A = doRLC(ctx, 1, BR.A);
  5283. }
  5284. static void RLC_B (Z80Context* ctx)
  5285. {
  5286. BR.B = doRLC(ctx, 1, BR.B);
  5287. }
  5288. static void RLC_C (Z80Context* ctx)
  5289. {
  5290. BR.C = doRLC(ctx, 1, BR.C);
  5291. }
  5292. static void RLC_D (Z80Context* ctx)
  5293. {
  5294. BR.D = doRLC(ctx, 1, BR.D);
  5295. }
  5296. static void RLC_E (Z80Context* ctx)
  5297. {
  5298. BR.E = doRLC(ctx, 1, BR.E);
  5299. }
  5300. static void RLC_H (Z80Context* ctx)
  5301. {
  5302. BR.H = doRLC(ctx, 1, BR.H);
  5303. }
  5304. static void RLC_L (Z80Context* ctx)
  5305. {
  5306. BR.L = doRLC(ctx, 1, BR.L);
  5307. }
  5308. static void RLCA (Z80Context* ctx)
  5309. {
  5310. BR.A = doRLC(ctx, 0, BR.A);
  5311. }
  5312. static void RLD (Z80Context* ctx)
  5313. {
  5314. ctx->tstates += 4;
  5315. byte Ah = BR.A & 0x0f;
  5316. byte hl = read8(ctx, WR.HL);
  5317. BR.A = (BR.A & 0xf0) | ((hl & 0xf0) >> 4);
  5318. hl = (hl << 4) | Ah;
  5319. write8(ctx, WR.HL, hl);
  5320. RESFLAG(F_H | F_N);
  5321. adjustFlagSZP(ctx, BR.A);
  5322. adjustFlags(ctx, BR.A);
  5323. }
  5324. static void RR_off_HL (Z80Context* ctx)
  5325. {
  5326. ctx->tstates += 1;
  5327. write8(ctx, WR.HL, doRR(ctx, 1, read8(ctx, WR.HL)));
  5328. }
  5329. static void RR_off_IX_d (Z80Context* ctx)
  5330. {
  5331. ctx->tstates += 2;
  5332. signed char off = read8(ctx, ctx->PC++);
  5333. write8(ctx, WR.IX + off, doRR(ctx, 1, read8(ctx, WR.IX + off)));
  5334. }
  5335. static void RR_off_IY_d (Z80Context* ctx)
  5336. {
  5337. ctx->tstates += 2;
  5338. signed char off = read8(ctx, ctx->PC++);
  5339. write8(ctx, WR.IY + off, doRR(ctx, 1, read8(ctx, WR.IY + off)));
  5340. }
  5341. static void RR_A (Z80Context* ctx)
  5342. {
  5343. BR.A = doRR(ctx, 1, BR.A);
  5344. }
  5345. static void RR_B (Z80Context* ctx)
  5346. {
  5347. BR.B = doRR(ctx, 1, BR.B);
  5348. }
  5349. static void RR_C (Z80Context* ctx)
  5350. {
  5351. BR.C = doRR(ctx, 1, BR.C);
  5352. }
  5353. static void RR_D (Z80Context* ctx)
  5354. {
  5355. BR.D = doRR(ctx, 1, BR.D);
  5356. }
  5357. static void RR_E (Z80Context* ctx)
  5358. {
  5359. BR.E = doRR(ctx, 1, BR.E);
  5360. }
  5361. static void RR_H (Z80Context* ctx)
  5362. {
  5363. BR.H = doRR(ctx, 1, BR.H);
  5364. }
  5365. static void RR_L (Z80Context* ctx)
  5366. {
  5367. BR.L = doRR(ctx, 1, BR.L);
  5368. }
  5369. static void RRA (Z80Context* ctx)
  5370. {
  5371. BR.A = doRR(ctx, 0, BR.A);
  5372. }
  5373. static void RRC_off_HL (Z80Context* ctx)
  5374. {
  5375. ctx->tstates += 1;
  5376. write8(ctx, WR.HL, doRRC(ctx, 1, read8(ctx, WR.HL)));
  5377. }
  5378. static void RRC_off_IX_d (Z80Context* ctx)
  5379. {
  5380. ctx->tstates += 2;
  5381. signed char off = read8(ctx, ctx->PC++);
  5382. write8(ctx, WR.IX + off, doRRC(ctx, 1, read8(ctx, WR.IX + off)));
  5383. }
  5384. static void RRC_off_IY_d (Z80Context* ctx)
  5385. {
  5386. ctx->tstates += 2;
  5387. signed char off = read8(ctx, ctx->PC++);
  5388. write8(ctx, WR.IY + off, doRRC(ctx, 1, read8(ctx, WR.IY + off)));
  5389. }
  5390. static void RRC_A (Z80Context* ctx)
  5391. {
  5392. BR.A = doRRC(ctx, 1, BR.A);
  5393. }
  5394. static void RRC_B (Z80Context* ctx)
  5395. {
  5396. BR.B = doRRC(ctx, 1, BR.B);
  5397. }
  5398. static void RRC_C (Z80Context* ctx)
  5399. {
  5400. BR.C = doRRC(ctx, 1, BR.C);
  5401. }
  5402. static void RRC_D (Z80Context* ctx)
  5403. {
  5404. BR.D = doRRC(ctx, 1, BR.D);
  5405. }
  5406. static void RRC_E (Z80Context* ctx)
  5407. {
  5408. BR.E = doRRC(ctx, 1, BR.E);
  5409. }
  5410. static void RRC_H (Z80Context* ctx)
  5411. {
  5412. BR.H = doRRC(ctx, 1, BR.H);
  5413. }
  5414. static void RRC_L (Z80Context* ctx)
  5415. {
  5416. BR.L = doRRC(ctx, 1, BR.L);
  5417. }
  5418. static void RRCA (Z80Context* ctx)
  5419. {
  5420. BR.A = doRRC(ctx, 0, BR.A);
  5421. }
  5422. static void RRD (Z80Context* ctx)
  5423. {
  5424. ctx->tstates += 4;
  5425. byte Ah = BR.A & 0x0f;
  5426. byte hl = read8(ctx, WR.HL);
  5427. BR.A = (BR.A & 0xf0) | (hl & 0x0f);
  5428. hl = (hl >> 4) | (Ah << 4);
  5429. write8(ctx, WR.HL, hl);
  5430. RESFLAG(F_H | F_N);
  5431. adjustFlagSZP(ctx, BR.A);
  5432. }
  5433. static void RST_0H (Z80Context* ctx)
  5434. {
  5435. ctx->tstates += 1;
  5436. doPush(ctx, ctx->PC);
  5437. ctx->PC = 0x00;
  5438. }
  5439. static void RST_10H (Z80Context* ctx)
  5440. {
  5441. ctx->tstates += 1;
  5442. doPush(ctx, ctx->PC);
  5443. ctx->PC = 0x010;
  5444. }
  5445. static void RST_18H (Z80Context* ctx)
  5446. {
  5447. ctx->tstates += 1;
  5448. doPush(ctx, ctx->PC);
  5449. ctx->PC = 0x018;
  5450. }
  5451. static void RST_20H (Z80Context* ctx)
  5452. {
  5453. ctx->tstates += 1;
  5454. doPush(ctx, ctx->PC);
  5455. ctx->PC = 0x020;
  5456. }
  5457. static void RST_28H (Z80Context* ctx)
  5458. {
  5459. ctx->tstates += 1;
  5460. doPush(ctx, ctx->PC);
  5461. ctx->PC = 0x028;
  5462. }
  5463. static void RST_30H (Z80Context* ctx)
  5464. {
  5465. ctx->tstates += 1;
  5466. doPush(ctx, ctx->PC);
  5467. ctx->PC = 0x030;
  5468. }
  5469. static void RST_38H (Z80Context* ctx)
  5470. {
  5471. ctx->tstates += 1;
  5472. doPush(ctx, ctx->PC);
  5473. ctx->PC = 0x038;
  5474. }
  5475. static void RST_8H (Z80Context* ctx)
  5476. {
  5477. ctx->tstates += 1;
  5478. doPush(ctx, ctx->PC);
  5479. ctx->PC = 0x08;
  5480. }
  5481. static void SBC_A_off_HL (Z80Context* ctx)
  5482. {
  5483. BR.A = doArithmetic(ctx, read8(ctx, WR.HL), F1_SBC, F2_SBC);
  5484. }
  5485. static void SBC_A_off_IX_d (Z80Context* ctx)
  5486. {
  5487. ctx->tstates += 5;
  5488. signed char displacement = read8(ctx, ctx->PC++);
  5489. BR.A = doArithmetic(ctx, read8(ctx, WR.IX + displacement), F1_SBC, F2_SBC);
  5490. }
  5491. static void SBC_A_off_IY_d (Z80Context* ctx)
  5492. {
  5493. ctx->tstates += 5;
  5494. signed char displacement = read8(ctx, ctx->PC++);
  5495. BR.A = doArithmetic(ctx, read8(ctx, WR.IY + displacement), F1_SBC, F2_SBC);
  5496. }
  5497. static void SBC_A_A (Z80Context* ctx)
  5498. {
  5499. BR.A = doArithmetic(ctx, BR.A, F1_SBC, F2_SBC);
  5500. }
  5501. static void SBC_A_B (Z80Context* ctx)
  5502. {
  5503. BR.A = doArithmetic(ctx, BR.B, F1_SBC, F2_SBC);
  5504. }
  5505. static void SBC_A_C (Z80Context* ctx)
  5506. {
  5507. BR.A = doArithmetic(ctx, BR.C, F1_SBC, F2_SBC);
  5508. }
  5509. static void SBC_A_D (Z80Context* ctx)
  5510. {
  5511. BR.A = doArithmetic(ctx, BR.D, F1_SBC, F2_SBC);
  5512. }
  5513. static void SBC_A_E (Z80Context* ctx)
  5514. {
  5515. BR.A = doArithmetic(ctx, BR.E, F1_SBC, F2_SBC);
  5516. }
  5517. static void SBC_A_H (Z80Context* ctx)
  5518. {
  5519. BR.A = doArithmetic(ctx, BR.H, F1_SBC, F2_SBC);
  5520. }
  5521. static void SBC_A_IXh (Z80Context* ctx)
  5522. {
  5523. BR.A = doArithmetic(ctx, BR.IXh, F1_SBC, F2_SBC);
  5524. }
  5525. static void SBC_A_IXl (Z80Context* ctx)
  5526. {
  5527. BR.A = doArithmetic(ctx, BR.IXl, F1_SBC, F2_SBC);
  5528. }
  5529. static void SBC_A_IYh (Z80Context* ctx)
  5530. {
  5531. BR.A = doArithmetic(ctx, BR.IYh, F1_SBC, F2_SBC);
  5532. }
  5533. static void SBC_A_IYl (Z80Context* ctx)
  5534. {
  5535. BR.A = doArithmetic(ctx, BR.IYl, F1_SBC, F2_SBC);
  5536. }
  5537. static void SBC_A_L (Z80Context* ctx)
  5538. {
  5539. BR.A = doArithmetic(ctx, BR.L, F1_SBC, F2_SBC);
  5540. }
  5541. static void SBC_A_n (Z80Context* ctx)
  5542. {
  5543. BR.A = doArithmetic(ctx, read8(ctx, ctx->PC++), F1_SBC, F2_SBC);
  5544. }
  5545. static void SBC_HL_BC (Z80Context* ctx)
  5546. {
  5547. ctx->tstates += 7;
  5548. WR.HL = doAddWord(ctx, WR.HL, WR.BC, F1_SBC, F2_SBC);
  5549. }
  5550. static void SBC_HL_DE (Z80Context* ctx)
  5551. {
  5552. ctx->tstates += 7;
  5553. WR.HL = doAddWord(ctx, WR.HL, WR.DE, F1_SBC, F2_SBC);
  5554. }
  5555. static void SBC_HL_HL (Z80Context* ctx)
  5556. {
  5557. ctx->tstates += 7;
  5558. WR.HL = doAddWord(ctx, WR.HL, WR.HL, F1_SBC, F2_SBC);
  5559. }
  5560. static void SBC_HL_SP (Z80Context* ctx)
  5561. {
  5562. ctx->tstates += 7;
  5563. WR.HL = doAddWord(ctx, WR.HL, WR.SP, F1_SBC, F2_SBC);
  5564. }
  5565. static void SCF (Z80Context* ctx)
  5566. {
  5567. SETFLAG(F_C);
  5568. RESFLAG(F_N | F_H);
  5569. adjustFlags(ctx, BR.A);
  5570. }
  5571. static void SET_0_off_HL (Z80Context* ctx)
  5572. {
  5573. ctx->tstates += 1;
  5574. write8(ctx, WR.HL, doSetRes(ctx, SR_SET, 0, read8(ctx, WR.HL)));
  5575. }
  5576. static void SET_0_off_IX_d (Z80Context* ctx)
  5577. {
  5578. ctx->tstates += 2;
  5579. signed char off = read8(ctx, ctx->PC++);
  5580. write8(ctx, WR.IX + off, doSetRes(ctx, SR_SET, 0, read8(ctx, WR.IX + off)));
  5581. }
  5582. static void SET_0_off_IY_d (Z80Context* ctx)
  5583. {
  5584. ctx->tstates += 2;
  5585. signed char off = read8(ctx, ctx->PC++);
  5586. write8(ctx, WR.IY + off, doSetRes(ctx, SR_SET, 0, read8(ctx, WR.IY + off)));
  5587. }
  5588. static void SET_0_A (Z80Context* ctx)
  5589. {
  5590. BR.A = doSetRes(ctx, SR_SET, 0, BR.A);
  5591. }
  5592. static void SET_0_B (Z80Context* ctx)
  5593. {
  5594. BR.B = doSetRes(ctx, SR_SET, 0, BR.B);
  5595. }
  5596. static void SET_0_C (Z80Context* ctx)
  5597. {
  5598. BR.C = doSetRes(ctx, SR_SET, 0, BR.C);
  5599. }
  5600. static void SET_0_D (Z80Context* ctx)
  5601. {
  5602. BR.D = doSetRes(ctx, SR_SET, 0, BR.D);
  5603. }
  5604. static void SET_0_E (Z80Context* ctx)
  5605. {
  5606. BR.E = doSetRes(ctx, SR_SET, 0, BR.E);
  5607. }
  5608. static void SET_0_H (Z80Context* ctx)
  5609. {
  5610. BR.H = doSetRes(ctx, SR_SET, 0, BR.H);
  5611. }
  5612. static void SET_0_L (Z80Context* ctx)
  5613. {
  5614. BR.L = doSetRes(ctx, SR_SET, 0, BR.L);
  5615. }
  5616. static void SET_1_off_HL (Z80Context* ctx)
  5617. {
  5618. ctx->tstates += 1;
  5619. write8(ctx, WR.HL, doSetRes(ctx, SR_SET, 1, read8(ctx, WR.HL)));
  5620. }
  5621. static void SET_1_off_IX_d (Z80Context* ctx)
  5622. {
  5623. ctx->tstates += 2;
  5624. signed char off = read8(ctx, ctx->PC++);
  5625. write8(ctx, WR.IX + off, doSetRes(ctx, SR_SET, 1, read8(ctx, WR.IX + off)));
  5626. }
  5627. static void SET_1_off_IY_d (Z80Context* ctx)
  5628. {
  5629. ctx->tstates += 2;
  5630. signed char off = read8(ctx, ctx->PC++);
  5631. write8(ctx, WR.IY + off, doSetRes(ctx, SR_SET, 1, read8(ctx, WR.IY + off)));
  5632. }
  5633. static void SET_1_A (Z80Context* ctx)
  5634. {
  5635. BR.A = doSetRes(ctx, SR_SET, 1, BR.A);
  5636. }
  5637. static void SET_1_B (Z80Context* ctx)
  5638. {
  5639. BR.B = doSetRes(ctx, SR_SET, 1, BR.B);
  5640. }
  5641. static void SET_1_C (Z80Context* ctx)
  5642. {
  5643. BR.C = doSetRes(ctx, SR_SET, 1, BR.C);
  5644. }
  5645. static void SET_1_D (Z80Context* ctx)
  5646. {
  5647. BR.D = doSetRes(ctx, SR_SET, 1, BR.D);
  5648. }
  5649. static void SET_1_E (Z80Context* ctx)
  5650. {
  5651. BR.E = doSetRes(ctx, SR_SET, 1, BR.E);
  5652. }
  5653. static void SET_1_H (Z80Context* ctx)
  5654. {
  5655. BR.H = doSetRes(ctx, SR_SET, 1, BR.H);
  5656. }
  5657. static void SET_1_L (Z80Context* ctx)
  5658. {
  5659. BR.L = doSetRes(ctx, SR_SET, 1, BR.L);
  5660. }
  5661. static void SET_2_off_HL (Z80Context* ctx)
  5662. {
  5663. ctx->tstates += 1;
  5664. write8(ctx, WR.HL, doSetRes(ctx, SR_SET, 2, read8(ctx, WR.HL)));
  5665. }
  5666. static void SET_2_off_IX_d (Z80Context* ctx)
  5667. {
  5668. ctx->tstates += 2;
  5669. signed char off = read8(ctx, ctx->PC++);
  5670. write8(ctx, WR.IX + off, doSetRes(ctx, SR_SET, 2, read8(ctx, WR.IX + off)));
  5671. }
  5672. static void SET_2_off_IY_d (Z80Context* ctx)
  5673. {
  5674. ctx->tstates += 2;
  5675. signed char off = read8(ctx, ctx->PC++);
  5676. write8(ctx, WR.IY + off, doSetRes(ctx, SR_SET, 2, read8(ctx, WR.IY + off)));
  5677. }
  5678. static void SET_2_A (Z80Context* ctx)
  5679. {
  5680. BR.A = doSetRes(ctx, SR_SET, 2, BR.A);
  5681. }
  5682. static void SET_2_B (Z80Context* ctx)
  5683. {
  5684. BR.B = doSetRes(ctx, SR_SET, 2, BR.B);
  5685. }
  5686. static void SET_2_C (Z80Context* ctx)
  5687. {
  5688. BR.C = doSetRes(ctx, SR_SET, 2, BR.C);
  5689. }
  5690. static void SET_2_D (Z80Context* ctx)
  5691. {
  5692. BR.D = doSetRes(ctx, SR_SET, 2, BR.D);
  5693. }
  5694. static void SET_2_E (Z80Context* ctx)
  5695. {
  5696. BR.E = doSetRes(ctx, SR_SET, 2, BR.E);
  5697. }
  5698. static void SET_2_H (Z80Context* ctx)
  5699. {
  5700. BR.H = doSetRes(ctx, SR_SET, 2, BR.H);
  5701. }
  5702. static void SET_2_L (Z80Context* ctx)
  5703. {
  5704. BR.L = doSetRes(ctx, SR_SET, 2, BR.L);
  5705. }
  5706. static void SET_3_off_HL (Z80Context* ctx)
  5707. {
  5708. ctx->tstates += 1;
  5709. write8(ctx, WR.HL, doSetRes(ctx, SR_SET, 3, read8(ctx, WR.HL)));
  5710. }
  5711. static void SET_3_off_IX_d (Z80Context* ctx)
  5712. {
  5713. ctx->tstates += 2;
  5714. signed char off = read8(ctx, ctx->PC++);
  5715. write8(ctx, WR.IX + off, doSetRes(ctx, SR_SET, 3, read8(ctx, WR.IX + off)));
  5716. }
  5717. static void SET_3_off_IY_d (Z80Context* ctx)
  5718. {
  5719. ctx->tstates += 2;
  5720. signed char off = read8(ctx, ctx->PC++);
  5721. write8(ctx, WR.IY + off, doSetRes(ctx, SR_SET, 3, read8(ctx, WR.IY + off)));
  5722. }
  5723. static void SET_3_A (Z80Context* ctx)
  5724. {
  5725. BR.A = doSetRes(ctx, SR_SET, 3, BR.A);
  5726. }
  5727. static void SET_3_B (Z80Context* ctx)
  5728. {
  5729. BR.B = doSetRes(ctx, SR_SET, 3, BR.B);
  5730. }
  5731. static void SET_3_C (Z80Context* ctx)
  5732. {
  5733. BR.C = doSetRes(ctx, SR_SET, 3, BR.C);
  5734. }
  5735. static void SET_3_D (Z80Context* ctx)
  5736. {
  5737. BR.D = doSetRes(ctx, SR_SET, 3, BR.D);
  5738. }
  5739. static void SET_3_E (Z80Context* ctx)
  5740. {
  5741. BR.E = doSetRes(ctx, SR_SET, 3, BR.E);
  5742. }
  5743. static void SET_3_H (Z80Context* ctx)
  5744. {
  5745. BR.H = doSetRes(ctx, SR_SET, 3, BR.H);
  5746. }
  5747. static void SET_3_L (Z80Context* ctx)
  5748. {
  5749. BR.L = doSetRes(ctx, SR_SET, 3, BR.L);
  5750. }
  5751. static void SET_4_off_HL (Z80Context* ctx)
  5752. {
  5753. ctx->tstates += 1;
  5754. write8(ctx, WR.HL, doSetRes(ctx, SR_SET, 4, read8(ctx, WR.HL)));
  5755. }
  5756. static void SET_4_off_IX_d (Z80Context* ctx)
  5757. {
  5758. ctx->tstates += 2;
  5759. signed char off = read8(ctx, ctx->PC++);
  5760. write8(ctx, WR.IX + off, doSetRes(ctx, SR_SET, 4, read8(ctx, WR.IX + off)));
  5761. }
  5762. static void SET_4_off_IY_d (Z80Context* ctx)
  5763. {
  5764. ctx->tstates += 2;
  5765. signed char off = read8(ctx, ctx->PC++);
  5766. write8(ctx, WR.IY + off, doSetRes(ctx, SR_SET, 4, read8(ctx, WR.IY + off)));
  5767. }
  5768. static void SET_4_A (Z80Context* ctx)
  5769. {
  5770. BR.A = doSetRes(ctx, SR_SET, 4, BR.A);
  5771. }
  5772. static void SET_4_B (Z80Context* ctx)
  5773. {
  5774. BR.B = doSetRes(ctx, SR_SET, 4, BR.B);
  5775. }
  5776. static void SET_4_C (Z80Context* ctx)
  5777. {
  5778. BR.C = doSetRes(ctx, SR_SET, 4, BR.C);
  5779. }
  5780. static void SET_4_D (Z80Context* ctx)
  5781. {
  5782. BR.D = doSetRes(ctx, SR_SET, 4, BR.D);
  5783. }
  5784. static void SET_4_E (Z80Context* ctx)
  5785. {
  5786. BR.E = doSetRes(ctx, SR_SET, 4, BR.E);
  5787. }
  5788. static void SET_4_H (Z80Context* ctx)
  5789. {
  5790. BR.H = doSetRes(ctx, SR_SET, 4, BR.H);
  5791. }
  5792. static void SET_4_L (Z80Context* ctx)
  5793. {
  5794. BR.L = doSetRes(ctx, SR_SET, 4, BR.L);
  5795. }
  5796. static void SET_5_off_HL (Z80Context* ctx)
  5797. {
  5798. ctx->tstates += 1;
  5799. write8(ctx, WR.HL, doSetRes(ctx, SR_SET, 5, read8(ctx, WR.HL)));
  5800. }
  5801. static void SET_5_off_IX_d (Z80Context* ctx)
  5802. {
  5803. ctx->tstates += 2;
  5804. signed char off = read8(ctx, ctx->PC++);
  5805. write8(ctx, WR.IX + off, doSetRes(ctx, SR_SET, 5, read8(ctx, WR.IX + off)));
  5806. }
  5807. static void SET_5_off_IY_d (Z80Context* ctx)
  5808. {
  5809. ctx->tstates += 2;
  5810. signed char off = read8(ctx, ctx->PC++);
  5811. write8(ctx, WR.IY + off, doSetRes(ctx, SR_SET, 5, read8(ctx, WR.IY + off)));
  5812. }
  5813. static void SET_5_A (Z80Context* ctx)
  5814. {
  5815. BR.A = doSetRes(ctx, SR_SET, 5, BR.A);
  5816. }
  5817. static void SET_5_B (Z80Context* ctx)
  5818. {
  5819. BR.B = doSetRes(ctx, SR_SET, 5, BR.B);
  5820. }
  5821. static void SET_5_C (Z80Context* ctx)
  5822. {
  5823. BR.C = doSetRes(ctx, SR_SET, 5, BR.C);
  5824. }
  5825. static void SET_5_D (Z80Context* ctx)
  5826. {
  5827. BR.D = doSetRes(ctx, SR_SET, 5, BR.D);
  5828. }
  5829. static void SET_5_E (Z80Context* ctx)
  5830. {
  5831. BR.E = doSetRes(ctx, SR_SET, 5, BR.E);
  5832. }
  5833. static void SET_5_H (Z80Context* ctx)
  5834. {
  5835. BR.H = doSetRes(ctx, SR_SET, 5, BR.H);
  5836. }
  5837. static void SET_5_L (Z80Context* ctx)
  5838. {
  5839. BR.L = doSetRes(ctx, SR_SET, 5, BR.L);
  5840. }
  5841. static void SET_6_off_HL (Z80Context* ctx)
  5842. {
  5843. ctx->tstates += 1;
  5844. write8(ctx, WR.HL, doSetRes(ctx, SR_SET, 6, read8(ctx, WR.HL)));
  5845. }
  5846. static void SET_6_off_IX_d (Z80Context* ctx)
  5847. {
  5848. ctx->tstates += 2;
  5849. signed char off = read8(ctx, ctx->PC++);
  5850. write8(ctx, WR.IX + off, doSetRes(ctx, SR_SET, 6, read8(ctx, WR.IX + off)));
  5851. }
  5852. static void SET_6_off_IY_d (Z80Context* ctx)
  5853. {
  5854. ctx->tstates += 2;
  5855. signed char off = read8(ctx, ctx->PC++);
  5856. write8(ctx, WR.IY + off, doSetRes(ctx, SR_SET, 6, read8(ctx, WR.IY + off)));
  5857. }
  5858. static void SET_6_A (Z80Context* ctx)
  5859. {
  5860. BR.A = doSetRes(ctx, SR_SET, 6, BR.A);
  5861. }
  5862. static void SET_6_B (Z80Context* ctx)
  5863. {
  5864. BR.B = doSetRes(ctx, SR_SET, 6, BR.B);
  5865. }
  5866. static void SET_6_C (Z80Context* ctx)
  5867. {
  5868. BR.C = doSetRes(ctx, SR_SET, 6, BR.C);
  5869. }
  5870. static void SET_6_D (Z80Context* ctx)
  5871. {
  5872. BR.D = doSetRes(ctx, SR_SET, 6, BR.D);
  5873. }
  5874. static void SET_6_E (Z80Context* ctx)
  5875. {
  5876. BR.E = doSetRes(ctx, SR_SET, 6, BR.E);
  5877. }
  5878. static void SET_6_H (Z80Context* ctx)
  5879. {
  5880. BR.H = doSetRes(ctx, SR_SET, 6, BR.H);
  5881. }
  5882. static void SET_6_L (Z80Context* ctx)
  5883. {
  5884. BR.L = doSetRes(ctx, SR_SET, 6, BR.L);
  5885. }
  5886. static void SET_7_off_HL (Z80Context* ctx)
  5887. {
  5888. ctx->tstates += 1;
  5889. write8(ctx, WR.HL, doSetRes(ctx, SR_SET, 7, read8(ctx, WR.HL)));
  5890. }
  5891. static void SET_7_off_IX_d (Z80Context* ctx)
  5892. {
  5893. ctx->tstates += 2;
  5894. signed char off = read8(ctx, ctx->PC++);
  5895. write8(ctx, WR.IX + off, doSetRes(ctx, SR_SET, 7, read8(ctx, WR.IX + off)));
  5896. }
  5897. static void SET_7_off_IY_d (Z80Context* ctx)
  5898. {
  5899. ctx->tstates += 2;
  5900. signed char off = read8(ctx, ctx->PC++);
  5901. write8(ctx, WR.IY + off, doSetRes(ctx, SR_SET, 7, read8(ctx, WR.IY + off)));
  5902. }
  5903. static void SET_7_A (Z80Context* ctx)
  5904. {
  5905. BR.A = doSetRes(ctx, SR_SET, 7, BR.A);
  5906. }
  5907. static void SET_7_B (Z80Context* ctx)
  5908. {
  5909. BR.B = doSetRes(ctx, SR_SET, 7, BR.B);
  5910. }
  5911. static void SET_7_C (Z80Context* ctx)
  5912. {
  5913. BR.C = doSetRes(ctx, SR_SET, 7, BR.C);
  5914. }
  5915. static void SET_7_D (Z80Context* ctx)
  5916. {
  5917. BR.D = doSetRes(ctx, SR_SET, 7, BR.D);
  5918. }
  5919. static void SET_7_E (Z80Context* ctx)
  5920. {
  5921. BR.E = doSetRes(ctx, SR_SET, 7, BR.E);
  5922. }
  5923. static void SET_7_H (Z80Context* ctx)
  5924. {
  5925. BR.H = doSetRes(ctx, SR_SET, 7, BR.H);
  5926. }
  5927. static void SET_7_L (Z80Context* ctx)
  5928. {
  5929. BR.L = doSetRes(ctx, SR_SET, 7, BR.L);
  5930. }
  5931. static void SLA_off_HL (Z80Context* ctx)
  5932. {
  5933. ctx->tstates += 1;
  5934. write8(ctx, WR.HL, doSL(ctx, read8(ctx, WR.HL), IA_A));
  5935. }
  5936. static void SLA_off_IX_d (Z80Context* ctx)
  5937. {
  5938. ctx->tstates += 2;
  5939. signed char off = read8(ctx, ctx->PC++);
  5940. write8(ctx, WR.IX + off, doSL(ctx, read8(ctx, WR.IX + off), IA_A));
  5941. }
  5942. static void SLA_off_IY_d (Z80Context* ctx)
  5943. {
  5944. ctx->tstates += 2;
  5945. signed char off = read8(ctx, ctx->PC++);
  5946. write8(ctx, WR.IY + off, doSL(ctx, read8(ctx, WR.IY + off), IA_A));
  5947. }
  5948. static void SLA_A (Z80Context* ctx)
  5949. {
  5950. BR.A = doSL(ctx, BR.A, IA_A);
  5951. }
  5952. static void SLA_B (Z80Context* ctx)
  5953. {
  5954. BR.B = doSL(ctx, BR.B, IA_A);
  5955. }
  5956. static void SLA_C (Z80Context* ctx)
  5957. {
  5958. BR.C = doSL(ctx, BR.C, IA_A);
  5959. }
  5960. static void SLA_D (Z80Context* ctx)
  5961. {
  5962. BR.D = doSL(ctx, BR.D, IA_A);
  5963. }
  5964. static void SLA_E (Z80Context* ctx)
  5965. {
  5966. BR.E = doSL(ctx, BR.E, IA_A);
  5967. }
  5968. static void SLA_H (Z80Context* ctx)
  5969. {
  5970. BR.H = doSL(ctx, BR.H, IA_A);
  5971. }
  5972. static void SLA_L (Z80Context* ctx)
  5973. {
  5974. BR.L = doSL(ctx, BR.L, IA_A);
  5975. }
  5976. static void SLL_off_HL (Z80Context* ctx)
  5977. {
  5978. ctx->tstates += 1;
  5979. write8(ctx, WR.HL, doSL(ctx, read8(ctx, WR.HL), IA_L));
  5980. }
  5981. static void SLL_off_IX_d (Z80Context* ctx)
  5982. {
  5983. ctx->tstates += 2;
  5984. signed char off = read8(ctx, ctx->PC++);
  5985. write8(ctx, WR.IX + off, doSL(ctx, read8(ctx, WR.IX + off), IA_L));
  5986. }
  5987. static void SLL_off_IY_d (Z80Context* ctx)
  5988. {
  5989. ctx->tstates += 2;
  5990. signed char off = read8(ctx, ctx->PC++);
  5991. write8(ctx, WR.IY + off, doSL(ctx, read8(ctx, WR.IY + off), IA_L));
  5992. }
  5993. static void SLL_A (Z80Context* ctx)
  5994. {
  5995. BR.A = doSL(ctx, BR.A, IA_L);
  5996. }
  5997. static void SLL_B (Z80Context* ctx)
  5998. {
  5999. BR.B = doSL(ctx, BR.B, IA_L);
  6000. }
  6001. static void SLL_C (Z80Context* ctx)
  6002. {
  6003. BR.C = doSL(ctx, BR.C, IA_L);
  6004. }
  6005. static void SLL_D (Z80Context* ctx)
  6006. {
  6007. BR.D = doSL(ctx, BR.D, IA_L);
  6008. }
  6009. static void SLL_E (Z80Context* ctx)
  6010. {
  6011. BR.E = doSL(ctx, BR.E, IA_L);
  6012. }
  6013. static void SLL_H (Z80Context* ctx)
  6014. {
  6015. BR.H = doSL(ctx, BR.H, IA_L);
  6016. }
  6017. static void SLL_L (Z80Context* ctx)
  6018. {
  6019. BR.L = doSL(ctx, BR.L, IA_L);
  6020. }
  6021. static void SRA_off_HL (Z80Context* ctx)
  6022. {
  6023. ctx->tstates += 1;
  6024. write8(ctx, WR.HL, doSR(ctx, read8(ctx, WR.HL), IA_A));
  6025. }
  6026. static void SRA_off_IX_d (Z80Context* ctx)
  6027. {
  6028. ctx->tstates += 2;
  6029. signed char off = read8(ctx, ctx->PC++);
  6030. write8(ctx, WR.IX + off, doSR(ctx, read8(ctx, WR.IX + off), IA_A));
  6031. }
  6032. static void SRA_off_IY_d (Z80Context* ctx)
  6033. {
  6034. ctx->tstates += 2;
  6035. signed char off = read8(ctx, ctx->PC++);
  6036. write8(ctx, WR.IY + off, doSR(ctx, read8(ctx, WR.IY + off), IA_A));
  6037. }
  6038. static void SRA_A (Z80Context* ctx)
  6039. {
  6040. BR.A = doSR(ctx, BR.A, IA_A);
  6041. }
  6042. static void SRA_B (Z80Context* ctx)
  6043. {
  6044. BR.B = doSR(ctx, BR.B, IA_A);
  6045. }
  6046. static void SRA_C (Z80Context* ctx)
  6047. {
  6048. BR.C = doSR(ctx, BR.C, IA_A);
  6049. }
  6050. static void SRA_D (Z80Context* ctx)
  6051. {
  6052. BR.D = doSR(ctx, BR.D, IA_A);
  6053. }
  6054. static void SRA_E (Z80Context* ctx)
  6055. {
  6056. BR.E = doSR(ctx, BR.E, IA_A);
  6057. }
  6058. static void SRA_H (Z80Context* ctx)
  6059. {
  6060. BR.H = doSR(ctx, BR.H, IA_A);
  6061. }
  6062. static void SRA_L (Z80Context* ctx)
  6063. {
  6064. BR.L = doSR(ctx, BR.L, IA_A);
  6065. }
  6066. static void SRL_off_HL (Z80Context* ctx)
  6067. {
  6068. ctx->tstates += 1;
  6069. write8(ctx, WR.HL, doSR(ctx, read8(ctx, WR.HL), IA_L));
  6070. }
  6071. static void SRL_off_IX_d (Z80Context* ctx)
  6072. {
  6073. ctx->tstates += 2;
  6074. signed char off = read8(ctx, ctx->PC++);
  6075. write8(ctx, WR.IX + off, doSR(ctx, read8(ctx, WR.IX + off), IA_L));
  6076. }
  6077. static void SRL_off_IY_d (Z80Context* ctx)
  6078. {
  6079. ctx->tstates += 2;
  6080. signed char off = read8(ctx, ctx->PC++);
  6081. write8(ctx, WR.IY + off, doSR(ctx, read8(ctx, WR.IY + off), IA_L));
  6082. }
  6083. static void SRL_A (Z80Context* ctx)
  6084. {
  6085. BR.A = doSR(ctx, BR.A, IA_L);
  6086. }
  6087. static void SRL_B (Z80Context* ctx)
  6088. {
  6089. BR.B = doSR(ctx, BR.B, IA_L);
  6090. }
  6091. static void SRL_C (Z80Context* ctx)
  6092. {
  6093. BR.C = doSR(ctx, BR.C, IA_L);
  6094. }
  6095. static void SRL_D (Z80Context* ctx)
  6096. {
  6097. BR.D = doSR(ctx, BR.D, IA_L);
  6098. }
  6099. static void SRL_E (Z80Context* ctx)
  6100. {
  6101. BR.E = doSR(ctx, BR.E, IA_L);
  6102. }
  6103. static void SRL_H (Z80Context* ctx)
  6104. {
  6105. BR.H = doSR(ctx, BR.H, IA_L);
  6106. }
  6107. static void SRL_L (Z80Context* ctx)
  6108. {
  6109. BR.L = doSR(ctx, BR.L, IA_L);
  6110. }
  6111. static void SUB_A_off_HL (Z80Context* ctx)
  6112. {
  6113. BR.A = doArithmetic(ctx, read8(ctx, WR.HL), F1_SUB, F2_SUB);
  6114. }
  6115. static void SUB_A_off_IX_d (Z80Context* ctx)
  6116. {
  6117. ctx->tstates += 5;
  6118. signed char displacement = read8(ctx, ctx->PC++);
  6119. BR.A = doArithmetic(ctx, read8(ctx, WR.IX + displacement), F1_SUB, F2_SUB);
  6120. }
  6121. static void SUB_A_off_IY_d (Z80Context* ctx)
  6122. {
  6123. ctx->tstates += 5;
  6124. signed char displacement = read8(ctx, ctx->PC++);
  6125. BR.A = doArithmetic(ctx, read8(ctx, WR.IY + displacement), F1_SUB, F2_SUB);
  6126. }
  6127. static void SUB_A_A (Z80Context* ctx)
  6128. {
  6129. BR.A = doArithmetic(ctx, BR.A, F1_SUB, F2_SUB);
  6130. }
  6131. static void SUB_A_B (Z80Context* ctx)
  6132. {
  6133. BR.A = doArithmetic(ctx, BR.B, F1_SUB, F2_SUB);
  6134. }
  6135. static void SUB_A_C (Z80Context* ctx)
  6136. {
  6137. BR.A = doArithmetic(ctx, BR.C, F1_SUB, F2_SUB);
  6138. }
  6139. static void SUB_A_D (Z80Context* ctx)
  6140. {
  6141. BR.A = doArithmetic(ctx, BR.D, F1_SUB, F2_SUB);
  6142. }
  6143. static void SUB_A_E (Z80Context* ctx)
  6144. {
  6145. BR.A = doArithmetic(ctx, BR.E, F1_SUB, F2_SUB);
  6146. }
  6147. static void SUB_A_H (Z80Context* ctx)
  6148. {
  6149. BR.A = doArithmetic(ctx, BR.H, F1_SUB, F2_SUB);
  6150. }
  6151. static void SUB_A_IXh (Z80Context* ctx)
  6152. {
  6153. BR.A = doArithmetic(ctx, BR.IXh, F1_SUB, F2_SUB);
  6154. }
  6155. static void SUB_A_IXl (Z80Context* ctx)
  6156. {
  6157. BR.A = doArithmetic(ctx, BR.IXl, F1_SUB, F2_SUB);
  6158. }
  6159. static void SUB_A_IYh (Z80Context* ctx)
  6160. {
  6161. BR.A = doArithmetic(ctx, BR.IYh, F1_SUB, F2_SUB);
  6162. }
  6163. static void SUB_A_IYl (Z80Context* ctx)
  6164. {
  6165. BR.A = doArithmetic(ctx, BR.IYl, F1_SUB, F2_SUB);
  6166. }
  6167. static void SUB_A_L (Z80Context* ctx)
  6168. {
  6169. BR.A = doArithmetic(ctx, BR.L, F1_SUB, F2_SUB);
  6170. }
  6171. static void SUB_A_n (Z80Context* ctx)
  6172. {
  6173. BR.A = doArithmetic(ctx, read8(ctx, ctx->PC++), F1_SUB, F2_SUB);
  6174. }
  6175. static void XOR_off_HL (Z80Context* ctx)
  6176. {
  6177. doXOR(ctx, read8(ctx, WR.HL));
  6178. }
  6179. static void XOR_off_IX_d (Z80Context* ctx)
  6180. {
  6181. ctx->tstates += 5;
  6182. doXOR(ctx, read8(ctx, WR.IX + (signed char) read8(ctx, ctx->PC++)));
  6183. }
  6184. static void XOR_off_IY_d (Z80Context* ctx)
  6185. {
  6186. ctx->tstates += 5;
  6187. doXOR(ctx, read8(ctx, WR.IY + (signed char) read8(ctx, ctx->PC++)));
  6188. }
  6189. static void XOR_A (Z80Context* ctx)
  6190. {
  6191. doXOR(ctx, BR.A);
  6192. }
  6193. static void XOR_B (Z80Context* ctx)
  6194. {
  6195. doXOR(ctx, BR.B);
  6196. }
  6197. static void XOR_C (Z80Context* ctx)
  6198. {
  6199. doXOR(ctx, BR.C);
  6200. }
  6201. static void XOR_D (Z80Context* ctx)
  6202. {
  6203. doXOR(ctx, BR.D);
  6204. }
  6205. static void XOR_E (Z80Context* ctx)
  6206. {
  6207. doXOR(ctx, BR.E);
  6208. }
  6209. static void XOR_H (Z80Context* ctx)
  6210. {
  6211. doXOR(ctx, BR.H);
  6212. }
  6213. static void XOR_IXh (Z80Context* ctx)
  6214. {
  6215. doXOR(ctx, BR.IXh);
  6216. }
  6217. static void XOR_IXl (Z80Context* ctx)
  6218. {
  6219. doXOR(ctx, BR.IXl);
  6220. }
  6221. static void XOR_IYh (Z80Context* ctx)
  6222. {
  6223. doXOR(ctx, BR.IYh);
  6224. }
  6225. static void XOR_IYl (Z80Context* ctx)
  6226. {
  6227. doXOR(ctx, BR.IYl);
  6228. }
  6229. static void XOR_L (Z80Context* ctx)
  6230. {
  6231. doXOR(ctx, BR.L);
  6232. }
  6233. static void XOR_n (Z80Context* ctx)
  6234. {
  6235. doXOR(ctx, read8(ctx, ctx->PC++));
  6236. }