2.3.1 Source File

The assembler accepts, as input, a source file that consists of DSC device instructions, assembler directives and comments. A sample source file is shown below.

Note: Microchip Technology strongly suggests an .s extension for assembly source files. This will enable you to easily use the C compiler driver without having to specify the option to tell the driver that the file should be treated as an assembly file. See the MPLAB® XC-DSC C Compiler User’s Guide (DS-50003589) for more details on the C compiler driver.

For more information, see 3.1 Command-Line Syntax and Assembler Directives.

Sample Assembler Code

        .title " Sample dsPIC Assembler Source Code"
        .sbttl " For illustration only."

        ; dsPIC registers
        .equ CORCONL, CORCON
        .equ PSV,2

        .section .const,psv
hello:
        .ascii "Hello world!\n\0"

        .text
        .global __reset
__reset:
        ; set PSVPAG to page that contains 'hello'
        mov     #psvpage(hello),w0
        mov     w0,PSVPAG

        ; enable Program Space Visibility
        bset.b  CORCONL,#PSV

        ; make a pointer to 'hello'
        mov     #psvoffset(hello),w0

        .end