Scott Dattalo wrote: > You can rearrange the xor > > ; now output current2 > movf current2,w ; > movwf PORTB ; send to motor! > > ; nop ; let ports settle > ; nop ; + some delay > > nop > movf inouts_last,w > xorwf PORTA,w > movwf diff > skpz > goto pwm_loop > > Now in the 3 cycles spare in the above loop, change 2 of the nops > to > > movf diff,w > xorwf inputs_last,f > > making use of the A = (A ^ B) ^ B trick. > > Is that clear? I doubt it... Actually it is. You store the new pins in an XORed form. :o) But there is a problem that your code below still takes 9 cycles (once goto is included). ;------------------------- ; now output current2 movf current2,w ; movwf PORTB ; send to motor! nop movf inputs_last,w xorwf PORTA,w movwf diff skpz goto pwm_loop > What is your're trying to do? This is supposed to: * output byte 2 to PORTB for 8 cycles exact * output byte 1 to PORTB for 4 cycles exact as a form of PWM that is modulating between 2 values of PORTB, weighted so that one is output for exactly twice as long as the other. Somethere in there I need to see if any PORTA pins have changed, and if so exit with the new PORTA values in "inputs". The variable "inputs_last" must not be destroyed. -Roman -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads