Many of you will recall a couple of recent threads involving my BIN2BCD acro and the DAW instruction. These threads revolved around the details of how the DAW instruction handled carrry. I had assumed, when writing the macro, the DAW would 'do the right thing'. This means that if carry was set before the DAW instruction it would not be cleared by the DAW, but that if carry was clear, then DAW could set it in appropriate circumstances. Someone posted that their experience was that the DAW instruction would clear carry. This meant that the very simple sequence my macro used: movf VAL_A,W addwf VAL_B,W daw movwf SUM movf VAL_A+1,W addwfc VAL_B+1,W daw movwf SUM+1 etc. had to be complicated by code to save the carry before the DAW instructions, and then 'or' it in to the carry out of the DAW. I have recently encounted an errata document on the MChip site: DS80152A - PIC18F4320 Rev. B2 "ES" Silicon Errata Sheet This document seems to indicate that my interpretation of the operation of the DAW was correct, but that at least some PICs have a bug in their implementation. Section 3 of that document reads as follows: 3. Module: DAW Instruction The DAW instruction may improperly clear the CARRY bit (STATUS<0>) when executed. Work around Test the CARRY bit state before executing the DAW instruction. If the CARRY bit is set, increment the next higher byte to be added, using an instruction such as INCFSZ (this instruction does not affect any STATUS flags, and will not overflow a BCD nibble). After the DAW instruction has been executed, process the CARRY bit normally (see Figure 2). FIGURE 2: PROCESSING THE CARRY BIT DURING BCD ADDITIONS MOVLW 0x80 ; .80 (BCD) ADDLW 0x80 ; .80 (BCD) BTFSC STATUS,C ; test C INCFSZ byte2 ; inc next higher LSB DAW BTFSC STATUS,C ; test C INCFSZ byte2 ; inc next higher LSB This is repeated for each DAW instruction. Interesting indeed! Bob Ammerman RAm Systems -- http://www.piclist.com hint: PICList Posts must start with ONE topic: [PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads