diff options
Diffstat (limited to 'src/core.rs')
-rw-r--r-- | src/core.rs | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/core.rs b/src/core.rs index 7779dab..a05d75e 100644 --- a/src/core.rs +++ b/src/core.rs @@ -80,6 +80,19 @@ impl fmt::Display for Op { } } +impl Operand { + fn size(&self) -> usize { + match self { + Operand::Acc => 0, + Operand::Direct(_) => 1, + Operand::Indirect(_) => 0, + Operand::Data(_) => 1, + Operand::Register(_) => 0, + Operand::Reladdr(_) => 1, + } + } +} + pub struct Core { pc: u16, ram: Ram, @@ -116,9 +129,12 @@ impl Core { } else { None }; + let operand2_offset = match &operand1 { + Some(o) => o.size(), + _ => 0, + }; let operand2 = if let Some(operand) = op.operand2 { - // TODO: offset must be based on operand1's size - Some(self.map_operand(operand, 2)) + Some(self.map_operand(operand, operand2_offset)) } else { None }; |