This commit is contained in:
2026-07-19 20:43:49 -04:00
parent 1944683dc5
commit 9f7d95a67e
3 changed files with 156 additions and 166 deletions
+12 -5
View File
@@ -11,9 +11,10 @@ pub struct Code {
}
impl Code {
pub fn mov(&mut self, dst: impl RegMem, src: impl Into<RegMemImm>) -> EncodeRes {
pub fn mov(&mut self, dst: impl Into<RegMemKind>, src: impl Into<RegMemImm>) -> EncodeRes {
let src = src.into();
match dst.kind() {
let dst = dst.into();
match dst {
RegMemKind::Reg(mut dst) => match src {
RegMemImm::Reg(src) => {
if dst.width() != src.width() {
@@ -162,7 +163,13 @@ impl Code {
self.bytes.push(0xc3);
}
fn add_sub(&mut self, dst: impl RegMem, src: impl Into<RegMemImm>, ext: u8) -> EncodeRes {
fn add_sub(
&mut self,
dst: impl Into<RegMemKind>,
src: impl Into<RegMemImm>,
ext: u8,
) -> EncodeRes {
let dst = dst.into();
match src.into() {
RegMemImm::Reg(src) => {
if src.width() != dst.width() {
@@ -219,11 +226,11 @@ impl Code {
Ok(())
}
pub fn add(&mut self, dst: impl RegMem, src: impl Into<RegMemImm>) -> EncodeRes {
pub fn add(&mut self, dst: impl Into<RegMemKind>, src: impl Into<RegMemImm>) -> EncodeRes {
self.add_sub(dst, src, 0)
}
pub fn sub(&mut self, dst: impl RegMem, src: impl Into<RegMemImm>) -> EncodeRes {
pub fn sub(&mut self, dst: impl Into<RegMemKind>, src: impl Into<RegMemImm>) -> EncodeRes {
self.add_sub(dst, src, 5)
}