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.

carry and digit carry definition

Status
Not open for further replies.

max_imum2000

New Member
hello
i am very new to electronics and learning , so excuse my stupid questions from now and then.
can anyone please explain what is carry and what is digit carry (not the flags the math itself)

thanks
 
I'm sorry. Im not quite sure what you are asking. Do you mean:

the carry is the bit gets set (=1) whenever two single-digits add up to be too large?

ie. in the decimal system (with digits 0,1,2,3,4,5,6,7,8,9). if you add 9+2 by hand, 9+2 > 9(the largest digit) and so a carry would occur producing a 2-digit number 11 (where the leftmost 1 is the result of the carry, since the adding the numbers in the "ones" position caused it too be too big it had to "carry" over to a "tens" digit.

or in binary (with digits 0,1): a 1+1 operation is bigger than the largest digit available (a 1) and a carry would occur producing an answer of 10
 
Last edited:
The digit carry is a bit that can be used when the two low order nibbles of a byte add up to more than 15 which is the largest value that can fit in four bits. The uses for this bit are probably as rare as hen's teeth.
 
So a carry bit represents when there is an overflow for a digit into the next order of magnitude....and a digital carry represents an overflow nibbles?
 
Papabravo said:
The digit carry is a bit that can be used when the two low order nibbles of a byte add up to more than 15 which is the largest value that can fit in four bits. The uses for this bit are probably as rare as hen's teeth.

Hi Papa Bravo,

I can think of a couple 'common' uses for the DC bit...

Regards, Mike

Code:
;
;  increment packed-bcd CLK data in CLKSEC, CLKMIN, and CLKHRS
;  once per second
;
ISR_CLK	
	incf	CLKSEC,f	; increment seconds [00..59]	  |B0
	movf	CLKSEC,W	;				  |B0
	addlw	h'06'		; lo nybble < 10 ?		  |B0
	bndc	ISR_ALM		; yes, branch			  |B0
	movwf	CLKSEC		; else update			  |B0
	xorlw	h'60'		; is it < 60?			  |B0
	bnz	ISR_ALM		; yes, branch			  |B0
	movwf	CLKSEC		; else, reset sec to '00' and	  |B0
	incf	CLKMIN,f	; increment minutes [00..59]	  |B0
	movf	CLKMIN,W	;				  |B0
	addlw	h'06'		; lo nybble < 10?		  |B0
	bndc	ISR_ALM		; yes, branch			  |B0
	movwf	CLKMIN		; else update			  |B0
	xorlw	h'60'		; is it < 60?			  |B0
	bnz	ISR_ALM		; yes, branch			  |B0
	movwf	CLKMIN		; else, reset min to '00' and	  |B0
	incf	CLKHRS,f	; increment hours [00..23]	  |B0
	movf	CLKHRS,W	;				  |B0
	addlw	h'06'		; lo nybble < 10?		  |B0
	skpndc			; yes, skip			  |B0
	movwf	CLKHRS		; else update			  |B0
	xorlw	h'24'+6		; not '24'?			  |B0
	bnz	ISR_ALM		; yes, branch			  |B0
	movwf	CLKHRS		; else, reset hrs to '00' and	  |B0
Code:
;
;  Print byte in W as two ASCII nybbles
;
PutByte movwf   TEMP            ; save byte                       |B0
        swapf	TEMP,W		; swap nibbles in W		  |B0
	call	Hex2Asc		; process left nibble		  |B0
	movf	TEMP,W		; process right nibble		  |B0
Hex2Asc	andlw	b'00001111'	; mask off left nibble		  |B0
	addlw	h'36'		;				  |B0
	btfsc	STATUS,DC	;				  |B0
	addlw	h'07'		;				  |B0
	addlw	0-6		; ($FA)				  |B0
	goto	Put232		; print ASCII nibble		  |B0
 
I had a feeling that if I offered a personal observation on the subject of Digit Carry that applications would show up as if by magic. Thanks for a most ejoyable code read. It's just like a jigsaw puzzle.

ROFL
 
Status
Not open for further replies.

Latest threads

Back
Top