store current_pos in VM for better logging

This commit is contained in:
2024-11-16 22:05:20 +05:00
parent 83172df776
commit 9d2a26fae3
12 changed files with 110 additions and 51 deletions

View File

@@ -3,7 +3,7 @@
///@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 i32 (*InstructionImplFunc_t)(VM* vm);
typedef struct Instruction {
const char* name;
@@ -20,15 +20,15 @@ typedef struct Instruction {
/// @return ptr to struct or NULL
const Instruction* NULLABLE(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);
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);