1
0

26 lines
573 B
Rust
Raw Normal View History

2024-11-26 07:14:30 -05:00
use crate::{Instruction, Operation};
pub struct Jump {
pub offset: u8,
2024-11-26 07:14:30 -05:00
pub is_positive: bool,
}
impl From<&Instruction> for Jump {
fn from(instruction: &Instruction) -> Self {
Jump {
offset: instruction.b_field(),
is_positive: instruction.c_field() != 0,
2024-11-26 07:14:30 -05:00
}
}
}
impl From<Jump> for Instruction {
fn from(jump: Jump) -> Self {
2024-12-11 09:26:38 -05:00
let operation = Operation::JUMP;
let b = jump.offset;
let c = jump.is_positive as u8;
Instruction::new(operation, 0, b, c, false, false, false)
2024-11-26 07:14:30 -05:00
}
}