-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathc018.c
More file actions
66 lines (52 loc) · 1.43 KB
/
c018.c
File metadata and controls
66 lines (52 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include "devincs.h"
#ifdef __18CXX
// Modified from Microchip standard version for different load address due to boot loader
/* Copyright (c)1999 Microchip Technology */
/* MPLAB-C18 startup code */
/* external reference to __init() function */
extern void __init (void);
/* external reference to the user's main routine */
extern void main (void);
/* prototype for the startup function */
void _entry (void);
void _startup (void);
extern near char __FPFLAGS;
#define RND 6
//#pragma code _entry_scn=0x000000
#pragma code _entry_scn=0x000800
/* Redirected reset vector comes here */
void
//_entry (void)
RESET_VECT (void)
{
_asm nop _endasm
_asm goto _startup _endasm
}
// #pragma code _startup_scn
#pragma code APP
void
_startup (void)
{
_asm
// Fill stack with known value for code profiling
lfsr 1, 0x200
movlw 0x80
movwf 0, 0
movlw 0xa5
fill_loop: movwf POSTINC1, 0
decfsz 0, 1, 0
bra fill_loop
// Initialize the stack pointer
lfsr 1, _stack
lfsr 2, _stack
clrf TBLPTRU, 0 // 1st silicon doesn't do this on POR
bcf __FPFLAGS,RND,0 // Initalize rounding flag for floating point libs
_endasm loop:
// If user defined __init is not found, the one in clib.lib will be used
__init ();
// Call the user's main routine
main ();
goto loop;
} /* end _startup() */
#endif
//