1
0

27 lines
557 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 {
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 {
let metadata = Operation::Jump as u8;
let a = 0;
let b = jump.offset;
let c = jump.is_positive as u8;
Instruction { metadata, a, b, c }
2024-11-26 07:14:30 -05:00
}
}