r8lib/operations/
op1nnn.rs1use log::debug;
4
5use crate::Machine;
6
7use super::{Operation, OperationResult};
8
9pub(crate) struct Op1nnn {
11 nnn: u16,
13}
14
15impl Op1nnn {
16 pub(crate) fn new(nnn: u16) -> Self {
18 Self { nnn }
19 }
20}
21
22impl Operation for Op1nnn {
23 fn exec(&self, _: &mut Machine) -> OperationResult {
25 debug!("op_1nnn, nnn={:#06x?}", self.nnn);
26
27 OperationResult::JumpTo(self.nnn as usize)
28 }
29}
30
31#[cfg(test)]
32mod test_op1nnn {
33 use super::*;
34
35 #[test]
36 fn test_op1nnn_exec() {
37 let mut machine = Machine::default();
38 let nnn = 0xA;
39
40 let op = Op1nnn::new(nnn);
41 let result = op.exec(&mut machine);
42
43 assert_eq!(
44 result,
45 OperationResult::JumpTo(nnn as usize),
46 "should return JumpTo(nnn)"
47 );
48 }
49}