X-Git-Url: https://notaz.gp2x.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=cpu%2Fdrc%2Femit_x86.c;fp=cpu%2Fdrc%2Femit_x86.c;h=3624f5c3f1c55cb14d4b430069de5536f583622d;hb=04092e329bbd050073d42defcd609550d8545e74;hp=225735921fe05f885a3d2734e9b903d56ec27e56;hpb=a2b8c5a54568093b247ced39f0754cbb30324830;p=picodrive.git diff --git a/cpu/drc/emit_x86.c b/cpu/drc/emit_x86.c index 2257359..3624f5c 100644 --- a/cpu/drc/emit_x86.c +++ b/cpu/drc/emit_x86.c @@ -63,10 +63,10 @@ enum { xAX = 0, xCX, xDX, xBX, xSP, xBP, xSI, xDI }; #define EMIT_SIB(scale,index,base) \ EMIT(((scale)<<6) | ((index)<<3) | (base), u8) -#define EMIT_OP_MODRM(op,mod,r,rm) { \ +#define EMIT_OP_MODRM(op,mod,r,rm) do { \ EMIT_OP(op); \ EMIT_MODRM(mod, r, rm); \ -} +} while (0) #define JMP8_POS(ptr) \ ptr = tcache_ptr; \ @@ -418,48 +418,43 @@ enum { xAX = 0, xCX, xDX, xBX, xSP, xBP, xSI, xDI }; #define is_abcdx(r) (xAX <= (r) && (r) <= xDX) -#define emith_read_op_8_16(op, r, rs, offs) do { \ +#define emith_read_r_r_offs(r, rs, offs) \ + emith_deref_op(0x8b, r, rs, offs) + +#define emith_write_r_r_offs(r, rs, offs) \ + emith_deref_op(0x89, r, rs, offs) + +// note: don't use prefixes on this +#define emith_read8_r_r_offs(r, rs, offs) do { \ int r_ = r; \ if (!is_abcdx(r)) \ r_ = rcache_get_tmp(); \ - emith_deref_op(op, r_, rs, offs); \ + emith_deref_op(0x8a, r_, rs, offs); \ if ((r) != r_) { \ emith_move_r_r(r, r_); \ rcache_free_tmp(r_); \ } \ } while (0) -#define emith_write_op_8_16(op, r, rs, offs) do { \ +#define emith_write8_r_r_offs(r, rs, offs) do {\ int r_ = r; \ if (!is_abcdx(r)) { \ r_ = rcache_get_tmp(); \ emith_move_r_r(r_, r); \ } \ - emith_deref_op(op, r_, rs, offs); \ + emith_deref_op(0x88, r_, rs, offs); \ if ((r) != r_) \ rcache_free_tmp(r_); \ } while (0) -#define emith_read_r_r_offs(r, rs, offs) \ - emith_deref_op(0x8b, r, rs, offs) - -#define emith_write_r_r_offs(r, rs, offs) \ - emith_deref_op(0x89, r, rs, offs) - -#define emith_read8_r_r_offs(r, rs, offs) \ - emith_read_op_8_16(0x8a, r, rs, offs) - -#define emith_write8_r_r_offs(r, rs, offs) \ - emith_write_op_8_16(0x88, r, rs, offs) - #define emith_read16_r_r_offs(r, rs, offs) { \ EMIT(0x66, u8); /* operand override */ \ - emith_read_op_8_16(0x8b, r, rs, offs); \ + emith_read_r_r_offs(r, rs, offs); \ } #define emith_write16_r_r_offs(r, rs, offs) { \ EMIT(0x66, u8); \ - emith_read_op_8_16(0x89, r, rs, offs); \ + emith_write_r_r_offs(r, rs, offs); \ } #define emith_ctx_read(r, offs) \