mirror of
https://github.com/Zenithsiz/dcb.git
synced 2026-02-04 16:35:09 +00:00
Fixed issue with encoding some basic instructions
This commit is contained in:
parent
9270461f33
commit
521d85b355
@ -182,11 +182,11 @@ impl InstFmt for Inst {
|
||||
RegisterKind::Control => write!(f, "ctc{n} {src}, {dst:#x}"),
|
||||
}
|
||||
Kind::Branch { offset, on } => match on {
|
||||
true => write!(f, "bc{n}f {:#x}", SignedHex(offset)),
|
||||
false => write!(f, "bc{n}t {:#x}", SignedHex(offset)),
|
||||
true => write!(f, "bc{n}f {:#}", SignedHex(offset)),
|
||||
false => write!(f, "bc{n}t {:#}", SignedHex(offset)),
|
||||
}
|
||||
Kind::Load { dst, src, offset } => write!(f, "lwc{n} {dst:#x}, {:#x}({src})", SignedHex(offset)),
|
||||
Kind::Store { dst, src, offset } => write!(f, "swc{n} {dst:#x}, {:#x}({src})", SignedHex(offset)),
|
||||
Kind::Load { dst, src, offset } => write!(f, "lwc{n} {dst:#x}, {:#}({src})", SignedHex(offset)),
|
||||
Kind::Store { dst, src, offset } => write!(f, "swc{n} {dst:#x}, {:#}({src})", SignedHex(offset)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -136,7 +136,7 @@ impl InstTargetFmt for Inst {
|
||||
|
||||
// `beq $zr, $zr, offset` => `b offset`
|
||||
// `beq $zr, $arg, offset` => `beqz $arg, offset`
|
||||
// `beq $zr, $arg, offset` => `bnez $arg, offset`
|
||||
// `bne $zr, $arg, offset` => `bnez $arg, offset`
|
||||
match kind {
|
||||
Kind::Equal(Register::Zr) => match arg {
|
||||
Register::Zr => write!(f, "b {target}"),
|
||||
|
||||
@ -116,8 +116,8 @@ impl Encodable for Inst {
|
||||
Kind::HalfWordUnsigned => 0x5,
|
||||
Kind::WordRight => 0x6,
|
||||
};
|
||||
let s = self.value.idx();
|
||||
let t = self.addr.idx();
|
||||
let t = self.value.idx();
|
||||
let s = self.addr.idx();
|
||||
let i = self.offset.as_unsigned().zero_extended::<u32>();
|
||||
|
||||
Raw { p, s, t, i }
|
||||
|
||||
@ -99,7 +99,7 @@ impl Inst {
|
||||
(MultKind::Mult, MultMode:: Signed) => "mult",
|
||||
(MultKind::Mult, MultMode::Unsigned) => "multu",
|
||||
(MultKind::Div , MultMode:: Signed) => "div",
|
||||
(MultKind::Div , MultMode::Unsigned) => "diu",
|
||||
(MultKind::Div , MultMode::Unsigned) => "divu",
|
||||
},
|
||||
Self::MoveFrom { src, .. } => match src {
|
||||
MultReg::Hi => "mfhi",
|
||||
|
||||
@ -103,8 +103,8 @@ impl Encodable for Inst {
|
||||
Kind::Word => 0x3,
|
||||
Kind::WordRight => 0x6,
|
||||
};
|
||||
let s = self.value.idx();
|
||||
let t = self.addr.idx();
|
||||
let t = self.value.idx();
|
||||
let s = self.addr.idx();
|
||||
let i = self.offset.as_unsigned().zero_extended::<u32>();
|
||||
|
||||
Raw { p, s, t, i }
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user