2024-11-26 07:14:30 -05:00
|
|
|
use crate::{Instruction, Operation};
|
|
|
|
|
|
|
|
pub struct Jump {
|
2024-12-09 07:01:07 -05:00
|
|
|
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 {
|
2024-12-09 07:01:07 -05:00
|
|
|
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
|
|
|
}
|
|
|
|
}
|