#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){
-// debug("program: %d", program[pc]);
-// debug("stack: %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x",
-// stack[0], stack[1], stack[2], stack[3], stack[4],
-// stack[5], stack[6], stack[7], stack[8], stack[9]);
-
switch(program[pc++]){
case BCNOP: trace("nop");
break;
sp--;
break;
#endif
+ case BCRETURN: trace("Return");
+ debug("Task returned");
+ task_delete(t->taskid);
+ return;
default:
trace("unrecognized");
die("Unrecognized command: %d", program[pc-1]);