On Friday, May 05, 2000 Kevin Blain wrote: > I am having trouble with window detection - using the subwf function. It > looks to me very much like the following code section should work, but then > again, have I just been staring at it too long? Looks like you did it right. > I am using interrupts - Yes, I am preserving all the right registers, but > could the C flag be getting corrupted is teh interrupt occurs during the > skpc instruction??? Interrupt can't occur during skpc execution. Two cycle instructions are executed actually in one cycle, the other cycle is dummy, during which the next instruction is fetched. So even if C flag gets corrupted by interrupt, it can happen only between instructions. Just make the registers saving/restoring in interrupt by the book and you must be safe. > For reference, device PIC16C72 > entry to routine is with ADRES freshly captured. That bit seems okay. BTW, you can make the program a bit shorter: Radix = DEC movf ADRES, w ;w = ADRES addlw -176 ;w = ADRES - 176 = ADRES + (256 - 176) = ADRES + 80 skpc goto SECTION_C ;ADRES < 176 ;numbers 176-255 now start from 0 addlw -(198-176) ;w = w - 22 = w + 234 skpc goto SECTION_B ;176 <= ADRES < 198 ;numbers 198-255 now start from 0 addlw -(221-198) skpc goto SECTION_A ;198 <= ADRES < 221 Hint: ready to pack into a macro :) Nikolai http://techref.massmind.org/member/NG--944