|
@@ -101,7 +101,9 @@ TURMIT_OP(swp)
|
101
|
101
|
|
102
|
102
|
TURMIT_OP(jmp)
|
103
|
103
|
{
|
104
|
|
- turmit->op_cur += SPOP(turmit) - 1;
|
|
104
|
+ turmit_int a;
|
|
105
|
+ a = SPOP(turmit);
|
|
106
|
+ TURMIT_JMP(turmit, a);
|
105
|
107
|
}
|
106
|
108
|
|
107
|
109
|
TURMIT_OP(jz)
|
|
@@ -111,7 +113,7 @@ TURMIT_OP(jz)
|
111
|
113
|
b = SPOP(turmit);
|
112
|
114
|
if(b == 0)
|
113
|
115
|
{
|
114
|
|
- turmit->op_cur += a - 1;
|
|
116
|
+ TURMIT_JMP(turmit, a);
|
115
|
117
|
}
|
116
|
118
|
}
|
117
|
119
|
|
|
@@ -125,7 +127,7 @@ TURMIT_OP(jcmp)
|
125
|
127
|
if(((cnd & 7) == 0 && a != b) || (cnd > 6) || ((cnd & 1) && a == b) ||
|
126
|
128
|
((cnd & 7) > 2 && a < b) || ((cnd & 7) > 4 && a > b))
|
127
|
129
|
{
|
128
|
|
- turmit->op_cur += offset - 1;
|
|
130
|
+ TURMIT_JMP(turmit, offset);
|
129
|
131
|
}
|
130
|
132
|
}
|
131
|
133
|
|
|
@@ -152,6 +154,7 @@ turmit_t *turmit_init(turmit_t *turmit, ssize_t stack_sz, ssize_t int_max,
|
152
|
154
|
turmit->op_expr = NULL;
|
153
|
155
|
turmit->op_expr_sz = 0;
|
154
|
156
|
turmit->op_cur = 0;
|
|
157
|
+ turmit->op_end = 0;
|
155
|
158
|
turmit->stack_sz = stack_sz;
|
156
|
159
|
turmit->stack_cur = turmit->stack_sz - 1;
|
157
|
160
|
turmit->stack = malloc(sizeof(turmit_int) * turmit->stack_sz);
|
|
@@ -225,7 +228,8 @@ turmit_int turmit_exec(turmit_t *turmit, const turmit_int args[5])
|
225
|
228
|
turmit_op_t *op;
|
226
|
229
|
|
227
|
230
|
turmit->op_cur = 0;
|
228
|
|
- while(turmit->op_cur < turmit->op_expr_sz)
|
|
231
|
+ turmit->op_end = 0;
|
|
232
|
+ while(!turmit->op_end && turmit->op_cur < turmit->op_expr_sz)
|
229
|
233
|
{
|
230
|
234
|
op = &(turmit->op_expr[turmit->op_cur]);
|
231
|
235
|
switch(op->value)
|