![]() | ![]() | ![]() |
| | |||||||
| General Electronics Chat This forum is for general chat about electronics, eg: Dont know what a part does? Dont know how to read a circuit? Want to get an opinion? |
| | LinkBack | Thread Tools | Display Modes |
| | (permalink) |
| 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 | |
| |
| | (permalink) |
| 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 by dknguyen; 8th May 2006 at 01:19 AM. | |
| |
| | (permalink) |
| 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. | |
| |
| | (permalink) |
| 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? | |
| |
| | (permalink) |
| C -> 8th bit Overflow DC -> 4th bit Overflow
__________________ Gods own Country Incredible !ndia www.flickr.com/photos/_akg/ "Give a man a fish, and he will eat for a day. Teach that man to fish, and he will eat for a lifetime." | |
| |
| | (permalink) | |
| Quote:
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 | ||
| |
| | (permalink) |
| 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 | |
| |