use crate::emulator::instructions::functions::*;
use crate::emulator::instructions::*;
use crate::ForwardComEmulator;
pub const NO_MEMORY: usize = 0;
pub const SOME_MEMORY: usize = 1;
pub const ALL_MEMORY: usize = 2;
pub const SYS_CALLS: [SimpleIsaInstruction; 3] = [
SimpleIsaInstruction {
function: ForwardComEmulator::handle_sys_call::<NO_MEMORY>,
inputs: 1,
instr_type: instruction_type::BRANCH,
instruction_flags: 0,
..SimpleIsaInstruction::DEFAULT
},
SimpleIsaInstruction {
function: ForwardComEmulator::handle_sys_call::<SOME_MEMORY>,
inputs: 3,
instr_type: instruction_type::BRANCH,
instruction_flags: 0,
..SimpleIsaInstruction::DEFAULT
},
SimpleIsaInstruction {
function: ForwardComEmulator::handle_sys_call::<ALL_MEMORY>,
inputs: 3,
instr_type: instruction_type::BRANCH,
instruction_flags: 0,
..SimpleIsaInstruction::DEFAULT
},
];
pub const JUMP_INSTRUCTIONS_FORMAT_1_6: [SimpleIsaInstruction; 5] = [
SimpleIsaInstruction {
function: indirect_jump,
inputs: 1,
instr_type: instruction_type::BRANCH,
instruction_flags: instruction_flags::BR_TYPE_JUMP | instruction_flags::BR_INDIRECT,
..SimpleIsaInstruction::DEFAULT
},
SimpleIsaInstruction {
function: indirect_jump,
inputs: 1,
instr_type: instruction_type::BRANCH,
instruction_flags: instruction_flags::BR_TYPE_CALL | instruction_flags::BR_INDIRECT,
..SimpleIsaInstruction::DEFAULT
},
SimpleIsaInstruction {
function: multiway_jump,
inputs: 2,
instr_type: instruction_type::BRANCH,
instruction_flags: instruction_flags::BR_TYPE_CONDITIONAL | instruction_flags::BR_INDIRECT,
..SimpleIsaInstruction::DEFAULT
},
SimpleIsaInstruction {
function: multiway_jump,
inputs: 2,
instr_type: instruction_type::BRANCH,
instruction_flags: instruction_flags::BR_TYPE_CALL | instruction_flags::BR_INDIRECT,
..SimpleIsaInstruction::DEFAULT
},
SimpleIsaInstruction {
function: |_, _, _| (),
inputs: 0,
instr_type: instruction_type::BRANCH,
instruction_flags: instruction_flags::BR_TYPE_CALL | instruction_flags::BR_RETURN,
..SimpleIsaInstruction::DEFAULT
},
];
pub const JUMP_INSTRUCTIONS_FORMAT_1_7: [SimpleIsaInstruction; 6] = [
UNSPECIFIED_INSTRUCTION,
UNSPECIFIED_INSTRUCTION,
SimpleIsaInstruction {
function: indirect_jump,
inputs: 1,
instr_type: instruction_type::BRANCH,
instruction_flags: instruction_flags::BR_TYPE_JUMP | instruction_flags::BR_INDIRECT,
..SimpleIsaInstruction::DEFAULT
},
SimpleIsaInstruction {
function: indirect_jump,
inputs: 1,
instr_type: instruction_type::BRANCH,
instruction_flags: instruction_flags::BR_TYPE_CALL | instruction_flags::BR_INDIRECT,
..SimpleIsaInstruction::DEFAULT
},
PRIVILEGED_INSTRUCTION,
NOT_YET_IMPLEMENTED_INSTRUCTION,
];
pub const JUMP_INSTRUCTIONS_FORMAT_2_5_2: [SimpleIsaInstruction; 6] = [
SimpleIsaInstruction {
function: indirect_jump,
inputs: 1,
instr_type: instruction_type::BRANCH,
instruction_flags: instruction_flags::BR_TYPE_JUMP | instruction_flags::BR_INDIRECT,
..SimpleIsaInstruction::DEFAULT
},
SimpleIsaInstruction {
function: indirect_jump,
inputs: 1,
instr_type: instruction_type::BRANCH,
instruction_flags: instruction_flags::BR_TYPE_CALL | instruction_flags::BR_INDIRECT,
..SimpleIsaInstruction::DEFAULT
},
SimpleIsaInstruction {
function: multiway_jump,
inputs: 2,
instr_type: instruction_type::BRANCH,
instruction_flags: instruction_flags::BR_TYPE_CONDITIONAL | instruction_flags::BR_INDIRECT,
..SimpleIsaInstruction::DEFAULT
},
UNSPECIFIED_INSTRUCTION,
UNSPECIFIED_INSTRUCTION,
UNSPECIFIED_INSTRUCTION,
];
pub const DIRECT_JUMPS: [SimpleIsaInstruction; 2] = [
SimpleIsaInstruction {
function: |_, _, _| (),
inputs: 0,
instr_type: instruction_type::BRANCH,
instruction_flags: instruction_flags::BR_TYPE_JUMP,
..SimpleIsaInstruction::DEFAULT
},
SimpleIsaInstruction {
function: |_, _, _| (),
inputs: 0,
instr_type: instruction_type::BRANCH,
instruction_flags: instruction_flags::BR_TYPE_CALL,
..SimpleIsaInstruction::DEFAULT
},
];