+// fake
+#define emith_bic_r_imm(r, imm) \
+ emith_arith_r_imm(4, r, ~(imm))
+
+// fake conditionals (using SJMP instead)
+#define emith_add_r_imm_c(cond, r, imm) { \
+ (void)(cond); \
+ emith_arith_r_imm(0, r, imm); \
+}
+
+#define emith_or_r_imm_c(cond, r, imm) { \
+ (void)(cond); \
+ emith_arith_r_imm(1, r, imm); \
+}
+
+#define emith_sub_r_imm_c(cond, r, imm) { \
+ (void)(cond); \
+ emith_arith_r_imm(5, r, imm); \
+}
+
+// shift
+#define emith_shift(op, d, s, cnt) { \
+ if (d != s) \
+ emith_move_r_r(d, s); \
+ EMIT_OP_MODRM(0xc1, 3, op, d); \
+ EMIT(cnt, u8); \
+}
+
+#define emith_asr(d, s, cnt) \
+ emith_shift(7, d, s, cnt)
+
+#define emith_lsl(d, s, cnt) \
+ emith_shift(4, d, s, cnt)
+
+// misc
+#define emith_push(r) \
+ EMIT_OP(0x50 + (r))
+
+#define emith_pop(r) \
+ EMIT_OP(0x58 + (r))
+
+#define emith_neg_r(r) \
+ EMIT_OP_MODRM(0xf7, 3, 3, r)
+
+#define emith_clear_msb(d, s, count) { \
+ u32 t = (u32)-1; \
+ t >>= count; \
+ if (d != s) \
+ emith_move_r_r(d, s); \
+ emith_and_r_imm(d, t); \
+}
+
+#define emith_sext(d, s, bits) { \
+ emith_lsl(d, s, 32 - (bits)); \
+ emith_asr(d, d, 32 - (bits)); \
+}
+
+// XXX: stupid mess
+#define emith_mul(d, s1, s2) { \
+ int rmr; \
+ if (d != xAX) \
+ emith_push(xAX); \
+ if ((s1) == xAX) \
+ rmr = s2; \
+ else if ((s2) == xAX) \
+ rmr = s1; \
+ else { \
+ emith_move_r_r(xAX, s1); \
+ rmr = s2; \
+ } \
+ emith_push(xDX); \
+ EMIT_OP_MODRM(0xf7, 3, 4, rmr); /* MUL rmr */ \
+ emith_pop(xDX); \
+ if (d != xAX) { \
+ emith_move_r_r(d, xAX); \
+ emith_pop(xAX); \
+ } \
+}
+
+// "flag" instructions are the same
+#define emith_subf_r_imm emith_sub_r_imm
+#define emith_subf_r_r emith_sub_r_r
+