1 /*-------------------------------------------------------------------------
2 crt0.c - SDCC pic16 port runtime start code
4 Copyright (C) 2004, Vangelis Rokas <vrokas at otenet.gr>
6 This library is free software; you can redistribute it and/or modify it
7 under the terms of the GNU General Public License as published by the
8 Free Software Foundation; either version 2, or (at your option) any
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this library; see the file COPYING. If not, write to the
18 Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston,
21 As a special exception, if you link this library with other files,
22 some of which are compiled with SDCC, to produce an executable,
23 this library does not by itself cause the resulting executable to
24 be covered by the GNU General Public License. This exception does
25 not however invalidate any other reasons why the executable file
26 might be covered by the GNU General Public License.
27 -------------------------------------------------------------------------*/
30 * based on Microchip MPLAB-C18 startup files
36 /* external reference to the user's main routine */
37 extern void main (void);
39 void _entry (void) __naked
__interrupt (0);
40 void _startup (void) __naked
;
42 /* Access bank selector. */
47 * entry function, placed at interrupt vector 0 (RESET)
50 _entry (void) __naked
__interrupt (0)
58 _startup (void) __naked
61 ; Initialize the stack pointer
65 ; 1st silicon does
not do this on POR
68 ; Initialize the flash memory access configuration
.
69 ; This is harmless
for non
-flash devices
, so we
do it on all parts
.
70 bsf
0xa6, 7, a
; EECON1
.EEPGD
= 1, TBLPTR accesses program memory
71 bcf
0xa6, 6, a
; EECON1
.CFGS
= 0, TBLPTR accesses program memory
74 /* Call the main routine. */
79 ; Returning from main will lock up
.