1pub mod register;
18
19pub mod compare;
20
21#[cfg(feature = "processor")]
22pub mod operation;
23
24#[cfg(feature = "communication")]
25pub mod communication;
26
27#[cfg(feature = "processor")]
28pub mod processor;
29
30#[cfg(test)]
31#[cfg(feature = "processor")]
32mod tests {
33 use std::cell::RefCell;
34 use std::rc::Rc;
35 use osiris_data::data::atomic::Word;
36 use osiris_data::memory::Memory;
37
38 use crate::operation::{Instruction, Operation, OperationSet};
39 use crate::operation::scheme::{ArgumentType, OperationId};
40
41 use crate::processor::Cpu;
42
43 #[test]
44 fn test_creation() {
45 let instr = Instruction::new(0);
46 assert_eq!(instr.to_u64(), 0);
47 }
48
49 #[test]
50 fn test_operation() {
51 const OPID: OperationId = OperationId::new(0x7357);
52
53 let operation = Operation::new(
54 OPID, "SET R:$1 = 1".to_string(),
55 true, ArgumentType::NoArgument,
56 |cpu, scheme| {
57 cpu.bank_set(scheme.target, Word::new(1));
58 Ok(())
59 },
60 );
61
62 let mut cpu = Cpu::new(RefCell::new(Memory::new()), Rc::new(OperationSet::new()));
63
64 let instr = Instruction::new(0x7357_0000_0000_0000);
65 let scheme = instr.scheme(ArgumentType::NoArgument);
66 operation.call(&mut cpu, scheme).unwrap();
67 assert_eq!(cpu.bank_get(scheme.target), Word::new(1));
68 }
69}