# HG changeset patch # User Mike Pavone # Date 1357368661 28800 # Node ID 4791c02044104d07f122accf43356f2f31eb6f97 # Parent 42c031184e8a665ce4c66ec60a2e4beb113c6e2d Small fix for bit instructions diff -r 42c031184e8a -r 4791c0204410 68kinst.c --- a/68kinst.c Fri Jan 04 21:47:09 2013 -0800 +++ b/68kinst.c Fri Jan 04 22:51:01 2013 -0800 @@ -727,10 +727,12 @@ decoded->variant = VAR_WORD; immed = *(++istream); immed = sign_extend16(immed); +#ifdef M68020 } else if (immed == 0xFF) { decoded->variant = VAR_LONG; immed = *(++istream) << 16; immed |= *(++istream); +#endif } else { decoded->variant = VAR_BYTE; immed = sign_extend8(immed); diff -r 42c031184e8a -r 4791c0204410 m68k_to_x86.c --- a/m68k_to_x86.c Fri Jan 04 21:47:09 2013 -0800 +++ b/m68k_to_x86.c Fri Jan 04 22:51:01 2013 -0800 @@ -347,7 +347,7 @@ break; default: m68k_disasm(inst, disasm_buf); - printf("%s\naddress mode %d not implemented (src)\n", disasm_buf, inst->src.addr_mode); + printf("%X: %s\naddress mode %d not implemented (src)\n", inst->address, disasm_buf, inst->src.addr_mode); exit(1); } return out; @@ -613,7 +613,7 @@ break; default: m68k_disasm(inst, disasm_buf); - printf("%s\naddress mode %d not implemented (dst)\n", disasm_buf, inst->dst.addr_mode); + printf("%X: %s\naddress mode %d not implemented (dst)\n", inst->address, disasm_buf, inst->dst.addr_mode); exit(1); } return out; @@ -961,7 +961,7 @@ break; default: m68k_disasm(inst, disasm_buf); - printf("%s\naddress mode %d not implemented (move dst)\n", disasm_buf, inst->dst.addr_mode); + printf("%X: %s\naddress mode %d not implemented (move dst)\n", inst->address, disasm_buf, inst->dst.addr_mode); exit(1); } @@ -1002,7 +1002,7 @@ break; default: m68k_disasm(inst, disasm_buf); - printf("%s\naddress mode %d not implemented (movem dst)\n", disasm_buf, inst->dst.addr_mode); + printf("%X: %s\naddress mode %d not implemented (movem dst)\n", inst->address, disasm_buf, inst->dst.addr_mode); exit(1); } dst = cycles(dst, early_cycles); @@ -1064,7 +1064,7 @@ break; default: m68k_disasm(inst, disasm_buf); - printf("%s\naddress mode %d not implemented (movem src)\n", disasm_buf, inst->src.addr_mode); + printf("%X: %s\naddress mode %d not implemented (movem src)\n", inst->address, disasm_buf, inst->src.addr_mode); exit(1); } dst = cycles(dst, early_cycles); @@ -1301,7 +1301,7 @@ break; default: m68k_disasm(inst, disasm_buf); - printf("%s\naddress mode %d not implemented (lea src)\n", disasm_buf, inst->src.addr_mode); + printf("%X: %s\naddress mode %d not implemented (lea src)\n", inst->address, disasm_buf, inst->src.addr_mode); exit(1); } return dst; @@ -1382,7 +1382,7 @@ break; default: m68k_disasm(inst, disasm_buf); - printf("%s\naddress mode %d not implemented (lea src)\n", disasm_buf, inst->src.addr_mode); + printf("%X: %s\naddress mode %d not implemented (lea src)\n", inst->address, disasm_buf, inst->src.addr_mode); exit(1); } dst = sub_ir(dst, 4, opts->aregs[7], SZ_D); @@ -1394,7 +1394,7 @@ uint8_t * translate_m68k_bsr(uint8_t * dst, m68kinst * inst, x86_68k_options * opts) { int32_t disp = inst->src.params.immed; - uint32_t after = inst->address + 2; + uint32_t after = inst->address + (inst->variant == VAR_BYTE ? 2 : 4); //TODO: Add cycles in the right place relative to pushing the return address on the stack dst = cycles(dst, 10); dst = mov_ir(dst, after, SCRATCH1, SZ_D); @@ -1402,9 +1402,9 @@ dst = sub_ir(dst, 4, opts->aregs[7], SZ_D); dst = mov_rr(dst, opts->aregs[7], SCRATCH2, SZ_D); dst = call(dst, (char *)m68k_write_long_highfirst); - uint8_t * dest_addr = get_native_address(opts->native_code_map, after + disp); + uint8_t * dest_addr = get_native_address(opts->native_code_map, (inst->address+2) + disp); if (!dest_addr) { - opts->deferred = defer_address(opts->deferred, after + disp, dst + 1); + opts->deferred = defer_address(opts->deferred, (inst->address+2) + disp, dst + 1); //dummy address to be replaced later dest_addr = dst + 5; } @@ -2321,6 +2321,18 @@ src_op.base = SCRATCH1; } } + if (dst_op.mode == MODE_REG_DISPLACE8) { + if (src_op.base != SCRATCH1 && src_op.base != SCRATCH2) { + if (src_op.mode == MODE_REG_DIRECT) { + dst = mov_rr(dst, src_op.base, SCRATCH1, SZ_D); + } else { + dst = mov_rdisp8r(dst, src_op.base, src_op.disp, SCRATCH1, SZ_D); + src_op.mode = MODE_REG_DIRECT; + } + src_op.base = SCRATCH1; + } + dst = and_ir(dst, 31, SCRATCH1, SZ_D); + } if (inst->op == M68K_BTST) { if (dst_op.mode == MODE_REG_DIRECT) { dst = bt_rr(dst, src_op.base, dst_op.base, inst->extra.size);