SX Embedded Controller Instruction

ADD W,fr

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

Add fr to W

Operation: W =W + fr

Flags affected: C, DC, Z

Opcode: 0001 110f ffff

Description: This instruction adds the contents of the specified file register to the contents of W and writes the 8- bit result into W. The file register 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 W. 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 register has been programmed to 0, this instruction also adds the C flag as a carry- in input: W = W + fr + C

Cycles: 1

Example: add W,$ 12

This example adds the contents of file register 12h to W. For example, if the file register contains 81h and W contains 82h, this instruction adds 81h to 82h and writes the lower eight bits of the result, 03h, into W. It sets the C flag because of the carry out of bit 7, and clears the DC flag because there is no carry from bit 3 to bit 4. The Z flag is cleared because the result is nonzero.