armwrestler-fix: Fix MULL_MLAL instructions
Also fix disassembly for MULL_MLAL Former-commit-id: f535b2db7edb5d056160699436dbeb0c15e61388
This commit is contained in:
parent
7429236471
commit
e06c77b6fd
|
@ -352,30 +352,18 @@ impl ArmInstruction {
|
|||
}
|
||||
|
||||
fn fmt_mull_mlal(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
if self.accumulate_flag() {
|
||||
write!(
|
||||
f,
|
||||
"{sign}mlal{S}{cond}\t{RdLo}, {RdHi}, {Rm}, {Rs}",
|
||||
sign = self.sign_mark(),
|
||||
S = self.set_cond_mark(),
|
||||
cond = self.cond,
|
||||
RdLo = reg_string(self.rd_lo()),
|
||||
RdHi = reg_string(self.rd_hi()),
|
||||
Rm = reg_string(self.rm()),
|
||||
Rs = reg_string(self.rs()),
|
||||
)
|
||||
} else {
|
||||
write!(
|
||||
f,
|
||||
"{sign}mull{S}{cond}\t{RdLo}, {RdHi}, {Rm}",
|
||||
sign = self.sign_mark(),
|
||||
S = self.set_cond_mark(),
|
||||
cond = self.cond,
|
||||
RdLo = reg_string(self.rd_lo()),
|
||||
RdHi = reg_string(self.rd_hi()),
|
||||
Rm = reg_string(self.rm())
|
||||
)
|
||||
}
|
||||
write!(
|
||||
f,
|
||||
"{sign}{mnem}{S}{cond}\t{RdLo}, {RdHi}, {Rm}, {Rs}",
|
||||
sign = self.sign_mark(),
|
||||
mnem = if self.accumulate_flag() { "mlal" } else { "mull" },
|
||||
S = self.set_cond_mark(),
|
||||
cond = self.cond,
|
||||
RdLo = reg_string(self.rd_lo()),
|
||||
RdHi = reg_string(self.rd_hi()),
|
||||
Rm = reg_string(self.rm()),
|
||||
Rs = reg_string(self.rs()),
|
||||
)
|
||||
}
|
||||
|
||||
fn fmt_ldr_str_hs(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
|
|
|
@ -464,13 +464,13 @@ impl Core {
|
|||
return Err(CpuError::IllegalInstruction);
|
||||
}
|
||||
|
||||
let op1 = self.get_reg(rm) as u64;
|
||||
let op2 = self.get_reg(rs) as u64;
|
||||
let op1 = self.get_reg(rm);
|
||||
let op2 = self.get_reg(rs);
|
||||
let mut result: u64 = if insn.u_flag() {
|
||||
// signed
|
||||
(op1 as i64).wrapping_mul(op2 as i64) as u64
|
||||
(op1 as i32 as i64).wrapping_mul(op2 as i32 as i64) as u64
|
||||
} else {
|
||||
op1.wrapping_mul(op2)
|
||||
(op1 as u64).wrapping_mul(op2 as u64)
|
||||
};
|
||||
self.add_cycle();
|
||||
|
||||
|
@ -481,8 +481,8 @@ impl Core {
|
|||
self.add_cycle();
|
||||
}
|
||||
|
||||
self.set_reg(rd_hi, (result >> 32) as u32);
|
||||
self.set_reg(rd_lo, (result & 0xffffffff) as u32);
|
||||
self.set_reg(rd_hi, (result >> 32) as i32 as u32);
|
||||
self.set_reg(rd_lo, (result & 0xffffffff) as i32 as u32);
|
||||
|
||||
let m = self.get_required_multipiler_array_cycles(self.get_reg(rs) as i32);
|
||||
for _ in 0..m {
|
||||
|
@ -490,8 +490,10 @@ impl Core {
|
|||
}
|
||||
|
||||
if insn.set_cond_flag() {
|
||||
self.cpsr.set_N((result as i64) < 0);
|
||||
self.cpsr.set_N(result.bit(63));
|
||||
self.cpsr.set_Z(result == 0);
|
||||
self.cpsr.set_C(false);
|
||||
self.cpsr.set_V(false);
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
|
Reference in a new issue