[self-modifying code.] Also, I was thinking more along the lines of the lookup table being in RAM, not compiled in. So you just modify the RAM table for different duty cycles - although that would take a few cycles. Right. They're very similar. I was thinking along the lines of: for (i=0; i < 256; i++) { PWMCODE[i] = asm("NOP"); /* More fictional syntax! */ } for (i=0; i < 8; i++) { PWMCODE[stoptime[i]] = asm("BCF port, i"); } PWMCODE[256] = asm("ret"); while (1) { outp(port, 255); /* All bits on */ asm ("call PWMCODE"); /* Call code to turn them off */ /* at appropriate times */ } This saves you one instruction (50%!!!) (assuming a pic) for each time you only need to change one bit on the port, because you can put the bit number in a single instruction instead of having to load w and then output it. BillW