On Sun, 2 Dec 2001, Dwayne Reid wrote: > Good day to all. > > Second attempt: > > F1_TIME_1, 2, 3 contain the number to be divided /2 > R1_TIME_1, 2, 3 contains the result > > rrf F1_TIME_1,W ;/2 > andlw b'01110111' ; > btfsc F1_TIME_1,4 ;is nxt nyb odd? > addlw 5 ;add 5 to lower nyb > btfsc F2_TIME_1,0 ;is nxt nyb odd? > addlw 0x50 ;add 5 to upper nyb > movwf R1_TIME_1 ; > > Any thoughts? Yeah. You haven't read my response to your first message :). If you wish to try the approach in that snippet above, you don't need to bother with the ANDing and adding 5. Instead, you can skip the AND and add a -3. For example, suppose F1 = 0x52 If we divide this BCD number by two, we should get 0x26. A shift right by itself will produce 0x29. But if we subtract 3 then we end up with 0x26. The reason this works is simple. When an odd BCD digit is binary shifted right it will add 8 to the next BCD digit to its right. When an odd decimal digit is divided by two, 5 is added to the digit to its right. The difference between 8 and 5 is 3. clrc rrf F1_TIME_1,W ;/2 movwf R1_TIME_1 ; rrf F1_TIME_2,W ;/2 movwf R1_TIME_2 ; rrf F1_TIME_3,W ;/2 btfsc F1_TIME_3,4 ;is nxt nyb odd? addlw -3 ;subtract 3 from lower nyb btfsc F2_TIME_2,0 ;is nxt nyb odd? addlw -0x30 ;subtract 3 from upper nyb movwf R1_TIME_2 ; etc. But this doesn't lead to any shorter code than what was posted earlier. BTW, there was an error in the constants in the earlier post. Scott -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads