Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

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.

Latest threads

New Articles From Microcontroller Tips

Back
Top