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
use faucon_asm::Instruction;
use super::{utils, Cpu, PC};
pub fn call(cpu: &mut Cpu, insn: &Instruction) -> usize {
let target = insn.operands()[0];
cpu.stack_push(cpu.registers[PC] + insn.raw_bytes().len() as u32);
cpu.registers[PC] = utils::get_value(cpu, insn.operand_size(), target);
cpu.increment_pc = false;
4
}
pub fn bra(cpu: &mut Cpu, insn: &Instruction) -> usize {
let target = insn.operands()[0];
cpu.registers[PC] = utils::get_value(cpu, insn.operand_size(), target);
cpu.increment_pc = false;
4
}
pub fn ret(cpu: &mut Cpu, _: &Instruction) -> usize {
cpu.registers[PC] = cpu.stack_pop();
cpu.increment_pc = false;
5
}