Electronic Projects, forums and more.

Go Back   Electronic Circuits Projects Diagrams Free > Electronics Categories > Micro Controllers


Micro Controllers Discuss all aspects of micro controllers - building them, coding them, etc. All controllers are welcome - PIC, BASIC, Z8 Encore!, etc.

Reply
 
LinkBack Thread Tools Display Modes
Old 28th November 2007, 09:03 AM   (permalink)
Exclamation What is carry bit?

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
Suraj143 is offline  
Old 28th November 2007, 10:15 AM   (permalink)
Default

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
__________________
Pete
picprojects.org.uk

Last edited by geko; 28th November 2007 at 10:17 AM.
geko is offline  
Old 28th November 2007, 10:23 AM   (permalink)
Default

OK thanks Geko for the reply.

Can you tell me whats my result in my example? is it -4?
Suraj143 is offline  
Old 28th November 2007, 10:31 AM   (permalink)
Default

Quote:
Can you tell me whats my result in my example? is it -4?
Yes, with carry cleared.
__________________
Pete
picprojects.org.uk
geko is offline  
Old 28th November 2007, 10:34 AM   (permalink)
Default

Ok thanks geko now I got it.
Suraj143 is offline  
Reply

Bookmarks

Thread Tools
Display Modes



Similar Threads
Title Starter Forum Replies Latest
HD44780 lcd help jay543_uk Micro Controllers 12 8th November 2007 04:26 PM
16 bit serial in parallel out shift registers forder Electronic Projects Design/Ideas/Reviews 13 27th October 2007 12:24 PM
RS232 Converter e.chain Micro Controllers 0 6th October 2007 07:19 PM
carry and digit carry definition max_imum2000 General Electronics Chat 6 8th May 2006 05:40 PM
PIC subtraction: Carry flag eblc1388 Micro Controllers 4 19th June 2005 02:47 PM



All times are GMT. The time now is 02:00 AM.


Electronic Circuits  |  Learning Electronics
Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.

eXTReMe Tracker