I'm in the middle of a project in which I need to compare a 12-bit value from an A/D with a set-value. Let's say that the A/D-value is stored in two registers, the low eight bits are stored in AD_LOW, and the four high bits are stored in AD_HIGH. The remaining four bits in AD_HIGH can be considered to be 0. The same criterion is applicable for the set-value, stored in SET_LOW and SET_HIGH. Bit 2 in a register named STAT holds the last compare status. The A/D-value shall be compared to the set-value, and if it is greater, then bit 2 in the STAT register will be set. If it is smaller (or equal) the bit shall be cleared. The W register can be thrashed, but the other registers must be preserved How fast and/or small code can be written to do this? Here's one way : movf AD_HIGH,0 ;Copy the high bits of the A/D value to W xorwf SET_HIGH,0 ;Compare with the high bits of the set-value skpz goto label1 movf AD_LOW,0 ;Copy the low bits of the A/D value to W subwf SET_LOW,0 ;Subtract from the SET_LOW value skpc bsf STAT,2 ;If it is greater than SET_LOW bit 2 of STAT is set skpnc bcf STAT,2 ;If it is less than SET_LOW (or equal to) bit 2 of STAT is cleared goto label2 label1 ; Compare the high parts movf AD_HIGH,0 subwf SET_HIGH,0 skpc bsf STAT,2 skpnc bcf STAT,2 label2 ;Compare finished Points will be scored as follows: 8 points for each instruction word used. 20 points for each (extra) RAM location used. 6 points for each instruction cycle. (worst case) -8 points for isosynchronous execution. My rather sluggish example scores (if I've counted correctly): 17*8+0+11*6 = 202 points.. It should be possible to shave a lot of points here... There is no award to be won, but the winner will get all the glory... -Oyvind oyvind.kaurstad@nofac.abb.no