At 11:48 PM 2/16/2004 +0800, you wrote: >Dear all, > >I read from datasheet regarding OV flag. > >"This bit is used for signed arithmetic. It indicates an overflow of the >7-bit magnitude, which causes the sign bit to change." > >Is that mean whenever the MSB toggled (not include the result from bsf & >bcf), this flag will be set? No. One counterexample will suffice. Consider the case of: movlw 0x20 ; 32 addlw 0x80 ; -128 result: 0xA0 (-96), the MSB of w has changed, but there is no OV You can see that overflow is not possible if the signs of the two numbers being added are different. What Microchip means is that the sign of the result is always incorrect when there has been overflow. For example, movlw 0x80 (-128) addlw 0x80 (-128) result 0x00 (0) or: movlw 0x7F (127) addlw 0x7F (127) result 0xFE (-2) I'll leave checking the rest of the possibilities or finding a proof as an exercise. ;-) I'm glad they added the OV flag to some newer PICs, it's something I often missed when writing math routines. Best regards, Spehro Pefhany --"it's the network..." "The Journey is the reward" speff@interlog.com Info for manufacturers: http://www.trexon.com Embedded software/hardware/analog Info for designers: http://www.speff.com -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads