Using the mplab, C17 c compiler – Arizona Picdem 17 User Manual

Page 33

Advertising
background image

2001 Microchip Technology Inc.

DS39024B-page 27

Using the MPLAB

®

C17 C Compiler

movlw HIGH _start

movwf PCLATH

movlw LOW _start

movwf PCL

;***********************************************************;

_start_section CODE

;-----------------------------------------------------------;

;

;Beginning of startup code

;

_start

;------------------------------------------------------------;

; Optionally call the routine that copies initlialized data ;

; from program memory to data memory. ;

;------------------------------------------------------------;

#IFDEF USE_INITDATA

movlw HIGH copy_init_data

movwf PCLATH

lcall copy_init_data

#ENDIF

;------------------------------------------------------------;

; Set up the stack for use with function arguments and local ;

; (auto) variables. ;

;------------------------------------------------------------;

_setup_stack

BANKSEL _stack ;Switch to bank where the stack pointer is

movlw _stack+2 ;Store the address of the stack pointer + 2

movwf _stack ;Into the stack pointer

;------------------------------------------------------------;

; Branch to main() in the C program ;

;------------------------------------------------------------;

movlw HIGH main

movwf PCLATH

movlw LOW main

movwf PCL

END

Advertising