diff options
Diffstat (limited to 'src/devices/cpu/drcbec.cpp')
-rw-r--r-- | src/devices/cpu/drcbec.cpp | 254 |
1 files changed, 199 insertions, 55 deletions
diff --git a/src/devices/cpu/drcbec.cpp b/src/devices/cpu/drcbec.cpp index 14cac9e5501..5e93429dbf6 100644 --- a/src/devices/cpu/drcbec.cpp +++ b/src/devices/cpu/drcbec.cpp @@ -181,6 +181,7 @@ enum // compute C and V flags for 32-bit add/subtract #define FLAGS32_C_ADD(a,b) ((uint32_t)~(a) < (uint32_t)(b)) #define FLAGS32_C_SUB(a,b) ((uint32_t)(b) > (uint32_t)(a)) +#define FLAGS32_C_SUBC(a,b,c) (((uint32_t)(c) != 0 && ((uint32_t)(b) + (uint32_t)(c)) == 0) || (uint32_t)(b) + (uint32_t)(c) > (uint32_t)(a)) #define FLAGS32_V_SUB(r,a,b) (((((a) ^ (b)) & ((a) ^ (r))) >> 30) & FLAG_V) #define FLAGS32_V_ADD(r,a,b) (((~((a) ^ (b)) & ((a) ^ (r))) >> 30) & FLAG_V) @@ -188,10 +189,12 @@ enum #define FLAGS32_NZ(v) ((((v) >> 28) & FLAG_S) | (((uint32_t)(v) == 0) << 2)) #define FLAGS32_NZCV_ADD(r,a,b) (FLAGS32_NZ(r) | FLAGS32_C_ADD(a,b) | FLAGS32_V_ADD(r,a,b)) #define FLAGS32_NZCV_SUB(r,a,b) (FLAGS32_NZ(r) | FLAGS32_C_SUB(a,b) | FLAGS32_V_SUB(r,a,b)) +#define FLAGS32_NZCV_SUBC(r,a,b,c) (FLAGS32_NZ(r) | FLAGS32_C_SUBC(a,b,c) | FLAGS32_V_SUB(r,a,b)) // compute C and V flags for 64-bit add/subtract #define FLAGS64_C_ADD(a,b) ((uint64_t)~(a) < (uint64_t)(b)) #define FLAGS64_C_SUB(a,b) ((uint64_t)(b) > (uint64_t)(a)) +#define FLAGS64_C_SUBC(a,b,c) (((uint64_t)(c) != 0 && ((uint64_t)(b) + (uint64_t)(c)) == 0) || (uint64_t)(b) + (uint64_t)(c) > (uint64_t)(a)) #define FLAGS64_V_SUB(r,a,b) (((((a) ^ (b)) & ((a) ^ (r))) >> 62) & FLAG_V) #define FLAGS64_V_ADD(r,a,b) (((~((a) ^ (b)) & ((a) ^ (r))) >> 62) & FLAG_V) @@ -199,6 +202,7 @@ enum #define FLAGS64_NZ(v) ((((v) >> 60) & FLAG_S) | (((uint64_t)(v) == 0) << 2)) #define FLAGS64_NZCV_ADD(r,a,b) (FLAGS64_NZ(r) | FLAGS64_C_ADD(a,b) | FLAGS64_V_ADD(r,a,b)) #define FLAGS64_NZCV_SUB(r,a,b) (FLAGS64_NZ(r) | FLAGS64_C_SUB(a,b) | FLAGS64_V_SUB(r,a,b)) +#define FLAGS64_NZCV_SUBC(r,a,b,c) (FLAGS64_NZ(r) | FLAGS64_C_SUBC(a,b,c) | FLAGS64_V_SUB(r,a,b)) @@ -320,13 +324,30 @@ void drcbe_c::reset() void drcbe_c::generate(drcuml_block &block, const instruction *instlist, uint32_t numinst) { + // Calculate the max possible number of register clears required + uint32_t regclears = 0; + + for (int inum = 0; inum < numinst; inum++) + { + const instruction &inst = instlist[inum]; + + if (inst.size() != 4) + continue; + + for (int pnum = 0; pnum < inst.numparams(); pnum++) + { + if (inst.is_param_out(pnum) && inst.param(pnum).is_int_register()) + regclears++; + } + } + // tell all of our utility objects that a block is beginning - m_hash.block_begin(block, instlist, numinst); + m_hash.block_begin(block, instlist, numinst + regclears); m_labels.block_begin(block); m_map.block_begin(block); // begin codegen; fail if we can't - drccodeptr *cachetop = m_cache.begin_codegen(numinst * sizeof(drcbec_instruction) * 4); + drccodeptr *cachetop = m_cache.begin_codegen((numinst + regclears) * sizeof(drcbec_instruction) * 4); if (cachetop == nullptr) block.abort(); @@ -334,6 +355,9 @@ void drcbe_c::generate(drcuml_block &block, const instruction *instlist, uint32_ drcbec_instruction *base = (drcbec_instruction *)(((uintptr_t)*cachetop + sizeof(drcbec_instruction) - 1) & ~(sizeof(drcbec_instruction) - 1)); drcbec_instruction *dst = base; + bool ireg_needs_clearing[REG_I_COUNT]; + std::fill(std::begin(ireg_needs_clearing), std::end(ireg_needs_clearing), true); + // generate code by copying the instructions and extracting immediates for (int inum = 0; inum < numinst; inum++) { @@ -359,9 +383,10 @@ void drcbe_c::generate(drcuml_block &block, const instruction *instlist, uint32_ m_labels.set_codeptr(inst.param(0).label(), (drccodeptr)dst); break; - // ignore COMMENT and NOP opcodes + // ignore COMMENT, NOP, and BREAK opcodes case OP_COMMENT: case OP_NOP: + case OP_BREAK: break; // when we hit a MAPVAR opcode, log the change for the current PC @@ -386,10 +411,14 @@ void drcbe_c::generate(drcuml_block &block, const instruction *instlist, uint32_ psize[2] = 4; if (opcode == OP_STORE || opcode == OP_FSTORE) psize[1] = 4; - if (opcode == OP_READ || opcode == OP_READM || opcode == OP_FREAD) + if (opcode == OP_READ || opcode == OP_FREAD) psize[1] = psize[2] = 4; - if (opcode == OP_WRITE || opcode == OP_WRITEM || opcode == OP_FWRITE) + if (opcode == OP_WRITE || opcode == OP_FWRITE) psize[0] = psize[2] = 4; + if (opcode == OP_READM) + psize[1] = psize[3] = 4; + if (opcode == OP_WRITEM) + psize[0] = psize[3] = 4; if (opcode == OP_SEXT && inst.param(2).size() != SIZE_QWORD) psize[1] = 4; if (opcode == OP_FTOINT) @@ -444,6 +473,41 @@ void drcbe_c::generate(drcuml_block &block, const instruction *instlist, uint32_ // point past the end of the immediates dst += immedwords; + + // Keep track of which registers had an 8 byte write and clear it the next time it's written + if (inst.size() == 4) + { + for (int pnum = 0; pnum < inst.numparams(); pnum++) + { + if (inst.is_param_out(pnum) && inst.param(pnum).is_int_register() && ireg_needs_clearing[inst.param(pnum).ireg() - REG_I0]) + { + immedwords = (8 + sizeof(drcbec_instruction) - 1) / sizeof(drcbec_instruction); + + (dst++)->i = MAKE_OPCODE_FULL(OP_AND, 8, 0, 0, 3 + immedwords); + + immed = dst + 3; + + output_parameter(&dst, &immed, 8, inst.param(pnum)); + output_parameter(&dst, &immed, 8, inst.param(pnum)); + output_parameter(&dst, &immed, 8, 0xffffffff); + + dst += immedwords; + + ireg_needs_clearing[inst.param(pnum).ireg() - REG_I0] = false; + } + } + } + else if (inst.size() == 8) + { + for (int pnum = 0; pnum < inst.numparams(); pnum++) + { + if (inst.is_param_out(pnum) && inst.param(pnum).is_int_register()) + { + ireg_needs_clearing[inst.param(pnum).ireg() - REG_I0] = true; + } + } + } + break; } } @@ -518,6 +582,10 @@ int drcbe_c::execute(code_handle &entry) // these opcodes should be processed at compile-time only fatalerror("Unexpected opcode\n"); + case MAKE_OPCODE_SHORT(OP_BREAK, 4, 0): + osd_break_into_debugger("break from drc"); + break; + case MAKE_OPCODE_SHORT(OP_DEBUG, 4, 0): // DEBUG pc if (m_device.machine().debug_flags & DEBUG_FLAG_CALL_HOOK) m_device.debug()->instruction_hook(PARAM0); @@ -628,6 +696,11 @@ int drcbe_c::execute(code_handle &entry) PARAM0 = flags & PARAM1; break; + case MAKE_OPCODE_SHORT(OP_SETFLGS, 4, 0): // SETFLGS src + case MAKE_OPCODE_SHORT(OP_SETFLGS, 4, 1): + flags = PARAM0; + break; + case MAKE_OPCODE_SHORT(OP_SAVE, 4, 0): // SAVE dst *inst[0].state = m_state; inst[0].state->flags = flags; @@ -826,7 +899,8 @@ int drcbe_c::execute(code_handle &entry) m_space[PARAM3]->write_dword(PARAM0, PARAM1, PARAM2); break; - case MAKE_OPCODE_SHORT(OP_CARRY, 4, 1): // CARRY src,bitnum + case MAKE_OPCODE_SHORT(OP_CARRY, 4, 0): // CARRY src,bitnum + case MAKE_OPCODE_SHORT(OP_CARRY, 4, 1): flags = (flags & ~FLAG_C) | ((PARAM0 >> (PARAM1 & 31)) & FLAG_C); break; @@ -930,16 +1004,7 @@ int drcbe_c::execute(code_handle &entry) case MAKE_OPCODE_SHORT(OP_SUBB, 4, 1): temp32 = PARAM1 - PARAM2 - (flags & FLAG_C); - temp64 = (uint64_t)PARAM1 - (uint64_t)PARAM2 - (uint64_t)(flags & FLAG_C); - if (PARAM2 + 1 != 0) - flags = FLAGS32_NZCV_SUB(temp32, PARAM1, PARAM2 + (flags & FLAG_C)); - else - { - flags = FLAGS32_NZCV_SUB(temp32, PARAM1 - (flags & FLAG_C), PARAM2); - flags &= ~(FLAG_C | FLAG_V); - flags |= ((temp64>>32) & 1) ? FLAG_C : 0; - flags |= (((PARAM1) ^ (PARAM2)) & ((PARAM1) ^ (temp64)) & 0x80000000) ? FLAG_V : 0; - } + flags = FLAGS32_NZCV_SUBC(temp32, PARAM1, PARAM2, flags & FLAG_C); PARAM0 = temp32; break; @@ -964,6 +1029,20 @@ int drcbe_c::execute(code_handle &entry) flags |= FLAG_V; break; + case MAKE_OPCODE_SHORT(OP_MULULW, 4, 0): // MULULW dst,src1,src2[,f] + temp64 = mulu_32x32(PARAM1, PARAM2); + PARAM0 = (uint32_t)temp64; + break; + + case MAKE_OPCODE_SHORT(OP_MULULW, 4, 1): + temp64 = mulu_32x32(PARAM1, PARAM2); + temp32 = (uint32_t)temp64; + flags = FLAGS32_NZ(temp32); + PARAM0 = temp32; + if (temp64 > temp32) + flags |= FLAG_V; + break; + case MAKE_OPCODE_SHORT(OP_MULS, 4, 0): // MULS dst,edst,src1,src2[,f] temp64 = mul_32x32(PARAM2, PARAM3); PARAM1 = temp64 >> 32; @@ -972,11 +1051,24 @@ int drcbe_c::execute(code_handle &entry) case MAKE_OPCODE_SHORT(OP_MULS, 4, 1): temp64 = mul_32x32(PARAM2, PARAM3); - temp32 = (int32_t)temp64; - flags = FLAGS32_NZ(temp32); + flags = FLAGS64_NZ(temp64); PARAM1 = temp64 >> 32; PARAM0 = (uint32_t)temp64; - if (temp64 != (int32_t)temp64) + if ((int64_t)temp64 != (int32_t)temp64) + flags |= FLAG_V; + break; + + case MAKE_OPCODE_SHORT(OP_MULSLW, 4, 0): // MULSLW dst,src1,src2[,f] + temp64 = mul_32x32(PARAM1, PARAM2); + PARAM0 = (int32_t)temp64; + break; + + case MAKE_OPCODE_SHORT(OP_MULSLW, 4, 1): + temp64 = mul_32x32(PARAM1, PARAM2); + temp32 = (int32_t)temp64; + flags = FLAGS32_NZ(temp32); + PARAM0 = temp32; + if ((int64_t)temp64 != (int32_t)temp64) flags |= FLAG_V; break; @@ -1084,8 +1176,8 @@ int drcbe_c::execute(code_handle &entry) case MAKE_OPCODE_SHORT(OP_BSWAP, 4, 1): temp32 = PARAM1; - flags = FLAGS32_NZ(temp32); PARAM0 = swapendian_int32(temp32); + flags = FLAGS32_NZ(PARAM0); break; case MAKE_OPCODE_SHORT(OP_SHL, 4, 0): // SHL dst,src,count[,f] @@ -1154,6 +1246,8 @@ int drcbe_c::execute(code_handle &entry) PARAM0 = (PARAM1 << shift) | ((flags & FLAG_C) << (shift - 1)) | (PARAM1 >> (33 - shift)); else if (shift == 1) PARAM0 = (PARAM1 << shift) | (flags & FLAG_C); + else + PARAM0 = PARAM1; break; case MAKE_OPCODE_SHORT(OP_ROLC, 4, 1): @@ -1164,8 +1258,11 @@ int drcbe_c::execute(code_handle &entry) temp32 = (PARAM1 << shift) | (flags & FLAG_C); else temp32 = PARAM1; - flags = FLAGS32_NZ(temp32); - if (shift != 0) flags |= ((PARAM1 << (shift - 1)) >> 31) & FLAG_C; + if (shift != 0) + { + flags = FLAGS32_NZ(temp32); + flags |= ((PARAM1 << (shift - 1)) >> 31) & FLAG_C; + } PARAM0 = temp32; break; @@ -1176,8 +1273,11 @@ int drcbe_c::execute(code_handle &entry) case MAKE_OPCODE_SHORT(OP_ROR, 4, 1): shift = PARAM2 & 31; temp32 = rotr_32(PARAM1, shift); - flags = FLAGS32_NZ(temp32); - if (shift != 0) flags |= (PARAM1 >> (shift - 1)) & FLAG_C; + if (shift != 0) + { + flags = FLAGS32_NZ(temp32); + flags |= (PARAM1 >> (shift - 1)) & FLAG_C; + } PARAM0 = temp32; break; @@ -1187,6 +1287,8 @@ int drcbe_c::execute(code_handle &entry) PARAM0 = (PARAM1 >> shift) | (((flags & FLAG_C) << 31) >> (shift - 1)) | (PARAM1 << (33 - shift)); else if (shift == 1) PARAM0 = (PARAM1 >> shift) | ((flags & FLAG_C) << 31); + else + PARAM0 = PARAM1; break; case MAKE_OPCODE_SHORT(OP_RORC, 4, 1): @@ -1197,8 +1299,11 @@ int drcbe_c::execute(code_handle &entry) temp32 = (PARAM1 >> shift) | ((flags & FLAG_C) << 31); else temp32 = PARAM1; - flags = FLAGS32_NZ(temp32); - if (shift != 0) flags |= (PARAM1 >> (shift - 1)) & FLAG_C; + if (shift != 0) + { + flags = FLAGS32_NZ(temp32); + flags |= (PARAM1 >> (shift - 1)) & FLAG_C; + } PARAM0 = temp32; break; @@ -1409,20 +1514,20 @@ int drcbe_c::execute(code_handle &entry) DPARAM0 = m_space[PARAM2]->read_dword(PARAM1); break; - case MAKE_OPCODE_SHORT(OP_READ8, 8, 0): // DREAD dst,src1,space_QOWRD + case MAKE_OPCODE_SHORT(OP_READ8, 8, 0): // DREAD dst,src1,space_QWORD DPARAM0 = m_space[PARAM2]->read_qword(PARAM1); break; case MAKE_OPCODE_SHORT(OP_READM2, 8, 0): // DREADM dst,src1,mask,space_WORD - DPARAM0 = m_space[PARAM3]->read_word(PARAM1, PARAM2); + DPARAM0 = m_space[PARAM3]->read_word(PARAM1, DPARAM2); break; case MAKE_OPCODE_SHORT(OP_READM4, 8, 0): // DREADM dst,src1,mask,space_DWORD - DPARAM0 = m_space[PARAM3]->read_dword(PARAM1, PARAM2); + DPARAM0 = m_space[PARAM3]->read_dword(PARAM1, DPARAM2); break; case MAKE_OPCODE_SHORT(OP_READM8, 8, 0): // DREADM dst,src1,mask,space_QWORD - DPARAM0 = m_space[PARAM3]->read_qword(PARAM1, PARAM2); + DPARAM0 = m_space[PARAM3]->read_qword(PARAM1, DPARAM2); break; case MAKE_OPCODE_SHORT(OP_WRITE1, 8, 0): // DWRITE dst,src1,space_BYTE @@ -1454,6 +1559,7 @@ int drcbe_c::execute(code_handle &entry) break; case MAKE_OPCODE_SHORT(OP_CARRY, 8, 0): // DCARRY src,bitnum + case MAKE_OPCODE_SHORT(OP_CARRY, 8, 1): flags = (flags & ~FLAG_C) | ((DPARAM0 >> (DPARAM1 & 63)) & FLAG_C); break; @@ -1559,10 +1665,7 @@ int drcbe_c::execute(code_handle &entry) case MAKE_OPCODE_SHORT(OP_SUBB, 8, 1): temp64 = DPARAM1 - DPARAM2 - (flags & FLAG_C); - if (DPARAM2 + 1 != 0) - flags = FLAGS64_NZCV_SUB(temp64, DPARAM1, DPARAM2 + (flags & FLAG_C)); - else - flags = FLAGS64_NZCV_SUB(temp64, DPARAM1 - (flags & FLAG_C), DPARAM2); + flags = FLAGS64_NZCV_SUBC(temp64, DPARAM1, DPARAM2, flags & FLAG_C); DPARAM0 = temp64; break; @@ -1579,6 +1682,15 @@ int drcbe_c::execute(code_handle &entry) flags = dmulu(*inst[0].puint64, *inst[1].puint64, DPARAM2, DPARAM3, true); break; + case MAKE_OPCODE_SHORT(OP_MULULW, 8, 0): // DMULULW dst,src1,src2[,f] + dmulu(*inst[0].puint64, *inst[0].puint64, DPARAM1, DPARAM2, false); + break; + + case MAKE_OPCODE_SHORT(OP_MULULW, 8, 1): + flags = dmulu(*inst[0].puint64, *inst[0].puint64, DPARAM1, DPARAM2, true); + flags = FLAGS64_NZ(DPARAM0) | (flags & FLAG_V); + break; + case MAKE_OPCODE_SHORT(OP_MULS, 8, 0): // DMULS dst,edst,src1,src2[,f] dmuls(*inst[0].puint64, *inst[1].puint64, DPARAM2, DPARAM3, false); break; @@ -1587,6 +1699,15 @@ int drcbe_c::execute(code_handle &entry) flags = dmuls(*inst[0].puint64, *inst[1].puint64, DPARAM2, DPARAM3, true); break; + case MAKE_OPCODE_SHORT(OP_MULSLW, 8, 0): // DMULSLW dst,src1,src2[,f] + dmuls(*inst[0].puint64, *inst[0].puint64, DPARAM1, DPARAM2, false); + break; + + case MAKE_OPCODE_SHORT(OP_MULSLW, 8, 1): + flags = dmuls(*inst[0].puint64, *inst[0].puint64, DPARAM1, DPARAM2, true); + flags = FLAGS64_NZ(DPARAM0) | (flags & FLAG_V); + break; + case MAKE_OPCODE_SHORT(OP_DIVU, 8, 0): // DDIVU dst,edst,src1,src2[,f] if (DPARAM3 != 0) { @@ -1691,8 +1812,8 @@ int drcbe_c::execute(code_handle &entry) case MAKE_OPCODE_SHORT(OP_BSWAP, 8, 1): temp64 = DPARAM1; - flags = FLAGS64_NZ(temp64); DPARAM0 = swapendian_int64(temp64); + flags = FLAGS64_NZ(DPARAM0); break; case MAKE_OPCODE_SHORT(OP_SHL, 8, 0): // DSHL dst,src,count[,f] @@ -1702,8 +1823,11 @@ int drcbe_c::execute(code_handle &entry) case MAKE_OPCODE_SHORT(OP_SHL, 8, 1): shift = DPARAM2 & 63; temp64 = DPARAM1 << shift; - flags = FLAGS64_NZ(temp64); - if (shift != 0) flags |= ((DPARAM1 << (shift - 1)) >> 63) & FLAG_C; + if (shift != 0) + { + flags = FLAGS64_NZ(temp64); + flags |= ((DPARAM1 << (shift - 1)) >> 63) & FLAG_C; + } DPARAM0 = temp64; break; @@ -1714,8 +1838,11 @@ int drcbe_c::execute(code_handle &entry) case MAKE_OPCODE_SHORT(OP_SHR, 8, 1): shift = DPARAM2 & 63; temp64 = DPARAM1 >> shift; - flags = FLAGS64_NZ(temp64); - if (shift != 0) flags |= (DPARAM1 >> (shift - 1)) & FLAG_C; + if (shift != 0) + { + flags = FLAGS64_NZ(temp64); + flags |= (DPARAM1 >> (shift - 1)) & FLAG_C; + } DPARAM0 = temp64; break; @@ -1725,9 +1852,12 @@ int drcbe_c::execute(code_handle &entry) case MAKE_OPCODE_SHORT(OP_SAR, 8, 1): shift = DPARAM2 & 63; - temp64 = (int32_t)DPARAM1 >> shift; - flags = FLAGS64_NZ(temp64); - if (shift != 0) flags |= (DPARAM1 >> (shift - 1)) & FLAG_C; + temp64 = (int64_t)DPARAM1 >> shift; + if (shift != 0) + { + flags = FLAGS64_NZ(temp64); + flags |= (DPARAM1 >> (shift - 1)) & FLAG_C; + } DPARAM0 = temp64; break; @@ -1738,8 +1868,11 @@ int drcbe_c::execute(code_handle &entry) case MAKE_OPCODE_SHORT(OP_ROL, 8, 1): shift = DPARAM2 & 63; temp64 = rotl_64(DPARAM1, shift); - flags = FLAGS64_NZ(temp64); - if (shift != 0) flags |= ((DPARAM1 << (shift - 1)) >> 63) & FLAG_C; + if (shift != 0) + { + flags = FLAGS64_NZ(temp64); + flags |= ((DPARAM1 << (shift - 1)) >> 63) & FLAG_C; + } DPARAM0 = temp64; break; @@ -1749,6 +1882,8 @@ int drcbe_c::execute(code_handle &entry) DPARAM0 = (DPARAM1 << shift) | ((flags & FLAG_C) << (shift - 1)) | (DPARAM1 >> (65 - shift)); else if (shift == 1) DPARAM0 = (DPARAM1 << shift) | (flags & FLAG_C); + else + DPARAM0 = DPARAM1; break; case MAKE_OPCODE_SHORT(OP_ROLC, 8, 1): @@ -1759,8 +1894,11 @@ int drcbe_c::execute(code_handle &entry) temp64 = (DPARAM1 << shift) | (flags & FLAG_C); else temp64 = DPARAM1; - flags = FLAGS64_NZ(temp64); - if (shift != 0) flags |= ((DPARAM1 << (shift - 1)) >> 63) & FLAG_C; + if (shift != 0) + { + flags = FLAGS64_NZ(temp64); + flags |= ((DPARAM1 << (shift - 1)) >> 63) & FLAG_C; + } DPARAM0 = temp64; break; @@ -1771,8 +1909,11 @@ int drcbe_c::execute(code_handle &entry) case MAKE_OPCODE_SHORT(OP_ROR, 8, 1): shift = DPARAM2 & 63; temp64 = rotr_64(DPARAM1, shift); - flags = FLAGS64_NZ(temp64); - if (shift != 0) flags |= (DPARAM1 >> (shift - 1)) & FLAG_C; + if (shift != 0) + { + flags = FLAGS64_NZ(temp64); + flags |= (DPARAM1 >> (shift - 1)) & FLAG_C; + } DPARAM0 = temp64; break; @@ -1782,6 +1923,8 @@ int drcbe_c::execute(code_handle &entry) DPARAM0 = (DPARAM1 >> shift) | ((((uint64_t)flags & FLAG_C) << 63) >> (shift - 1)) | (DPARAM1 << (65 - shift)); else if (shift == 1) DPARAM0 = (DPARAM1 >> shift) | (((uint64_t)flags & FLAG_C) << 63); + else + DPARAM0 = DPARAM1; break; case MAKE_OPCODE_SHORT(OP_RORC, 8, 1): @@ -1792,8 +1935,11 @@ int drcbe_c::execute(code_handle &entry) temp64 = (DPARAM1 >> shift) | (((uint64_t)flags & FLAG_C) << 63); else temp64 = DPARAM1; - flags = FLAGS64_NZ(temp64); - if (shift != 0) flags |= (DPARAM1 >> (shift - 1)) & FLAG_C; + if (shift != 0) + { + flags = FLAGS64_NZ(temp64); + flags |= (DPARAM1 >> (shift - 1)) & FLAG_C; + } DPARAM0 = temp64; break; @@ -2108,7 +2254,6 @@ void drcbe_c::output_parameter(drcbec_instruction **dstptr, void **immedptr, int { drcbec_instruction *dst = *dstptr; void *immed = *immedptr; - parameter temp_param; switch (param.type()) { @@ -2145,8 +2290,7 @@ void drcbe_c::output_parameter(drcbec_instruction **dstptr, void **immedptr, int // convert mapvars to immediates case parameter::PTYPE_MAPVAR: - temp_param = m_map.get_last_value(param.mapvar()); - return output_parameter(dstptr, immedptr, size, temp_param); + return output_parameter(dstptr, immedptr, size, param.mapvar()); // memory just points to the memory case parameter::PTYPE_MEMORY: @@ -2239,7 +2383,7 @@ int drcbe_c::dmulu(uint64_t &dstlo, uint64_t &dsthi, uint64_t src1, uint64_t src // store the results dsthi = hi; dstlo = lo; - return ((hi >> 60) & FLAG_S) | ((dsthi != 0) << 1); + return ((hi >> 60) & FLAG_S) | ((hi != 0) << 1); } @@ -2290,7 +2434,7 @@ int drcbe_c::dmuls(uint64_t &dstlo, uint64_t &dsthi, int64_t src1, int64_t src2, // store the results dsthi = hi; dstlo = lo; - return ((hi >> 60) & FLAG_S) | ((dsthi != ((int64_t)lo >> 63)) << 1); + return ((hi >> 60) & FLAG_S) | ((hi != ((int64_t)lo >> 63)) << 1); } uint32_t drcbe_c::tzcount32(uint32_t value) |