Vault 7: Projects
This publication series is about specific projects related to the Vault 7 main publication.
PIC24F Family Reference Manual
DS39715A-page 4-10 Advance Information © 2007 Microchip Technology Inc.
4.6 TABLE INSTRUCTION OPERATION
The table instructions provide one method of transferring data between the program memory
space and the data memory space of the PIC24F devices. A summary of the table instructions
used during programming of the Flash program memory is provided in this section. There are
four basic table instructions:
• TBLRDL: Table Read Low
• TBLRDH: Table Read High
• TBLWTL: Table Write Low
• TBLWTH: Table Write High
The TBLRDL and the TBLWTL instructions are used to read and write to bits<15:0> of program
memory space. TBLRDL and TBLWTL can access program memory in Word or Byte mode.
The TBLRDH and TBLWTH instructions are used to read or write to bits<23:16> of program mem-
ory space. TBLRDH and TBLWTH can access program memory in Word or Byte mode. Since the
program memory is only 24 bits wide, the TBLRDH and TBLWTH instructions have the ability to
address an upper byte of program memory that does not exist. This byte is called the ‘phantom
byte’. Any read of the phantom byte will return 0x00 and a write to the phantom byte has no effect.
The 24-bit program memory can be regarded as two, side-by-side 16-bit spaces, with each space
sharing the same address range. Therefore, the TBLRDL and TBLWTL instructions access the
‘low’ program memory space (PM<15:0>). The TBLRDH and TBLWTH instructions access the
‘high’ program memory space (PM<31:16>). Any reads or writes to PM<31:24> will access the
phantom (unimplemented) byte. When any of the table instructions are used in Byte mode, the
LSb of the table address will be used as the byte select bit. The LSb determines which byte in
the high or low program memory space is accessed.
Figure 4-10 shows how the program memory is addressed using the table instructions. A 24-bit
program memory address is formed using the TBLPAG<7:0> bits and the Effective Address (EA)
from a W register, specified in the table instruction. The 24-bit program counter is shown in
Figure 4-10 for reference. The upper 23 bits of the EA are used to select the program memory
location. For the Byte mode table instructions, the LSb of the W register EA is used to pick which
byte of the 16-bit program memory word is addressed. A ‘1’ selects bits<15:8>, a ‘0’ selects
bits<7:0>. The LSb of the W register EA is ignored for a table instruction in Word mode.
In addition to the program memory address, the table instructions also specify a W register (or a
W Pointer to a memory location) that is the source of the program memory data to be written, or
the destination for a program memory read. For a table write operation in Byte mode, bits<15:8>
of the working source register are ignored.
Figure 4-10: Addressing for Table Registers
0
Program Counter
24 bits
Program
TBLPAG Reg
8 bits
Working Reg EA
16 bits
Using
Byte
24-bit EA
0
1/0
Select
Table
Instruction
Counter
Using
User/Configuration
Space Select
Protego_Release_01_05-Related-OEM-Documentation-PIC24FJ32MC10X-Reference_Manual-Section4-Program_Memory.pdf