Introduction
The Microchip PIC family has four instruction sets that share their mnemonics and little else. The disassembler offers them as five variants:
| Variant | Word | Chips | Instructions |
|---|---|---|---|
pic12 Baseline | 12 bits | PIC10F, PIC12C5xx, PIC12F5xx, PIC16C5x (data sheet DS40139E) | 33 opcodes; GOTO has 9 address bits, CALL 8; TRIS and OPTION are instructions |
pic14 Mid-range | 14 bits | PIC12C6xx, PIC16F84A, PIC16F87x and most PIC16 (DS35007B, DS33023A) | 35 instructions plus the legacy OPTION and TRIS |
pic14e Enhanced mid-range | 14 bits | PIC12F1xxx, PIC16F1xxx (DS40001413E) | 51 mnemonics (with the legacy OPTION and TRIS): adds ADDWFC, ASRF, LSLF, LSRF, SUBWFB, MOVLB, MOVLP, BRA, BRW, CALLW, RESET, ADDFSR, MOVIW, MOVWI |
pic18 PIC18 | 16 bits | PIC18F and PIC18 (DS39632E) | 75 standard instructions; four take two words (CALL, GOTO, LFSR, MOVFF) |
pic18x PIC18, extended set | 16 bits | PIC18 with the configuration bit XINST = 1 | the standard set and eight more (ADDFSR, ADDULNK, CALLW, MOVSF, MOVSS, PUSHL, SUBFSR, SUBULNK; MOVSF and MOVSS take two words) |
All of them are word machines: an instruction is one word (two for six PIC18 instructions: four standard, two of the extended set), and the program memory is addressed in words (PIC12, PIC14) or in bytes (PIC18). In a HEX file every address is a byte address and each word is written low byte first; so word address 5 is byte address 0x0A. The disassembler writes the addresses of the 12-bit and 14-bit sets as MPASM does, in words, and the PIC18 addresses in bytes. The Intel HEX viewer reads a file as PIC words when you choose “Addresses and words: PIC words” and disassembles it when you choose this processor; one processor is chosen for the whole file.
Every instruction with its bit pattern, operands, cycles and the status flags it changes is on the instructions page.
Statuses in the disassembly
| Status | Meaning |
|---|---|
| Documented | An instruction in the data sheet tables read. |
| Illegal | A word that no instruction of the chosen set uses, a two-word instruction whose second word does not start with 1111, an LFSR of FSR3, and an instruction cut short by the end of the data. (A PIC18 instruction of the extended set is illegal while the standard set is chosen.) |
| Odd address | A byte at an odd address: an instruction starts only at an even byte address. |
Notation
MPASM form: MOVLW 0x55, ADDWF 0x20, F (the destination is W or F), BCF 0x03, 5, ADDWF 0x20, F, ACCESS on the PIC18 (the access bank flag is ACCESS or BANKED), RETURN FAST. Options: mnemonic case and number base (0x1F, 1Fh, decimal). A GOTO or CALL shows the address it goes to, taken in the same page as the instruction (the chip takes the upper bits from PCLATH or the STATUS page bits, which a disassembler cannot know). Byte order: a HEX file holds each word low byte first (the default); big-endian is offered for raw code.
Not described
Known, not yet covered
- Reference: this site has the instruction tables only: no register maps, no memory layouts of the many devices, no configuration words, no peripheral descriptions, no timing beyond the cycle counts of the tables. The PIC17 and the PIC24, dsPIC and PIC32 (other cores) are not covered. The PIC18 instruction encodings are those of DS39632E, whose summary table and description of
MOVLBdiffer (4-bit and 8-bit literal): the 8-bit form is used (the same as Ghidra). Newer PIC18 chips (the Q and K families) have more instructions and widerMOVLBthan the device read. - Viewer: the bank (BSR, STATUS) and page (PCLATH) are not tracked, so a file register is a number and a
GOTOorCALLstays in its page; the register names (STATUS,PORTB) of a given chip are not used; a file that mixes chips or instruction sets is read as the one set chosen; two-word PIC18 instructions are decoded at every even address, so an instruction that starts in the middle of one is shown as well, in another column.
Unknown
- Reference: what the processors do with the 12-bit and 14-bit words that no instruction uses (the data sheets do not say), and the legacy
00 0000 0xx0 0000forms ofNOPother than the one the mid-range data sheet lists.
How this was checked
The tables were read from rendered data sheet pages and typed once; they are tested against two sources they were not typed from: the encoding lines of the Mid-Range Reference Manual (DS33023A) and the SLEIGH files of Ghidra (every word of the 12-bit, enhanced 14-bit and PIC18 spaces, 144,000 words, agree on the mnemonic). Two differences found are named above (MOVLB) and on the instructions page (PUSHL). No assembler or disassembler of Microchip was run.
Links
Reference
- PIC12C5XX data sheet (DS40139E) – Microchip: the baseline instruction set summary, table 9-2
- PIC16F84A data sheet (DS35007B) – Microchip: the mid-range instruction set, table 7-2
- PICmicro Mid-Range MCU Family Reference Manual (DS33023A) – Microchip: section 29, every mid-range instruction with its encoding
- PIC12(L)F1822/16(L)F1823 data sheet (DS40001413E) – Microchip: the enhanced mid-range set, table 29-3
- PIC18F2455/2550/4455/4550 data sheet (DS39632E) – Microchip: the PIC18 and its extended instruction set, tables 26-2 and 26-3
- Ghidra PIC processor modules – the SLEIGH files used as the second table in the tests