mirror of
https://github.com/Zenithsiz/dcb.git
synced 2026-02-08 19:34:27 +00:00
Fixed wrong formatting for some instructions.
This commit is contained in:
@@ -57,7 +57,7 @@ pub struct AluImmInst {
|
||||
/// Lhs argument, `rs`
|
||||
pub lhs: Register,
|
||||
|
||||
/// Rhs immediate argument
|
||||
/// Rhs argument, immediate
|
||||
pub rhs: u32,
|
||||
|
||||
/// Opcode
|
||||
|
||||
@@ -69,6 +69,6 @@ impl fmt::Display for JmpInst {
|
||||
JmpKind::Link => "jal",
|
||||
};
|
||||
|
||||
write!(f, "{mnemonic} {target}")
|
||||
write!(f, "{mnemonic} {target:#x}")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! Load instructions
|
||||
|
||||
// Imports
|
||||
use crate::game::exe::instruction::Register;
|
||||
use crate::{game::exe::instruction::Register, util::SignedHex};
|
||||
use int_conv::{Signed, Truncated, ZeroExtended};
|
||||
use std::{convert::TryFrom, fmt};
|
||||
|
||||
@@ -104,6 +104,6 @@ impl fmt::Display for LoadInst {
|
||||
LoadOpcode::WordRight => "lwr",
|
||||
};
|
||||
|
||||
write!(f, "{mnemonic} {dest}, {offset}({source})")
|
||||
write!(f, "{mnemonic} {dest}, {:#x}({source})", SignedHex(offset))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -39,14 +39,14 @@ pub struct ShiftImmRaw {
|
||||
/// Shift immediate instructions
|
||||
#[derive(PartialEq, Eq, Clone, Copy, Debug)]
|
||||
pub struct ShiftImmInst {
|
||||
/// Source register, `rd`
|
||||
pub source: Register,
|
||||
|
||||
/// Destination register, `rt`
|
||||
pub dest: Register,
|
||||
|
||||
/// Immediate argument
|
||||
pub arg: i16,
|
||||
/// Lhs argument, `rd`
|
||||
pub lhs: Register,
|
||||
|
||||
/// Rhs argument, immediate
|
||||
pub rhs: i16,
|
||||
|
||||
/// Function
|
||||
pub func: ShiftImmFunc,
|
||||
@@ -59,9 +59,9 @@ impl ShiftImmInst {
|
||||
let func = ShiftImmFunc::try_from(raw.f.truncated::<u8>()).ok()?;
|
||||
|
||||
Some(Self {
|
||||
source: Register::new(raw.t)?,
|
||||
lhs: Register::new(raw.t)?,
|
||||
dest: Register::new(raw.d)?,
|
||||
arg: raw.i.truncated::<u16>().as_signed(),
|
||||
rhs: raw.i.truncated::<u16>().as_signed(),
|
||||
func,
|
||||
})
|
||||
}
|
||||
@@ -69,9 +69,9 @@ impl ShiftImmInst {
|
||||
/// Encodes this instruction
|
||||
#[must_use]
|
||||
pub fn encode(self) -> ShiftImmRaw {
|
||||
let t = self.source.idx();
|
||||
let t = self.lhs.idx();
|
||||
let d = self.dest.idx();
|
||||
let i = self.arg.as_unsigned().zero_extended::<u32>();
|
||||
let i = self.rhs.as_unsigned().zero_extended::<u32>();
|
||||
let f = u8::from(self.func).zero_extended::<u32>();
|
||||
|
||||
ShiftImmRaw { f, t, d, i }
|
||||
@@ -80,7 +80,7 @@ impl ShiftImmInst {
|
||||
|
||||
impl fmt::Display for ShiftImmInst {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
let Self { source, dest, arg, func } = self;
|
||||
let Self { lhs, dest, rhs, func } = self;
|
||||
|
||||
let mnemonic = match func {
|
||||
ShiftImmFunc::LeftLogical => "sll",
|
||||
@@ -88,6 +88,6 @@ impl fmt::Display for ShiftImmInst {
|
||||
ShiftImmFunc::RightArithmetic => "sra",
|
||||
};
|
||||
|
||||
write!(f, "{mnemonic} {dest}, {source}, {arg}")
|
||||
write!(f, "{mnemonic} {dest}, {lhs}, {rhs:#x}")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -84,6 +84,6 @@ impl fmt::Display for SysInst {
|
||||
SysFunc::Break => "break",
|
||||
};
|
||||
|
||||
write!(f, "{mnemonic} {comment}")
|
||||
write!(f, "{mnemonic} {comment:#x}")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
//! Store instructions
|
||||
|
||||
// Imports
|
||||
use crate::game::exe::instruction::Register;
|
||||
use crate::{game::exe::instruction::Register, util::SignedHex};
|
||||
use int_conv::{Signed, Truncated, ZeroExtended};
|
||||
use std::{convert::TryFrom, fmt};
|
||||
|
||||
@@ -101,6 +101,6 @@ impl fmt::Display for StoreInst {
|
||||
StoreOpcode::WordLeft => "swl",
|
||||
};
|
||||
|
||||
write!(f, "{mnemonic} {dest}, {offset}({source})")
|
||||
write!(f, "{mnemonic} {dest}, {:#x}({source})", SignedHex(offset))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user