What is carry bit?

Status
Not open for further replies.

Suraj143

Active Member
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
 
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:
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…