2024-12-17 18:11:06 -05:00
|
|
|
use crate::{Instruction, Operation};
|
2024-11-26 07:14:30 -05:00
|
|
|
|
2025-01-13 06:01:38 -05:00
|
|
|
use super::InstructionBuilder;
|
|
|
|
|
2024-11-26 07:14:30 -05:00
|
|
|
pub struct Test {
|
2025-01-13 06:01:38 -05:00
|
|
|
pub operand_register: u16,
|
2024-11-28 05:36:10 -05:00
|
|
|
pub test_value: bool,
|
2024-11-26 07:14:30 -05:00
|
|
|
}
|
|
|
|
|
2025-01-08 04:21:01 -05:00
|
|
|
impl From<Instruction> for Test {
|
|
|
|
fn from(instruction: Instruction) -> Self {
|
2024-12-17 18:11:06 -05:00
|
|
|
let operand_register = instruction.b_field();
|
2024-12-11 06:49:43 -05:00
|
|
|
let test_value = instruction.c_field() != 0;
|
2024-12-08 08:01:15 -05:00
|
|
|
|
2024-11-26 07:14:30 -05:00
|
|
|
Test {
|
2024-12-17 18:11:06 -05:00
|
|
|
operand_register,
|
2024-12-08 08:01:15 -05:00
|
|
|
test_value,
|
2024-11-26 07:14:30 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl From<Test> for Instruction {
|
|
|
|
fn from(test: Test) -> Self {
|
2025-01-13 06:01:38 -05:00
|
|
|
let b_field = test.operand_register;
|
|
|
|
let c_field = test.test_value as u16;
|
|
|
|
|
|
|
|
InstructionBuilder {
|
|
|
|
operation: Operation::TEST,
|
|
|
|
b_field,
|
|
|
|
c_field,
|
|
|
|
..Default::default()
|
|
|
|
}
|
|
|
|
.build()
|
2024-11-26 07:14:30 -05:00
|
|
|
}
|
|
|
|
}
|