PIC and C operators

Addressing modes

The PIC architecture has several addressing modes that are needed to access C arrays, structures, and pointers.

Types of register indirect addressing

The ++ and -- increment or decrement by two for word operations and by one for byte operations. Also, the following is not allowed because the offset register differs in the two fields.
    MOV  [W5+W6],[W7+W8]

Literal offset

MOV allows signed literal register offsets as either source or destination. Here are a couple of examples:

    MOV    W5, [W6+32]
    MOV.B  W5, [W6+15]
    MOV    [W7-1000], W13
    MOV    [W4+5], [W8+13]         ;; ILLEGAL -- only one literal offset
    MOV    [W7+2000], W13          ;; ILLEGAL -- offset too large
    MOV.B  [W7+1000], W13          ;; ILLEGAL -- offset too large for byte

Places to use these addressing modes

Some C operators and their PIC equivalents

In these examples, Wb, Wn, Wns, and Wnd are registers; Ws and Wd are registers with indirect addressing modes; Wso and Wdo are registers with indirect and offset addressing modes; lit10 is a 10-bit literal (0 to 1023), and lit5 is a 5-bit literal (0 to 31).

Uses of these instructions

C declarations

You cannot depend on short, int, and long in C. Use the fixed width types of C99 and C++.