847485e9eef63b1282d07f6455315b2f4404848f
[fw/sdcc] / src / pic16 / NOTES
1 lNOTES file for SDCC pic16 port
2 $Id$
3
4 Current pic16 port status is: Development
5
6 Some things may change without notification between port updates. The latest
7 CVS snapshot is guarenteed to compile without problems, but does not
8 guarantee backwards compatibility.
9
10 For any questions please ask the current port
11 developers.
12
13 Current developer:
14 Vangelis Rokas  <vrokas AT users.sourceforge.net>
15 Raphael Neider  <rneider AT web.de>
16
17 Other people to contact:
18 Scott Dattalo   <scott AT dattalo.com>
19
20 ======================================================================
21 ======================================================================
22 2005-Mar-23 Vangelis Rokas
23 1. I have added some optimizations that are controlled via enviroment
24 variables to allow checking. Later these will be either enabled globally
25 or controlled by command line options. The variables are:
26         a. OPTIMIZE_BITFIELD_POINTER_GET : optimizes bit field pointer reads
27
28         b. NO_REG_OPT : there is no register optimization performed by pCode
29                         optimizer
30
31
32
33 2004-Oct-29 Vangelis Rokas
34 1. Function parameters are passed now all via stack. This might
35 lower performance, but some issues are solved this way. Later
36 we can enable passing through WREG,PRODL,PRODH,FSR0L by implementing
37 specific pragmas
38
39
40 2004-Sep-27 Vangelis Rokas
41 1. Function parameters have been extended to cover functions with
42 variable arguments. Now function parameters follow the rules below:
43
44   a) void foo(long a, int b, char c)
45      void foo(long a, int b, char c) reentrant
46
47 Stack layout: c, b+1, b, a+3, a+2, a+1 and WREG = a
48
49   b) prototype: void foo(long a, int b, ...)
50
51         example: foo(0xaaffeedd, 0xbbcc, 0x4455, 0x7788);
52
53 Stack layout: 0x77, 0x88, 0x44, 0x55, 0xbb, 0xcc, 0xaa, 0xff, 0xee, 0xdd
54
55 WREG is not used in functions with variable arguments so that the address
56 of the first parameter can be taken.
57
58
59
60
61 2004-Sep-24 Vangelis Rokas
62 1. Began implementation of generic pointers, current specs are:
63         0x0 xxxxxxx -> code pointer
64         0x8 xxxxxxx -> data pointer
65         0x4 xxxxxxx -> eeprom pointer (currently unimplemented)
66
67
68 2004-Aug-30 Vangelis Rokas
69 1. A few months ago Hans Dorn had the idea to support general pointer
70 for accessing all code, eeprom data and data ram memory. These pointers
71 would have 3 bytes of size (24-bits), of which only the 21 lower bits
72 would be useful. The rest of them could be used to indicate the pointer
73 type. I.e.
74 0x4xxxxxxx would mean code pointer
75 0x8xxxxxxx would mean eeprom pointer
76 0xcxxxxxxx would mean data ram pointer
77
78 The implementatio of such pointers needs a lot of work and general
79 reform of pointer access, data initializing functions and the writing
80 of support functions for decoding their type.
81
82 The implementation of such pointers along with the implementation of
83 a more SDCC like stack access system will allow the writing of variable
84 arguments functions like printf etc... Also one set of functions will be
85 able to handle all data types without having to worry about where they
86 are placed.
87
88
89 2004-May-23 Vangelis Rokas
90
91 1. The improvement of the port has been stalled a bit. But, struct/union
92 SFR headers are ready for the PIC18F[45][45][28] chips along with their
93 respective sources.
94
95 2. The genCmp function should be rewritten from scratch.
96
97 3. The internal helper functions for char/int/long/float arithmetic
98 now compile and will be placed in the appropriate directory under device/
99
100
101
102 2004-Feb-20 Vangelis Rokas
103 Major update with many bugfixes.
104
105 1. The most of the pic16 regression tests (former pic regression tests) pass
106 successfully. Many thanks to Hans Dorn who did a great job with the
107 arithmetic, shift and pointer functions.
108
109 2. Bit fields now work properly.
110
111 3. Stack is permanently enabled. Command argument -pstack-enable is deleted
112 and no more recognized by the port.
113
114
115 2004-Feb-07 Vangelis Rokas
116
117 1. Fixed a bug so that compiler allocated internal registered, will
118 be shared along multiple sources via '.registers' section placed
119 in absolute data memory address 0x0000. Registers 0x00 to 0x7f are
120 considered as internal since they can be used for fast access.
121
122
123
124 2004-Jan-11 Vangelis Rokas
125
126 1. Compiling
127 The current release of the port can produce object code which is not
128 completely bug free. To use the new features the user should enable them via
129 command line arguments. A sane set of command arguments that I use to test
130 programs is:
131
132 - debug options
133         --debug         enable sdcc debug information
134         --debug-xtra    enable pic16 port debug information (most useful)
135         --debug-ralloc  enable register allocator debug messages
136         --pcode-verbose enable verbose pcode generator messages
137
138 - port options
139         --pno-banksel   disable banksel directives for the assembler
140         --pomit-config-words    does not emit configuration instruction in
141                         the translation This is useful when copmiling
142                         multiple sources, when you do not want multiple
143                         config instructions in the end file
144         --pomit-ivt     disables the dumping of the interrupt vector tables
145                         in the translation for the same reasons as above
146         --penable-stack enables stack support. This option uses stack to
147                         pass function arguments, and reuses registers between
148                         functions by saving the registers used in the function
149                         on the stack
150
151 - compiler options
152         --all-callee-saves      you may omit this options as the port
153                         enables it by default, all functions are currently
154                         compiled as reentrant and they are marked as
155                         callee-saves
156         --no-peep       peephole optimizer is better to be switched off,
157                         because it behaves strangely in some cases
158         --fommit-frame-pointer  this omits frame pointer in functions that
159                         don't use registers (maybe changed later, not
160                         important)
161
162
163 2. Functions
164 The current implementation puts every function in its own code section in
165 PIC's program memory. This may not be the standard, but I think its more
166 flexible.
167
168 3. Pragmas
169 Since SDCC is goind for a release, its better to document pragmas available.
170
171 3.1. code
172 The 'code' pragma emits a function's code at a specific address in program
173 memory. Currently it is only used for functions.
174 Syntax:
175 #pragma code [function_name] [address]
176
177 3.2. stack
178 The 'stack' pragma initializes the stack/frame pointer at an address of the
179 data ram other than the default (which is the end of the available data ram)
180 Synatx:
181 #pragma stack [address]
182
183 3.3. maxram
184 The 'maxram' pragma sets maximum data ram of the device. Currently is not
185 used at all, but it may be useful in the future when devices with external
186 memory will be supported.
187 Syntax:
188 #pragma maxram [max_address]
189
190
191 4. Internal compiler functions
192 Internal SDCC functions like, __fsmul, etc... are currently supported by the
193 port, but the libraries for the pic16 port are not yet ready. So one cannot
194 use long and float variables.
195
196
197 5. Special Function Registers (SFRs)
198 The processor SFRs are not anymore declared in any header file. The user can
199 define by himself all the needed SFR's. The code to that is:
200
201 sfr at [sfr_address] [sfr_name];
202
203 Where sfr_address is the SFR address in the data ram, and sfr_name is the
204 name of the SFR. i.e.:
205
206 sfr at 0xf80 PORTA;