X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;ds=sidebyside;f=client%2Finterpret.c;h=e5907cf2ded4d38b965a6b550a626d60516cf120;hb=a2df77cbda43d5a24eeb8ac7db7452baae9f18aa;hp=9862e7bc4099c0fa75dbde315f3ae9541ec7d760;hpb=8246c6551faa818be7a58638dbbc2e521f21c454;p=mTask.git diff --git a/client/interpret.c b/client/interpret.c index 9862e7b..e5907cf 100644 --- a/client/interpret.c +++ b/client/interpret.c @@ -16,13 +16,14 @@ #define f16(p) program[pc]*265+program[pc+1] +uint16_t stack[STACKSIZE] = {0}; + void run_task(struct task *t) { uint8_t *program = t->bc; - int plen = t->tlen; + int plen = t->tasklength; int pc = 0; int sp = 0; - char stack[STACKSIZE] = {0}; debug("Running task with length: %d", plen); while(pc < plen){ switch(program[pc++]){ @@ -161,6 +162,10 @@ void run_task(struct task *t) sp--; break; #endif + case BCRETURN: trace("Return"); + pc = plen; + t->value = (uint16_t) stack[sp-1]; + break; default: trace("unrecognized"); die("Unrecognized command: %d", program[pc-1]);