Byron A Jeff wrote: >Algorithm 2 is definitely along the right lines. It's better because it >takes a constant amount of time to execute no matter which bit is being = set. >In my bytecode interpreter I used the >following fragment which is analogous to Algorithm 2 BCF STATUS, C RLF DATAIN, W ANDLW 0x0F ADDWF PCL, F BSF INDF, 0 I have well simulated your code moving DATAOUT to FSR and it takes 12 cycles, cool, but looking at Scott proposal, I see: 1.No PCLATH issues, 2.It don't cares what the mask is used for: BFS or BCF (IORWF or XORWF) 3.And it takes 10 cycles max. But I'll steal your idea to re-arrange some parts of the code. To Scott, many thanks for this "piece of art". Is very simple and very tricky and very helpful. I saw it first on your pwm256, but until now, I didn't "really *see* it" at all. After a few seconds I found the original code from Mike Keitz on the PicList web site and the file is mask.htm (techref/microchip/math/bit/mask.htm?key=3DMike+Keitz&from=3D) So I have to thanks and recognize the great job all the admins do for us. _________________________________________________________ Do You Yahoo!? Get your free @yahoo.com address at http://mail.yahoo.com -- http://www.piclist.com hint: The PICList is archived three different ways. See http://www.piclist.com/#archives for details.