All branch/jump and set instructions impl
Signed-off-by: Rachel <508861+Ryex@users.noreply.github.com>
This commit is contained in:
@@ -223,6 +223,38 @@ impl Operand {
|
||||
&Operand::DeviceSpec { .. } => Err(interpreter::ICError::DeviceNotValue),
|
||||
}
|
||||
}
|
||||
pub fn get_device_id(
|
||||
&self,
|
||||
ic: &interpreter::IC,
|
||||
) -> Result<(Option<u16>, Option<u32>), interpreter::ICError> {
|
||||
match &self {
|
||||
&Operand::DeviceSpec { device, channel } => match device {
|
||||
Device::Db => Ok((Some(ic.id), *channel)),
|
||||
Device::Numbered(p) => {
|
||||
let dp = ic
|
||||
.pins
|
||||
.get(*p as usize)
|
||||
.ok_or(interpreter::ICError::DeviceIndexOutOfRange(*p as f64))
|
||||
.copied()?;
|
||||
Ok((dp, *channel))
|
||||
}
|
||||
Device::Indirect {
|
||||
indirection,
|
||||
target,
|
||||
} => {
|
||||
let val = ic.get_register(*indirection, *target)?;
|
||||
let dp = ic
|
||||
.pins
|
||||
.get(val as usize)
|
||||
.ok_or(interpreter::ICError::DeviceIndexOutOfRange(val))
|
||||
.copied()?;
|
||||
Ok((dp, *channel))
|
||||
}
|
||||
},
|
||||
&Operand::Identifier(id) => ic.get_ident_device_id(&id.name),
|
||||
_ => Err(interpreter::ICError::ValueNotDevice),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl FromStr for Operand {
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
21
ic10emu_wasm/Cargo.lock
generated
21
ic10emu_wasm/Cargo.lock
generated
@@ -129,6 +129,7 @@ dependencies = [
|
||||
"phf_codegen",
|
||||
"regex",
|
||||
"strum_macros",
|
||||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
@@ -337,6 +338,26 @@ dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror"
|
||||
version = "1.0.58"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "03468839009160513471e86a034bb2c5c0e4baae3b43f79ffc55c4a5427b3297"
|
||||
dependencies = [
|
||||
"thiserror-impl",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "thiserror-impl"
|
||||
version = "1.0.58"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "c61f3ba182994efc43764a46c018c347bc492c79f024e705f46567b418f6d4f7"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.12"
|
||||
|
||||
Reference in New Issue
Block a user