SX Embedded Controller Instruction

ADD fr,W

Description: Add W into fr
Operation: fr += W
Flags affected: C DC Z
Registers affected: fr
Sources referenced: W
Cycles: 1
Opcode:
Details: SX Users Manual page # 69
Microchip PIC syntax: ADDWF fr,1
Notes:

ADD fr, W

Add W to fr

Operation: fr = fr + W

Flags affected: C, DC, Z

Opcode: 0001 111f ffff

Description: This instruction adds the contents of W to the contents of the specified file register and writes the 8- bit result into the same file register. W is left unchanged. The register contents are treated as unsigned values.

If the result of addition exceeds FFh, the C flag is set and the lower eight bits of the result are written to the file register. Otherwise, the C flag is cleared.

If there is a carry from bit 3 to bit 4, the DC (digit carry) flag is set. Otherwise, the flag is cleared.

If the result of addition is 00h, the Z flag is set. Otherwise, the flag is cleared. An addition result of 100h is considered zero and therefore sets the Z flag.

Config. Option: If the CF bit in the FUSEX configuration register has been programmed to 0, this instruction also adds the C flag as a carry- in input:

fr = fr + W + C

Cycles: 1

Example: add $12, W

This example adds the contents of W to file register 12h. For example, if the file register contains 7Fh and W contains 02h, this instruction adds 02h to 7Fh and writes the result, 81h, into the file register; and clears the C and Z flags. It sets the DC flag because of the carry from bit 3 to bit 4.