S Suraj143 Active Member Nov 28, 2007 #1 I have confused with carry bit in many cases, still I don’t know what the real meaning is. Ex: before this subtraction occurred TEMP = 5 & COUNT = 1 Code: movf TEMP,W subwf COUNT,F btfss STATUS,C What is the result after the subtraction? What made to SET or CLEAR the carry bit? Please explain this to me. Thanks
I have confused with carry bit in many cases, still I don’t know what the real meaning is. Ex: before this subtraction occurred TEMP = 5 & COUNT = 1 Code: movf TEMP,W subwf COUNT,F btfss STATUS,C What is the result after the subtraction? What made to SET or CLEAR the carry bit? Please explain this to me. Thanks
geko Active Member Nov 28, 2007 #2 The subtract instruction sets or clears the carry flag. If the flag is set after the subtract, there was no borrow e.g 10-4 = 6 carry flag set also 10-10 = 0 carry flag set If the flag is clear after the subtract there was a borrow e.g. 4-10 = -6 Carry flag cleared In your example Wreg = 5, Count = 1 1-5 = -4, Carry is clear Last edited: Nov 28, 2007
The subtract instruction sets or clears the carry flag. If the flag is set after the subtract, there was no borrow e.g 10-4 = 6 carry flag set also 10-10 = 0 carry flag set If the flag is clear after the subtract there was a borrow e.g. 4-10 = -6 Carry flag cleared In your example Wreg = 5, Count = 1 1-5 = -4, Carry is clear
S Suraj143 Active Member Nov 28, 2007 #3 OK thanks Geko for the reply. Can you tell me whats my result in my example? is it -4?
geko Active Member Nov 28, 2007 #4 Can you tell me whats my result in my example? is it -4? Click to expand... Yes, with carry cleared.