38 lines
894 B
C
38 lines
894 B
C
#include "instructions.h"
|
|
|
|
i32 NOP_impl(VM* vm);
|
|
i32 PUSH_impl(VM* vm);
|
|
i32 MOV_impl(VM* vm);
|
|
i32 ADD_impl(VM* vm);
|
|
i32 SUB_impl(VM* vm);
|
|
i32 MUL_impl(VM* vm);
|
|
i32 DIV_impl(VM* vm);
|
|
i32 MOD_impl(VM* vm);
|
|
i32 SYS_impl(VM* vm);
|
|
i32 EXIT_impl(VM* vm);
|
|
i32 JMP_impl(VM* vm);
|
|
i32 CALL_impl(VM* vm);
|
|
|
|
|
|
const Instruction instructions[] = {
|
|
Instruction_construct(NOP),
|
|
Instruction_construct(PUSH),
|
|
Instruction_construct(MOV),
|
|
Instruction_construct(ADD),
|
|
Instruction_construct(SUB),
|
|
Instruction_construct(MUL),
|
|
Instruction_construct(DIV),
|
|
Instruction_construct(MOD),
|
|
Instruction_construct(SYS),
|
|
Instruction_construct(EXIT),
|
|
// Instruction_construct(JMP),
|
|
// Instruction_construct(CALL),
|
|
};
|
|
|
|
const Instruction* Instruction_getByOpcode(Opcode opcode){
|
|
if(opcode >= ARRAY_SIZE(instructions))
|
|
return NULL;
|
|
|
|
return instructions + opcode;
|
|
}
|