1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
use faucon_asm::Instruction;
use super::{utils, Cpu, ExecutionState};
pub fn exit(cpu: &mut Cpu, _: &Instruction) -> usize {
cpu.state = ExecutionState::Stopped;
1
}
pub fn sleep(cpu: &mut Cpu, insn: &Instruction) -> usize {
let flag = insn.operands()[0];
let flag = utils::parse_flag(flag).unwrap();
if cpu.registers.get_flag(flag) {
cpu.state = ExecutionState::Sleeping;
}
cpu.increment_pc = false;
1
}
pub fn mov(cpu: &mut Cpu, insn: &Instruction) -> usize {
let operands = insn.operands();
let destination = operands[0];
let source = operands[1];
utils::write_reg(cpu, insn.operand_size(), destination, source);
cpu.increment_pc = true;
1
}