1
0

30 lines
621 B
Rust
Raw Normal View History

2024-11-26 07:14:30 -05:00
use crate::{Instruction, Operation};
2024-12-08 08:01:15 -05:00
use super::InstructionOptions;
2024-11-26 07:14:30 -05:00
pub struct Jump {
pub offset: u16,
pub is_positive: bool,
}
impl From<&Instruction> for Jump {
fn from(instruction: &Instruction) -> Self {
Jump {
2024-12-08 08:01:15 -05:00
offset: instruction.b,
is_positive: instruction.c != 0,
2024-11-26 07:14:30 -05:00
}
}
}
impl From<Jump> for Instruction {
fn from(jump: Jump) -> Self {
2024-12-08 08:01:15 -05:00
Instruction {
operation: Operation::JUMP,
options: InstructionOptions::empty(),
a: 0,
b: jump.offset,
c: jump.is_positive as u16,
}
2024-11-26 07:14:30 -05:00
}
}