Lessons
2012 Microchip Technology Inc. DS41628B-page 87
3.13.6 New Instructions:
3.13.6.1 BOTH:
3.13.6.1.1 retlw
The WREG register is loaded with the 8-bit literal specified as 8 bits in the instruction
word. The program counter is then loaded from the top of the stack (the return
address). Recall that the PIC MCU utilizes a modified Harvard architecture. It is mod-
ified because it allows the contents of the instruction memory to be accessed as if it
were data.
3.13.6.2 ENHANCED MID-RANGE
3.13.6.2.1 moviw
This instruction is used to move data between WREG and one of the indirect registers
(INDFn). Before/after this move, the pointer (FSRn) is updated by pre/post increment-
ing/decrementing it.
Recall that the INDFn registers are not physical registers. Any instruction that accesses
an INDFn register actually accesses the register at the address specified by the FSRn.
FSRn is limited to the range 0000h-FFFFh. Incrementing/decrementing it beyond
these bounds will cause it to wrap around.
3.13.6.2.2 brw
The brw, relative branch, instruction adds an offset to the PC. brw allows relocatable
code and codes that cross page boundaries. This adds the contents of WREG
(unsigned) to the PC. Since the PC will have incremented to fetch the next instruction,
the new address will be PC + 1 + (WREG). The designer does not need to worry about
program memory boundaries being crossed when using this.
3.13.6.3 PIC18:
3.13.6.3.1 tblrd
This instruction is used to read the contents of program memory. To address the
program memory, a three-byte pointer called Table Pointer is used. All three bytes of
Table Pointer must be setup before executing the
tblrd* instruction.
TABLE 3-41: NEW INSTRUCTIONS FOR BOTH DEVICES
Instruction English Purpose
retlw Return with literal in WREG Table look-ups
TABLE 3-42: NEW INSTRUCTIONS FOR ENHANCED MID-RANGE
Instruction English Purpose
moviw Move INDFx to WREG Shorthand movlw with increment/decrement
brw Relative with WREG Local jump table
TABLE 3-43: NEW INSTRUCTIONS FOR PIC18
Instruction English Purpose
tblrd* Table Read Table look-up data retrieval