4.9.8 Dabs Directive

The DABS directive allows one or more bytes of memory to be reserved at the specified address. The general form of the directive is:

DABS memorySpace, address, bytes [,symbol]

where memorySpace is a number representing the memory space in which the reservation will take place, address is the address at which the reservation will take place and bytes is the number of bytes that is to be reserved. The symbol is optional and refers to the name of the object at the address.

Specifying a symbol allows you to access the reserved memory in your code. This symbol is automatically made globally accessible and is equated to the address specified in the directive. For example, the symbol, foo, defined by the following directive:
DABS 1,0x100,4,foo
can be used in code, for example:
    movlw 20
    movwf BANKMASK(foo)
Note: The manual masking of addresses used as instruction operands (for example using the BANKMASK() or PAGEMASK() macros or ANDing the operand with a mask) is not necessary when using the -Wl,--fixupoverflow option and any of the ignore, warn, or lstwarn arguments.

This directive differs to the DS directive in that it can be used to reserve memory at any location, not just within the current psect. Indeed, these directives can be placed anywhere in the assembly code and do not contribute to the currently selected psect in any way. Additionally, objects defined by the DS directive inside a psect are allocated free memory by the linker, whereas the allocation address must be specified and manged by the programmer when using the DABS directive.

The memory space number is the same as the number specified with the space flag option to psects (see 4.9.47.18 Space Flag).

The linker reads this DABS-related information from object files and ensures that the reserved addresses are not used for other memory placement.