implemented hexstrings, implemented MOVE, PUTCOLOR, GETCHAR, GETCOLOR, modified PUTCHAR, several fixes.
This commit is contained in:
88
vm.cpp
88
vm.cpp
@@ -13,84 +13,6 @@
|
||||
typedef unsigned char byte;
|
||||
typedef unsigned short word;
|
||||
|
||||
/*enum OPS {
|
||||
OP_NOP = 0,
|
||||
OP_PUSH,
|
||||
OP_POP,
|
||||
OP_DUP,
|
||||
OP_SWAP,
|
||||
|
||||
OP_LOAD,
|
||||
OP_LOADI,
|
||||
OP_STORE,
|
||||
OP_STOREI,
|
||||
|
||||
OP_LOADXY,
|
||||
OP_STOREXY,
|
||||
OP_SETX,
|
||||
OP_SETY,
|
||||
OP_SETZ,
|
||||
OP_GETY,
|
||||
OP_GETZ,
|
||||
OP_INCX,
|
||||
OP_DECX,
|
||||
OP_INCY,
|
||||
OP_DECY,
|
||||
OP_INCZ,
|
||||
OP_DECZ,
|
||||
|
||||
OP_JMP,
|
||||
OP_JNT,
|
||||
OP_JTR,
|
||||
OP_JSR,
|
||||
OP_RET,
|
||||
OP_CALL,
|
||||
|
||||
OP_RJ,
|
||||
OP_RB,
|
||||
OP_RJZ,
|
||||
OP_RJN,
|
||||
OP_RBZ,
|
||||
OP_RBN,
|
||||
|
||||
OP_RJYZ,
|
||||
OP_RJYN,
|
||||
OP_RBYZ,
|
||||
OP_RBYN,
|
||||
OP_RJZZ,
|
||||
OP_RJZN,
|
||||
OP_RBZZ,
|
||||
OP_RBZN,
|
||||
|
||||
OP_ADD,
|
||||
OP_SUB,
|
||||
OP_MUL,
|
||||
OP_DIV,
|
||||
OP_MOD,
|
||||
OP_AND,
|
||||
OP_OR,
|
||||
OP_NOT,
|
||||
OP_NEG,
|
||||
OP_INC,
|
||||
OP_DEC,
|
||||
OP_CONCAT,
|
||||
|
||||
OP_EQ,
|
||||
OP_NEQ,
|
||||
OP_LT,
|
||||
OP_GT,
|
||||
OP_LEQ,
|
||||
OP_GEQ,
|
||||
|
||||
OP_IN,
|
||||
OP_OUT,
|
||||
OP_SLEEP,
|
||||
};*/
|
||||
|
||||
/*typedef void(*t_extcall)(t_stack&);
|
||||
t_extcall external_calls[MAX_EXTERNAL_CALLS];
|
||||
int numcallbacks = 0;*/
|
||||
|
||||
typedef void(*t_out_port)(const byte&);
|
||||
typedef byte(*t_in_port)();
|
||||
static t_out_port out_ports[256];
|
||||
@@ -215,13 +137,13 @@ const unsigned short vm_step() {
|
||||
case OP_RJZN: if (rZ != 0) vm_pc += vm_program[vm_pc]; else vm_pc++; vm_cycles++; break;
|
||||
case OP_RBZZ: if (rZ == 0) vm_pc -= vm_program[vm_pc] + 1; else vm_pc++; vm_cycles++; break;
|
||||
case OP_RBZN: if (rZ != 0) vm_pc -= vm_program[vm_pc] + 1; else vm_pc++; vm_cycles++; break;
|
||||
case OP_ADD: GRAB(ds); PUSH(ds, a + b); vm_cycles++; break;
|
||||
case OP_SUB: GRAB(ds); PUSH(ds, a - b); vm_cycles++; break;
|
||||
case OP_MUL: GRAB(ds); PUSH(ds, a * b); vm_cycles++; break;
|
||||
case OP_ADD: GRAB(ds); PUSH(ds, b + a); vm_cycles++; break;
|
||||
case OP_SUB: GRAB(ds); PUSH(ds, b - a); vm_cycles++; break;
|
||||
case OP_MUL: GRAB(ds); PUSH(ds, b * a); vm_cycles++; break;
|
||||
case OP_DIV: GRAB(ds); PUSH(ds, b / a); vm_cycles++; break;
|
||||
case OP_MOD: GRAB(ds); PUSH(ds, b % a); vm_cycles++; break;
|
||||
case OP_AND: GRAB(ds); PUSH(ds, a & b); vm_cycles++; break;
|
||||
case OP_OR: GRAB(ds); PUSH(ds, a | b); vm_cycles++; break;
|
||||
case OP_AND: GRAB(ds); PUSH(ds, b & a); vm_cycles++; break;
|
||||
case OP_OR: GRAB(ds); PUSH(ds, b | a); vm_cycles++; break;
|
||||
case OP_NOT: a = POP(ds); PUSH(ds, !a); vm_cycles++; break;
|
||||
case OP_NEG: a = POP(ds); PUSH(ds, -a); vm_cycles++; break;
|
||||
case OP_INC: a = POP(ds); PUSH(ds, a + 1); vm_cycles++; break;
|
||||
|
||||
Reference in New Issue
Block a user