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       fWREG
MOV.B     f
MOV       WREGf283
MOV       fWnd284
MOV       Wnsf285
MOV.B     #lit8Wnd286
MOV       #lit16Wnd287
MOV       [Ws+Slit10], Wnd   288
MOV       Wns, [Wd+Slit10]289
MOV       WsWd290
MOV.D     WnsWd292
ADD       f100
ADD       fWREG
ADD.B     f
ADD       #lit10Wn101
ADD.B     #lit8Wn
ADD       Wb, #lit5Wd102
ADD       WbWsWd104
INC       f258
INC       fWREG
INC.B     f
INC       WsWd259
INC.B     WsWd

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 ;