X-Git-Url: https://git.martlubbers.net/?a=blobdiff_plain;f=client%2Finterpret.c;h=6f2f20d7ae70967f46a2e86c34d2b4a29f73096a;hb=09b207a39b7791098daafd7d87c3ad9d3db3e19f;hp=ac0c0bc1e45601aa6c3d9b183c5442369acd6616;hpb=6f7f4cf5968d6d8a626a15eac77026236fc0667e;p=mTask.git diff --git a/client/interpret.c b/client/interpret.c index ac0c0bc..6f2f20d 100644 --- a/client/interpret.c +++ b/client/interpret.c @@ -19,17 +19,12 @@ 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; @@ -37,8 +32,21 @@ void run_task(struct task *t) pc++; break; case BCPUSH: trace("push %d", program[pc]*265+program[pc+1]); - stack[sp++] = f16(pc); - pc+=2; + switch(program[pc++]){ + //Long + case 'l': + //Int + case 'i': + stack[sp++] = f16(pc); + pc+=2; + break; + case 'b': //Bool + case 'c': //Character + case 'B': //Button + case 'L': //UserLED + stack[sp++] = program[pc++]; + break; + } break; case BCPOP: trace("pop"); sp--; @@ -125,6 +133,7 @@ void run_task(struct task *t) break; case BCSERIALPARSEINT: trace("SerialParseInt()"); break; +#if HAVEAIO == 1 case BCANALOGREAD: trace("AnalogRead(%d)", program[pc]); stack[sp++] = read_apin(program[pc++]); break; @@ -132,6 +141,8 @@ void run_task(struct task *t) write_apin(program[pc++], stack[sp-1]); sp--; break; +#endif +#if HAVEDIO == 1 case BCDIGITALREAD: trace("DigitalRead(%d)", program[pc]); stack[sp++] = read_dpin(program[pc++]); break; @@ -139,6 +150,8 @@ void run_task(struct task *t) write_dpin(program[pc++], stack[sp-1]); sp--; break; +#endif +#if HAVELED == 1 case BCLEDON: trace("LedOn(%d)", program[pc]); led_on(stack[sp-1]); sp--; @@ -147,6 +160,7 @@ void run_task(struct task *t) led_off(stack[sp-1]); sp--; break; +#endif default: trace("unrecognized"); die("Unrecognized command: %d", program[pc-1]);