S Suraj143 Active Member Nov 3, 2008 #1 I have a 16bit subtract code. Can I tell one of the values greater or less than by looking at the CARRY bit? I dont need the result I need to know what value is bigger or less. Code: Num_L,Num_H =value to be subtracted NumF_L,NumF_H =fix value [Num_H] [Num_L]= [Num_H] [Num_L] - [NumF_H] [NumF_L] Sub16 movf NumF_L,W subwf Num_L,F movf NumF_H,W btfss STATUS,C addlw .1 subwf Num_H,F btfss STATUS,C ;if carry set [Num_H] [Num_L] bigger ;if carry not set [NumF_H] [NumF_L] bigger
I have a 16bit subtract code. Can I tell one of the values greater or less than by looking at the CARRY bit? I dont need the result I need to know what value is bigger or less. Code: Num_L,Num_H =value to be subtracted NumF_L,NumF_H =fix value [Num_H] [Num_L]= [Num_H] [Num_L] - [NumF_H] [NumF_L] Sub16 movf NumF_L,W subwf Num_L,F movf NumF_H,W btfss STATUS,C addlw .1 subwf Num_H,F btfss STATUS,C ;if carry set [Num_H] [Num_L] bigger ;if carry not set [NumF_H] [NumF_L] bigger
P Pommie Well-Known Member Most Helpful Member Nov 3, 2008 #2 when I don't need to know the result I use, Code: movfw Num1H ;compare high bytes subwf Num2H,W btfss STATUS,Z ;if same compare low bytes goto GotResult movfw Num1L subwf Num2L,W GotResult ;carry Set if Num1<=Num2 Mike.
when I don't need to know the result I use, Code: movfw Num1H ;compare high bytes subwf Num2H,W btfss STATUS,Z ;if same compare low bytes goto GotResult movfw Num1L subwf Num2L,W GotResult ;carry Set if Num1<=Num2 Mike.
S Suraj143 Active Member Nov 3, 2008 #3 Pommie said: when I don't need to know the result I use, Code: movfw Num1H ;compare high bytes subwf Num2H,W btfss STATUS,Z ;if same compare low bytes goto GotResult movfw Num1L subwf Num2L,W GotResult ;carry Set if Num1<=Num2 Mike. Click to expand... Thats exactly what I need thanks for that.
Pommie said: when I don't need to know the result I use, Code: movfw Num1H ;compare high bytes subwf Num2H,W btfss STATUS,Z ;if same compare low bytes goto GotResult movfw Num1L subwf Num2L,W GotResult ;carry Set if Num1<=Num2 Mike. Click to expand... Thats exactly what I need thanks for that.