goto Home

  PIC Midrange MCU Instruction Set

2003 Microchip Technology Inc

 

Where the operand shows f, d you can specify whether the d(estination) for the operation is the file register (F) (think RAM) or the working register (W) (think Accumulator in 8086, 6502,68xx etc).  In a way this doubles up each of these instructions, so although there are only 35 instructions, each of the fourteen byte oriented instructions can store its result in the F or W register, effectively giving you 28 instructions.

Because all the data memory is internal the RAM works like an extended set of registers on a 'big' CPU. There is no distinction between instructions that work on CPU registers and instructions that work on RAM, it's all File Registers. 

For example MOVF  0x20, F moves the contents of the file register at 0x20 back into 0x20, may seem pointless but in the process it sets the Z(ero) flag in the STATUS register according to the value in the file register, so you can test for zero without altering the data in F, or affecting the W register.

You can also do something like RLF 0x20,W which rotates the contents of 0x20 left 1-bit with the MSB ending up in the STATUS C(arry) flag, but the actual data in 0x20 isn't changed because the rotated data ends up in W. You can then do a RLF 0x21,F followed by RLF 0x20,F which performs a 16 bit rotate left with the MSB of the Hi byte being fed into the LSB of the lo byte.

All the Byte oriented instructions allow you to specify whether the data is stored back in the File Register or the Working Register, except the two that explicitly work on the W register (CLRW, MOVWF).  Once you get the hang of this you can do some really trick code.

There's a bit more to it than that and I recommend you browse through the  Microchip Mid-Range MCU family  data sheet to get the full story, it's a big document, but it's well sectioned and easy to find what you looking for.