-#define emith_carry_to_t(srr, is_sub) { \
- int tmp = rcache_get_tmp(); \
- EMIT_OP(0x0f); \
- EMIT(0x92, u8); \
- EMIT_MODRM(3, 0, tmp); /* SETC */ \
- emith_bic_r_imm(srr, 1); \
- EMIT_OP_MODRM(0x08, 3, tmp, srr); /* OR srrl, tmpl */ \
- rcache_free_tmp(tmp); \
+#define emith_tpop_carry(sr, is_sub) \
+ emith_lsr(sr, sr, 1)
+
+#define emith_tpush_carry(sr, is_sub) \
+ emith_adc_r_r(sr, sr)
+
+/*
+ * if Q
+ * t = carry(Rn += Rm)
+ * else
+ * t = carry(Rn -= Rm)
+ * T ^= t
+ */
+#define emith_sh2_div1_step(rn, rm, sr) { \
+ u8 *jmp0, *jmp1; \
+ int tmp_ = rcache_get_tmp(); \
+ emith_eor_r_r(tmp_, tmp_); \
+ emith_tst_r_imm(sr, Q); /* if (Q ^ M) */ \
+ JMP8_POS(jmp0); /* je do_sub */ \
+ emith_add_r_r(rn, rm); \
+ JMP8_POS(jmp1); /* jmp done */ \
+ JMP8_EMIT(ICOND_JE, jmp0); /* do_sub: */ \
+ emith_sub_r_r(rn, rm); \
+ JMP8_EMIT_NC(jmp1); /* done: */ \
+ emith_setc(tmp_); \
+ EMIT_OP_MODRM(0x31, 3, tmp_, sr); /* T = Q1 ^ Q2 */ \
+ rcache_free_tmp(tmp_); \