Add OP_GET_PC to implement coroutines/yield in stdlib later.
This commit is contained in:
parent
aa16b6b348
commit
744f2d526b
|
@ -5,7 +5,8 @@
|
|||
|
||||
typedef enum {
|
||||
OP_HALT, /* halt : terminate execution */
|
||||
OP_JMP, /* jump : jump to address src1 unconditionally */
|
||||
OP_JMP, /* jump : jump to address dest unconditionally */
|
||||
OP_GET_PC, /* pc : dest = current program counter */
|
||||
OP_CALL, /* call : creates a new frame */
|
||||
OP_RETURN, /* retn : returns from a frame to the parent frame */
|
||||
OP_LOAD, /* load : dest = &[next memory location] */
|
||||
|
|
5
src/vm.c
5
src/vm.c
|
@ -1,5 +1,4 @@
|
|||
#include "vm.h"
|
||||
#include "debug.h"
|
||||
#include <string.h>
|
||||
|
||||
/* no inline fn in ANSI C :( */
|
||||
|
@ -221,6 +220,10 @@ bool step_vm(VM *vm) {
|
|||
vm->pc = vm->frames[vm->fp].registers[dest].u; /* Jump to address */
|
||||
return true;
|
||||
}
|
||||
case OP_GET_PC: {
|
||||
vm->frames[vm->fp].registers[dest].u = vm->pc;
|
||||
return true;
|
||||
}
|
||||
case OP_JEQ_UINT: {
|
||||
COMPARE_AND_JUMP(uint32_t, u, ==);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue