first commit
This commit is contained in:
34
src/instructions/instructions.h
Normal file
34
src/instructions/instructions.h
Normal file
@@ -0,0 +1,34 @@
|
||||
#pragma once
|
||||
#include "../VM/VM.h"
|
||||
|
||||
///@param program_pos position in vm->program next afrer opcode
|
||||
///@returns number of bytes read
|
||||
typedef i32 (*InstructionImplFunc_t)(VM* vm, size_t program_pos);
|
||||
|
||||
typedef struct Instruction {
|
||||
const char* name;
|
||||
InstructionImplFunc_t implementation;
|
||||
} Instruction;
|
||||
|
||||
#define Instruction_construct(NAME) {\
|
||||
.name = #NAME, \
|
||||
.implementation = NAME##_impl \
|
||||
}
|
||||
|
||||
/// @brief get instruction info from table
|
||||
/// @param opcode any byte
|
||||
/// @return ptr to struct or NULL
|
||||
const Instruction* Instruction_getFromOpcode(u8 opcode);
|
||||
|
||||
i32 NOP_impl(VM* vm, size_t pos);
|
||||
i32 PUSH_impl(VM* vm, size_t pos);
|
||||
i32 MOV_impl(VM* vm, size_t pos);
|
||||
i32 ADD_impl(VM* vm, size_t pos);
|
||||
i32 SUB_impl(VM* vm, size_t pos);
|
||||
i32 MUL_impl(VM* vm, size_t pos);
|
||||
i32 DIV_impl(VM* vm, size_t pos);
|
||||
i32 MOD_impl(VM* vm, size_t pos);
|
||||
i32 SYS_impl(VM* vm, size_t pos);
|
||||
i32 EXIT_impl(VM* vm, size_t pos);
|
||||
i32 JMP_impl(VM* vm, size_t pos);
|
||||
i32 CALL_impl(VM* vm, size_t pos);
|
||||
Reference in New Issue
Block a user