Microchip Technology XC8 Standard Compiler (Workstation) SW006021-1 SW006021-1 User Manual

Product codes
SW006021-1
Page of 518
MPLAB
®
 XC8 C Compiler User’s Guide
DS52053B-page 260
 2012 Microchip Technology Inc.
6.4.9.7
DB
The DB directive is used to initialize storage as bytes. The argument is a comma-sep-
arated list of expressions, each of which will be assembled into one byte and 
assembled into consecutive memory locations.
Examples:
alabel: DB  ’X’,1,2,3,4,
If the size of an address unit in the program memory is 2 bytes, as it will be for baseline 
and mid-range devices (see Section 6.4.9.3.4 “Delta”), the DB pseudo-op will initialise 
a word with the upper byte set to zero. So the above example will define bytes padded 
to the following words.
0058 0001 0002 0003 0004
But on PIC18 devices (PSECT directive’s delta flag should be 1) no padding will occur 
and the following data will appear in the HEX file.
58 01 02 03 04
6.4.9.8
DW
The DW directive operates in a similar fashion to DB, except that it assembles 
expressions into 16-bit words. Example:
DW -1, 3664h, ’A’
6.4.9.9
DDW
The DDW directive operates in a similar fashion to DW, except that it assembles 
expressions into double-width (32-bit) words. Example:
DDW ’d’, 12345678h, 0
6.4.9.10
DS
This directive reserves, but does not initialize, memory locations. The single argument 
is the number of bytes to be reserved.
This directive is typically used to reserve memory location for RAM-based objects in 
the data memory. If used in a psect linked into the program memory, it will move the 
location counter, but not place anything in the HEX file output. Note that because the 
size of an address unit in the program memory is 2 bytes (see 
Section 6.4.9.3.4 “Delta”), the DS pseudo-op will actually reserve an entire word.
A variable is typically defined by using a label and then the DS directive to reserve 
locations at the label location.
Examples:
alabel: DS 23    ;Reserve 23 bytes of memory
xlabel: DS 2+3   ;Reserve 5 bytes of memory