# Vault 7: Projects

This publication series is about specific projects related to the Vault 7 main publication.

### Protego

# MPLAB XC16 C-Compiler

- 1
- 2
…
- 164
- 165
- 166
- 167
- 168
…
- 365
- 366

MPLAB
®
XC16 C Compiler Users Guide
DS50002071C-page 166  2012-2013 Microchip Technology Inc.
10.10.2 Accessing EEDATA Using TBLRDx Instructions
The TBLRDx instructions are not directly supported by the compiler, but they can be
used via inline assembly or compiler built-in functions. Like PSV accesses, a 23-bit
address is formed from an SFR value and the address encoded as part of the instruc-
tion. To access the same memory as given in the previous example, the following code
may be used:
To use the TBLRDx instructions:
 The TBLPAG register must be set to the appropriate address for the program
memory to be accessed. For EE data, this will be 0x7F, but it is best to use the
__builtin_tblpage() function.
 The TBLRDx instruction can be accessed from an __asm__ statement or through
one of the __builtin_tblrd functions; refer to the dsPIC30F/33F
Programmers Reference Manual (DS70157) for information on this instruction.
EXAMPLE 10-2: EEDATA ACCESS VIA TABLE READ
#include <xc.h>
#define eedata_read(src, offset, dest) { \
register int eedata_addr; \
register int eedata_val; \
\
eedata_addr =
__builtin_tbloffset(&src)+offset; \
eedata_val = __builtin_tblrdl(eedata_addr); \
dest = eedata_val; \
}
char user_data[] __attribute__((space(eedata))) = { /* values */ };
int main(void) {
int value;
TBLPAG =
__builtin_tblpage(&user_data);
eedata_read(user_data,2*sizeof(user_data[0]), value);
if (value) ; /* do something */
}

- 1
- 2
…
- 164
- 165
- 166
- 167
- 168
…
- 365
- 366