PIC instruction sampler

The reference

This description is based on tables from the 16-bit MCU and DSC Programmer’s Reference Manual. It differs a little from the tables in the textbook. The textbook authors make an attempt to put a bit more structure in the instruction set.

All following page reference are from the Programmer’s Reference Manual.

Some instructions

Here are all the instuctions for moving and adding. Similar instructions exist for other operations. We will have to cover flow control instructions a bit later.

MOV       f282
MOV       f, WREG
MOV.B     f
MOV.B     f, WREG
MOV       WREG, f283
MOV.B     WREG, f
MOV       f, Wnd284
MOV       Wns, f285
MOV.B     #lit8, Wnd286
MOV       #lit16, Wnd287
MOV       [Ws+Slit10], Wnd   288
MOV       Wns, [Wd+Slit10]289
MOV       Ws, Wd290
MOV.D     Wns, Wd292
ADD       f100
ADD       f, WREG
ADD.B     f
ADD.B     f, WREG
ADD       #lit10, Wn101
ADD.B     #lit8, Wn
ADD       Wb, #lit5, Wd102
ADD       Wb, Ws, Wd104
INC       f258
INC       f, WREG
INC.B     f
INC.B     f, WREG
INC       Ws, Wd259
INC.B     Ws, Wd

PIC addressing modes

Let’s take a look at page 95 of the Programmer’s Reference Manual to see how address modes are encoded.

Some lines of C to consider

x = y + 15 ;
x = dept.chair ;
x = dept->chair ;
x = y + z ;
x = y + V[5] ;
x = y + V[i] ;
V[i] = V[i+1] ;
V[0] = 15 ;
x = u + v + w + y + z ;