66a4ae743cca9fb77edad044bf4577ef8d7cc8c8
[fw/sdcc] / doc / sdccman.lyx
1 #LyX 1.5.0 created this file. For more info see http://www.lyx.org/
2 \lyxformat 245
3 \begin_document
4 \begin_header
5 \textclass book
6 \begin_preamble
7 \pdfoptionpdfminorversion=3
8 \usepackage[
9   pdftitle={SDCC Compiler User Guide},
10   pdfauthor={SDCC development team},
11   pdfsubject={installation, user manual},
12   pdfkeywords={68hc08 8032 8051 ansi c compiler assembler CPU DS390 embedded development free Floating Point Arithmetic Freescale GPL HC08 inline Intel ISO/IEC 9899:1990 Linux MAC OS X manual Maxim mcs51 Microchip microcontroller open source PIC Unix Windows Z80 Zilog},
13   pdfpagemode=UseOutlines,
14   colorlinks=true,
15   linkcolor=blue] {hyperref}
16 %
17 \sloppy
18 \tolerance=500          
19 \emergencystretch=30pt 
20 %
21 \date{}
22 \end_preamble
23 \language english
24 \inputencoding default
25 \fontscheme pslatex
26 \graphics default
27 \paperfontsize default
28 \spacing single
29 \papersize letterpaper
30 \use_geometry true
31 \use_amsmath 1
32 \cite_engine basic
33 \use_bibtopic false
34 \paperorientation portrait
35 \leftmargin 30mm
36 \topmargin 20mm
37 \rightmargin 25mm
38 \bottommargin 20mm
39 \secnumdepth 3
40 \tocdepth 3
41 \paragraph_separation indent
42 \defskip medskip
43 \quotes_language swedish
44 \papercolumns 1
45 \papersides 1
46 \paperpagestyle fancy
47 \tracking_changes false
48 \output_changes false
49 \author ""
50 \author ""
51 \end_header
52
53 \begin_body
54
55 \begin_layout Standard
56 \begin_inset Note Note
57 status collapsed
58
59 \begin_layout Standard
60 Please note: double dashed longoptions (e.g.
61  --version) are written this way: -
62 \begin_inset ERT
63 status collapsed
64
65 \begin_layout Standard
66
67
68 \backslash
69 /
70 \end_layout
71
72 \end_inset
73
74 -
75 \end_layout
76
77 \begin_layout Standard
78 Two resp.
79  three consecutive dashes would otherwise result in a long resp.
80  extra long dash.
81 \end_layout
82
83 \begin_layout Standard
84 Architecture specific stuff (like memory models, code examples) should maybe
85  later go
86 \end_layout
87
88 \begin_layout Standard
89 into seperate sections/chapters/appendices (it is hard to document PIC or
90  Z80 in 
91 \end_layout
92
93 \begin_layout Standard
94 a 8051 centered document) - for now simply add.
95 \end_layout
96
97 \end_inset
98
99
100 \end_layout
101
102 \begin_layout Title
103 SDCC Compiler User Guide
104 \end_layout
105
106 \begin_layout Date
107
108 \size normal
109 SDCC 2.7.3
110 \size footnotesize
111
112 \newline
113 $Date::             $ 
114 \newline
115 $Revision$
116 \end_layout
117
118 \begin_layout Standard
119 \begin_inset Note Note
120 status collapsed
121
122 \begin_layout Standard
123 The above strings enclosed in $ are automatically updated by Subversion
124 \end_layout
125
126 \end_inset
127
128
129 \end_layout
130
131 \begin_layout Standard
132 \begin_inset LatexCommand \tableofcontents{}
133
134 \end_inset
135
136
137 \end_layout
138
139 \begin_layout Chapter
140 Introduction
141 \end_layout
142
143 \begin_layout Section
144 About SDCC
145 \end_layout
146
147 \begin_layout Standard
148
149 \series bold
150 SDCC
151 \series default
152  (
153 \emph on
154 S
155 \emph default
156 mall 
157 \emph on
158 D
159 \emph default
160 evice 
161 \emph on
162 C
163 \emph default
164  
165 \emph on
166 C
167 \emph default
168 ompiler) is free open source, retargettable, optimizing ANSI-C compiler
169  by 
170 \series bold
171 Sandeep Dutta
172 \series default
173  designed for 8 bit Microprocessors.
174  The current version targets Intel MCS51 based Microprocessors (8031, 8032,
175  8051, 8052
176 \begin_inset LatexCommand \index{8031, 8032, 8051, 8052, mcs51 CPU}
177
178 \end_inset
179
180 , etc.), Dallas DS80C390 variants, Freescale (formerly Motorola) HC08 and
181  Zilog Z80 based MCUs.
182  It can be retargeted for other microprocessors, support for Microchip PIC,
183  Atmel AVR is under development.
184  The entire source code for the compiler is distributed under GPL.
185  SDCC uses ASXXXX
186 \begin_inset LatexCommand \index{asXXXX (as-gbz80, as-hc08, asx8051, as-z80)}
187
188 \end_inset
189
190  & ASLINK
191 \begin_inset LatexCommand \index{aslink}
192
193 \end_inset
194
195 , an open source retargetable assembler & linker.
196  SDCC has extensive language extensions suitable for utilizing various microcont
197 rollers and underlying hardware effectively.
198  
199 \newline
200
201 \newline
202 In addition to the MCU specific optimizations SDCC also does a host of
203  standard optimizations like:
204 \end_layout
205
206 \begin_layout Itemize
207 global sub expression elimination, 
208 \end_layout
209
210 \begin_layout Itemize
211 loop optimizations (loop invariant, strength reduction of induction variables
212  and loop reversing), 
213 \end_layout
214
215 \begin_layout Itemize
216 constant folding & propagation, 
217 \end_layout
218
219 \begin_layout Itemize
220 copy propagation, 
221 \end_layout
222
223 \begin_layout Itemize
224 dead code elimination 
225 \end_layout
226
227 \begin_layout Itemize
228 jump tables for 
229 \emph on
230 switch
231 \emph default
232  statements.
233 \end_layout
234
235 \begin_layout Standard
236 For the back-end SDCC uses a global register allocation scheme which should
237  be well suited for other 8 bit MCUs.
238  
239 \newline
240
241 \newline
242 The peep hole optimizer uses a rule based substitution mechanism which
243  is MCU independent.
244  
245 \newline
246
247 \newline
248 Supported data-types are:
249 \end_layout
250
251 \begin_layout Standard
252 \begin_inset Tabular
253 <lyxtabular version="3" rows="8" columns="5">
254 <features>
255 <column alignment="center" valignment="top" leftline="true" width="0">
256 <column alignment="center" valignment="top" leftline="true" width="0">
257 <column alignment="center" valignment="top" leftline="true" width="0">
258 <column alignment="center" valignment="top" leftline="true" width="0">
259 <column alignment="block" valignment="top" leftline="true" rightline="true" width="20text%">
260 <row topline="true" bottomline="true">
261 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
262 \begin_inset Text
263
264 \begin_layout Standard
265 type
266 \end_layout
267
268 \end_inset
269 </cell>
270 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
271 \begin_inset Text
272
273 \begin_layout Standard
274 width
275 \end_layout
276
277 \end_inset
278 </cell>
279 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
280 \begin_inset Text
281
282 \begin_layout Standard
283 default
284 \end_layout
285
286 \end_inset
287 </cell>
288 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
289 \begin_inset Text
290
291 \begin_layout Standard
292 signed range
293 \end_layout
294
295 \end_inset
296 </cell>
297 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
298 \begin_inset Text
299
300 \begin_layout Standard
301 unsigned range
302 \end_layout
303
304 \end_inset
305 </cell>
306 </row>
307 <row topline="true">
308 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
309 \begin_inset Text
310
311 \begin_layout Standard
312 bool
313 \end_layout
314
315 \end_inset
316 </cell>
317 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
318 \begin_inset Text
319
320 \begin_layout Standard
321 1 bit
322 \end_layout
323
324 \end_inset
325 </cell>
326 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
327 \begin_inset Text
328
329 \begin_layout Standard
330 unsigned
331 \end_layout
332
333 \end_inset
334 </cell>
335 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
336 \begin_inset Text
337
338 \begin_layout Standard
339 -
340 \end_layout
341
342 \end_inset
343 </cell>
344 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
345 \begin_inset Text
346
347 \begin_layout Standard
348 0, 1
349 \end_layout
350
351 \end_inset
352 </cell>
353 </row>
354 <row topline="true">
355 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
356 \begin_inset Text
357
358 \begin_layout Standard
359 char
360 \end_layout
361
362 \end_inset
363 </cell>
364 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
365 \begin_inset Text
366
367 \begin_layout Standard
368 8 bits, 1 byte
369 \end_layout
370
371 \end_inset
372 </cell>
373 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
374 \begin_inset Text
375
376 \begin_layout Standard
377 signed
378 \end_layout
379
380 \end_inset
381 </cell>
382 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
383 \begin_inset Text
384
385 \begin_layout Standard
386 -128, +127
387 \end_layout
388
389 \end_inset
390 </cell>
391 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
392 \begin_inset Text
393
394 \begin_layout Standard
395 0, +255
396 \end_layout
397
398 \end_inset
399 </cell>
400 </row>
401 <row topline="true">
402 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
403 \begin_inset Text
404
405 \begin_layout Standard
406 short
407 \end_layout
408
409 \end_inset
410 </cell>
411 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
412 \begin_inset Text
413
414 \begin_layout Standard
415 16 bits, 2 bytes
416 \end_layout
417
418 \end_inset
419 </cell>
420 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
421 \begin_inset Text
422
423 \begin_layout Standard
424 signed
425 \end_layout
426
427 \end_inset
428 </cell>
429 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
430 \begin_inset Text
431
432 \begin_layout Standard
433 -32.768, +32.767
434 \end_layout
435
436 \end_inset
437 </cell>
438 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
439 \begin_inset Text
440
441 \begin_layout Standard
442 0, +65.535
443 \end_layout
444
445 \end_inset
446 </cell>
447 </row>
448 <row topline="true">
449 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
450 \begin_inset Text
451
452 \begin_layout Standard
453 int
454 \end_layout
455
456 \end_inset
457 </cell>
458 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
459 \begin_inset Text
460
461 \begin_layout Standard
462 16 bits, 2 bytes
463 \end_layout
464
465 \end_inset
466 </cell>
467 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
468 \begin_inset Text
469
470 \begin_layout Standard
471 signed
472 \end_layout
473
474 \end_inset
475 </cell>
476 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
477 \begin_inset Text
478
479 \begin_layout Standard
480 -32.768, +32.767
481 \end_layout
482
483 \end_inset
484 </cell>
485 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
486 \begin_inset Text
487
488 \begin_layout Standard
489 0, +65.535
490 \end_layout
491
492 \end_inset
493 </cell>
494 </row>
495 <row topline="true" bottomline="true">
496 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
497 \begin_inset Text
498
499 \begin_layout Standard
500 long
501 \end_layout
502
503 \end_inset
504 </cell>
505 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
506 \begin_inset Text
507
508 \begin_layout Standard
509 32 bits, 4 bytes
510 \end_layout
511
512 \end_inset
513 </cell>
514 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
515 \begin_inset Text
516
517 \begin_layout Standard
518 signed
519 \end_layout
520
521 \end_inset
522 </cell>
523 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
524 \begin_inset Text
525
526 \begin_layout Standard
527 -2.147.483.648, +2.147.483.647
528 \end_layout
529
530 \end_inset
531 </cell>
532 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
533 \begin_inset Text
534
535 \begin_layout Standard
536 0, +4.294.967.295
537 \end_layout
538
539 \end_inset
540 </cell>
541 </row>
542 <row topline="true" bottomline="true">
543 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
544 \begin_inset Text
545
546 \begin_layout Standard
547 float
548 \end_layout
549
550 \end_inset
551 </cell>
552 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
553 \begin_inset Text
554
555 \begin_layout Standard
556 4 bytes IEEE 754
557 \end_layout
558
559 \end_inset
560 </cell>
561 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
562 \begin_inset Text
563
564 \begin_layout Standard
565 signed
566 \end_layout
567
568 \end_inset
569 </cell>
570 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
571 \begin_inset Text
572
573 \begin_layout Standard
574
575 \end_layout
576
577 \end_inset
578 </cell>
579 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
580 \begin_inset Text
581
582 \begin_layout Standard
583 1.175494351E-38, 
584 \family roman
585 \series medium
586 \shape up
587 \size normal
588 \emph off
589 \bar no
590 \noun off
591 \color none
592 3.402823466E+38
593 \end_layout
594
595 \end_inset
596 </cell>
597 </row>
598 <row topline="true" bottomline="true">
599 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
600 \begin_inset Text
601
602 \begin_layout Standard
603 pointer
604 \end_layout
605
606 \end_inset
607 </cell>
608 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
609 \begin_inset Text
610
611 \begin_layout Standard
612 1, 2, 3 or 4 bytes
613 \end_layout
614
615 \end_inset
616 </cell>
617 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
618 \begin_inset Text
619
620 \begin_layout Standard
621 generic
622 \end_layout
623
624 \end_inset
625 </cell>
626 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
627 \begin_inset Text
628
629 \begin_layout Standard
630
631 \end_layout
632
633 \end_inset
634 </cell>
635 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
636 \begin_inset Text
637
638 \begin_layout Standard
639
640 \end_layout
641
642 \end_inset
643 </cell>
644 </row>
645 </lyxtabular>
646
647 \end_inset
648
649
650 \newline
651 The compiler also allows 
652 \emph on
653 inline assembler code
654 \emph default
655  to be embedded anywhere in a function.
656  In addition, routines developed in assembly can also be called.
657 \newline
658
659 \newline
660 SDCC also
661  provides an option (-
662 \begin_inset ERT
663 status collapsed
664
665 \begin_layout Standard
666
667
668 \backslash
669 /
670 \end_layout
671
672 \end_inset
673
674 -cyclomatic) to report the relative complexity of a function.
675  These functions can then be further optimized, or hand coded in assembly
676  if needed.
677  
678 \newline
679
680 \newline
681 SDCC also comes with a companion source level debugger SDCDB.
682  The debugger currently uses ucSim, a free open source simulator for 8051
683  and other micro-controllers.
684 \newline
685
686 \newline
687 The latest SDCC version can be downloaded from
688  
689 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/snap.php}
690
691 \end_inset
692
693 .
694  
695 \emph on
696 Please note: the compiler will probably always be some steps ahead of this
697  documentation
698 \series bold
699 \emph default
700
701 \begin_inset LatexCommand \index{Status of documentation}
702
703 \end_inset
704
705
706 \begin_inset Foot
707 status open
708
709 \begin_layout Standard
710 Obviously this has pros and cons
711 \end_layout
712
713 \end_inset
714
715 .
716 \end_layout
717
718 \begin_layout Section
719 Open Source
720 \end_layout
721
722 \begin_layout Standard
723 All packages used in this compiler system are 
724 \emph on
725 open source
726 \emph default
727  and 
728 \emph on
729 freeware
730 \emph default
731 ; source code for all the sub-packages (pre-processor, assemblers, linkers
732  etc.) is distributed with the package.
733  This documentation is maintained using a free open source word processor
734  (LyX).
735 \newline
736 This program is free software; you can redistribute it and/or modify
737  it under the terms of the GNU General Public License
738 \begin_inset LatexCommand \index{GNU General Public License, GPL}
739
740 \end_inset
741
742  as published by the Free Software Foundation; either version 2, or (at
743  your option) any later version.
744  This program is distributed in the hope that it will be useful, but WITHOUT
745  ANY WARRANTY; without even the implied warranty
746 \begin_inset LatexCommand \index{warranty}
747
748 \end_inset
749
750  of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
751  See the GNU General Public License for more details.
752  You should have received a copy of the GNU General Public License along
753  with this program; if not, write to the Free Software Foundation, 59 Temple
754  Place - Suite 330, Boston, MA 02111-1307, USA.
755  In other words, you are welcome to use, share and improve this program.
756  You are forbidden to forbid anyone else to use, share and improve what
757  you give them.
758  Help stamp out software-hoarding! 
759 \end_layout
760
761 \begin_layout Section
762 Typographic conventions
763 \begin_inset LatexCommand \index{Typographic conventions}
764
765 \end_inset
766
767
768 \end_layout
769
770 \begin_layout Standard
771 Throughout this manual, we will use the following convention.
772  Commands you have to type in are printed in 
773 \family sans
774 \series bold
775 "sans serif"
776 \series default
777 .
778
779 \family default
780  Code samples are printed in 
781 \family typewriter
782 typewriter font.
783
784 \family default
785  Interesting items and new terms are printed in 
786 \emph on
787 italic.
788 \end_layout
789
790 \begin_layout Section
791 Compatibility
792 \begin_inset LatexCommand \label{sec:Compatibility-with-previous}
793
794 \end_inset
795
796  with previous versions
797 \begin_inset LatexCommand \index{Compatibility with previous versions}
798
799 \end_inset
800
801
802 \end_layout
803
804 \begin_layout Standard
805 Newer versions have usually numerous bug fixes compared with the previous
806  version.
807  But we also sometimes introduce some incompatibilities with older versions.
808  Not just for the fun of it, but to make the compiler more stable, efficient
809  and ANSI compliant
810 \begin_inset LatexCommand \index{ANSI-compliance}
811
812 \end_inset
813
814  (see section 
815 \begin_inset LatexCommand \ref{sub:ANSI-Compliance}
816
817 \end_inset
818
819  for ANSI-Compliance).
820  
821 \begin_inset Note Note
822 status collapsed
823
824 \begin_layout Standard
825 It would be fine to add to each item, in which version was it changed.
826 \end_layout
827
828 \end_inset
829
830
831 \newline
832
833 \end_layout
834
835 \begin_layout Itemize
836 short is now equivalent to int (16 bits), it used to be equivalent to char
837  (8 bits) which is not ANSI compliant.
838  To maintain compatibility, old programs may be compiled using the -
839 \begin_inset ERT
840 status collapsed
841
842 \begin_layout Standard
843
844
845 \backslash
846 /
847 \end_layout
848
849 \end_inset
850
851 -short-is-8bits commandline option (see 
852 \begin_inset LatexCommand \vref{lyx:--short-is-8bits}
853
854 \end_inset
855
856 ).
857 \end_layout
858
859 \begin_layout Itemize
860 the default directory for gcc-builds where include, library and documentation
861  files are stored is now in /usr/local/share.
862 \end_layout
863
864 \begin_layout Itemize
865 char type parameters to vararg
866 \begin_inset LatexCommand \index{vararg, va\\_arg}
867
868 \end_inset
869
870  functions are casted to int unless explicitly casted
871 \begin_inset Marginal
872 status collapsed
873
874 \begin_layout Standard
875
876 \series bold
877 \InsetSpace ~
878 !
879 \end_layout
880
881 \end_inset
882
883 , e.g.: 
884 \newline
885
886 \family typewriter
887 \InsetSpace ~
888 \InsetSpace ~
889 char a=3;
890 \newline
891 \InsetSpace ~
892 \InsetSpace ~
893 printf ("%d %c
894 \backslash
895 n", a, (char)a);
896 \family default
897
898 \newline
899  will push a as an int and as a char resp.
900 \end_layout
901
902 \begin_layout Itemize
903 option -
904 \begin_inset ERT
905 status collapsed
906
907 \begin_layout Standard
908
909
910 \backslash
911 /
912 \end_layout
913
914 \end_inset
915
916 -regextend has been removed.
917 \end_layout
918
919 \begin_layout Itemize
920 option -
921 \begin_inset ERT
922 status collapsed
923
924 \begin_layout Standard
925
926
927 \backslash
928 /
929 \end_layout
930
931 \end_inset
932
933 -noregparms has been removed.
934 \end_layout
935
936 \begin_layout Itemize
937 option -
938 \begin_inset ERT
939 status collapsed
940
941 \begin_layout Standard
942
943
944 \backslash
945 /
946 \end_layout
947
948 \end_inset
949
950 -stack-after-data has been removed.
951 \end_layout
952
953 \begin_layout Itemize
954 bit
955 \begin_inset LatexCommand \index{bit}
956
957 \end_inset
958
959  and sbit
960 \begin_inset LatexCommand \index{sbit}
961
962 \end_inset
963
964
965 \begin_inset LatexCommand \index{\\_\\_sbit}
966
967 \end_inset
968
969  types now consistently behave like the C99 _Bool type with respect to type
970  conversion
971 \begin_inset LatexCommand \index{type conversion}
972
973 \end_inset
974
975
976 \begin_inset LatexCommand \index{type promotion}
977
978 \end_inset
979
980 .
981  The most common incompatibility resulting from this change is related to
982  bit toggling
983 \begin_inset LatexCommand \index{Bit toggling}
984
985 \end_inset
986
987  idioms, e.g.:
988 \newline
989
990 \family typewriter
991 \InsetSpace ~
992 \InsetSpace ~
993 bit b;
994 \newline
995 \InsetSpace ~
996 \InsetSpace ~
997 b = ~
998 \begin_inset LatexCommand \index{\\~\\/ Operator}
999
1000 \end_inset
1001
1002 b; /* equivalent to b=1 instead of toggling b */
1003 \begin_inset Marginal
1004 status collapsed
1005
1006 \begin_layout Standard
1007
1008 \series bold
1009 \InsetSpace ~
1010 !
1011 \end_layout
1012
1013 \end_inset
1014
1015
1016 \newline
1017 \InsetSpace ~
1018 \InsetSpace ~
1019 b = !b; /* toggles b */
1020 \newline
1021
1022 \family default
1023 In previous versions, both forms would have toggled the bit.
1024 \end_layout
1025
1026 \begin_layout Standard
1027
1028 \emph on
1029 <pending: more incompatibilities?>
1030 \end_layout
1031
1032 \begin_layout Section
1033 System Requirements
1034 \end_layout
1035
1036 \begin_layout Standard
1037 What do you need before you start installation of SDCC? A computer, and
1038  a desire to compute.
1039  The preferred method of installation is to compile SDCC from source using
1040  GNU gcc and make.
1041  For Windows some pre-compiled binary distributions are available for your
1042  convenience.
1043  You should have some experience with command line tools and compiler use.
1044 \end_layout
1045
1046 \begin_layout Section
1047 Other Resources
1048 \end_layout
1049
1050 \begin_layout Standard
1051 The SDCC home page at 
1052 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/}
1053
1054 \end_inset
1055
1056  is a great place to find distribution sets.
1057  You can also find links to the user mailing lists that offer help or discuss
1058  SDCC with other SDCC users.
1059  Web links to other SDCC related sites can also be found here.
1060  This document can be found in the DOC directory of the source package as
1061  a text or HTML file.
1062  A pdf version of this document is available at 
1063 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/doc/sdccman.pdf}
1064
1065 \end_inset
1066
1067 .
1068  Some of the other tools (simulator and assembler) included with SDCC contain
1069  their own documentation and can be found in the source distribution.
1070  If you want the latest unreleased software, the complete source package
1071  is available directly from Subversion on https://sdcc.svn.sourceforge.net/svnroot/
1072 sdcc/trunk/sdcc.
1073 \end_layout
1074
1075 \begin_layout Section
1076 Wishes for the future
1077 \end_layout
1078
1079 \begin_layout Standard
1080 There are (and always will be) some things that could be done.
1081  Here are some I can think of:
1082 \newline
1083
1084 \end_layout
1085
1086 \begin_layout Standard
1087
1088 \family typewriter
1089 char KernelFunction3(char p) at 0x340;
1090 \newline
1091
1092 \end_layout
1093
1094 \begin_layout Standard
1095
1096 \family typewriter
1097 better code banking
1098 \begin_inset LatexCommand \index{code banking (limited support)}
1099
1100 \end_inset
1101
1102  support for mcs51
1103 \newline
1104
1105 \newline
1106
1107 \family default
1108 If you can think of some more, please see the section 
1109 \begin_inset LatexCommand \ref{sub:Requesting-Features}
1110
1111 \end_inset
1112
1113  about filing feature requests
1114 \begin_inset LatexCommand \index{Requesting features}
1115
1116 \end_inset
1117
1118
1119 \begin_inset LatexCommand \index{Feature request}
1120
1121 \end_inset
1122
1123 .
1124 \newline
1125
1126 \end_layout
1127
1128 \begin_layout Chapter
1129 Installing SDCC
1130 \begin_inset LatexCommand \index{Installation}
1131
1132 \end_inset
1133
1134
1135 \end_layout
1136
1137 \begin_layout Standard
1138 For most users it is sufficient to skip to either section 
1139 \begin_inset LatexCommand \ref{sub:Building-SDCC-on-Linux}
1140
1141 \end_inset
1142
1143  (Unix) or section 
1144 \begin_inset LatexCommand \ref{sub:Windows-Install}
1145
1146 \end_inset
1147
1148  (Windows).
1149  More detailed instructions follow below.
1150 \end_layout
1151
1152 \begin_layout Section
1153 Configure Options
1154 \begin_inset LatexCommand \index{Options SDCC configuration}
1155
1156 \end_inset
1157
1158
1159 \end_layout
1160
1161 \begin_layout Standard
1162 The install paths, search paths and other options are defined when running
1163  'configure'.
1164  The defaults can be overridden by:
1165 \end_layout
1166
1167 \begin_layout List
1168 \labelwidthstring 00.00.0000
1169 -
1170 \begin_inset ERT
1171 status collapsed
1172
1173 \begin_layout Standard
1174
1175
1176 \backslash
1177 /
1178 \end_layout
1179
1180 \end_inset
1181
1182 -prefix see table below
1183 \end_layout
1184
1185 \begin_layout List
1186 \labelwidthstring 00.00.0000
1187 -
1188 \begin_inset ERT
1189 status collapsed
1190
1191 \begin_layout Standard
1192
1193
1194 \backslash
1195 /
1196 \end_layout
1197
1198 \end_inset
1199
1200 -exec_prefix see table below
1201 \end_layout
1202
1203 \begin_layout List
1204 \labelwidthstring 00.00.0000
1205 -
1206 \begin_inset ERT
1207 status collapsed
1208
1209 \begin_layout Standard
1210
1211
1212 \backslash
1213 /
1214 \end_layout
1215
1216 \end_inset
1217
1218 -bindir see table below
1219 \end_layout
1220
1221 \begin_layout List
1222 \labelwidthstring 00.00.0000
1223 -
1224 \begin_inset ERT
1225 status collapsed
1226
1227 \begin_layout Standard
1228
1229
1230 \backslash
1231 /
1232 \end_layout
1233
1234 \end_inset
1235
1236 -datadir see table below
1237 \end_layout
1238
1239 \begin_layout List
1240 \labelwidthstring 00.00.0000
1241 -
1242 \begin_inset ERT
1243 status collapsed
1244
1245 \begin_layout Standard
1246
1247
1248 \backslash
1249 /
1250 \end_layout
1251
1252 \end_inset
1253
1254 -datarootdir see table below
1255 \newline
1256
1257 \end_layout
1258
1259 \begin_layout List
1260 \labelwidthstring 00.00.0000
1261 \InsetSpace ~
1262 \InsetSpace ~
1263 docdir environment variable, see table below
1264 \end_layout
1265
1266 \begin_layout List
1267 \labelwidthstring 00.00.0000
1268 \InsetSpace ~
1269 \InsetSpace ~
1270 include_dir_suffix environment variable, see table below
1271 \end_layout
1272
1273 \begin_layout List
1274 \labelwidthstring 00.00.0000
1275 \InsetSpace ~
1276 \InsetSpace ~
1277 lib_dir_suffix environment variable, see table below
1278 \end_layout
1279
1280 \begin_layout List
1281 \labelwidthstring 00.00.0000
1282 \InsetSpace ~
1283 \InsetSpace ~
1284 sdccconf_h_dir_separator environment variable, either / or 
1285 \backslash
1286
1287 \backslash
1288  makes sense here.
1289  This character will only be used in sdccconf.h; don't forget it's a C-header,
1290  therefore a double-backslash is needed there.
1291 \newline
1292
1293 \end_layout
1294
1295 \begin_layout List
1296 \labelwidthstring 00.00.0000
1297 -
1298 \begin_inset ERT
1299 status collapsed
1300
1301 \begin_layout Standard
1302
1303
1304 \backslash
1305 /
1306 \end_layout
1307
1308 \end_inset
1309
1310 -disable-mcs51-port Excludes the Intel mcs51 port
1311 \end_layout
1312
1313 \begin_layout List
1314 \labelwidthstring 00.00.0000
1315 -
1316 \begin_inset ERT
1317 status collapsed
1318
1319 \begin_layout Standard
1320
1321
1322 \backslash
1323 /
1324 \end_layout
1325
1326 \end_inset
1327
1328 -disable-gbz80-port Excludes the Gameboy gbz80 port
1329 \end_layout
1330
1331 \begin_layout List
1332 \labelwidthstring 00.00.0000
1333 -
1334 \begin_inset ERT
1335 status collapsed
1336
1337 \begin_layout Standard
1338
1339
1340 \backslash
1341 /
1342 \end_layout
1343
1344 \end_inset
1345
1346 -disable-z80-port Excludes the z80 port
1347 \end_layout
1348
1349 \begin_layout List
1350 \labelwidthstring 00.00.0000
1351 -
1352 \begin_inset ERT
1353 status collapsed
1354
1355 \begin_layout Standard
1356
1357
1358 \backslash
1359 /
1360 \end_layout
1361
1362 \end_inset
1363
1364 -disable-avr-port Excludes the AVR port
1365 \end_layout
1366
1367 \begin_layout List
1368 \labelwidthstring 00.00.0000
1369 -
1370 \begin_inset ERT
1371 status collapsed
1372
1373 \begin_layout Standard
1374
1375
1376 \backslash
1377 /
1378 \end_layout
1379
1380 \end_inset
1381
1382 -disable-ds390-port Excludes the DS390 port
1383 \end_layout
1384
1385 \begin_layout List
1386 \labelwidthstring 00.00.0000
1387 -
1388 \begin_inset ERT
1389 status collapsed
1390
1391 \begin_layout Standard
1392
1393
1394 \backslash
1395 /
1396 \end_layout
1397
1398 \end_inset
1399
1400 -disable-hc08-port Excludes the HC08 port
1401 \end_layout
1402
1403 \begin_layout List
1404 \labelwidthstring 00.00.0000
1405 -
1406 \begin_inset ERT
1407 status collapsed
1408
1409 \begin_layout Standard
1410
1411
1412 \backslash
1413 /
1414 \end_layout
1415
1416 \end_inset
1417
1418 -disable-pic-port Excludes the PIC14 port
1419 \end_layout
1420
1421 \begin_layout List
1422 \labelwidthstring 00.00.0000
1423 -
1424 \begin_inset ERT
1425 status collapsed
1426
1427 \begin_layout Standard
1428
1429
1430 \backslash
1431 /
1432 \end_layout
1433
1434 \end_inset
1435
1436 -disable-pic16-port Excludes the PIC16 port
1437 \end_layout
1438
1439 \begin_layout List
1440 \labelwidthstring 00.00.0000
1441 -
1442 \begin_inset ERT
1443 status collapsed
1444
1445 \begin_layout Standard
1446
1447
1448 \backslash
1449 /
1450 \end_layout
1451
1452 \end_inset
1453
1454 -disable-xa51-port Excludes the XA51 port
1455 \end_layout
1456
1457 \begin_layout List
1458 \labelwidthstring 00.00.0000
1459 -
1460 \begin_inset ERT
1461 status collapsed
1462
1463 \begin_layout Standard
1464
1465
1466 \backslash
1467 /
1468 \end_layout
1469
1470 \end_inset
1471
1472 -disable-ucsim Disables configuring and building of ucsim
1473 \end_layout
1474
1475 \begin_layout List
1476 \labelwidthstring 00.00.0000
1477 -
1478 \begin_inset ERT
1479 status collapsed
1480
1481 \begin_layout Standard
1482
1483
1484 \backslash
1485 /
1486 \end_layout
1487
1488 \end_inset
1489
1490 -disable-device-lib Disables automatically building device libraries
1491 \end_layout
1492
1493 \begin_layout List
1494 \labelwidthstring 00.00.0000
1495 -
1496 \begin_inset ERT
1497 status collapsed
1498
1499 \begin_layout Standard
1500
1501
1502 \backslash
1503 /
1504 \end_layout
1505
1506 \end_inset
1507
1508 -disable-packihx Disables building packihx
1509 \newline
1510
1511 \end_layout
1512
1513 \begin_layout List
1514 \labelwidthstring 00.00.0000
1515 -
1516 \begin_inset ERT
1517 status collapsed
1518
1519 \begin_layout Standard
1520
1521
1522 \backslash
1523 /
1524 \end_layout
1525
1526 \end_inset
1527
1528 -enable-doc Build pdf, html and txt files from the lyx sources
1529 \end_layout
1530
1531 \begin_layout List
1532 \labelwidthstring 00.00.0000
1533 -
1534 \begin_inset ERT
1535 status collapsed
1536
1537 \begin_layout Standard
1538
1539
1540 \backslash
1541 /
1542 \end_layout
1543
1544 \end_inset
1545
1546 -enable-libgc Use the Bohem memory allocator.
1547  Lower runtime footprint.
1548 \end_layout
1549
1550 \begin_layout Standard
1551 Furthermore the environment variables CC, CFLAGS, ...
1552  the tools and their arguments can be influenced.
1553  Please see `configure -
1554 \begin_inset ERT
1555 status collapsed
1556
1557 \begin_layout Standard
1558
1559
1560 \backslash
1561 /
1562 \end_layout
1563
1564 \end_inset
1565
1566 -help' and the man/info pages of `configure' for details.
1567 \newline
1568
1569 \newline
1570 The names of the
1571  standard libraries STD_LIB, STD_INT_LIB, STD_LONG_LIB, STD_FP_LIB, STD_DS390_LI
1572 B, STD_XA51_LIB and the environment variables SDCC_DIR_NAME, SDCC_INCLUDE_NAME,
1573  SDCC_LIB_NAME are defined by `configure' too.
1574  At the moment it's not possible to change the default settings (it was
1575  simply never required).
1576 \newline
1577
1578 \newline
1579 These configure options are compiled into the binaries,
1580  and can only be changed by rerunning 'configure' and recompiling SDCC.
1581  The configure options are written in 
1582 \emph on
1583 italics
1584 \emph default
1585  to distinguish them from run time environment variables (see section search
1586  paths).
1587 \newline
1588
1589 \newline
1590 The settings for 
1591 \begin_inset Quotes sld
1592 \end_inset
1593
1594 Win32 builds
1595 \begin_inset Quotes srd
1596 \end_inset
1597
1598  are used by the SDCC team to build the official Win32 binaries.
1599  The SDCC team uses Mingw32 to build the official Windows binaries, because
1600  it's
1601 \end_layout
1602
1603 \begin_layout Enumerate
1604 open source, 
1605 \end_layout
1606
1607 \begin_layout Enumerate
1608 a gcc compiler and last but not least
1609 \end_layout
1610
1611 \begin_layout Enumerate
1612 the binaries can be built by cross compiling on SDCC Distributed Compile
1613  Farm.
1614 \end_layout
1615
1616 \begin_layout Standard
1617 See the examples, how to pass the Win32 settings to 'configure'.
1618  The other Win32 builds using Borland, VC or whatever don't use 'configure',
1619  but a header file sdcc_vc_in.h is the same as sdccconf.h built by 'configure'
1620  for Win32.
1621 \newline
1622
1623 \newline
1624 These defaults are:
1625 \newline
1626
1627 \end_layout
1628
1629 \begin_layout Standard
1630 \align center
1631 \begin_inset Tabular
1632 <lyxtabular version="3" rows="9" columns="3">
1633 <features>
1634 <column alignment="block" valignment="top" leftline="true" width="0in">
1635 <column alignment="block" valignment="top" leftline="true" width="0in">
1636 <column alignment="block" valignment="top" leftline="true" rightline="true" width="0in">
1637 <row topline="true" bottomline="true">
1638 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1639 \begin_inset Text
1640
1641 \begin_layout Standard
1642 Variable
1643 \end_layout
1644
1645 \end_inset
1646 </cell>
1647 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1648 \begin_inset Text
1649
1650 \begin_layout Standard
1651 default
1652 \end_layout
1653
1654 \end_inset
1655 </cell>
1656 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1657 \begin_inset Text
1658
1659 \begin_layout Standard
1660 Win32 builds
1661 \end_layout
1662
1663 \end_inset
1664 </cell>
1665 </row>
1666 <row topline="true">
1667 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1668 \begin_inset Text
1669
1670 \begin_layout Standard
1671
1672 \emph on
1673 PREFIX
1674 \end_layout
1675
1676 \end_inset
1677 </cell>
1678 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1679 \begin_inset Text
1680
1681 \begin_layout Standard
1682 /usr/local
1683 \end_layout
1684
1685 \end_inset
1686 </cell>
1687 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1688 \begin_inset Text
1689
1690 \begin_layout Standard
1691
1692 \backslash
1693 sdcc
1694 \end_layout
1695
1696 \end_inset
1697 </cell>
1698 </row>
1699 <row topline="true">
1700 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1701 \begin_inset Text
1702
1703 \begin_layout Standard
1704
1705 \emph on
1706 EXEC_PREFIX
1707 \end_layout
1708
1709 \end_inset
1710 </cell>
1711 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1712 \begin_inset Text
1713
1714 \begin_layout Standard
1715
1716 \emph on
1717 $PREFIX
1718 \end_layout
1719
1720 \end_inset
1721 </cell>
1722 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1723 \begin_inset Text
1724
1725 \begin_layout Standard
1726
1727 \emph on
1728 $PREFIX
1729 \end_layout
1730
1731 \end_inset
1732 </cell>
1733 </row>
1734 <row topline="true">
1735 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1736 \begin_inset Text
1737
1738 \begin_layout Standard
1739
1740 \emph on
1741 BINDIR
1742 \end_layout
1743
1744 \end_inset
1745 </cell>
1746 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1747 \begin_inset Text
1748
1749 \begin_layout Standard
1750
1751 \emph on
1752 $EXEC_PREFIX
1753 \emph default
1754 /bin
1755 \end_layout
1756
1757 \end_inset
1758 </cell>
1759 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1760 \begin_inset Text
1761
1762 \begin_layout Standard
1763
1764 \emph on
1765 $EXEC_PREFIX
1766 \emph default
1767
1768 \backslash
1769 bin
1770 \end_layout
1771
1772 \end_inset
1773 </cell>
1774 </row>
1775 <row topline="true">
1776 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1777 \begin_inset Text
1778
1779 \begin_layout Standard
1780
1781 \emph on
1782 DATADIR
1783 \end_layout
1784
1785 \end_inset
1786 </cell>
1787 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1788 \begin_inset Text
1789
1790 \begin_layout Standard
1791
1792 \emph on
1793 $DATAROOTDIR
1794 \end_layout
1795
1796 \end_inset
1797 </cell>
1798 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1799 \begin_inset Text
1800
1801 \begin_layout Standard
1802
1803 \emph on
1804 $DATAROOTDIR
1805 \end_layout
1806
1807 \end_inset
1808 </cell>
1809 </row>
1810 <row topline="true">
1811 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1812 \begin_inset Text
1813
1814 \begin_layout Standard
1815
1816 \emph on
1817 DATAROOTDIR
1818 \end_layout
1819
1820 \end_inset
1821 </cell>
1822 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1823 \begin_inset Text
1824
1825 \begin_layout Standard
1826
1827 \emph on
1828 $PREFIX
1829 \emph default
1830 /share
1831 \end_layout
1832
1833 \end_inset
1834 </cell>
1835 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1836 \begin_inset Text
1837
1838 \begin_layout Standard
1839
1840 \emph on
1841 $PREFIX
1842 \end_layout
1843
1844 \end_inset
1845 </cell>
1846 </row>
1847 <row topline="true">
1848 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1849 \begin_inset Text
1850
1851 \begin_layout Standard
1852
1853 \emph on
1854 DOCDIR
1855 \end_layout
1856
1857 \end_inset
1858 </cell>
1859 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1860 \begin_inset Text
1861
1862 \begin_layout Standard
1863
1864 \emph on
1865 $DATAROOTDIR
1866 \emph default
1867 /sdcc/doc
1868 \end_layout
1869
1870 \end_inset
1871 </cell>
1872 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1873 \begin_inset Text
1874
1875 \begin_layout Standard
1876
1877 \emph on
1878 $DATAROOTDIR
1879 \emph default
1880
1881 \backslash
1882 doc
1883 \end_layout
1884
1885 \end_inset
1886 </cell>
1887 </row>
1888 <row topline="true">
1889 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1890 \begin_inset Text
1891
1892 \begin_layout Standard
1893
1894 \emph on
1895 INCLUDE_DIR_SUFFIX
1896 \end_layout
1897
1898 \end_inset
1899 </cell>
1900 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1901 \begin_inset Text
1902
1903 \begin_layout Standard
1904 sdcc/include
1905 \end_layout
1906
1907 \end_inset
1908 </cell>
1909 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1910 \begin_inset Text
1911
1912 \begin_layout Standard
1913 include
1914 \end_layout
1915
1916 \end_inset
1917 </cell>
1918 </row>
1919 <row topline="true" bottomline="true">
1920 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1921 \begin_inset Text
1922
1923 \begin_layout Standard
1924
1925 \emph on
1926 LIB_DIR_SUFFIX
1927 \end_layout
1928
1929 \end_inset
1930 </cell>
1931 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1932 \begin_inset Text
1933
1934 \begin_layout Standard
1935 sdcc/lib
1936 \end_layout
1937
1938 \end_inset
1939 </cell>
1940 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1941 \begin_inset Text
1942
1943 \begin_layout Standard
1944 lib
1945 \end_layout
1946
1947 \end_inset
1948 </cell>
1949 </row>
1950 </lyxtabular>
1951
1952 \end_inset
1953
1954
1955 \newline
1956
1957 \end_layout
1958
1959 \begin_layout Standard
1960 \noindent
1961 'configure' also computes relative paths.
1962  This is needed for full relocatability of a binary package and to complete
1963  search paths (see section search paths below):
1964 \newline
1965  
1966 \end_layout
1967
1968 \begin_layout Standard
1969 \align center
1970 \begin_inset Tabular
1971 <lyxtabular version="3" rows="4" columns="3">
1972 <features>
1973 <column alignment="block" valignment="top" leftline="true" width="0in">
1974 <column alignment="block" valignment="top" leftline="true" width="0in">
1975 <column alignment="block" valignment="top" leftline="true" rightline="true" width="0in">
1976 <row topline="true" bottomline="true">
1977 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1978 \begin_inset Text
1979
1980 \begin_layout Standard
1981 Variable (computed)
1982 \end_layout
1983
1984 \end_inset
1985 </cell>
1986 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1987 \begin_inset Text
1988
1989 \begin_layout Standard
1990 default
1991 \end_layout
1992
1993 \end_inset
1994 </cell>
1995 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
1996 \begin_inset Text
1997
1998 \begin_layout Standard
1999 Win32 builds
2000 \end_layout
2001
2002 \end_inset
2003 </cell>
2004 </row>
2005 <row topline="true" bottomline="true">
2006 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2007 \begin_inset Text
2008
2009 \begin_layout Standard
2010
2011 \emph on
2012 BIN2DATA_DIR
2013 \end_layout
2014
2015 \end_inset
2016 </cell>
2017 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2018 \begin_inset Text
2019
2020 \begin_layout Standard
2021 ../share
2022 \end_layout
2023
2024 \end_inset
2025 </cell>
2026 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2027 \begin_inset Text
2028
2029 \begin_layout Standard
2030 ..
2031 \end_layout
2032
2033 \end_inset
2034 </cell>
2035 </row>
2036 <row bottomline="true">
2037 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2038 \begin_inset Text
2039
2040 \begin_layout Standard
2041
2042 \emph on
2043 PREFIX2BIN_DIR
2044 \end_layout
2045
2046 \end_inset
2047 </cell>
2048 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2049 \begin_inset Text
2050
2051 \begin_layout Standard
2052 bin
2053 \end_layout
2054
2055 \end_inset
2056 </cell>
2057 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2058 \begin_inset Text
2059
2060 \begin_layout Standard
2061 bin
2062 \end_layout
2063
2064 \end_inset
2065 </cell>
2066 </row>
2067 <row bottomline="true">
2068 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2069 \begin_inset Text
2070
2071 \begin_layout Standard
2072
2073 \emph on
2074 PREFIX2DATA_DIR
2075 \end_layout
2076
2077 \end_inset
2078 </cell>
2079 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2080 \begin_inset Text
2081
2082 \begin_layout Standard
2083 share/sdcc
2084 \end_layout
2085
2086 \end_inset
2087 </cell>
2088 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2089 \begin_inset Text
2090
2091 \begin_layout Standard
2092
2093 \end_layout
2094
2095 \end_inset
2096 </cell>
2097 </row>
2098 </lyxtabular>
2099
2100 \end_inset
2101
2102
2103 \newline
2104
2105 \end_layout
2106
2107 \begin_layout Standard
2108 \noindent
2109 Examples:
2110 \end_layout
2111
2112 \begin_layout LyX-Code
2113 ./configure
2114 \newline
2115 ./configure -
2116 \begin_inset ERT
2117 status collapsed
2118
2119 \begin_layout Standard
2120
2121
2122 \backslash
2123 /
2124 \end_layout
2125
2126 \end_inset
2127
2128 -prefix=
2129 \begin_inset Quotes srd
2130 \end_inset
2131
2132 /usr/bin
2133 \begin_inset Quotes srd
2134 \end_inset
2135
2136  -
2137 \begin_inset ERT
2138 status collapsed
2139
2140 \begin_layout Standard
2141
2142
2143 \backslash
2144 /
2145 \end_layout
2146
2147 \end_inset
2148
2149 -datarootdir=
2150 \begin_inset Quotes srd
2151 \end_inset
2152
2153 /usr/share
2154 \begin_inset Quotes srd
2155 \end_inset
2156
2157
2158 \newline
2159 ./configure -
2160 \begin_inset ERT
2161 status collapsed
2162
2163 \begin_layout Standard
2164
2165
2166 \backslash
2167 /
2168 \end_layout
2169
2170 \end_inset
2171
2172 -disable-avr-port -
2173 \begin_inset ERT
2174 status collapsed
2175
2176 \begin_layout Standard
2177
2178
2179 \backslash
2180 /
2181 \end_layout
2182
2183 \end_inset
2184
2185 -disable-xa51-port
2186 \end_layout
2187
2188 \begin_layout Standard
2189 To cross compile on linux for Mingw32 (see also 'sdcc/support/scripts/sdcc_mingw
2190 32'):
2191 \end_layout
2192
2193 \begin_layout LyX-Code
2194 ./configure 
2195 \backslash
2196
2197 \newline
2198 CC=
2199 \begin_inset Quotes srd
2200 \end_inset
2201
2202 i586-mingw32msvc-gcc
2203 \begin_inset Quotes srd
2204 \end_inset
2205
2206  CXX=
2207 \begin_inset Quotes srd
2208 \end_inset
2209
2210 i586-mingw32msvc-g++
2211 \begin_inset Quotes srd
2212 \end_inset
2213
2214  
2215 \backslash
2216  
2217 \newline
2218 RANLIB=
2219 \begin_inset Quotes srd
2220 \end_inset
2221
2222 i586-mingw32msvc-ranlib
2223 \begin_inset Quotes srd
2224 \end_inset
2225
2226  
2227 \backslash
2228
2229 \newline
2230 STRIP=
2231 \begin_inset Quotes srd
2232 \end_inset
2233
2234 i586-mingw32msvc-strip
2235 \begin_inset Quotes srd
2236 \end_inset
2237
2238  
2239 \backslash
2240
2241 \newline
2242 -
2243 \begin_inset ERT
2244 status collapsed
2245
2246 \begin_layout Standard
2247
2248
2249 \backslash
2250 /
2251 \end_layout
2252
2253 \end_inset
2254
2255 -prefix=
2256 \begin_inset Quotes srd
2257 \end_inset
2258
2259 /sdcc
2260 \begin_inset Quotes srd
2261 \end_inset
2262
2263  
2264 \backslash
2265
2266 \newline
2267 -
2268 \begin_inset ERT
2269 status collapsed
2270
2271 \begin_layout Standard
2272
2273
2274 \backslash
2275 /
2276 \end_layout
2277
2278 \end_inset
2279
2280 -datarootdir=
2281 \begin_inset Quotes srd
2282 \end_inset
2283
2284 /sdcc
2285 \begin_inset Quotes srd
2286 \end_inset
2287
2288  
2289 \backslash
2290
2291 \newline
2292 docdir=
2293 \begin_inset Quotes srd
2294 \end_inset
2295
2296
2297 \backslash
2298 ${datarootdir}/doc
2299 \begin_inset Quotes srd
2300 \end_inset
2301
2302  
2303 \backslash
2304
2305 \newline
2306 include_dir_suffix=
2307 \begin_inset Quotes srd
2308 \end_inset
2309
2310 include
2311 \begin_inset Quotes srd
2312 \end_inset
2313
2314  
2315 \backslash
2316
2317 \newline
2318 lib_dir_suffix=
2319 \begin_inset Quotes srd
2320 \end_inset
2321
2322 lib
2323 \begin_inset Quotes srd
2324 \end_inset
2325
2326  
2327 \backslash
2328
2329 \newline
2330 sdccconf_h_dir_separator=
2331 \begin_inset Quotes srd
2332 \end_inset
2333
2334
2335 \backslash
2336
2337 \backslash
2338
2339 \backslash
2340
2341 \backslash
2342
2343 \begin_inset Quotes srd
2344 \end_inset
2345
2346  
2347 \backslash
2348
2349 \newline
2350 -
2351 \begin_inset ERT
2352 status collapsed
2353
2354 \begin_layout Standard
2355
2356
2357 \backslash
2358 /
2359 \end_layout
2360
2361 \end_inset
2362
2363 -disable-device-lib
2364 \backslash
2365
2366 \newline
2367 -
2368 \begin_inset ERT
2369 status collapsed
2370
2371 \begin_layout Standard
2372
2373
2374 \backslash
2375 /
2376 \end_layout
2377
2378 \end_inset
2379
2380 -host=i586-mingw32msvc
2381 \backslash
2382
2383 \newline
2384 -
2385 \begin_inset ERT
2386 status collapsed
2387
2388 \begin_layout Standard
2389
2390
2391 \backslash
2392 /
2393 \end_layout
2394
2395 \end_inset
2396
2397 -build=unknown-unknown-linux-gnu
2398 \end_layout
2399
2400 \begin_layout Standard
2401 To 
2402 \begin_inset Quotes sld
2403 \end_inset
2404
2405 cross
2406 \begin_inset Quotes srd
2407 \end_inset
2408
2409 compile on Cygwin for Mingw32 (see also sdcc/support/scripts/sdcc_cygwin_mingw32
2410 ):
2411 \end_layout
2412
2413 \begin_layout LyX-Code
2414 ./configure -C 
2415 \backslash
2416
2417 \newline
2418 -
2419 \begin_inset ERT
2420 status collapsed
2421
2422 \begin_layout Standard
2423
2424
2425 \backslash
2426 /
2427 \end_layout
2428
2429 \end_inset
2430
2431 -prefix=
2432 \begin_inset Quotes srd
2433 \end_inset
2434
2435 /sdcc
2436 \begin_inset Quotes srd
2437 \end_inset
2438
2439  
2440 \backslash
2441
2442 \newline
2443 -
2444 \begin_inset ERT
2445 status collapsed
2446
2447 \begin_layout Standard
2448
2449
2450 \backslash
2451 /
2452 \end_layout
2453
2454 \end_inset
2455
2456 -datarootdir=
2457 \begin_inset Quotes srd
2458 \end_inset
2459
2460 /sdcc
2461 \begin_inset Quotes srd
2462 \end_inset
2463
2464  
2465 \backslash
2466
2467 \newline
2468 docdir=
2469 \begin_inset Quotes srd
2470 \end_inset
2471
2472
2473 \backslash
2474 ${datarootdir}/doc
2475 \begin_inset Quotes srd
2476 \end_inset
2477
2478  
2479 \backslash
2480  
2481 \newline
2482 include_dir_suffix=
2483 \begin_inset Quotes srd
2484 \end_inset
2485
2486 include
2487 \begin_inset Quotes srd
2488 \end_inset
2489
2490  
2491 \backslash
2492
2493 \newline
2494 lib_dir_suffix=
2495 \begin_inset Quotes srd
2496 \end_inset
2497
2498 lib
2499 \begin_inset Quotes srd
2500 \end_inset
2501
2502  
2503 \backslash
2504
2505 \newline
2506 sdccconf_h_dir_separator=
2507 \begin_inset Quotes srd
2508 \end_inset
2509
2510
2511 \backslash
2512
2513 \backslash
2514
2515 \backslash
2516
2517 \backslash
2518
2519 \begin_inset Quotes srd
2520 \end_inset
2521
2522  
2523 \backslash
2524
2525 \newline
2526 CC=
2527 \begin_inset Quotes srd
2528 \end_inset
2529
2530 gcc -mno-cygwin
2531 \begin_inset Quotes srd
2532 \end_inset
2533
2534  
2535 \backslash
2536
2537 \newline
2538 CXX=
2539 \begin_inset Quotes srd
2540 \end_inset
2541
2542 g++ -mno-cygwin
2543 \begin_inset Quotes srd
2544 \end_inset
2545
2546  
2547 \end_layout
2548
2549 \begin_layout Standard
2550 'configure' is quite slow on Cygwin (at least on windows before Win2000/XP).
2551  The option '-
2552 \begin_inset ERT
2553 status collapsed
2554
2555 \begin_layout Standard
2556
2557
2558 \backslash
2559 /
2560 \end_layout
2561
2562 \end_inset
2563
2564 -C' turns on caching, which gives a little bit extra speed.
2565  However if options are changed, it can be necessary to delete the config.cache
2566  file.
2567 \end_layout
2568
2569 \begin_layout Section
2570 Install paths
2571 \begin_inset LatexCommand \label{sub:Install-paths}
2572
2573 \end_inset
2574
2575
2576 \begin_inset LatexCommand \index{Install paths}
2577
2578 \end_inset
2579
2580
2581 \end_layout
2582
2583 \begin_layout Standard
2584 \begin_inset VSpace medskip
2585 \end_inset
2586
2587
2588 \end_layout
2589
2590 \begin_layout Standard
2591 \align center
2592 \begin_inset Tabular
2593 <lyxtabular version="3" rows="5" columns="4">
2594 <features>
2595 <column alignment="left" valignment="top" leftline="true" width="0">
2596 <column alignment="left" valignment="top" leftline="true" width="0">
2597 <column alignment="left" valignment="top" leftline="true" width="0">
2598 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0">
2599 <row topline="true" bottomline="true">
2600 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2601 \begin_inset Text
2602
2603 \begin_layout Standard
2604
2605 \series bold
2606 Description
2607 \end_layout
2608
2609 \end_inset
2610 </cell>
2611 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2612 \begin_inset Text
2613
2614 \begin_layout Standard
2615
2616 \series bold
2617 Path
2618 \end_layout
2619
2620 \end_inset
2621 </cell>
2622 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2623 \begin_inset Text
2624
2625 \begin_layout Standard
2626
2627 \series bold
2628 Default
2629 \end_layout
2630
2631 \end_inset
2632 </cell>
2633 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2634 \begin_inset Text
2635
2636 \begin_layout Standard
2637
2638 \series bold
2639 Win32 builds
2640 \end_layout
2641
2642 \end_inset
2643 </cell>
2644 </row>
2645 <row topline="true">
2646 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2647 \begin_inset Text
2648
2649 \begin_layout Standard
2650 Binary files*
2651 \end_layout
2652
2653 \end_inset
2654 </cell>
2655 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2656 \begin_inset Text
2657
2658 \begin_layout Standard
2659
2660 \emph on
2661 $EXEC_PREFIX
2662 \end_layout
2663
2664 \end_inset
2665 </cell>
2666 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2667 \begin_inset Text
2668
2669 \begin_layout Standard
2670 /usr/local/bin
2671 \end_layout
2672
2673 \end_inset
2674 </cell>
2675 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2676 \begin_inset Text
2677
2678 \begin_layout Standard
2679
2680 \backslash
2681 sdcc
2682 \backslash
2683 bin
2684 \end_layout
2685
2686 \end_inset
2687 </cell>
2688 </row>
2689 <row topline="true">
2690 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2691 \begin_inset Text
2692
2693 \begin_layout Standard
2694 Include files
2695 \end_layout
2696
2697 \end_inset
2698 </cell>
2699 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2700 \begin_inset Text
2701
2702 \begin_layout Standard
2703
2704 \emph on
2705 $DATADIR/ $INCLUDE_DIR_SUFFIX
2706 \end_layout
2707
2708 \end_inset
2709 </cell>
2710 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2711 \begin_inset Text
2712
2713 \begin_layout Standard
2714 /usr/local/share/sdcc/include
2715 \end_layout
2716
2717 \end_inset
2718 </cell>
2719 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2720 \begin_inset Text
2721
2722 \begin_layout Standard
2723
2724 \backslash
2725 sdcc
2726 \backslash
2727 include
2728 \end_layout
2729
2730 \end_inset
2731 </cell>
2732 </row>
2733 <row topline="true">
2734 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2735 \begin_inset Text
2736
2737 \begin_layout Standard
2738 Library file**
2739 \end_layout
2740
2741 \end_inset
2742 </cell>
2743 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2744 \begin_inset Text
2745
2746 \begin_layout Standard
2747
2748 \emph on
2749 $DATADIR/$LIB_DIR_SUFFIX
2750 \end_layout
2751
2752 \end_inset
2753 </cell>
2754 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2755 \begin_inset Text
2756
2757 \begin_layout Standard
2758 /usr/local/share/sdcc/lib
2759 \end_layout
2760
2761 \end_inset
2762 </cell>
2763 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2764 \begin_inset Text
2765
2766 \begin_layout Standard
2767
2768 \backslash
2769 sdcc
2770 \backslash
2771 lib
2772 \end_layout
2773
2774 \end_inset
2775 </cell>
2776 </row>
2777 <row topline="true" bottomline="true">
2778 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2779 \begin_inset Text
2780
2781 \begin_layout Standard
2782 Documentation
2783 \end_layout
2784
2785 \end_inset
2786 </cell>
2787 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2788 \begin_inset Text
2789
2790 \begin_layout Standard
2791
2792 \emph on
2793 $DOCDIR
2794 \end_layout
2795
2796 \end_inset
2797 </cell>
2798 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2799 \begin_inset Text
2800
2801 \begin_layout Standard
2802 /usr/local/share/sdcc/doc
2803 \end_layout
2804
2805 \end_inset
2806 </cell>
2807 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2808 \begin_inset Text
2809
2810 \begin_layout Standard
2811
2812 \backslash
2813 sdcc
2814 \backslash
2815 doc
2816 \end_layout
2817
2818 \end_inset
2819 </cell>
2820 </row>
2821 </lyxtabular>
2822
2823 \end_inset
2824
2825
2826 \end_layout
2827
2828 \begin_layout Verse
2829
2830 \size footnotesize
2831 *compiler, preprocessor, assembler, and linker
2832 \newline
2833 **the 
2834 \shape italic
2835 model
2836 \shape default
2837  is auto-appended by the compiler, e.g.
2838  small, large, z80, ds390 etc
2839 \end_layout
2840
2841 \begin_layout Standard
2842 \noindent
2843 The install paths can still be changed during `make install' with e.g.:
2844 \end_layout
2845
2846 \begin_layout LyX-Code
2847 make install prefix=$(HOME)/local/sdcc
2848 \end_layout
2849
2850 \begin_layout Standard
2851 Of course this doesn't change the search paths compiled into the binaries.
2852 \newline
2853
2854 \newline
2855 Moreove
2856 r the install path can be changed by defining DESTDIR
2857 \begin_inset LatexCommand \index{DESTDIR}
2858
2859 \end_inset
2860
2861 :
2862 \end_layout
2863
2864 \begin_layout LyX-Code
2865 make install DESTDIR=$(HOME)/sdcc.rpm/
2866 \end_layout
2867
2868 \begin_layout Standard
2869 Please note that DESTDIR must have a trailing slash!
2870 \end_layout
2871
2872 \begin_layout Section
2873 Search Paths
2874 \begin_inset LatexCommand \label{sub:Search-Paths}
2875
2876 \end_inset
2877
2878
2879 \begin_inset LatexCommand \index{Search path}
2880
2881 \end_inset
2882
2883
2884 \end_layout
2885
2886 \begin_layout Standard
2887 Some search paths or parts of them are determined by configure variables
2888  (in 
2889 \emph on
2890 italics
2891 \emph default
2892 , see section above).
2893  Further search paths are determined by environment variables during runtime.
2894  
2895 \newline
2896 The paths searched when running the compiler are as follows (the first
2897  catch wins):
2898 \newline
2899
2900 \newline
2901 1.
2902  Binary files (preprocessor, assembler and linker)
2903 \newline
2904
2905 \end_layout
2906
2907 \begin_layout Standard
2908 \align center
2909 \begin_inset Tabular
2910 <lyxtabular version="3" rows="4" columns="3">
2911 <features>
2912 <column alignment="block" valignment="top" leftline="true" width="0in">
2913 <column alignment="block" valignment="top" leftline="true" width="0in">
2914 <column alignment="block" valignment="top" leftline="true" rightline="true" width="0in">
2915 <row topline="true" bottomline="true">
2916 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2917 \begin_inset Text
2918
2919 \begin_layout Standard
2920 Search path
2921 \end_layout
2922
2923 \end_inset
2924 </cell>
2925 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2926 \begin_inset Text
2927
2928 \begin_layout Standard
2929 default
2930 \end_layout
2931
2932 \end_inset
2933 </cell>
2934 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2935 \begin_inset Text
2936
2937 \begin_layout Standard
2938 Win32 builds
2939 \end_layout
2940
2941 \end_inset
2942 </cell>
2943 </row>
2944 <row topline="true">
2945 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2946 \begin_inset Text
2947
2948 \begin_layout Standard
2949 $SDCC_HOME/
2950 \emph on
2951 $PPREFIX2BIN_DIR
2952 \end_layout
2953
2954 \end_inset
2955 </cell>
2956 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2957 \begin_inset Text
2958
2959 \begin_layout Standard
2960 $SDCC_HOME/bin
2961 \end_layout
2962
2963 \end_inset
2964 </cell>
2965 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2966 \begin_inset Text
2967
2968 \begin_layout Standard
2969 $SDCC_HOME
2970 \backslash
2971 bin
2972 \end_layout
2973
2974 \end_inset
2975 </cell>
2976 </row>
2977 <row topline="true">
2978 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2979 \begin_inset Text
2980
2981 \begin_layout Standard
2982 Path of argv[0] (if available)
2983 \end_layout
2984
2985 \end_inset
2986 </cell>
2987 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2988 \begin_inset Text
2989
2990 \begin_layout Standard
2991 Path of argv[0]
2992 \end_layout
2993
2994 \end_inset
2995 </cell>
2996 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2997 \begin_inset Text
2998
2999 \begin_layout Standard
3000 Path of argv[0]
3001 \end_layout
3002
3003 \end_inset
3004 </cell>
3005 </row>
3006 <row topline="true" bottomline="true">
3007 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3008 \begin_inset Text
3009
3010 \begin_layout Standard
3011 $PATH
3012 \end_layout
3013
3014 \end_inset
3015 </cell>
3016 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3017 \begin_inset Text
3018
3019 \begin_layout Standard
3020 $PATH
3021 \end_layout
3022
3023 \end_inset
3024 </cell>
3025 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3026 \begin_inset Text
3027
3028 \begin_layout Standard
3029 $PATH
3030 \end_layout
3031
3032 \end_inset
3033 </cell>
3034 </row>
3035 </lyxtabular>
3036
3037 \end_inset
3038
3039  
3040 \newline
3041
3042 \end_layout
3043
3044 \begin_layout Standard
3045 \noindent
3046 2.
3047  Include files
3048 \newline
3049
3050 \end_layout
3051
3052 \begin_layout Standard
3053 \align center
3054 \begin_inset Tabular
3055 <lyxtabular version="3" rows="6" columns="3">
3056 <features>
3057 <column alignment="block" valignment="top" leftline="true" width="1.5in">
3058 <column alignment="block" valignment="top" leftline="true" width="1.5in">
3059 <column alignment="block" valignment="top" leftline="true" rightline="true" width="0in">
3060 <row topline="true" bottomline="true">
3061 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3062 \begin_inset Text
3063
3064 \begin_layout Standard
3065 Search path
3066 \end_layout
3067
3068 \end_inset
3069 </cell>
3070 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3071 \begin_inset Text
3072
3073 \begin_layout Standard
3074 default
3075 \end_layout
3076
3077 \end_inset
3078 </cell>
3079 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3080 \begin_inset Text
3081
3082 \begin_layout Standard
3083 Win32 builds
3084 \end_layout
3085
3086 \end_inset
3087 </cell>
3088 </row>
3089 <row topline="true">
3090 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3091 \begin_inset Text
3092
3093 \begin_layout Standard
3094 -
3095 \begin_inset ERT
3096 status collapsed
3097
3098 \begin_layout Standard
3099
3100
3101 \backslash
3102 /
3103 \end_layout
3104
3105 \end_inset
3106
3107 -I dir
3108 \end_layout
3109
3110 \end_inset
3111 </cell>
3112 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3113 \begin_inset Text
3114
3115 \begin_layout Standard
3116 -
3117 \begin_inset ERT
3118 status collapsed
3119
3120 \begin_layout Standard
3121
3122
3123 \backslash
3124 /
3125 \end_layout
3126
3127 \end_inset
3128
3129 -I dir
3130 \end_layout
3131
3132 \end_inset
3133 </cell>
3134 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3135 \begin_inset Text
3136
3137 \begin_layout Standard
3138 -
3139 \begin_inset ERT
3140 status collapsed
3141
3142 \begin_layout Standard
3143
3144
3145 \backslash
3146 /
3147 \end_layout
3148
3149 \end_inset
3150
3151 -I dir
3152 \end_layout
3153
3154 \end_inset
3155 </cell>
3156 </row>
3157 <row topline="true">
3158 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3159 \begin_inset Text
3160
3161 \begin_layout Standard
3162 $SDCC_INCLUDE
3163 \end_layout
3164
3165 \end_inset
3166 </cell>
3167 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3168 \begin_inset Text
3169
3170 \begin_layout Standard
3171 $SDCC_INCLUDE
3172 \end_layout
3173
3174 \end_inset
3175 </cell>
3176 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3177 \begin_inset Text
3178
3179 \begin_layout Standard
3180 $SDCC_INCLUDE
3181 \end_layout
3182
3183 \end_inset
3184 </cell>
3185 </row>
3186 <row topline="true">
3187 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3188 \begin_inset Text
3189
3190 \begin_layout Standard
3191 $SDCC_HOME/
3192 \newline
3193
3194 \emph on
3195 $PREFIX2DATA_DIR/
3196 \newline
3197 $INCLUDE_DIR_SUFFIX
3198 \end_layout
3199
3200 \end_inset
3201 </cell>
3202 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3203 \begin_inset Text
3204
3205 \begin_layout Standard
3206 $SDCC_ HOME/
3207 \newline
3208 share/sdcc/
3209 \newline
3210 include
3211 \end_layout
3212
3213 \end_inset
3214 </cell>
3215 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3216 \begin_inset Text
3217
3218 \begin_layout Standard
3219 $SDCC_HOME
3220 \backslash
3221 include
3222 \end_layout
3223
3224 \end_inset
3225 </cell>
3226 </row>
3227 <row topline="true">
3228 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3229 \begin_inset Text
3230
3231 \begin_layout Standard
3232 path(argv[0])/
3233 \newline
3234
3235 \emph on
3236 $BIN2DATADIR/
3237 \emph default
3238
3239 \newline
3240
3241 \emph on
3242 $INCLUDE_DIR_SUFFIX
3243 \end_layout
3244
3245 \end_inset
3246 </cell>
3247 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3248 \begin_inset Text
3249
3250 \begin_layout Standard
3251 path(argv[0])/
3252 \newline
3253 ../sdcc/include
3254 \newline
3255 \InsetSpace ~
3256 \InsetSpace ~
3257 \InsetSpace ~
3258 \InsetSpace ~
3259 \InsetSpace ~
3260 \InsetSpace ~
3261 \InsetSpace ~
3262 \InsetSpace ~
3263 \InsetSpace ~
3264 \InsetSpace ~
3265 \InsetSpace ~
3266 \InsetSpace ~
3267 \InsetSpace ~
3268 \InsetSpace ~
3269 \InsetSpace ~
3270 \InsetSpace ~
3271 \InsetSpace ~
3272 \InsetSpace ~
3273 \InsetSpace ~
3274 \InsetSpace ~
3275 \InsetSpace ~
3276 \InsetSpace ~
3277 \InsetSpace ~
3278 \InsetSpace ~
3279 \InsetSpace ~
3280 \InsetSpace ~
3281 \InsetSpace ~
3282 \InsetSpace ~
3283 \InsetSpace ~
3284 \InsetSpace ~
3285 \InsetSpace ~
3286 \InsetSpace ~
3287 \InsetSpace ~
3288 \InsetSpace ~
3289 \InsetSpace ~
3290 \InsetSpace ~
3291 \InsetSpace ~
3292 \InsetSpace ~
3293
3294 \end_layout
3295
3296 \end_inset
3297 </cell>
3298 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3299 \begin_inset Text
3300
3301 \begin_layout Standard
3302 path(argv[0])
3303 \backslash
3304 ..
3305 \backslash
3306 include
3307 \end_layout
3308
3309 \end_inset
3310 </cell>
3311 </row>
3312 <row topline="true" bottomline="true">
3313 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3314 \begin_inset Text
3315
3316 \begin_layout Standard
3317
3318 \emph on
3319 $DATADIR/
3320 \emph default
3321
3322 \newline
3323
3324 \emph on
3325 $INCLUDE_DIR_SUFFIX
3326 \end_layout
3327
3328 \end_inset
3329 </cell>
3330 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3331 \begin_inset Text
3332
3333 \begin_layout Standard
3334 /usr/local/share/sdcc/
3335 \newline
3336 include
3337 \end_layout
3338
3339 \end_inset
3340 </cell>
3341 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3342 \begin_inset Text
3343
3344 \begin_layout Standard
3345 (not on Win32)
3346 \end_layout
3347
3348 \end_inset
3349 </cell>
3350 </row>
3351 </lyxtabular>
3352
3353 \end_inset
3354
3355  
3356 \newline
3357
3358 \end_layout
3359
3360 \begin_layout Standard
3361 \noindent
3362 The option -
3363 \begin_inset ERT
3364 status collapsed
3365
3366 \begin_layout Standard
3367
3368
3369 \backslash
3370 /
3371 \end_layout
3372
3373 \end_inset
3374
3375 -nostdinc disables the last two search paths.
3376 \newline
3377
3378 \newline
3379 3.
3380  Library files 
3381 \newline
3382
3383 \end_layout
3384
3385 \begin_layout Standard
3386 With the exception of 
3387 \begin_inset Quotes sld
3388 \end_inset
3389
3390 -
3391 \begin_inset ERT
3392 status collapsed
3393
3394 \begin_layout Standard
3395
3396
3397 \backslash
3398 /
3399 \end_layout
3400
3401 \end_inset
3402
3403 -L dir
3404 \begin_inset Quotes srd
3405 \end_inset
3406
3407  the 
3408 \shape italic
3409 model
3410 \shape default
3411  is auto-appended by the compiler (e.g.
3412  small, large, z80, ds390 etc.).
3413  
3414 \newline
3415
3416 \end_layout
3417
3418 \begin_layout Standard
3419 \align center
3420 \begin_inset Tabular
3421 <lyxtabular version="3" rows="6" columns="3">
3422 <features>
3423 <column alignment="block" valignment="top" leftline="true" width="1.7in">
3424 <column alignment="block" valignment="top" leftline="true" width="1.2in">
3425 <column alignment="block" valignment="top" leftline="true" rightline="true" width="1.2in">
3426 <row topline="true" bottomline="true">
3427 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3428 \begin_inset Text
3429
3430 \begin_layout Standard
3431 Search path
3432 \end_layout
3433
3434 \end_inset
3435 </cell>
3436 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3437 \begin_inset Text
3438
3439 \begin_layout Standard
3440 default
3441 \end_layout
3442
3443 \end_inset
3444 </cell>
3445 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3446 \begin_inset Text
3447
3448 \begin_layout Standard
3449 Win32 builds
3450 \end_layout
3451
3452 \end_inset
3453 </cell>
3454 </row>
3455 <row topline="true">
3456 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3457 \begin_inset Text
3458
3459 \begin_layout Standard
3460 -
3461 \begin_inset ERT
3462 status collapsed
3463
3464 \begin_layout Standard
3465
3466
3467 \backslash
3468 /
3469 \end_layout
3470
3471 \end_inset
3472
3473 -L dir
3474 \end_layout
3475
3476 \end_inset
3477 </cell>
3478 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3479 \begin_inset Text
3480
3481 \begin_layout Standard
3482 -
3483 \begin_inset ERT
3484 status collapsed
3485
3486 \begin_layout Standard
3487
3488
3489 \backslash
3490 /
3491 \end_layout
3492
3493 \end_inset
3494
3495 -L dir
3496 \end_layout
3497
3498 \end_inset
3499 </cell>
3500 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3501 \begin_inset Text
3502
3503 \begin_layout Standard
3504 -
3505 \begin_inset ERT
3506 status collapsed
3507
3508 \begin_layout Standard
3509
3510
3511 \backslash
3512 /
3513 \end_layout
3514
3515 \end_inset
3516
3517 -L dir
3518 \end_layout
3519
3520 \end_inset
3521 </cell>
3522 </row>
3523 <row topline="true">
3524 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3525 \begin_inset Text
3526
3527 \begin_layout Standard
3528 $SDCC_LIB/
3529 \newline
3530
3531 \emph on
3532 <model>
3533 \end_layout
3534
3535 \end_inset
3536 </cell>
3537 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3538 \begin_inset Text
3539
3540 \begin_layout Standard
3541 $SDCC_LIB/
3542 \newline
3543
3544 \emph on
3545 <model>
3546 \end_layout
3547
3548 \end_inset
3549 </cell>
3550 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3551 \begin_inset Text
3552
3553 \begin_layout Standard
3554 $SDCC_LIB
3555 \backslash
3556
3557 \newline
3558
3559 \emph on
3560 <model>
3561 \end_layout
3562
3563 \end_inset
3564 </cell>
3565 </row>
3566 <row topline="true">
3567 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3568 \begin_inset Text
3569
3570 \begin_layout Standard
3571 $SDCC_HOME/
3572 \newline
3573
3574 \emph on
3575 $PREFIX2DATA_DIR/
3576 \newline
3577 $LIB_DIR_SUFFIX/<model>
3578 \end_layout
3579
3580 \end_inset
3581 </cell>
3582 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3583 \begin_inset Text
3584
3585 \begin_layout Standard
3586 $SDCC_HOME/
3587 \newline
3588 share/sdcc/
3589 \newline
3590 lib/
3591 \emph on
3592 <model>
3593 \end_layout
3594
3595 \end_inset
3596 </cell>
3597 <cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3598 \begin_inset Text
3599
3600 \begin_layout Standard
3601 $SDCC_HOME
3602 \backslash
3603 lib
3604 \backslash
3605
3606 \emph on
3607
3608 \newline
3609 <model>
3610 \end_layout
3611
3612 \end_inset
3613 </cell>
3614 </row>
3615 <row topline="true">
3616 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3617 \begin_inset Text
3618
3619 \begin_layout Standard
3620 path(argv[0])/
3621 \newline
3622
3623 \emph on
3624 $BIN2DATADIR/
3625 \emph default
3626
3627 \newline
3628
3629 \emph on
3630 $LIB_DIR_SUFFIX/<model>
3631 \end_layout
3632
3633 \end_inset
3634 </cell>
3635 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3636 \begin_inset Text
3637
3638 \begin_layout Standard
3639 path(argv[0])/
3640 \newline
3641 ../sdcc/lib/
3642 \emph on
3643 <model>
3644 \newline
3645 \InsetSpace ~
3646 \InsetSpace ~
3647 \InsetSpace ~
3648 \InsetSpace ~
3649 \InsetSpace ~
3650 \InsetSpace ~
3651 \InsetSpace ~
3652 \InsetSpace ~
3653 \InsetSpace ~
3654 \InsetSpace ~
3655 \InsetSpace ~
3656 \InsetSpace ~
3657 \InsetSpace ~
3658 \InsetSpace ~
3659 \InsetSpace ~
3660 \InsetSpace ~
3661 \InsetSpace ~
3662 \InsetSpace ~
3663 \InsetSpace ~
3664 \InsetSpace ~
3665 \InsetSpace ~
3666 \InsetSpace ~
3667 \InsetSpace ~
3668 \InsetSpace ~
3669 \InsetSpace ~
3670 \InsetSpace ~
3671 \InsetSpace ~
3672 \InsetSpace ~
3673 \InsetSpace ~
3674 \InsetSpace ~
3675 \InsetSpace ~
3676 \InsetSpace ~
3677 \InsetSpace ~
3678 \InsetSpace ~
3679 \InsetSpace ~
3680 \InsetSpace ~
3681 \InsetSpace ~
3682 \InsetSpace ~
3683 \InsetSpace ~
3684
3685 \end_layout
3686
3687 \end_inset
3688 </cell>
3689 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3690 \begin_inset Text
3691
3692 \begin_layout Standard
3693 path(argv[0])
3694 \backslash
3695
3696 \newline
3697 ..
3698 \backslash
3699 lib
3700 \backslash
3701
3702 \emph on
3703 <model>
3704 \newline
3705 \InsetSpace ~
3706 \InsetSpace ~
3707 \InsetSpace ~
3708 \InsetSpace ~
3709 \InsetSpace ~
3710 \InsetSpace ~
3711 \InsetSpace ~
3712 \InsetSpace ~
3713 \InsetSpace ~
3714 \InsetSpace ~
3715 \InsetSpace ~
3716 \InsetSpace ~
3717 \InsetSpace ~
3718 \InsetSpace ~
3719 \InsetSpace ~
3720 \InsetSpace ~
3721 \InsetSpace ~
3722 \InsetSpace ~
3723 \InsetSpace ~
3724 \InsetSpace ~
3725 \InsetSpace ~
3726 \InsetSpace ~
3727 \InsetSpace ~
3728 \InsetSpace ~
3729 \InsetSpace ~
3730 \InsetSpace ~
3731 \InsetSpace ~
3732 \InsetSpace ~
3733 \InsetSpace ~
3734 \InsetSpace ~
3735 \InsetSpace ~
3736 \InsetSpace ~
3737 \InsetSpace ~
3738 \InsetSpace ~
3739 \InsetSpace ~
3740
3741 \end_layout
3742
3743 \end_inset
3744 </cell>
3745 </row>
3746 <row topline="true" bottomline="true">
3747 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3748 \begin_inset Text
3749
3750 \begin_layout Standard
3751
3752 \emph on
3753 $DATADIR/
3754 \newline
3755 $LIB_DIR_SUFFIX/<model>
3756 \end_layout
3757
3758 \end_inset
3759 </cell>
3760 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3761 \begin_inset Text
3762
3763 \begin_layout Standard
3764 /usr/local/share/sdcc/
3765 \newline
3766 lib/
3767 \emph on
3768 <model>
3769 \end_layout
3770
3771 \end_inset
3772 </cell>
3773 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3774 \begin_inset Text
3775
3776 \begin_layout Standard
3777 (not on Win32)
3778 \end_layout
3779
3780 \end_inset
3781 </cell>
3782 </row>
3783 </lyxtabular>
3784
3785 \end_inset
3786
3787
3788 \newline
3789
3790 \end_layout
3791
3792 \begin_layout Standard
3793 \begin_inset Note Note
3794 status collapsed
3795
3796 \begin_layout Standard
3797 Don't delete any of the stray spaces in the table above without checking
3798  the HTML output (last line)!
3799 \end_layout
3800
3801 \end_inset
3802
3803
3804 \end_layout
3805
3806 \begin_layout Standard
3807 \InsetSpace ~
3808
3809 \newline
3810 The option -
3811 \begin_inset ERT
3812 status collapsed
3813
3814 \begin_layout Standard
3815
3816
3817 \backslash
3818 /
3819 \end_layout
3820
3821 \end_inset
3822
3823 -nostdlib disables the last two search paths.
3824 \end_layout
3825
3826 \begin_layout Section
3827 Building SDCC
3828 \begin_inset LatexCommand \index{Building SDCC}
3829
3830 \end_inset
3831
3832
3833 \end_layout
3834
3835 \begin_layout Subsection
3836 Building SDCC on Linux
3837 \begin_inset LatexCommand \label{sub:Building-SDCC-on-Linux}
3838
3839 \end_inset
3840
3841
3842 \end_layout
3843
3844 \begin_layout Enumerate
3845
3846 \series medium
3847 Download the source package
3848 \series default
3849  either from the SDCC Subversion repository or from snapshot builds
3850 \series medium
3851 , it will be named something like sdcc
3852 \series default
3853 -src
3854 \series medium
3855 -yyyymmdd-rrrr.t
3856 \series default
3857 ar.
3858 \series medium
3859 bz2
3860 \series default
3861  
3862 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/snap.php}
3863
3864 \end_inset
3865
3866 .
3867 \end_layout
3868
3869 \begin_layout Enumerate
3870
3871 \series medium
3872 Bring up a command line terminal, such as xterm.
3873 \end_layout
3874
3875 \begin_layout Enumerate
3876
3877 \series medium
3878 Unpack the file using a command like:
3879 \series default
3880  
3881 \family sans
3882 \series bold
3883 "tar -xvzf sdcc-src-yyyymmdd-rrrr.tar.bz2
3884 \begin_inset Quotes srd
3885 \end_inset
3886
3887
3888 \family default
3889 \series medium
3890 , this will create a sub-directory called sdcc with all of the sources.
3891 \end_layout
3892
3893 \begin_layout Enumerate
3894 Change directory into the main SDCC directory, for example type: 
3895 \family sans
3896 \series bold
3897 "cd sdcc
3898 \series default
3899 ".
3900 \end_layout
3901
3902 \begin_layout Enumerate
3903
3904 \series medium
3905 Type
3906 \series default
3907  
3908 \family sans
3909 \series bold
3910 "./configure
3911 \family default
3912 \series default
3913 ".
3914  This configures the package for compilation on your system.
3915 \end_layout
3916
3917 \begin_layout Enumerate
3918
3919 \series medium
3920 Type
3921 \series default
3922  
3923 \family sans
3924 \series bold
3925 "make
3926 \family default
3927 \series default
3928 "
3929 \series medium
3930 .
3931
3932 \series default
3933  All of the source packages will compile, this can take a while.
3934 \end_layout
3935
3936 \begin_layout Enumerate
3937
3938 \series medium
3939 Type
3940 \series default
3941  
3942 \family sans
3943 \series bold
3944 "make install"
3945 \family default
3946 \series default
3947  as root
3948 \series medium
3949 .
3950
3951 \series default
3952  This copies the binary executables, the include files, the libraries and
3953  the documentation to the install directories.
3954  Proceed with section 
3955 \begin_inset LatexCommand \ref{sec:Testing-the-SDCC}
3956
3957 \end_inset
3958
3959 .
3960 \end_layout
3961
3962 \begin_layout Subsection
3963 Building SDCC on Mac OS X
3964 \end_layout
3965
3966 \begin_layout Standard
3967 Follow the instruction for Linux.
3968 \newline
3969
3970 \newline
3971 On Mac OS X 10.2.x it was reported, that the
3972  default gcc (version 3.1 20020420 (prerelease)) fails to compile SDCC.
3973  Fortunately there's also gcc 2.9.x installed, which works fine.
3974  This compiler can be selected by running 'configure' with:
3975 \end_layout
3976
3977 \begin_layout LyX-Code
3978 ./configure CC=gcc2 CXX=g++2
3979 \end_layout
3980
3981 \begin_layout Subsection
3982 Cross compiling SDCC on Linux for Windows
3983 \end_layout
3984
3985 \begin_layout Standard
3986 With the Mingw32 gcc cross compiler it's easy to compile SDCC for Win32.
3987  See section 'Configure Options'.
3988 \end_layout
3989
3990 \begin_layout Subsection
3991 Building SDCC using Cygwin and Mingw32
3992 \end_layout
3993
3994 \begin_layout Standard
3995 For building and installing a Cygwin executable follow the instructions
3996  for Linux.
3997 \newline
3998
3999 \newline
4000 On Cygwin a 
4001 \begin_inset Quotes sld
4002 \end_inset
4003
4004 native
4005 \begin_inset Quotes srd
4006 \end_inset
4007
4008  Win32-binary can be built, which will not need the Cygwin-DLL.
4009  For the necessary 'configure' options see section 'configure options' or
4010  the script 'sdcc/support/scripts/sdcc_cygwin_mingw32'.
4011 \newline
4012
4013 \newline
4014 In order to install
4015  Cygwin on Windows download setup.exe from 
4016 \begin_inset LatexCommand \url[www.cygwin.com]{http://www.cygwin.com/}
4017
4018 \end_inset
4019
4020 .
4021  Run it, set the 
4022 \begin_inset Quotes sld
4023 \end_inset
4024
4025 default text file type
4026 \begin_inset Quotes srd
4027 \end_inset
4028
4029  to 
4030 \begin_inset Quotes sld
4031 \end_inset
4032
4033 unix
4034 \begin_inset Quotes srd
4035 \end_inset
4036
4037  and download/install at least the following packages.
4038  Some packages are selected by default, others will be automatically selected
4039  because of dependencies with the manually selected packages.
4040  Never deselect these packages!
4041 \end_layout
4042
4043 \begin_layout Itemize
4044 flex
4045 \end_layout
4046
4047 \begin_layout Itemize
4048 bison
4049 \end_layout
4050
4051 \begin_layout Itemize
4052 gcc ; version 3.x is fine, no need to use the old 2.9x
4053 \end_layout
4054
4055 \begin_layout Itemize
4056 binutils ; selected with gcc
4057 \end_layout
4058
4059 \begin_layout Itemize
4060 make
4061 \end_layout
4062
4063 \begin_layout Itemize
4064 rxvt ; a nice console, which makes life much easier under windoze (see below)
4065 \end_layout
4066
4067 \begin_layout Itemize
4068 man ; not really needed for building SDCC, but you'll miss it sooner or
4069  later
4070 \end_layout
4071
4072 \begin_layout Itemize
4073 less ; not really needed for building SDCC, but you'll miss it sooner or
4074  later
4075 \end_layout
4076
4077 \begin_layout Itemize
4078 svn ; only if you use Subversion access
4079 \end_layout
4080
4081 \begin_layout Standard
4082 If you want to develop something you'll need:
4083 \end_layout
4084
4085 \begin_layout Itemize
4086 python ; for the regression tests
4087 \end_layout
4088
4089 \begin_layout Itemize
4090 gdb ; the gnu debugger, together with the nice GUI 
4091 \begin_inset Quotes sld
4092 \end_inset
4093
4094 insight
4095 \begin_inset Quotes srd
4096 \end_inset
4097
4098
4099 \end_layout
4100
4101 \begin_layout Itemize
4102 openssh ; to access the CF or commit changes
4103 \end_layout
4104
4105 \begin_layout Itemize
4106 autoconf and autoconf-devel ; if you want to fight with 'configure', don't
4107  use autoconf-stable!
4108 \end_layout
4109
4110 \begin_layout Standard
4111 rxvt is a nice console with history.
4112  Replace in your cygwin.bat the line
4113 \end_layout
4114
4115 \begin_layout LyX-Code
4116 bash -
4117 \begin_inset ERT
4118 status collapsed
4119
4120 \begin_layout Standard
4121
4122
4123 \backslash
4124 /
4125 \end_layout
4126
4127 \end_inset
4128
4129 -login -i 
4130 \end_layout
4131
4132 \begin_layout Standard
4133 with (one line):
4134 \end_layout
4135
4136 \begin_layout LyX-Code
4137 rxvt -sl 1000 -fn "Lucida Console-12" -sr -cr red
4138 \end_layout
4139
4140 \begin_layout LyX-Code
4141      -bg black -fg white -geometry 100x65 -e bash -
4142 \begin_inset ERT
4143 status collapsed
4144
4145 \begin_layout Standard
4146
4147
4148 \backslash
4149 /
4150 \end_layout
4151
4152 \end_inset
4153
4154 -login
4155 \end_layout
4156
4157 \begin_layout Standard
4158 Text selected with the mouse is automatically copied to the clipboard, pasting
4159  works with shift-insert.
4160 \newline
4161
4162 \newline
4163 The other good tip is to make sure you have no //c/-styl
4164 e paths anywhere, use /cygdrive/c/ instead.
4165  Using // invokes a network lookup which is very slow.
4166  If you think 
4167 \begin_inset Quotes sld
4168 \end_inset
4169
4170 cygdrive
4171 \begin_inset Quotes srd
4172 \end_inset
4173
4174  is too long, you can change it with e.g.
4175 \end_layout
4176
4177 \begin_layout LyX-Code
4178 mount -s -u -c /mnt
4179 \end_layout
4180
4181 \begin_layout Standard
4182 SDCC sources use the unix line ending LF.
4183  Life is much easier, if you store the source tree on a drive which is mounted
4184  in binary mode.
4185  And use an editor which can handle LF-only line endings.
4186  Make sure not to commit files with windows line endings.
4187  The tabulator spacing
4188 \begin_inset LatexCommand \index{tabulator spacing (8 columns)}
4189
4190 \end_inset
4191
4192  used in the project is 8.
4193  Although a tabulator spacing of 8 is a sensible choice for programmers
4194  (it's a power of 2 and allows to display 8/16 bit signed variables without
4195  loosing columns) the plan is to move towards using only spaces in the source.
4196 \end_layout
4197
4198 \begin_layout Subsection
4199 Building SDCC Using Microsoft Visual C++ 6.0/NET (MSVC)
4200 \end_layout
4201
4202 \begin_layout Standard
4203
4204 \series medium
4205 Download the source package
4206 \series default
4207  either from the SDCC Subversion repository or from the 
4208 \begin_inset LatexCommand \url[snapshot builds]{http://sdcc.sourceforge.net/snap.php}
4209
4210 \end_inset
4211
4212
4213 \series medium
4214 , it will be named something like sdcc
4215 \series default
4216 -src
4217 \series medium
4218 -yyyymmdd-rrrr.tar.bz2.
4219
4220 \series default
4221  SDCC is distributed with all the projects, workspaces, and files you need
4222  to build it using Visual C++ 6.0/NET (except for SDCDB and ucSim).
4223  The workspace name is 'sdcc.dsw'.
4224  Please note that as it is now, all the executables are created in a folder
4225  called sdcc
4226 \backslash
4227 bin_vc.
4228  Once built you need to copy the executables from sdcc
4229 \backslash
4230 bin_vc to sdcc
4231 \backslash
4232 bin before running SDCC.
4233  
4234 \newline
4235
4236 \newline
4237 WARNING: Visual studio is very picky with line terminations; it expects
4238  the 0x0d, 0x0a DOS style line endings, not the 0x0a Unix style line endings.
4239  When using the Subversion repository it's easiest to configure the svn
4240  client to convert automatically for you.
4241  If however you are getting a message such as "This makefile was not generated
4242  by Developer Studio etc.
4243  etc.
4244 \begin_inset Quotes srd
4245 \end_inset
4246
4247  when opening the sdcc.dsw workspace or any of the *.dsp projects, then you
4248  need to convert the Unix style line endings to DOS style line endings.
4249  To do so you can use the 
4250 \begin_inset Quotes sld
4251 \end_inset
4252
4253 unix2dos
4254 \begin_inset Quotes srd
4255 \end_inset
4256
4257  utility freely available on the internet.
4258  Doug Hawkins reported in the sdcc-user list that this works:
4259 \newline
4260
4261 \newline
4262 C:
4263 \backslash
4264 Programming
4265 \backslash
4266 SDCC> unix2dos sdcc.dsw
4267 \newline
4268 C:
4269 \backslash
4270 Programming
4271 \backslash
4272 SDCC> for /R %I in (*.dsp) do @unix2dos "%I"
4273 \newline
4274
4275 \newline
4276 In order to build SDCC with MSVC
4277  you need win32 executables of bison.exe, flex.exe, and gawk.exe.
4278  One good place to get them is 
4279 \begin_inset LatexCommand \url[here]{http://unxutils.sourceforge.net}
4280
4281 \end_inset
4282
4283
4284 \newline
4285
4286 \newline
4287 Download the file UnxUtils
4288 \begin_inset LatexCommand \index{UnxUtils}
4289
4290 \end_inset
4291
4292 .zip.
4293  Now you have to install the utilities and setup MSVC so it can locate the
4294  required programs.
4295  Here there are two alternatives (choose one!):
4296 \end_layout
4297
4298 \begin_layout Enumerate
4299 The easy way:
4300 \newline
4301
4302 \newline
4303 a) Extract UnxUtils.zip to your C:
4304 \backslash
4305  hard disk PRESERVING the original paths, otherwise bison won't work.
4306  (If you are using WinZip make certain that 'Use folder names' is selected)
4307 \newline
4308
4309 \newline
4310 b)
4311  In the Visual C++ IDE click Tools, Options, select the Directory tab, in
4312  'Show directories for:' select 'Executable files', and in the directories
4313  window add a new path: 'C:
4314 \backslash
4315 user
4316 \backslash
4317 local
4318 \backslash
4319 wbin', click ok.
4320 \newline
4321
4322 \newline
4323 (As a side effect, you get a bunch of Unix utilities that
4324  could be useful, such as diff and patch.)
4325 \end_layout
4326
4327 \begin_layout Enumerate
4328 A more compact way:
4329 \newline
4330
4331 \newline
4332 This one avoids extracting a bunch of files you may not
4333  use, but requires some extra work:
4334 \newline
4335
4336 \newline
4337 a) Create a directory were to put the
4338  tools needed, or use a directory already present.
4339  Say for example 'C:
4340 \backslash
4341 util'.
4342 \newline
4343
4344 \newline
4345 b) Extract 'bison.exe', 'bison.hairy', 'bison.simple', 'flex.exe', and
4346  gawk.exe to such directory WITHOUT preserving the original paths.
4347  (If you are using WinZip make certain that 'Use folder names' is not selected)
4348 \newline
4349
4350 \newline
4351 c
4352 ) Rename bison.exe to '_bison.exe'.
4353 \newline
4354
4355 \newline
4356 d) Create a batch file 'bison.bat' in 'C:
4357 \backslash
4358 util
4359 \backslash
4360 ' and add these lines: 
4361 \newline
4362 \InsetSpace ~
4363 \InsetSpace ~
4364 set BISON_SIMPLE=C:
4365 \backslash
4366 util
4367 \backslash
4368 bison.simple 
4369 \newline
4370 \InsetSpace ~
4371 \InsetSpace ~
4372 set BISON_HAIRY=C:
4373 \backslash
4374 util
4375 \backslash
4376 bison.hairy
4377 \newline
4378 \InsetSpace ~
4379 \InsetSpace ~
4380 _bison %1 %2 %3 %4 %5 %6 %7 %8 %9
4381 \newline
4382
4383 \newline
4384 Steps 'c' and 'd' are needed
4385  because bison requires by default that the files 'bison.simple' and 'bison.hairy'
4386  reside in some weird Unix directory, '/usr/local/share/' I think.
4387  So it is necessary to tell bison where those files are located if they
4388  are not in such directory.
4389  That is the function of the environment variables BISON_SIMPLE and BISON_HAIRY.
4390 \newline
4391
4392 \newline
4393 e
4394 ) In the Visual C++ IDE click Tools, Options, select the Directory tab,
4395  in 'Show directories for:' select 'Executable files', and in the directories
4396  window add a new path: 'c:
4397 \backslash
4398 util', click ok.
4399  Note that you can use any other path instead of 'c:
4400 \backslash
4401 util', even the path where the Visual C++ tools are, probably: 'C:
4402 \backslash
4403 Program Files
4404 \backslash
4405 Microsoft Visual Studio
4406 \backslash
4407 Common
4408 \backslash
4409 Tools'.
4410  So you don't have to execute step 'e' :)
4411 \end_layout
4412
4413 \begin_layout Standard
4414 That is it.
4415  Open 'sdcc.dsw' in Visual Studio, click 'build all', when it finishes copy
4416  the executables from sdcc
4417 \backslash
4418 bin_vc to sdcc
4419 \backslash
4420 bin, and you can compile using SDCC.
4421 \end_layout
4422
4423 \begin_layout Subsection
4424 Building SDCC Using Borland
4425 \end_layout
4426
4427 \begin_layout Enumerate
4428 From the sdcc directory, run the command "make -f Makefile.bcc".
4429  This should regenerate all the .exe files in the bin directory except for
4430  SDCDB and ucSim.
4431 \end_layout
4432
4433 \begin_layout Enumerate
4434 If you modify any source files and need to rebuild, be aware that the dependenci
4435 es may not be correctly calculated.
4436  The safest option is to delete all .obj files and run the build again.
4437  From a Cygwin BASH prompt, this can easily be done with the command (be
4438  sure you are in the sdcc directory):
4439 \newline
4440
4441 \newline
4442
4443 \family sans
4444 \series bold
4445 find .
4446  
4447 \backslash
4448 ( -name '*.obj' -o -name '*.lib' -o -name '*.rul' 
4449 \backslash
4450 ) -print -exec rm {} 
4451 \backslash
4452 ;
4453 \family default
4454 \series default
4455
4456 \newline
4457
4458 \newline
4459 or on Windows NT/2000/XP from the command prompt with the command:
4460 \newline
4461
4462 \family sans
4463 \series bold
4464
4465 \newline
4466 del /s *.obj *.lib *.rul
4467 \family default
4468 \series default
4469  from the sdcc directory.
4470 \end_layout
4471
4472 \begin_layout Subsection
4473 Windows Install Using a ZIP Package
4474 \end_layout
4475
4476 \begin_layout Enumerate
4477 Download the binary zip package from 
4478 \begin_inset LatexCommand \url{http://sdcc.sf.net/snap.php}
4479
4480 \end_inset
4481
4482  and unpack it using your favorite unpacking tool (gunzip, WinZip, etc).
4483  This should unpack to a group of sub-directories.
4484  An example directory structure after unpacking the mingw32 package is:
4485  c:
4486 \backslash
4487 sdcc
4488 \backslash
4489 bin for the executables, c:
4490 \backslash
4491 sdcc
4492 \backslash
4493 include and c:
4494 \backslash
4495 sdcc
4496 \backslash
4497 lib for the include and libraries.
4498 \end_layout
4499
4500 \begin_layout Enumerate
4501 Adjust your environment variable PATH to include the location of the bin
4502  directory or start sdcc using the full path.
4503 \end_layout
4504
4505 \begin_layout Subsection
4506 Windows Install Using the Setup Program
4507 \begin_inset LatexCommand \label{sub:Windows-Install}
4508
4509 \end_inset
4510
4511
4512 \end_layout
4513
4514 \begin_layout Standard
4515 Download the setup program 
4516 \emph on
4517 sdcc-x.y.z-setup.exe
4518 \emph default
4519  for an official release from 
4520 \newline
4521
4522 \begin_inset LatexCommand \url{http://sf.net/project/showfiles.php?group_id=599}
4523
4524 \end_inset
4525
4526  or a setup program for one of the snapshots 
4527 \emph on
4528 sdcc-yyyymmdd-xxxx-setup.exe
4529 \emph default
4530  from 
4531 \begin_inset LatexCommand \url{http://sdcc.sf.net/snap.php}
4532
4533 \end_inset
4534
4535  and execute it.
4536  A windows typical installer will guide you through the installation process.
4537 \end_layout
4538
4539 \begin_layout Subsection
4540 VPATH
4541 \begin_inset LatexCommand \index{VPATH}
4542
4543 \end_inset
4544
4545  feature
4546 \end_layout
4547
4548 \begin_layout Standard
4549 SDCC supports the VPATH feature provided by configure and make.
4550  It allows to separate the source and build trees.
4551  Here's an example:
4552 \end_layout
4553
4554 \begin_layout Standard
4555
4556 \family typewriter
4557 cd ~\InsetSpace ~
4558 \InsetSpace ~
4559 \InsetSpace ~
4560 \InsetSpace ~
4561 \InsetSpace ~
4562 \InsetSpace ~
4563 \InsetSpace ~
4564 \InsetSpace ~
4565 \InsetSpace ~
4566 \InsetSpace ~
4567 \InsetSpace ~
4568 \InsetSpace ~
4569 \InsetSpace ~
4570 \InsetSpace ~
4571 \InsetSpace ~
4572 \InsetSpace ~
4573 \InsetSpace ~
4574 \InsetSpace ~
4575 \InsetSpace ~
4576 \InsetSpace ~
4577 \InsetSpace ~
4578 # cd $HOME
4579 \end_layout
4580
4581 \begin_layout Standard
4582
4583 \family typewriter
4584 tar -xzf sdcc.src.tar.gz\InsetSpace ~
4585 # extract source to directory sdcc
4586 \end_layout
4587
4588 \begin_layout Standard
4589
4590 \family typewriter
4591 mkdir sdcc.build\InsetSpace ~
4592 \InsetSpace ~
4593 \InsetSpace ~
4594 \InsetSpace ~
4595 \InsetSpace ~
4596 \InsetSpace ~
4597 \InsetSpace ~
4598 \InsetSpace ~
4599 \InsetSpace ~
4600 # put output in sdcc.build
4601 \end_layout
4602
4603 \begin_layout Standard
4604
4605 \family typewriter
4606 cd sdcc.build
4607 \end_layout
4608
4609 \begin_layout Standard
4610
4611 \family typewriter
4612 ../sdcc/configure\InsetSpace ~
4613 \InsetSpace ~
4614 \InsetSpace ~
4615 \InsetSpace ~
4616 \InsetSpace ~
4617 \InsetSpace ~
4618 \InsetSpace ~
4619 \InsetSpace ~
4620 # configure is doing all the magic!
4621 \end_layout
4622
4623 \begin_layout Standard
4624
4625 \family typewriter
4626 make
4627 \end_layout
4628
4629 \begin_layout Standard
4630 \noindent
4631 That's it! 
4632 \series bold
4633 configure
4634 \series default
4635  will create the directory tree will all the necessary Makefiles in ~/sdcc.build.
4636  It automagically computes the variables srcdir, top_srcdir and top_buildir
4637  for each directory.
4638  After running 
4639 \series bold
4640 make
4641 \series default
4642  the generated files will be in ~/sdcc.build, while the source files stay
4643  in ~/sdcc.
4644 \newline
4645 This is not only usefull for building different binaries, e.g.
4646  when cross compiling.
4647  It also gives you a much better overview in the source tree when all the
4648  generated files are not scattered between the source files.
4649  And the best thing is: if you want to change a file you can leave the original
4650  file untouched in the source directory.
4651  Simply copy it to the build directory, edit it, enter `make clean', `rm
4652  Makefile.dep' and `make'.
4653  
4654 \series bold
4655 make
4656 \series default
4657  will do the rest for you!
4658 \end_layout
4659
4660 \begin_layout Section
4661 Building the Documentation
4662 \end_layout
4663
4664 \begin_layout Standard
4665 Add -
4666 \begin_inset ERT
4667 status collapsed
4668
4669 \begin_layout Standard
4670
4671
4672 \backslash
4673 /
4674 \end_layout
4675
4676 \end_inset
4677
4678 -enable-doc to the configure arguments to build the documentation together
4679  with all the other stuff.
4680  You will need several tools (LyX, LaTeX, LaTeX2HTML, pdflatex, dvipdf,
4681  dvips and makeindex) to get the job done.
4682  Another possibility is to change to the doc directory and to type 
4683 \family sans
4684 \series bold
4685
4686 \begin_inset Quotes srd
4687 \end_inset
4688
4689 make
4690 \begin_inset Quotes srd
4691 \end_inset
4692
4693
4694 \family default
4695 \series default
4696  there.
4697  You're invited to make changes and additions to this manual (sdcc/doc/sdccman.ly
4698 x).
4699  Using LyX 
4700 \begin_inset LatexCommand \url{http://www.lyx.org}
4701
4702 \end_inset
4703
4704  as editor is straightforward.
4705  Prebuilt documentation in html and pdf format is available from 
4706 \begin_inset LatexCommand \url{http://sdcc.sf.net/snap.php}
4707
4708 \end_inset
4709
4710 .
4711 \end_layout
4712
4713 \begin_layout Section
4714 Reading the Documentation
4715 \begin_inset LatexCommand \index{Documentation}
4716
4717 \end_inset
4718
4719
4720 \end_layout
4721
4722 \begin_layout Standard
4723 Currently reading the document in pdf format is recommended, as for unknown
4724  reason the hyperlinks are working there whereas in the html version they
4725  are not
4726 \begin_inset Foot
4727 status open
4728
4729 \begin_layout Standard
4730 If you should know why please drop us a note
4731 \end_layout
4732
4733 \end_inset
4734
4735 .
4736  
4737 \newline
4738 You'll find the pdf version
4739 \begin_inset LatexCommand \index{PDF version of this document}
4740
4741 \end_inset
4742
4743  at 
4744 \begin_inset LatexCommand \url{http://sdcc.sf.net/doc/sdccman.pdf}
4745
4746 \end_inset
4747
4748 .
4749  
4750 \newline
4751 A html version
4752 \begin_inset LatexCommand \index{HTML version of this document}
4753
4754 \end_inset
4755
4756  should be online at 
4757 \begin_inset LatexCommand \url{http://sdcc.sf.net/doc/sdccman.html/index.html}
4758
4759 \end_inset
4760
4761 .
4762 \newline
4763 This documentation is in some aspects different from a commercial documentation:
4764  
4765 \end_layout
4766
4767 \begin_layout Itemize
4768 It tries to document SDCC for several processor architectures in one document
4769  (commercially these probably would be separate documents/products).
4770  This document
4771 \begin_inset LatexCommand \index{Status of documentation}
4772
4773 \end_inset
4774
4775  currently matches SDCC for mcs51 and DS390 best and does give too few informati
4776 on about f.e.
4777  Z80, PIC14, PIC16 and HC08.
4778 \end_layout
4779
4780 \begin_layout Itemize
4781 There are many references pointing away from this documentation.
4782  Don't let this distract you.
4783  If there f.e.
4784  was a reference like 
4785 \begin_inset LatexCommand \url{http://www.opencores.org}
4786
4787 \end_inset
4788
4789  together with a statement 
4790 \begin_inset Quotes sld
4791 \end_inset
4792
4793 some processors which are targetted by SDCC can be implemented in a 
4794 \emph on
4795 f
4796 \emph default
4797 ield 
4798 \emph on
4799 p
4800 \emph default
4801 rogrammable 
4802 \emph on
4803 g
4804 \emph default
4805 ate 
4806 \emph on
4807 a
4808 \emph default
4809 rray
4810 \begin_inset LatexCommand \index{FPGA (field programmable gate array)}
4811
4812 \end_inset
4813
4814
4815 \begin_inset Quotes srd
4816 \end_inset
4817
4818  or 
4819 \begin_inset LatexCommand \url{http://sf.net/projects/fpgac}
4820
4821 \end_inset
4822
4823
4824 \begin_inset LatexCommand \index{FpgaC ((subset of) C to FPGA compiler)}
4825
4826 \end_inset
4827
4828  
4829 \begin_inset Quotes sld
4830 \end_inset
4831
4832 have you ever heard of an open source compiler that compiles a subset of
4833  C for an FPGA?
4834 \begin_inset Quotes srd
4835 \end_inset
4836
4837  we expect you to have a quick look there and come back.
4838  If you read this you are on the right track.
4839 \end_layout
4840
4841 \begin_layout Itemize
4842 Some sections attribute more space to problems, restrictions and warnings
4843  than to the solution.
4844 \end_layout
4845
4846 \begin_layout Itemize
4847 The installation section and the section about the debugger is intimidating.
4848 \end_layout
4849
4850 \begin_layout Itemize
4851 There are still lots of typos and there are more different writing styles
4852  than pictures.
4853 \end_layout
4854
4855 \begin_layout Section
4856 Testing the SDCC Compiler
4857 \begin_inset LatexCommand \label{sec:Testing-the-SDCC}
4858
4859 \end_inset
4860
4861
4862 \end_layout
4863
4864 \begin_layout Standard
4865 The first thing you should do after installing your SDCC compiler is to
4866  see if it runs.
4867  Type 
4868 \family sans
4869 \series bold
4870 "sdcc -
4871 \begin_inset ERT
4872 status collapsed
4873
4874 \begin_layout Standard
4875
4876
4877 \backslash
4878 /
4879 \end_layout
4880
4881 \end_inset
4882
4883 -version"
4884 \begin_inset LatexCommand \index{version}
4885
4886 \end_inset
4887
4888
4889 \family default
4890 \series default
4891  at the prompt, and the program should run and output its version like:
4892  
4893 \newline
4894
4895 \family typewriter
4896 SDCC : mcs51/z80/avr/ds390/pic16/pic14/ds400/hc08 2.5.6 #4169 (May 8 2006)
4897  (UNIX)
4898 \end_layout
4899
4900 \begin_layout Standard
4901 If it doesn't run, or gives a message about not finding sdcc program, then
4902  you need to check over your installation.
4903  Make sure that the sdcc bin directory is in your executable search path
4904  defined by the PATH environment setting (
4905 \series medium
4906 see
4907 \series default
4908  section 
4909 \begin_inset LatexCommand \ref{sub:Install-Trouble-shooting}
4910
4911 \end_inset
4912
4913 \InsetSpace ~
4914
4915 \series medium
4916 Install trouble-shooting for suggestions
4917 \series default
4918 ).
4919  Make sure that the sdcc program is in the bin folder, if not perhaps something
4920  did not install correctly.
4921 \newline
4922
4923 \newline
4924
4925 \series medium
4926 SDCC
4927 \series default
4928  is commonly installed as described in section 
4929 \begin_inset Quotes sld
4930 \end_inset
4931
4932 Install and search paths
4933 \begin_inset Quotes srd
4934 \end_inset
4935
4936 .
4937 \newline
4938
4939 \newline
4940
4941 \series medium
4942 Make sure the compiler works on a very simple example.
4943  Type in the following test.c program using your favorite
4944 \series default
4945  ASCII 
4946 \series medium
4947 editor:
4948 \end_layout
4949
4950 \begin_layout Verse
4951
4952 \family typewriter
4953 char test;
4954 \newline
4955
4956 \newline
4957 void main(void) {
4958 \newline
4959 \InsetSpace ~
4960 \InsetSpace ~
4961 \InsetSpace ~
4962 \InsetSpace ~
4963 test=0;
4964 \newline
4965 }
4966 \end_layout
4967
4968 \begin_layout Standard
4969
4970 \series medium
4971 Compile this using the following command:
4972 \series default
4973  
4974 \family sans
4975 \series bold
4976 "sdcc -c test.c".
4977
4978 \family default
4979 \series default
4980  
4981 \series medium
4982 If all goes well, the compiler will generate a test.asm and test.rel file.
4983  Congratulations, you've just compiled your first program with SDCC.
4984  We used the -c option to tell SDCC not to link the generated code, just
4985  to keep things simple for this step.
4986 \series default
4987
4988 \newline
4989
4990 \newline
4991
4992 \series medium
4993 The next step is to try it with the linker.
4994  Type in
4995 \series default
4996  
4997 \family sans
4998 \series bold
4999 "sdcc test.c
5000 \family default
5001 \series default
5002 "
5003 \series medium
5004 .
5005  If all goes well the compiler will link with the libraries and produce
5006  a test.ihx output file.
5007  If this step fails
5008 \series default
5009  
5010 \series medium
5011 (no test.ihx, and the linker generates warnings), then the problem is most
5012  likely that
5013 \series default
5014  SDCC 
5015 \series medium
5016 cannot find the
5017 \series default
5018  /
5019 \series medium
5020 usr/local/share/sdcc/lib directory
5021 \series default
5022  
5023 \series medium
5024 (see
5025 \series default
5026  section 
5027 \begin_inset LatexCommand \ref{sub:Install-Trouble-shooting}
5028
5029 \end_inset
5030
5031 \InsetSpace ~
5032
5033 \series medium
5034 Install trouble-shooting for suggestions).
5035 \series default
5036
5037 \newline
5038
5039 \newline
5040
5041 \series medium
5042 The final test is to ensure
5043 \series default
5044  SDCC 
5045 \series medium
5046 can use the
5047 \series default
5048  standard 
5049 \series medium
5050 header files and libraries.
5051  Edit test.c and change it to the following:
5052 \end_layout
5053
5054 \begin_layout Verse
5055
5056 \family typewriter
5057 #include <string.h>
5058 \newline
5059
5060 \newline
5061 char str1[10];
5062 \newline
5063
5064 \newline
5065 void main(void) {
5066 \newline
5067 \InsetSpace ~
5068 \InsetSpace ~
5069 strcpy(str1, "testing");
5070 \newline
5071 }
5072 \end_layout
5073
5074 \begin_layout Standard
5075
5076 \series medium
5077 Compile this by typing
5078 \series default
5079  
5080 \family sans
5081 \series bold
5082 "sdcc test.c"
5083 \family default
5084 \series medium
5085 .
5086  This should generate a test.ihx output file, and it should give no warnings
5087  such as not finding the string.h file.
5088  If it cannot find the string.h file, then the problem is that
5089 \series default
5090  SDCC 
5091 \series medium
5092 cannot find the /usr/local/share/sdcc/include directory
5093 \series default
5094  
5095 \series medium
5096 (see the
5097 \series default
5098  section 
5099 \begin_inset LatexCommand \ref{sub:Install-Trouble-shooting}
5100
5101 \end_inset
5102
5103 \InsetSpace ~
5104
5105 \series medium
5106 Install trouble-shooting section for suggestions).
5107
5108 \series default
5109  Use option 
5110 \series bold
5111 -
5112 \begin_inset ERT
5113 status collapsed
5114
5115 \begin_layout Standard
5116
5117
5118 \backslash
5119 /
5120 \end_layout
5121
5122 \end_inset
5123
5124 -print-search-dirs
5125 \series default
5126
5127 \begin_inset LatexCommand \index{-\\/-print-search-dirs}
5128
5129 \end_inset
5130
5131  to find exactly where SDCC is looking for the include and lib files.
5132 \end_layout
5133
5134 \begin_layout Section
5135 Install Trouble-shooting
5136 \begin_inset LatexCommand \label{sub:Install-Trouble-shooting}
5137
5138 \end_inset
5139
5140
5141 \begin_inset LatexCommand \index{Install trouble-shooting}
5142
5143 \end_inset
5144
5145
5146 \end_layout
5147
5148 \begin_layout Subsection
5149 If SDCC does not build correctly
5150 \end_layout
5151
5152 \begin_layout Standard
5153 A thing to try is starting from scratch by unpacking the .tgz source package
5154  again in an empty directory.
5155  Configure it like:
5156 \newline
5157
5158 \newline
5159
5160 \family sans
5161 \series bold
5162 ./configure 2>&1 | tee configure.log
5163 \family default
5164 \series default
5165
5166 \newline
5167
5168 \newline
5169 and build it like:
5170 \newline
5171
5172 \newline
5173
5174 \family sans
5175 \series bold
5176 make 2>&1 | tee make.log
5177 \family default
5178 \series default
5179
5180 \newline
5181
5182 \newline
5183 If anything goes wrong, you can review the log files to locate the problem.
5184  Or a relevant part of this can be attached to an email that could be helpful
5185  when requesting help from the mailing list.
5186 \end_layout
5187
5188 \begin_layout Subsection
5189 What the 
5190 \begin_inset Quotes sld
5191 \end_inset
5192
5193 ./configure
5194 \begin_inset Quotes srd
5195 \end_inset
5196
5197  does
5198 \end_layout
5199
5200 \begin_layout Standard
5201 The 
5202 \begin_inset Quotes sld
5203 \end_inset
5204
5205 ./configure
5206 \begin_inset Quotes srd
5207 \end_inset
5208
5209  command is a script that analyzes your system and performs some configuration
5210  to ensure the source package compiles on your system.
5211  It will take a few minutes to run, and will compile a few tests to determine
5212  what compiler features are installed.
5213 \end_layout
5214
5215 \begin_layout Subsection
5216 What the 
5217 \begin_inset Quotes sld
5218 \end_inset
5219
5220 make
5221 \begin_inset Quotes srd
5222 \end_inset
5223
5224  does
5225 \end_layout
5226
5227 \begin_layout Standard
5228 This runs the GNU make tool, which automatically compiles all the source
5229  packages into the final installed binary executables.
5230 \end_layout
5231
5232 \begin_layout Subsection
5233 What the 
5234 \begin_inset Quotes sld
5235 \end_inset
5236
5237 make install
5238 \begin_inset Quotes erd
5239 \end_inset
5240
5241  command does.
5242 \end_layout
5243
5244 \begin_layout Standard
5245 This will install the compiler, other executables libraries and include
5246  files into the appropriate directories.
5247  See sections 
5248 \begin_inset LatexCommand \ref{sub:Install-paths}
5249
5250 \end_inset
5251
5252 ,\InsetSpace ~
5253
5254 \begin_inset LatexCommand \ref{sub:Search-Paths}
5255
5256 \end_inset
5257
5258 \InsetSpace ~
5259 about install and search paths.
5260 \newline
5261 On most systems you will need super-user privilege
5262 s to do this.
5263 \end_layout
5264
5265 \begin_layout Section
5266 Components of SDCC
5267 \end_layout
5268
5269 \begin_layout Standard
5270 SDCC is not just a compiler, but a collection of tools by various developers.
5271  These include linkers, assemblers, simulators and other components.
5272  Here is a summary of some of the components.
5273  Note that the included simulator and assembler have separate documentation
5274  which you can find in the source package in their respective directories.
5275  As SDCC grows to include support for other processors, other packages from
5276  various developers are included and may have their own sets of documentation.
5277 \newline
5278
5279 \newline
5280 You
5281  might want to look at the files which are installed in <installdir>.
5282  At the time of this writing, we find the following programs for gcc-builds:
5283 \newline
5284
5285  
5286 \newline
5287 In <installdir>/bin:
5288 \end_layout
5289
5290 \begin_layout Itemize
5291 sdcc - The compiler.
5292 \end_layout
5293
5294 \begin_layout Itemize
5295 sdcpp - The C preprocessor.
5296 \end_layout
5297
5298 \begin_layout Itemize
5299 asx8051 - The assembler for 8051 type processors.
5300 \end_layout
5301
5302 \begin_layout Itemize
5303 as-z80
5304 \series bold
5305 ,
5306 \series default
5307  as-gbz80 - The Z80 and GameBoy Z80 assemblers.
5308 \end_layout
5309
5310 \begin_layout Itemize
5311 aslink -The linker for 8051 type processors.
5312 \end_layout
5313
5314 \begin_layout Itemize
5315 link-z80
5316 \series bold
5317 ,
5318 \series default
5319  link-gbz80 - The Z80 and GameBoy Z80 linkers.
5320 \end_layout
5321
5322 \begin_layout Itemize
5323 s51 - The ucSim 8051 simulator.
5324 \end_layout
5325
5326 \begin_layout Itemize
5327 sdcdb - The source debugger.
5328 \end_layout
5329
5330 \begin_layout Itemize
5331 packihx - A tool to pack (compress) Intel hex files.
5332 \end_layout
5333
5334 \begin_layout Standard
5335 In <installdir>/share/sdcc/include
5336 \end_layout
5337
5338 \begin_layout Itemize
5339 the include files
5340 \end_layout
5341
5342 \begin_layout Standard
5343 In <installdir>/share/sdcc/lib
5344 \end_layout
5345
5346 \begin_layout Itemize
5347 the subdirs src and small, large, z80, gbz80 and ds390 with the precompiled
5348  relocatables.
5349 \end_layout
5350
5351 \begin_layout Standard
5352 In <installdir>/share/sdcc/doc
5353 \end_layout
5354
5355 \begin_layout Itemize
5356 the documentation
5357 \end_layout
5358
5359 \begin_layout Standard
5360 As development for other processors proceeds, this list will expand to include
5361  executables to support processors like AVR, PIC, etc.
5362 \end_layout
5363
5364 \begin_layout Subsection
5365 sdcc - The Compiler
5366 \end_layout
5367
5368 \begin_layout Standard
5369 This is the actual compiler, it in turn uses the c-preprocessor and invokes
5370  the assembler and linkage editor.
5371 \end_layout
5372
5373 \begin_layout Subsection
5374 sdcpp - The C-Preprocessor
5375 \end_layout
5376
5377 \begin_layout Standard
5378 The preprocessor
5379 \begin_inset LatexCommand \index{sdcpp (preprocessor)}
5380
5381 \end_inset
5382
5383  is a modified version of the GNU cpp
5384 \begin_inset LatexCommand \index{cpp|see{sdcpp}}
5385
5386 \end_inset
5387
5388  preprocessor 
5389 \begin_inset LatexCommand \url{http://gcc.gnu.org/}
5390
5391 \end_inset
5392
5393 .
5394  The C preprocessor is used to pull in #include sources, process #ifdef
5395  statements, #defines and so on.
5396 \end_layout
5397
5398 \begin_layout Subsection
5399 as
5400 \emph on
5401 xxxx
5402 \emph default
5403 , aslink, link-
5404 \emph on
5405 xxx
5406 \emph default
5407  - The Assemblers and Linkage Editors
5408 \end_layout
5409
5410 \begin_layout Standard
5411 This is retargettable assembler & linkage editor, it was developed by Alan
5412  Baldwin.
5413  John Hartman created the version for 8051, and I (Sandeep) have made some
5414  enhancements and bug fixes for it to work properly with SDCC.
5415 \end_layout
5416
5417 \begin_layout Subsection
5418 s51 - The Simulator
5419 \end_layout
5420
5421 \begin_layout Standard
5422 S51
5423 \begin_inset LatexCommand \index{s51}
5424
5425 \end_inset
5426
5427  is a free open source simulator developed by Daniel Drotos.
5428  The simulator is built as part of the build process.
5429  For more information visit Daniel's web site at: 
5430 \begin_inset LatexCommand \url{http://mazsola.iit.uni-miskolc.hu/~drdani/embedded/s51}
5431
5432 \end_inset
5433
5434 .
5435  It currently supports the core mcs51, the Dallas DS80C390 and the Phillips
5436  XA51 family.
5437 \end_layout
5438
5439 \begin_layout Subsection
5440 sdcdb - Source Level Debugger
5441 \end_layout
5442
5443 \begin_layout Standard
5444 SDCDB
5445 \begin_inset LatexCommand \index{SDCDB (debugger)}
5446
5447 \end_inset
5448
5449  is the companion source level debugger.
5450  More about SDCDB in section 
5451 \begin_inset LatexCommand \ref{cha:Debugging-with-SDCDB}
5452
5453 \end_inset
5454
5455 .
5456  The current version of the debugger uses Daniel's Simulator S51
5457 \begin_inset LatexCommand \index{s51}
5458
5459 \end_inset
5460
5461 , but can be easily changed to use other simulators.
5462 \end_layout
5463
5464 \begin_layout Chapter
5465 Using SDCC
5466 \end_layout
5467
5468 \begin_layout Section
5469 Compiling
5470 \end_layout
5471
5472 \begin_layout Subsection
5473 Single Source File Projects
5474 \end_layout
5475
5476 \begin_layout Standard
5477 For single source file 8051 projects the process is very simple.
5478  Compile your programs with the following command 
5479 \family sans
5480 \series bold
5481 "sdcc sourcefile.c".
5482
5483 \family default
5484 \series default
5485  This will compile, assemble and link your source file.
5486  Output files are as follows:
5487 \end_layout
5488
5489 \begin_layout Itemize
5490 sourcefile.asm
5491 \begin_inset LatexCommand \index{<file>.asm}
5492
5493 \end_inset
5494
5495  - Assembler source
5496 \begin_inset LatexCommand \index{Assembler source}
5497
5498 \end_inset
5499
5500  file created by the compiler
5501 \end_layout
5502
5503 \begin_layout Itemize
5504 sourcefile.lst
5505 \begin_inset LatexCommand \index{<file>.lst}
5506
5507 \end_inset
5508
5509  - Assembler listing
5510 \begin_inset LatexCommand \index{Assembler listing}
5511
5512 \end_inset
5513
5514  file created by the Assembler
5515 \end_layout
5516
5517 \begin_layout Itemize
5518 sourcefile.rst
5519 \begin_inset LatexCommand \index{<file>.rst}
5520
5521 \end_inset
5522
5523  - Assembler listing
5524 \begin_inset LatexCommand \index{Assembler listing}
5525
5526 \end_inset
5527
5528  file updated with linkedit information, created by linkage editor
5529 \end_layout
5530
5531 \begin_layout Itemize
5532 sourcefile.sym
5533 \begin_inset LatexCommand \index{<file>.sym}
5534
5535 \end_inset
5536
5537  - symbol listing
5538 \begin_inset LatexCommand \index{Symbol listing}
5539
5540 \end_inset
5541
5542  for the sourcefile, created by the assembler
5543 \end_layout
5544
5545 \begin_layout Itemize
5546 sourcefile.rel
5547 \begin_inset LatexCommand \index{<file>.rel}
5548
5549 \end_inset
5550
5551  or sourcefile.o
5552 \begin_inset LatexCommand \index{<file>.o}
5553
5554 \end_inset
5555
5556  - Object file
5557 \begin_inset LatexCommand \index{Object file}
5558
5559 \end_inset
5560
5561  created by the assembler, input to Linkage editor
5562 \end_layout
5563
5564 \begin_layout Itemize
5565 sourcefile.map
5566 \begin_inset LatexCommand \index{<file>.map}
5567
5568 \end_inset
5569
5570  - The memory map
5571 \begin_inset LatexCommand \index{Memory map}
5572
5573 \end_inset
5574
5575  for the load module, created by the Linker
5576 \end_layout
5577
5578 \begin_layout Itemize
5579 sourcefile.mem
5580 \begin_inset LatexCommand \index{<file>.mem}
5581
5582 \end_inset
5583
5584  - A file with a summary of the memory usage
5585 \end_layout
5586
5587 \begin_layout Itemize
5588 sourcefile.ihx
5589 \begin_inset LatexCommand \index{<file>.ihx}
5590
5591 \end_inset
5592
5593  - The load module in Intel hex format
5594 \begin_inset LatexCommand \index{Intel hex format}
5595
5596 \end_inset
5597
5598  (you can select the Motorola S19 format
5599 \begin_inset LatexCommand \index{Motorola S19 format}
5600
5601 \end_inset
5602
5603  with -
5604 \begin_inset ERT
5605 status collapsed
5606
5607 \begin_layout Standard
5608
5609
5610 \backslash
5611 /
5612 \end_layout
5613
5614 \end_inset
5615
5616 -out-fmt-s19
5617 \begin_inset LatexCommand \index{-\\/-out-fmt-s19}
5618
5619 \end_inset
5620
5621 .
5622  If you need another format you might want to use 
5623 \family sans
5624 \shape italic
5625 objdump
5626 \family default
5627 \shape default
5628
5629 \begin_inset LatexCommand \index{objdump (tool)}
5630
5631 \end_inset
5632
5633  or 
5634 \family sans
5635 \shape italic
5636 srecord
5637 \family default
5638 \shape default
5639
5640 \begin_inset LatexCommand \index{srecord (bin, hex, ... tool)}
5641
5642 \end_inset
5643
5644
5645 \begin_inset Note Note
5646 status collapsed
5647
5648 \begin_layout Standard
5649 hyperlinks needed
5650 \end_layout
5651
5652 \end_inset
5653
5654  - see also section 
5655 \begin_inset LatexCommand \vref{sub:Postprocessing-the-Intel}
5656
5657 \end_inset
5658
5659 ).
5660  Both formats are documented in the documentation of srecord
5661 \begin_inset LatexCommand \index{srecord (bin, hex, ... tool)}
5662
5663 \end_inset
5664
5665
5666 \end_layout
5667
5668 \begin_layout Itemize
5669 sourcefile.adb
5670 \begin_inset LatexCommand \index{<file>.adb}
5671
5672 \end_inset
5673
5674  - An intermediate file containing debug information needed to create the
5675  .cdb file (with -
5676 \begin_inset ERT
5677 status collapsed
5678
5679 \begin_layout Standard
5680
5681
5682 \backslash
5683 /
5684 \end_layout
5685
5686 \end_inset
5687
5688 -debug
5689 \begin_inset LatexCommand \index{-\\/-debug}
5690
5691 \end_inset
5692
5693
5694 \end_layout
5695
5696 \begin_layout Itemize
5697 sourcefile.cdb
5698 \begin_inset LatexCommand \index{<file>.cdb}
5699
5700 \end_inset
5701
5702  - An optional file (with -
5703 \begin_inset ERT
5704 status collapsed
5705
5706 \begin_layout Standard
5707
5708
5709 \backslash
5710 /
5711 \end_layout
5712
5713 \end_inset
5714
5715 -debug) containing debug information.
5716  The format is documented in cdbfileformat.pdf
5717 \end_layout
5718
5719 \begin_layout Itemize
5720 sourcefile.
5721  - (no extension)
5722 \begin_inset LatexCommand \index{<file> (no extension)}
5723
5724 \end_inset
5725
5726  An optional AOMF or AOMF51
5727 \begin_inset LatexCommand \index{AOMF, AOMF51}
5728
5729 \end_inset
5730
5731  
5732 \begin_inset LatexCommand \label{OMF file}
5733
5734 \end_inset
5735
5736 file containing debug information (generated with option -
5737 \begin_inset ERT
5738 status collapsed
5739
5740 \begin_layout Standard
5741
5742
5743 \backslash
5744 /
5745 \end_layout
5746
5747 \end_inset
5748
5749 -debug).
5750  The (Intel) 
5751 \emph on
5752 a
5753 \emph default
5754 bsolute 
5755 \emph on
5756 o
5757 \emph default
5758 bject 
5759 \emph on
5760 m
5761 \emph default
5762 odule 
5763 \emph on
5764 f
5765 \emph default
5766 ormat is a subformat of the OMF51 format and is commonly used by third party
5767  tools (debuggers
5768 \begin_inset LatexCommand \index{Debugger}
5769
5770 \end_inset
5771
5772 , simulators, emulators).
5773 \end_layout
5774
5775 \begin_layout Itemize
5776 sourcefile.dump*
5777 \begin_inset LatexCommand \index{<file>.dump*}
5778
5779 \end_inset
5780
5781  - Dump file to debug the compiler it self (generated with option -
5782 \begin_inset ERT
5783 status collapsed
5784
5785 \begin_layout Standard
5786
5787
5788 \backslash
5789 /
5790 \end_layout
5791
5792 \end_inset
5793
5794 -dumpall) (see section 
5795 \begin_inset LatexCommand \ref{sub:Intermediate-Dump-Options}
5796
5797 \end_inset
5798
5799 \InsetSpace ~
5800  and section 
5801 \begin_inset LatexCommand \ref{sub:The-anatomy-of}
5802
5803 \end_inset
5804
5805 \InsetSpace ~
5806
5807 \begin_inset Quotes sld
5808 \end_inset
5809
5810 Anatomy of the compiler
5811 \begin_inset Quotes srd
5812 \end_inset
5813
5814 ).
5815 \end_layout
5816
5817 \begin_layout Subsection
5818 Postprocessing the Intel Hex
5819 \begin_inset LatexCommand \index{Intel hex format}
5820
5821 \end_inset
5822
5823  file
5824 \begin_inset LatexCommand \label{sub:Postprocessing-the-Intel}
5825
5826 \end_inset
5827
5828
5829 \end_layout
5830
5831 \begin_layout Standard
5832 In most cases this won't be needed but the Intel Hex file
5833 \begin_inset LatexCommand \index{<file>.ihx}
5834
5835 \end_inset
5836
5837  which is generated by SDCC might include lines of varying length and the
5838  addresses within the file are not guaranteed to be strictly ascending.
5839  If your toolchain or a bootloader does not like this you can use the tool
5840  
5841 \family typewriter
5842 packihx
5843 \family default
5844
5845 \begin_inset LatexCommand \index{packihx (tool)}
5846
5847 \end_inset
5848
5849  which is part of the SDCC distribution: 
5850 \newline
5851
5852 \newline
5853  
5854 \family sans
5855 \series bold
5856 packihx sourcefile.ihx >sourcefile.hex
5857 \family default
5858 \series default
5859
5860 \newline
5861
5862 \newline
5863 The separately available 
5864 \emph on
5865 srecord
5866 \emph default
5867
5868 \begin_inset LatexCommand \index{srecord (bin, hex, ... tool)}
5869
5870 \end_inset
5871
5872  package additionally allows to set undefined locations to a predefined
5873  value, to insert checksums
5874 \begin_inset LatexCommand \index{checksum}
5875
5876 \end_inset
5877
5878  of various flavours (crc, add, xor) and to perform other manipulations
5879  (convert, split, crop, offset, ...).
5880  
5881 \newline
5882
5883 \newline
5884
5885 \family sans
5886 \series bold
5887 srec_cat\InsetSpace ~
5888 \InsetSpace ~
5889 sourcefile.ihx -intel\InsetSpace ~
5890 \InsetSpace ~
5891 -o sourcefile.hex -intel
5892 \newline
5893
5894 \newline
5895
5896 \family default
5897 \series default
5898 An example for a more complex command line
5899 \begin_inset Foot
5900 status open
5901
5902 \begin_layout Standard
5903 the command backfills
5904 \begin_inset LatexCommand \index{backfill unused memory}
5905
5906 \end_inset
5907
5908  unused memory with 0x12 and the overall 16 bit sum of the complete 64 kByte
5909  block is zero.
5910  If the program counter on an mcs51 runs wild the backfill pattern 0x12
5911  will be interpreted as an 
5912 \family typewriter
5913 lcall
5914 \family default
5915  to address 
5916 \family typewriter
5917 0x1212
5918 \family default
5919  (where an emergency routine could sit).
5920 \end_layout
5921
5922 \end_inset
5923
5924  could look like:
5925 \newline
5926
5927 \newline
5928
5929 \family sans
5930 \series bold
5931 \size footnotesize
5932 srec_cat\InsetSpace ~
5933 sourcefile.ihx -intel\InsetSpace ~
5934 \InsetSpace ~
5935 -fill 0x12 0x0000 0xfffe\InsetSpace ~
5936 -little-endian-checksum-nega
5937 tive 0xfffe 0x02 0x02\InsetSpace ~
5938 \InsetSpace ~
5939 -o sourcefile.hex -intel
5940 \size default
5941
5942 \newline
5943
5944 \newline
5945
5946 \family default
5947 \series default
5948 The srecord package is available at 
5949 \begin_inset LatexCommand \url{http://sf.net/projects/srecord}
5950
5951 \end_inset
5952
5953  .
5954 \end_layout
5955
5956 \begin_layout Subsection
5957 Projects with Multiple Source Files
5958 \end_layout
5959
5960 \begin_layout Standard
5961 SDCC can compile only ONE file at a time.
5962  Let us for example assume that you have a project containing the following
5963  files:
5964 \newline
5965
5966 \newline
5967 foo1.c (contains some functions)
5968 \newline
5969 foo2.c (contains some more functions)
5970 \newline
5971 foomai
5972 n.c (contains more functions and the function main)
5973 \newline
5974
5975 \size footnotesize
5976
5977 \newline
5978
5979 \size default
5980 The first two files will need to be compiled separately with the commands:
5981 \size footnotesize
5982  
5983 \size default
5984
5985 \newline
5986
5987 \newline
5988
5989 \family sans
5990 \series bold
5991 sdcc\InsetSpace ~
5992 -c\InsetSpace ~
5993 foo1.c
5994 \family default
5995 \series default
5996 \size footnotesize
5997
5998 \newline
5999
6000 \family sans
6001 \series bold
6002 \size default
6003 sdcc\InsetSpace ~
6004 -c\InsetSpace ~
6005 foo2.c
6006 \family default
6007 \series default
6008
6009 \newline
6010
6011 \newline
6012 Then compile the source file containing the 
6013 \emph on
6014 main()
6015 \emph default
6016  function and link
6017 \begin_inset LatexCommand \index{Linker}
6018
6019 \end_inset
6020
6021  the files together with the following command: 
6022 \newline
6023
6024 \newline
6025
6026 \family sans
6027 \series bold
6028 sdcc\InsetSpace ~
6029 foomain.c\InsetSpace ~
6030 foo1.rel\InsetSpace ~
6031 foo2.rel
6032 \family default
6033 \series default
6034
6035 \begin_inset LatexCommand \index{<file>.rel}
6036
6037 \end_inset
6038
6039
6040 \newline
6041
6042 \newline
6043 Alternatively, 
6044 \emph on
6045 foomain.c
6046 \emph default
6047  can be separately compiled as well: 
6048 \family sans
6049 \series bold
6050
6051 \newline
6052
6053 \newline
6054 sdcc\InsetSpace ~
6055 -c\InsetSpace ~
6056 foomain.c
6057 \newline
6058 sdcc foomain.rel foo1.rel foo2.rel
6059 \newline
6060
6061 \newline
6062
6063 \family default
6064 \series default
6065 The file containing the 
6066 \emph on
6067 main()
6068 \emph default
6069  function 
6070 \noun on
6071 must
6072 \noun default
6073  be the 
6074 \noun on
6075 first
6076 \noun default
6077  file specified in the command line, since the linkage editor processes
6078  file in the order they are presented to it.
6079  The linker is invoked from SDCC using a script file with extension .lnk
6080 \begin_inset LatexCommand \index{<file>.lnk}
6081
6082 \end_inset
6083
6084 .
6085  You can view this file to troubleshoot linking problems such as those arising
6086  from missing libraries.
6087 \end_layout
6088
6089 \begin_layout Subsection
6090 Projects with Additional Libraries
6091 \begin_inset LatexCommand \index{Libraries}
6092
6093 \end_inset
6094
6095
6096 \end_layout
6097
6098 \begin_layout Standard
6099 Some reusable routines may be compiled into a library, see the documentation
6100  for the assembler and linkage editor (which are in <installdir>/share/sdcc/doc)
6101  for how to create a 
6102 \emph on
6103 .lib
6104 \begin_inset LatexCommand \index{<file>.lib}
6105
6106 \end_inset
6107
6108
6109 \emph default
6110  library file.
6111  Libraries created in this manner can be included in the command line.
6112  Make sure you include the -L <library-path> option to tell the linker where
6113  to look for these files if they are not in the current directory.
6114  Here is an example, assuming you have the source file 
6115 \emph on
6116 foomain.c
6117 \emph default
6118  and a library 
6119 \emph on
6120 foolib.lib
6121 \emph default
6122  in the directory 
6123 \emph on
6124 mylib
6125 \emph default
6126  (if that is not the same as your current project):
6127 \newline
6128
6129 \newline
6130
6131 \family sans
6132 \series bold
6133 sdcc foomain.c foolib.lib -L mylib
6134 \newline
6135
6136 \newline
6137
6138 \family default
6139 \series default
6140 Note here that 
6141 \emph on
6142 mylib
6143 \emph default
6144  must be an absolute path name.
6145 \newline
6146
6147 \newline
6148 The most efficient way to use libraries is
6149  to keep separate modules in separate source files.
6150  The lib file now should name all the modules.rel
6151 \begin_inset LatexCommand \index{<file>.rel}
6152
6153 \end_inset
6154
6155  files.
6156  For an example see the standard library file 
6157 \emph on
6158 libsdcc.lib
6159 \emph default
6160  in the directory <installdir>/share/lib/small.
6161 \end_layout
6162
6163 \begin_layout Subsection
6164 Using sdcclib to Create and Manage Libraries
6165 \begin_inset LatexCommand \index{sdcclib}
6166
6167 \end_inset
6168
6169
6170 \end_layout
6171
6172 \begin_layout Standard
6173 Alternatively, instead of having a .rel file for each entry on the library
6174  file as described in the preceding section, sdcclib can be used to embed
6175  all the modules belonging to such library in the library file itself.
6176  This results in a larger library file, but it greatly reduces the number
6177  of disk files accessed by the linker.
6178   Additionally, the packed library file contains an index of all include
6179  modules and symbols that significantly speeds up the linking process.
6180  To display a list of options supported by sdcclib type:
6181 \newline
6182
6183 \end_layout
6184
6185 \begin_layout Standard
6186
6187 \family sans
6188 \series bold
6189 sdcclib -?
6190 \begin_inset LatexCommand \index{sdcclib}
6191
6192 \end_inset
6193
6194
6195 \newline
6196
6197 \newline
6198
6199 \family default
6200 \series default
6201 To create a new library file, start by compiling all the required modules.
6202  For example:
6203 \newline
6204
6205 \end_layout
6206
6207 \begin_layout Standard
6208
6209 \family sans
6210 \series bold
6211 sdcc -c _divsint.c
6212 \end_layout
6213
6214 \begin_layout Standard
6215
6216 \family sans
6217 \series bold
6218 sdcc -c _divuint.c
6219 \end_layout
6220
6221 \begin_layout Standard
6222
6223 \family sans
6224 \series bold
6225 sdcc -c _modsint.c
6226 \end_layout
6227
6228 \begin_layout Standard
6229
6230 \family sans
6231 \series bold
6232 sdcc -c _moduint.c
6233 \end_layout
6234
6235 \begin_layout Standard
6236
6237 \family sans
6238 \series bold
6239 sdcc -c _mulint.c
6240 \newline
6241
6242 \end_layout
6243
6244 \begin_layout Standard
6245 This will create files _divsint.rel, _divuint.rel, _modsint.rel, _moduint.rel,
6246  and _mulint.rel.
6247  The next step is to add the .rel files to the library file:
6248 \newline
6249
6250 \end_layout
6251
6252 \begin_layout Standard
6253
6254 \family sans
6255 \series bold
6256 sdcclib libint.lib _divsint.rel
6257 \family default
6258
6259 \begin_inset LatexCommand \index{sdcclib}
6260
6261 \end_inset
6262
6263
6264 \end_layout
6265
6266 \begin_layout Standard
6267
6268 \family sans
6269 \series bold
6270 sdcclib libint.lib _divuint.rel
6271 \end_layout
6272
6273 \begin_layout Standard
6274
6275 \family sans
6276 \series bold
6277 sdcclib libint.lib _modsint.rel
6278 \end_layout
6279
6280 \begin_layout Standard
6281
6282 \family sans
6283 \series bold
6284 sdcclib libint.lib _moduint.rel
6285 \end_layout
6286
6287 \begin_layout Standard
6288
6289 \family sans
6290 \series bold
6291 sdcclib libint.lib _mulint.rel
6292 \series default
6293
6294 \newline
6295
6296 \end_layout
6297
6298 \begin_layout Standard
6299 Or, if you preffer:
6300 \newline
6301
6302 \end_layout
6303
6304 \begin_layout Standard
6305
6306 \family sans
6307 \series bold
6308 sdcclib libint.lib _divsint.rel _divuint.rel _modsint.rel _moduint.rel _mulint.rel
6309 \newline
6310
6311 \end_layout
6312
6313 \begin_layout Standard
6314 If the file already exists in the library, it will be replaced.
6315  If a list of .rel files is available, you can tell sdcclib to add those
6316  files to a library.
6317  For example, if the file 'myliblist.txt' contains
6318 \newline
6319
6320 \end_layout
6321
6322 \begin_layout Standard
6323
6324 \family sans
6325 \series bold
6326 _divsint.rel
6327 \end_layout
6328
6329 \begin_layout Standard
6330
6331 \family sans
6332 \series bold
6333 _divuint.rel
6334 \end_layout
6335
6336 \begin_layout Standard
6337
6338 \family sans
6339 \series bold
6340 _modsint.rel
6341 \end_layout
6342
6343 \begin_layout Standard
6344
6345 \family sans
6346 \series bold
6347 _moduint.rel
6348 \end_layout
6349
6350 \begin_layout Standard
6351
6352 \family sans
6353 \series bold
6354 _mulint.rel
6355 \series default
6356
6357 \newline
6358
6359 \end_layout
6360
6361 \begin_layout Standard
6362 Use 
6363 \newline
6364
6365 \end_layout
6366
6367 \begin_layout Standard
6368
6369 \family sans
6370 \series bold
6371 sdcclib -l libint.lib myliblist.txt
6372 \newline
6373
6374 \end_layout
6375
6376 \begin_layout Standard
6377 Additionally, you can instruct sdcclib to compile the files before adding
6378  them to the library by setting environment variables SDCCLIB_CC
6379 \begin_inset LatexCommand \index{SDCCLIB_CC}
6380
6381 \end_inset
6382
6383  and/or SDCCLIB_AS
6384 \begin_inset LatexCommand \index{SDCCLIB_AS}
6385
6386 \end_inset
6387
6388 .
6389  For example:
6390 \newline
6391
6392 \end_layout
6393
6394 \begin_layout Standard
6395
6396 \family sans
6397 \series bold
6398 set SDCCLIB_CC
6399 \begin_inset LatexCommand \index{SDCCLIB_CC}
6400
6401 \end_inset
6402
6403 =sdcc -
6404 \family default
6405
6406 \begin_inset ERT
6407 status collapsed
6408
6409 \begin_layout Standard
6410
6411
6412 \backslash
6413 /
6414 \end_layout
6415
6416 \end_inset
6417
6418
6419 \family sans
6420 -use-stdout -
6421 \family default
6422
6423 \begin_inset ERT
6424 status collapsed
6425
6426 \begin_layout Standard
6427
6428
6429 \backslash
6430 /
6431 \end_layout
6432
6433 \end_inset
6434
6435
6436 \family sans
6437 -model-small -c
6438 \end_layout
6439
6440 \begin_layout Standard
6441
6442 \family sans
6443 \series bold
6444 sdcclib -l libint.lib myliblist.txt
6445 \newline
6446
6447 \end_layout
6448
6449 \begin_layout Standard
6450 To see what modules and symbols are included in the library, options -s
6451  and -m are available.
6452  For example:
6453 \newline
6454
6455 \newline
6456
6457 \family sans
6458 \series bold
6459 sdcclib -s libint.lib
6460 \family default
6461
6462 \begin_inset LatexCommand \index{sdcclib}
6463
6464 \end_inset
6465
6466
6467 \newline
6468
6469 \family typewriter
6470 \series default
6471 _divsint.rel:
6472 \end_layout
6473
6474 \begin_layout Standard
6475
6476 \family typewriter
6477 __divsint_a_1_1
6478 \end_layout
6479
6480 \begin_layout Standard
6481
6482 \family typewriter
6483 __divsint_PARM_2
6484 \end_layout
6485
6486 \begin_layout Standard
6487
6488 \family typewriter
6489 __divsint
6490 \newline
6491 _divuint.rel:
6492 \end_layout
6493
6494 \begin_layout Standard
6495
6496 \family typewriter
6497 __divuint_a_1_1
6498 \end_layout
6499
6500 \begin_layout Standard
6501
6502 \family typewriter
6503 __divuint_PARM_2
6504 \end_layout
6505
6506 \begin_layout Standard
6507
6508 \family typewriter
6509 __divuint_reste_1_1
6510 \end_layout
6511
6512 \begin_layout Standard
6513
6514 \family typewriter
6515 __divuint_count_1_1
6516 \end_layout
6517
6518 \begin_layout Standard
6519
6520 \family typewriter
6521 __divuint
6522 \newline
6523 _modsint.rel:
6524 \end_layout
6525
6526 \begin_layout Standard
6527
6528 \family typewriter
6529 __modsint_a_1_1
6530 \end_layout
6531
6532 \begin_layout Standard
6533
6534 \family typewriter
6535 __modsint_PARM_2
6536 \end_layout
6537
6538 \begin_layout Standard
6539
6540 \family typewriter
6541 __modsint
6542 \newline
6543 _moduint.rel:
6544 \end_layout
6545
6546 \begin_layout Standard
6547
6548 \family typewriter
6549 __moduint_a_1_1
6550 \end_layout
6551
6552 \begin_layout Standard
6553
6554 \family typewriter
6555 __moduint_PARM_2
6556 \end_layout
6557
6558 \begin_layout Standard
6559
6560 \family typewriter
6561 __moduint_count_1_1
6562 \end_layout
6563
6564 \begin_layout Standard
6565
6566 \family typewriter
6567 __moduint
6568 \newline
6569 _mulint.rel:
6570 \end_layout
6571
6572 \begin_layout Standard
6573
6574 \family typewriter
6575 __mulint_PARM_2
6576 \end_layout
6577
6578 \begin_layout Standard
6579
6580 \family typewriter
6581 __mulint
6582 \family default
6583 \series bold
6584
6585 \newline
6586
6587 \end_layout
6588
6589 \begin_layout Standard
6590 If the source files are compiled using -
6591 \begin_inset ERT
6592 status collapsed
6593
6594 \begin_layout Standard
6595
6596
6597 \backslash
6598 /
6599 \end_layout
6600
6601 \end_inset
6602
6603 -debug
6604 \begin_inset LatexCommand \index{-\\/-debug}
6605
6606 \end_inset
6607
6608 , the corresponding debug information file .adb will be include in the library
6609  file as well.
6610  The library files created with sdcclib are plain text files, so they can
6611  be viewed with a text editor.
6612  It is not recomended to modify a library file created with sdcclib using
6613  a text editor, as there are file indexes numbers located accross the file
6614  used by the linker to quickly locate the required module to link.
6615  Once a .rel file (as well as a .adb file) is added to a library using sdcclib,
6616  it can be safely deleted, since all the information required for linking
6617  is embedded in the library file itself.
6618  Library files created using sdcclib are used as described in the preceding
6619  sections.
6620 \begin_inset VSpace bigskip
6621 \end_inset
6622
6623
6624 \end_layout
6625
6626 \begin_layout Section
6627 Command Line Options
6628 \begin_inset LatexCommand \index{Command Line Options}
6629
6630 \end_inset
6631
6632
6633 \begin_inset LatexCommand \label{sec:Command-Line-Options}
6634
6635 \end_inset
6636
6637
6638 \end_layout
6639
6640 \begin_layout Subsection
6641 Processor Selection Options
6642 \begin_inset LatexCommand \index{Options processor selection}
6643
6644 \end_inset
6645
6646
6647 \begin_inset LatexCommand \index{Processor selection options}
6648
6649 \end_inset
6650
6651
6652 \end_layout
6653
6654 \begin_layout List
6655 \labelwidthstring 00.00.0000
6656
6657 \series bold
6658 -mmcs51
6659 \begin_inset LatexCommand \index{-mmcs51}
6660
6661 \end_inset
6662
6663
6664 \series default
6665  Generate code for the Intel MCS51
6666 \begin_inset LatexCommand \index{MCS51}
6667
6668 \end_inset
6669
6670  family of processors.
6671  This is the default processor target.
6672 \end_layout
6673
6674 \begin_layout List
6675 \labelwidthstring 00.00.0000
6676
6677 \series bold
6678 -mds390
6679 \begin_inset LatexCommand \index{-mds390}
6680
6681 \end_inset
6682
6683
6684 \series default
6685  Generate code for the Dallas DS80C390
6686 \begin_inset LatexCommand \index{DS80C390}
6687
6688 \end_inset
6689
6690  processor.
6691 \end_layout
6692
6693 \begin_layout List
6694 \labelwidthstring 00.00.0000
6695
6696 \series bold
6697 -mds400
6698 \begin_inset LatexCommand \index{-mds400}
6699
6700 \end_inset
6701
6702
6703 \series default
6704  Generate code for the Dallas DS80C400
6705 \begin_inset LatexCommand \index{DS80C400}
6706
6707 \end_inset
6708
6709  processor.
6710 \end_layout
6711
6712 \begin_layout List
6713 \labelwidthstring 00.00.0000
6714
6715 \series bold
6716 -mhc08
6717 \begin_inset LatexCommand \index{-mhc08}
6718
6719 \end_inset
6720
6721
6722 \series default
6723  Generate code for the Freescale/Motorola HC08
6724 \begin_inset LatexCommand \index{HC08}
6725
6726 \end_inset
6727
6728  family of processors.
6729 \end_layout
6730
6731 \begin_layout List
6732 \labelwidthstring 00.00.0000
6733
6734 \series bold
6735 -mz80
6736 \begin_inset LatexCommand \index{-mz80}
6737
6738 \end_inset
6739
6740
6741 \series default
6742  Generate code for the Zilog Z80
6743 \begin_inset LatexCommand \index{Z80}
6744
6745 \end_inset
6746
6747  family of processors.
6748 \end_layout
6749
6750 \begin_layout List
6751 \labelwidthstring 00.00.0000
6752
6753 \series bold
6754 -mgbz80
6755 \begin_inset LatexCommand \index{-mgbz80}
6756
6757 \end_inset
6758
6759
6760 \series default
6761  Generate code for the GameBoy Z80
6762 \begin_inset LatexCommand \index{gbz80 (GameBoy Z80)}
6763
6764 \end_inset
6765
6766  processor (Not actively maintained).
6767 \end_layout
6768
6769 \begin_layout List
6770 \labelwidthstring 00.00.0000
6771
6772 \series bold
6773 -mavr
6774 \begin_inset LatexCommand \index{-mavr}
6775
6776 \end_inset
6777
6778
6779 \series default
6780  Generate code for the Atmel AVR
6781 \begin_inset LatexCommand \index{AVR}
6782
6783 \end_inset
6784
6785  processor (Not maintained, not complete).
6786  AVR users should probably have a look at winavr 
6787 \begin_inset LatexCommand \url{http://sourceforge.net/projects/winavr}
6788
6789 \end_inset
6790
6791  or 
6792 \begin_inset LatexCommand \url{http://www.avrfreaks.net/index.php?name=PNphpBB2&file=index}
6793
6794 \end_inset
6795
6796 , which is based on AVR-port of the gcc compiler.
6797 \end_layout
6798
6799 \begin_layout Standard
6800 \begin_inset Note Note
6801 status collapsed
6802
6803 \begin_layout Standard
6804 I think it is fair to direct users there for now.
6805  Open source is also about avoiding unnecessary work .
6806  But I didn't find the 'official' link.
6807 \end_layout
6808
6809 \end_inset
6810
6811
6812 \end_layout
6813
6814 \begin_layout List
6815 \labelwidthstring 00.00.0000
6816
6817 \series bold
6818 -mpic14
6819 \begin_inset LatexCommand \index{-mpic14}
6820
6821 \end_inset
6822
6823
6824 \series default
6825  Generate code for the Microchip PIC 14
6826 \begin_inset LatexCommand \index{PIC14}
6827
6828 \end_inset
6829
6830 -bit processors (p16f84 and variants.
6831  In development, not complete).
6832 \end_layout
6833
6834 \begin_layout Standard
6835 \begin_inset Note Note
6836 status collapsed
6837
6838 \begin_layout Standard
6839 p16f627 p16f628 p16f84 p16f873 p16f877?
6840 \end_layout
6841
6842 \end_inset
6843
6844
6845 \end_layout
6846
6847 \begin_layout List
6848 \labelwidthstring 00.00.0000
6849
6850 \series bold
6851 -mpic16
6852 \begin_inset LatexCommand \index{-mpic16}
6853
6854 \end_inset
6855
6856
6857 \series default
6858  Generate code for the Microchip PIC 16
6859 \begin_inset LatexCommand \index{PIC16}
6860
6861 \end_inset
6862
6863 -bit processors (p18f452 and variants.
6864  In development, not complete).
6865 \end_layout
6866
6867 \begin_layout List
6868 \labelwidthstring 00.00.0000
6869
6870 \series bold
6871 -mtlcs900h
6872 \series default
6873  Generate code for the Toshiba TLCS-900H
6874 \begin_inset LatexCommand \index{TLCS-900H}
6875
6876 \end_inset
6877
6878  processor (Not maintained, not complete).
6879 \end_layout
6880
6881 \begin_layout List
6882 \labelwidthstring 00.00.0000
6883
6884 \series bold
6885 -mxa51
6886 \begin_inset LatexCommand \index{-mxa51}
6887
6888 \end_inset
6889
6890
6891 \series default
6892  Generate code for the Phillips XA51
6893 \begin_inset LatexCommand \index{XA51}
6894
6895 \end_inset
6896
6897  processor (Not maintained, not complete).
6898 \end_layout
6899
6900 \begin_layout Standard
6901 \begin_inset VSpace bigskip
6902 \end_inset
6903
6904
6905 \end_layout
6906
6907 \begin_layout Subsection
6908 Preprocessor Options
6909 \begin_inset LatexCommand \index{Options preprocessor}
6910
6911 \end_inset
6912
6913
6914 \begin_inset LatexCommand \index{Preprocessor options}
6915
6916 \end_inset
6917
6918
6919 \begin_inset LatexCommand \index{sdcpp (preprocessor)}
6920
6921 \end_inset
6922
6923
6924 \end_layout
6925
6926 \begin_layout List
6927 \labelwidthstring 00.00.0000
6928
6929 \series bold
6930 -I<path>
6931 \begin_inset LatexCommand \index{-I<path>}
6932
6933 \end_inset
6934
6935
6936 \series default
6937  The additional location where the preprocessor will look for <..h> or 
6938 \begin_inset Quotes eld
6939 \end_inset
6940
6941 ..h
6942 \begin_inset Quotes erd
6943 \end_inset
6944
6945  files.
6946 \end_layout
6947
6948 \begin_layout List
6949 \labelwidthstring 00.00.0000
6950
6951 \series bold
6952 -D<macro[=value]>
6953 \begin_inset LatexCommand \index{-D<macro[=value]>}
6954
6955 \end_inset
6956
6957
6958 \series default
6959  Command line definition of macros.
6960  Passed to the preprocessor.
6961 \end_layout
6962
6963 \begin_layout List
6964 \labelwidthstring 00.00.0000
6965
6966 \series bold
6967 -M
6968 \begin_inset LatexCommand \index{-M}
6969
6970 \end_inset
6971
6972
6973 \series default
6974  Tell the preprocessor to output a rule suitable for make describing the
6975  dependencies of each object file.
6976  For each source file, the preprocessor outputs one make-rule whose target
6977  is the object file name for that source file and whose dependencies are
6978  all the files `#include'd in it.
6979  This rule may be a single line or may be continued with `
6980 \backslash
6981 '-newline if it is long.
6982  The list of rules is printed on standard output instead of the preprocessed
6983  C program.
6984  `-M' implies `-E
6985 \begin_inset LatexCommand \index{-E}
6986
6987 \end_inset
6988
6989 '.
6990 \end_layout
6991
6992 \begin_layout List
6993 \labelwidthstring 00.00.0000
6994
6995 \series bold
6996 -C
6997 \begin_inset LatexCommand \index{-C}
6998
6999 \end_inset
7000
7001
7002 \series default
7003  Tell the preprocessor not to discard comments.
7004  Used with the `-E' option.
7005 \end_layout
7006
7007 \begin_layout List
7008 \labelwidthstring 00.00.0000
7009
7010 \series bold
7011 -MM
7012 \begin_inset LatexCommand \index{-MM}
7013
7014 \end_inset
7015
7016
7017 \series default
7018 \size large
7019  
7020 \size default
7021 Like `-M' but the output mentions only the user header files included with
7022  `#include 
7023 \begin_inset Quotes eld
7024 \end_inset
7025
7026 file"'.
7027  System header files included with `#include <file>' are omitted.
7028 \end_layout
7029
7030 \begin_layout List
7031 \labelwidthstring 00.00.0000
7032
7033 \series bold
7034 -Aquestion(answer)
7035 \begin_inset LatexCommand \index{-Aquestion(answer)}
7036
7037 \end_inset
7038
7039
7040 \series default
7041  Assert the answer answer for question, in case it is tested with a preprocessor
7042  conditional such as `#if #question(answer)'.
7043  `-A-' disables the standard assertions that normally describe the target
7044  machine.
7045 \end_layout
7046
7047 \begin_layout List
7048 \labelwidthstring 00.00.0000
7049
7050 \series bold
7051 -Umacro
7052 \begin_inset LatexCommand \index{-Umacro}
7053
7054 \end_inset
7055
7056
7057 \series default
7058  Undefine macro macro.
7059  `-U' options are evaluated after all `-D' options, but before any `-include'
7060  and `-imacros' options.
7061 \end_layout
7062
7063 \begin_layout List
7064 \labelwidthstring 00.00.0000
7065
7066 \series bold
7067 -dM
7068 \begin_inset LatexCommand \index{-dM}
7069
7070 \end_inset
7071
7072
7073 \series default
7074  Tell the preprocessor to output only a list of the macro definitions that
7075  are in effect at the end of preprocessing.
7076  Used with the `-E' option.
7077 \end_layout
7078
7079 \begin_layout List
7080 \labelwidthstring 00.00.0000
7081
7082 \series bold
7083 -dD
7084 \begin_inset LatexCommand \index{-dD}
7085
7086 \end_inset
7087
7088
7089 \series default
7090  Tell the preprocessor to pass all macro definitions into the output, in
7091  their proper sequence in the rest of the output.
7092 \end_layout
7093
7094 \begin_layout List
7095 \labelwidthstring 00.00.0000
7096
7097 \series bold
7098 -dN
7099 \begin_inset LatexCommand \index{-dN}
7100
7101 \end_inset
7102
7103
7104 \series default
7105 \size large
7106  
7107 \size default
7108 Like `-dD' except that the macro arguments and contents are omitted.
7109  Only `#define name' is included in the output.
7110 \end_layout
7111
7112 \begin_layout List
7113 \labelwidthstring 00.00.0000
7114
7115 \series bold
7116 -pedantic-parse-number
7117 \begin_inset LatexCommand \index{pedantic}
7118
7119 \end_inset
7120
7121
7122 \begin_inset LatexCommand \index{-pedantic-parse-number}
7123
7124 \end_inset
7125
7126
7127 \size large
7128 \bar under
7129
7130 \begin_inset LatexCommand \label{lyx:-pedantic-parse-number}
7131
7132 \end_inset
7133
7134
7135 \series default
7136 \bar default
7137  
7138 \size default
7139 Pedantic parse numbers so that situations like 0xfe-LO_B(3) are parsed properly
7140  and the macro LO_B(3) gets expanded.
7141  See also #pragma pedantic_parse_number 
7142 \begin_inset LatexCommand \vpageref{ite:pedantic_parse_number}
7143
7144 \end_inset
7145
7146  in section
7147 \begin_inset LatexCommand \ref{sec:Pragmas}
7148
7149 \end_inset
7150
7151  
7152 \emph on
7153 Note: this functionality is not in conformance with C99 standard!
7154 \end_layout
7155
7156 \begin_layout List
7157 \labelwidthstring 00.00.0000
7158
7159 \series bold
7160 -Wp\InsetSpace ~
7161 preprocessorOption[,preprocessorOption]
7162 \series default
7163
7164 \begin_inset LatexCommand \index{-Wp preprocessorOption[,preprocessorOption]}
7165
7166 \end_inset
7167
7168 ...
7169  Pass the preprocessorOption to the preprocessor 
7170 \family typewriter
7171 sdcpp
7172 \family default
7173
7174 \begin_inset LatexCommand \index{sdcpp (preprocessor)}
7175
7176 \end_inset
7177
7178 .
7179  SDCC uses an adapted version of the preprocessor 
7180 \emph on
7181 cpp
7182 \emph default
7183  of the GNU Compiler Collection
7184 \begin_inset LatexCommand \index{gcc (GNU Compiler Collection)}
7185
7186 \end_inset
7187
7188  (
7189 \emph on
7190 gcc
7191 \emph default
7192  
7193 \begin_inset LatexCommand \url{http://gcc.gnu.org/}
7194
7195 \end_inset
7196
7197 ), if you need more dedicated options please refer to the GCC\InsetSpace ~
7198 4.1.1\InsetSpace ~
7199 CPP\InsetSpace ~
7200 Manual
7201  at 
7202 \begin_inset LatexCommand \htmlurl{http://www.gnu.org/software/gcc/onlinedocs/}
7203
7204 \end_inset
7205
7206 .
7207 \end_layout
7208
7209 \begin_layout Standard
7210 \begin_inset VSpace bigskip
7211 \end_inset
7212
7213
7214 \end_layout
7215
7216 \begin_layout Subsection
7217 Linker Options
7218 \begin_inset LatexCommand \index{Options linker}
7219
7220 \end_inset
7221
7222
7223 \begin_inset LatexCommand \index{Linker options}
7224
7225 \end_inset
7226
7227
7228 \end_layout
7229
7230 \begin_layout List
7231 \labelwidthstring 00.00.0000
7232
7233 \series bold
7234 -L\InsetSpace ~
7235 -
7236 \series default
7237
7238 \begin_inset ERT
7239 status collapsed
7240
7241 \begin_layout Standard
7242
7243
7244 \backslash
7245 /
7246 \end_layout
7247
7248 \end_inset
7249
7250
7251 \series bold
7252 -lib-path
7253 \begin_inset LatexCommand \index{-\\/-lib-path <path>}
7254
7255 \end_inset
7256
7257
7258 \begin_inset LatexCommand \index{-L -\\/-lib-path}
7259
7260 \end_inset
7261
7262
7263 \series default
7264 \InsetSpace ~
7265 <absolute path to additional libraries> This option is passed to the linkage
7266  editor's additional libraries
7267 \begin_inset LatexCommand \index{Libraries}
7268
7269 \end_inset
7270
7271  search path.
7272  The path name must be absolute.
7273  Additional library files may be specified in the command line.
7274  See section Compiling programs for more details.
7275 \end_layout
7276
7277 \begin_layout List
7278 \labelwidthstring 00.00.0000
7279
7280 \series bold
7281 -
7282 \begin_inset ERT
7283 status collapsed
7284
7285 \begin_layout Standard
7286
7287
7288 \backslash
7289 /
7290 \end_layout
7291
7292 \end_inset
7293
7294 -xram-loc
7295 \series default
7296
7297 \begin_inset LatexCommand \index{-\\/-xram-loc <Value>}
7298
7299 \end_inset
7300
7301 \InsetSpace ~
7302 <Value> The start location of the external ram
7303 \begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
7304
7305 \end_inset
7306
7307 , default value is 0.
7308  The value entered can be in Hexadecimal or Decimal format, e.g.: -
7309 \begin_inset ERT
7310 status collapsed
7311
7312 \begin_layout Standard
7313
7314
7315 \backslash
7316 /
7317 \end_layout
7318
7319 \end_inset
7320
7321 -xram-loc 0x8000 or -
7322 \begin_inset ERT
7323 status collapsed
7324
7325 \begin_layout Standard
7326
7327
7328 \backslash
7329 /
7330 \end_layout
7331
7332 \end_inset
7333
7334 -xram-loc 32768.
7335 \end_layout
7336
7337 \begin_layout List
7338 \labelwidthstring 00.00.0000
7339
7340 \series bold
7341 -
7342 \begin_inset ERT
7343 status collapsed
7344
7345 \begin_layout Standard
7346
7347
7348 \backslash
7349 /
7350 \end_layout
7351
7352 \end_inset
7353
7354 -code-loc
7355 \series default
7356
7357 \begin_inset LatexCommand \index{-\\/-code-loc <Value>}
7358
7359 \end_inset
7360
7361 \InsetSpace ~
7362 <Value> The start location of the code
7363 \begin_inset LatexCommand \index{code}
7364
7365 \end_inset
7366
7367  segment, default value 0.
7368  Note when this option is used the interrupt vector table
7369 \begin_inset LatexCommand \index{interrupt vector table}
7370
7371 \end_inset
7372
7373  is also relocated to the given address.
7374  The value entered can be in Hexadecimal or Decimal format, e.g.: -
7375 \begin_inset ERT
7376 status collapsed
7377
7378 \begin_layout Standard
7379
7380
7381 \backslash
7382 /
7383 \end_layout
7384
7385 \end_inset
7386
7387 -code-loc 0x8000 or -
7388 \begin_inset ERT
7389 status collapsed
7390
7391 \begin_layout Standard
7392
7393
7394 \backslash
7395 /
7396 \end_layout
7397
7398 \end_inset
7399
7400 -code-loc 32768.
7401 \end_layout
7402
7403 \begin_layout List
7404 \labelwidthstring 00.00.0000
7405
7406 \series bold
7407 -
7408 \begin_inset ERT
7409 status collapsed
7410
7411 \begin_layout Standard
7412
7413
7414 \backslash
7415 /
7416 \end_layout
7417
7418 \end_inset
7419
7420 -stack-loc
7421 \series default
7422
7423 \begin_inset LatexCommand \index{-\\/-stack-loc <Value>}
7424
7425 \end_inset
7426
7427 \InsetSpace ~
7428 <Value> By default the stack
7429 \begin_inset LatexCommand \index{stack}
7430
7431 \end_inset
7432
7433  is placed after the data segment.
7434  Using this option the stack can be placed anywhere in the internal memory
7435  space of the 8051.
7436  The value entered can be in Hexadecimal or Decimal format, e.g.
7437  -
7438 \begin_inset ERT
7439 status collapsed
7440
7441 \begin_layout Standard
7442
7443
7444 \backslash
7445 /
7446 \end_layout
7447
7448 \end_inset
7449
7450 -stack-loc 0x20 or -
7451 \begin_inset ERT
7452 status collapsed
7453
7454 \begin_layout Standard
7455
7456
7457 \backslash
7458 /
7459 \end_layout
7460
7461 \end_inset
7462
7463 -stack-loc 32.
7464  Since the sp register is incremented before a push or call, the initial
7465  sp will be set to one byte prior the provided value.
7466  The provided value should not overlap any other memory areas such as used
7467  register banks or the data segment and with enough space for the current
7468  application.
7469  The 
7470 \series bold
7471 -
7472 \begin_inset ERT
7473 status collapsed
7474
7475 \begin_layout Standard
7476
7477
7478 \backslash
7479 /
7480 \end_layout
7481
7482 \end_inset
7483
7484 -pack-iram
7485 \series default
7486 \InsetSpace ~
7487
7488 \begin_inset LatexCommand \index{-\\/-pack-iram}
7489
7490 \end_inset
7491
7492  option (which is now a default setting) will override this setting, so
7493  you should also specify the 
7494 \series bold
7495 -
7496 \begin_inset ERT
7497 status collapsed
7498
7499 \begin_layout Standard
7500
7501
7502 \backslash
7503 /
7504 \end_layout
7505
7506 \end_inset
7507
7508 -no-pack-iram
7509 \series default
7510 \InsetSpace ~
7511
7512 \begin_inset LatexCommand \index{-\\/-no-pack-iram}
7513
7514 \end_inset
7515
7516  option if you need to manually place the stack.
7517 \end_layout
7518
7519 \begin_layout List
7520 \labelwidthstring 00.00.0000
7521
7522 \series bold
7523 -
7524 \begin_inset ERT
7525 status collapsed
7526
7527 \begin_layout Standard
7528
7529
7530 \backslash
7531 /
7532 \end_layout
7533
7534 \end_inset
7535
7536 -xstack-loc
7537 \series default
7538
7539 \begin_inset LatexCommand \index{-\\/-xstack-loc <Value>}
7540
7541 \end_inset
7542
7543 \InsetSpace ~
7544 <Value> By default the external stack
7545 \begin_inset LatexCommand \index{xstack}
7546
7547 \end_inset
7548
7549  is placed after the pdata
7550 \begin_inset LatexCommand \index{pdata (mcs51, ds390 storage class)}
7551
7552 \end_inset
7553
7554  segment.
7555  Using this option the xstack can be placed anywhere in the external memory
7556  space of the 8051.
7557  The value entered can be in Hexadecimal or Decimal format, e.g.
7558  -
7559 \begin_inset ERT
7560 status collapsed
7561
7562 \begin_layout Standard
7563
7564
7565 \backslash
7566 /
7567 \end_layout
7568
7569 \end_inset
7570
7571 -xstack-loc 0x8000 or -
7572 \begin_inset ERT
7573 status collapsed
7574
7575 \begin_layout Standard
7576
7577
7578 \backslash
7579 /
7580 \end_layout
7581
7582 \end_inset
7583
7584 -stack-loc 32768.
7585  The provided value should not overlap any other memory areas such as the
7586  pdata or xdata segment and with enough space for the current application.
7587 \end_layout
7588
7589 \begin_layout List
7590 \labelwidthstring 00.00.0000
7591
7592 \series bold
7593 -
7594 \begin_inset ERT
7595 status collapsed
7596
7597 \begin_layout Standard
7598
7599
7600 \backslash
7601 /
7602 \end_layout
7603
7604 \end_inset
7605
7606 -data-loc
7607 \series default
7608
7609 \begin_inset LatexCommand \index{-\\/-data-loc <Value>}
7610
7611 \end_inset
7612
7613 \InsetSpace ~
7614 <Value> The start location of the internal ram data
7615 \begin_inset LatexCommand \index{data (mcs51, ds390 storage class)}
7616
7617 \end_inset
7618
7619  segment.
7620  The value entered can be in Hexadecimal or Decimal format, eg.
7621  -
7622 \begin_inset ERT
7623 status collapsed
7624
7625 \begin_layout Standard
7626
7627
7628 \backslash
7629 /
7630 \end_layout
7631
7632 \end_inset
7633
7634 -data-loc 0x20 or -
7635 \begin_inset ERT
7636 status collapsed
7637
7638 \begin_layout Standard
7639
7640
7641 \backslash
7642 /
7643 \end_layout
7644
7645 \end_inset
7646
7647 -data-loc 32.
7648  (By default, the start location of the internal ram data segment  is set
7649  as low as possible in memory, taking into account the used register banks
7650  and the bit segment at address 0x20.
7651  For example if register banks 0 and 1 are used without bit variables, the
7652  data segment will be set, if -
7653 \begin_inset ERT
7654 status collapsed
7655
7656 \begin_layout Standard
7657
7658
7659 \backslash
7660 /
7661 \end_layout
7662
7663 \end_inset
7664
7665 -data-loc is not used, to location 0x10.)
7666 \end_layout
7667
7668 \begin_layout List
7669 \labelwidthstring 00.00.0000
7670
7671 \series bold
7672 -
7673 \begin_inset ERT
7674 status collapsed
7675
7676 \begin_layout Standard
7677
7678
7679 \backslash
7680 /
7681 \end_layout
7682
7683 \end_inset
7684
7685 -idata-loc
7686 \series default
7687
7688 \begin_inset LatexCommand \index{-\\/-idata-loc <Value>}
7689
7690 \end_inset
7691
7692 \InsetSpace ~
7693 <Value> The start location of the indirectly addressable internal ram
7694 \begin_inset LatexCommand \index{idata (mcs51, ds390 storage class)}
7695
7696 \end_inset
7697
7698  of the 8051, default value is 0x80.
7699  The value entered can be in Hexadecimal or Decimal format, eg.
7700  -
7701 \begin_inset ERT
7702 status collapsed
7703
7704 \begin_layout Standard
7705
7706
7707 \backslash
7708 /
7709 \end_layout
7710
7711 \end_inset
7712
7713 -idata-loc 0x88 or -
7714 \begin_inset ERT
7715 status collapsed
7716
7717 \begin_layout Standard
7718
7719
7720 \backslash
7721 /
7722 \end_layout
7723
7724 \end_inset
7725
7726 -idata-loc 136.
7727 \end_layout
7728
7729 \begin_layout List
7730 \labelwidthstring 00.00.0000
7731
7732 \series bold
7733 -
7734 \begin_inset ERT
7735 status collapsed
7736
7737 \begin_layout Standard
7738
7739
7740 \backslash
7741 /
7742 \end_layout
7743
7744 \end_inset
7745
7746 -bit-loc
7747 \series default
7748 \InsetSpace ~
7749 <Value> The start location of the bit
7750 \begin_inset LatexCommand \index{bit}
7751
7752 \end_inset
7753
7754  addressable internal ram of the 8051.
7755  This is 
7756 \emph on
7757 not
7758 \emph default
7759  implemented yet.
7760  Instead an option can be passed directly to the linker: -Wl\InsetSpace ~
7761 -bBSEG=<Value>.
7762 \end_layout
7763
7764 \begin_layout List
7765 \labelwidthstring 00.00.0000
7766
7767 \series bold
7768 -
7769 \begin_inset ERT
7770 status collapsed
7771
7772 \begin_layout Standard
7773
7774
7775 \backslash
7776 /
7777 \end_layout
7778
7779 \end_inset
7780
7781 -out-fmt-ihx
7782 \begin_inset LatexCommand \index{-\\/-out-fmt-ihx}
7783
7784 \end_inset
7785
7786  
7787 \series default
7788 The linker output (final object code) is in Intel Hex format.
7789 \begin_inset LatexCommand \index{Intel hex format}
7790
7791 \end_inset
7792
7793  This is the default option.
7794  The format itself is documented in the documentation of srecord
7795 \begin_inset LatexCommand \index{srecord (bin, hex, ... tool)}
7796
7797 \end_inset
7798
7799 .
7800 \end_layout
7801
7802 \begin_layout List
7803 \labelwidthstring 00.00.0000
7804
7805 \series bold
7806 -
7807 \begin_inset ERT
7808 status collapsed
7809
7810 \begin_layout Standard
7811
7812
7813 \backslash
7814 /
7815 \end_layout
7816
7817 \end_inset
7818
7819 -out-fmt-s19
7820 \begin_inset LatexCommand \index{-\\/-out-fmt-s19}
7821
7822 \end_inset
7823
7824  
7825 \series default
7826 The linker output (final object code) is in Motorola S19 format
7827 \begin_inset LatexCommand \index{Motorola S19 format}
7828
7829 \end_inset
7830
7831 .
7832  The format itself is documented in the documentation of srecord.
7833 \end_layout
7834
7835 \begin_layout List
7836 \labelwidthstring 00.00.0000
7837
7838 \series bold
7839 -
7840 \begin_inset ERT
7841 status collapsed
7842
7843 \begin_layout Standard
7844
7845
7846 \backslash
7847 /
7848 \end_layout
7849
7850 \end_inset
7851
7852 -out-fmt-elf
7853 \begin_inset LatexCommand \index{-\\/-out-fmt-s19}
7854
7855 \end_inset
7856
7857
7858 \begin_inset LatexCommand \index{HC08!Options!-\\/-out-fmt-elf}
7859
7860 \end_inset
7861
7862  
7863 \series default
7864 The linker output (final object code) is in ELF format
7865 \begin_inset LatexCommand \index{ELF format}
7866
7867 \end_inset
7868
7869 .
7870  (Currently only supported for the HC08
7871 \begin_inset LatexCommand \index{HC08}
7872
7873 \end_inset
7874
7875  processors)
7876 \end_layout
7877
7878 \begin_layout List
7879 \labelwidthstring 00.00.0000
7880
7881 \series bold
7882 -Wl\InsetSpace ~
7883 linkOption[,linkOption]
7884 \series default
7885
7886 \begin_inset LatexCommand \index{-Wl linkOption[,linkOption]}
7887
7888 \end_inset
7889
7890 ...
7891  Pass the linkOption to the linker.
7892  If a bootloader is used an option like 
7893 \begin_inset Quotes sld
7894 \end_inset
7895
7896 -Wl\InsetSpace ~
7897 -bCSEG=0x1000
7898 \begin_inset Quotes srd
7899 \end_inset
7900
7901  would be typical to set the start of the code segment.
7902  See also #pragma constseg and #pragma codeseg in section 
7903 \begin_inset LatexCommand \ref{sec:Pragmas}
7904
7905 \end_inset
7906
7907  .
7908  File sdcc/as/doc/asxhtm.html has more on linker options.
7909 \end_layout
7910
7911 \begin_layout Standard
7912 \begin_inset VSpace bigskip
7913 \end_inset
7914
7915
7916 \end_layout
7917
7918 \begin_layout Subsection
7919 MCS51 Options
7920 \begin_inset LatexCommand \index{Options MCS51}
7921
7922 \end_inset
7923
7924
7925 \begin_inset LatexCommand \index{MCS51 options}
7926
7927 \end_inset
7928
7929
7930 \end_layout
7931
7932 \begin_layout List
7933 \labelwidthstring 00.00.0000
7934
7935 \series bold
7936 -
7937 \begin_inset ERT
7938 status collapsed
7939
7940 \begin_layout Standard
7941
7942
7943 \backslash
7944 /
7945 \end_layout
7946
7947 \end_inset
7948
7949 -model-small
7950 \begin_inset LatexCommand \index{-\\/-model-small}
7951
7952 \end_inset
7953
7954
7955 \series default
7956 \size large
7957  
7958 \size default
7959 Generate code for Small Model programs, see section Memory Models for more
7960  details.
7961  This is the default model.
7962 \end_layout
7963
7964 \begin_layout List
7965 \labelwidthstring 00.00.0000
7966
7967 \series bold
7968 -
7969 \begin_inset ERT
7970 status collapsed
7971
7972 \begin_layout Standard
7973
7974
7975 \backslash
7976 /
7977 \end_layout
7978
7979 \end_inset
7980
7981 -model-medium
7982 \begin_inset LatexCommand \index{-\\/-model-medium}
7983
7984 \end_inset
7985
7986
7987 \series default
7988  Generate code for Medium model programs, see section Memory Models for
7989  more details.
7990  If this option is used all source files in the project have to be compiled
7991  with this option.
7992  It must also be used when invoking the linker.
7993 \end_layout
7994
7995 \begin_layout List
7996 \labelwidthstring 00.00.0000
7997
7998 \series bold
7999 -
8000 \begin_inset ERT
8001 status collapsed
8002
8003 \begin_layout Standard
8004
8005
8006 \backslash
8007 /
8008 \end_layout
8009
8010 \end_inset
8011
8012 -model-large
8013 \begin_inset LatexCommand \index{-\\/-model-large}
8014
8015 \end_inset
8016
8017
8018 \series default
8019  Generate code for Large model programs, see section Memory Models for more
8020  details.
8021  If this option is used all source files in the project have to be compiled
8022  with this option.
8023  It must also be used when invoking the linker.
8024 \end_layout
8025
8026 \begin_layout List
8027 \labelwidthstring 00.00.0000
8028
8029 \series bold
8030 -
8031 \begin_inset ERT
8032 status collapsed
8033
8034 \begin_layout Standard
8035
8036
8037 \backslash
8038 /
8039 \end_layout
8040
8041 \end_inset
8042
8043 -xstack
8044 \begin_inset LatexCommand \index{-\\/-xstack}
8045
8046 \end_inset
8047
8048
8049 \series default
8050  Uses a pseudo stack in the pdata
8051 \begin_inset LatexCommand \index{pdata (mcs51, ds390 storage class)}
8052
8053 \end_inset
8054
8055  area (usually the first 256 bytes in the external ram) for allocating variables
8056  and passing parameters.
8057  See section 
8058 \begin_inset LatexCommand \ref{sub:External-Stack}
8059
8060 \end_inset
8061
8062 \InsetSpace ~
8063  External Stack for more details.
8064 \end_layout
8065
8066 \begin_layout List
8067 \labelwidthstring 00.00.0000
8068
8069 \series bold
8070 -
8071 \begin_inset ERT
8072 status collapsed
8073
8074 \begin_layout Standard
8075
8076
8077 \backslash
8078 /
8079 \end_layout
8080
8081 \end_inset
8082
8083 -iram-size
8084 \series default
8085 \InsetSpace ~
8086 <Value>
8087 \begin_inset LatexCommand \index{-\\/-iram-size <Value>}
8088
8089 \end_inset
8090
8091  Causes the linker to check if the internal ram usage is within limits of
8092  the given value.
8093 \end_layout
8094
8095 \begin_layout List
8096 \labelwidthstring 00.00.0000
8097
8098 \series bold
8099 -
8100 \begin_inset ERT
8101 status collapsed
8102
8103 \begin_layout Standard
8104
8105
8106 \backslash
8107 /
8108 \end_layout
8109
8110 \end_inset
8111
8112 -xram-size
8113 \series default
8114 \InsetSpace ~
8115 <Value>
8116 \begin_inset LatexCommand \index{-\\/-xram-size <Value>}
8117
8118 \end_inset
8119
8120  Causes the linker to check if the external ram usage is within limits of
8121  the given value.
8122 \end_layout
8123
8124 \begin_layout List
8125 \labelwidthstring 00.00.0000
8126
8127 \series bold
8128 -
8129 \begin_inset ERT
8130 status collapsed
8131
8132 \begin_layout Standard
8133
8134
8135 \backslash
8136 /
8137 \end_layout
8138
8139 \end_inset
8140
8141 -code-size
8142 \series default
8143 \InsetSpace ~
8144 <Value>
8145 \begin_inset LatexCommand \index{-\\/-code-size <Value>}
8146
8147 \end_inset
8148
8149  Causes the linker to check if the code memory usage is within limits of
8150  the given value.
8151 \end_layout
8152
8153 \begin_layout List
8154 \labelwidthstring 00.00.0000
8155
8156 \series bold
8157 -
8158 \begin_inset ERT
8159 status collapsed
8160
8161 \begin_layout Standard
8162
8163
8164 \backslash
8165 /
8166 \end_layout
8167
8168 \end_inset
8169
8170 -stack-size
8171 \series default
8172 \InsetSpace ~
8173 <Value>
8174 \begin_inset LatexCommand \index{-\\/-stack-size <Value>}
8175
8176 \end_inset
8177
8178  Causes the linker to check if there is at minimum <Value> bytes for stack.
8179 \end_layout
8180
8181 \begin_layout List
8182 \labelwidthstring 00.00.0000
8183
8184 \series bold
8185 -
8186 \begin_inset ERT
8187 status collapsed
8188
8189 \begin_layout Standard
8190
8191
8192 \backslash
8193 /
8194 \end_layout
8195
8196 \end_inset
8197
8198 -pack-iram
8199 \series default
8200 \InsetSpace ~
8201
8202 \begin_inset LatexCommand \index{-\\/-pack-iram}
8203
8204 \end_inset
8205
8206  Causes the linker to use unused register banks for data variables and pack
8207  data, idata and stack together.
8208  This is the default now.
8209 \end_layout
8210
8211 \begin_layout List
8212 \labelwidthstring 00.00.0000
8213
8214 \series bold
8215 -
8216 \begin_inset ERT
8217 status collapsed
8218
8219 \begin_layout Standard
8220
8221
8222 \backslash
8223 /
8224 \end_layout
8225
8226 \end_inset
8227
8228 -no-pack-iram
8229 \series default
8230 \InsetSpace ~
8231
8232 \begin_inset LatexCommand \index{-\\/-no-pack-iram}
8233
8234 \end_inset
8235
8236  Causes the linker to use old style for allocating memory areas.
8237 \end_layout
8238
8239 \begin_layout List
8240 \labelwidthstring 00.00.0000
8241
8242 \series bold
8243 -
8244 \begin_inset ERT
8245 status collapsed
8246
8247 \begin_layout Standard
8248
8249
8250 \backslash
8251 /
8252 \end_layout
8253
8254 \end_inset
8255
8256 -acall-ajmp
8257 \series default
8258 \InsetSpace ~
8259
8260 \begin_inset LatexCommand \index{-\\/-acall-ajmp}
8261
8262 \end_inset
8263
8264  Replaces the three byte instructions lcall/ljmp with the two byte instructions
8265  acall/ajmp.
8266  Only use this option if your code is in the same 2k block of memory.
8267  You may need to use this option for some 8051 derivatives which lack the
8268  lcall/ljmp instructions.
8269 \end_layout
8270
8271 \begin_layout Standard
8272 \begin_inset VSpace bigskip
8273 \end_inset
8274
8275
8276 \end_layout
8277
8278 \begin_layout Subsection
8279 DS390 / DS400 Options
8280 \begin_inset LatexCommand \index{Options DS390}
8281
8282 \end_inset
8283
8284
8285 \begin_inset LatexCommand \index{DS390}
8286
8287 \end_inset
8288
8289
8290 \end_layout
8291
8292 \begin_layout List
8293 \labelwidthstring 00.00.0000
8294
8295 \series bold
8296 -
8297 \begin_inset ERT
8298 status collapsed
8299
8300 \begin_layout Standard
8301
8302
8303 \backslash
8304 /
8305 \end_layout
8306
8307 \end_inset
8308
8309 -model-flat24
8310 \series default
8311
8312 \begin_inset LatexCommand \index{DS390!Options!-\\/-model-flat24}
8313
8314 \end_inset
8315
8316
8317 \size large
8318  
8319 \size default
8320 Generate 24-bit flat mode code.
8321  This is the one and only that the ds390 code generator supports right now
8322  and is default when using 
8323 \emph on
8324 -mds390
8325 \emph default
8326 .
8327  See section Memory Models for more details.
8328 \end_layout
8329
8330 \begin_layout List
8331 \labelwidthstring 00.00.0000
8332
8333 \series bold
8334 -
8335 \begin_inset ERT
8336 status collapsed
8337
8338 \begin_layout Standard
8339
8340
8341 \backslash
8342 /
8343 \end_layout
8344
8345 \end_inset
8346
8347 -protect-sp-update
8348 \begin_inset LatexCommand \index{DS390!Options!-\\/-protect-sp-update}
8349
8350 \end_inset
8351
8352
8353 \series default
8354  disable interrupts during ESP:SP updates.
8355 \end_layout
8356
8357 \begin_layout List
8358 \labelwidthstring 00.00.0000
8359
8360 \series bold
8361 -
8362 \begin_inset ERT
8363 status collapsed
8364
8365 \begin_layout Standard
8366
8367
8368 \backslash
8369 /
8370 \end_layout
8371
8372 \end_inset
8373
8374 -stack-10bit
8375 \series default
8376
8377 \begin_inset LatexCommand \index{DS390!Options!-\\/-stack-10bit}
8378
8379 \end_inset
8380
8381  Generate code for the 10 bit stack mode of the Dallas DS80C390 part.
8382  This is the one and only that the ds390 code generator supports right now
8383  and is default when using 
8384 \emph on
8385 -mds390
8386 \emph default
8387 .
8388  In this mode, the stack is located in the lower 1K of the internal RAM,
8389  which is mapped to 0x400000.
8390  Note that the support is incomplete, since it still uses a single byte
8391  as the stack pointer.
8392  This means that only the lower 256 bytes of the potential 1K stack space
8393  will actually be used.
8394  However, this does allow you to reclaim the precious 256 bytes of low RAM
8395  for use for the DATA and IDATA segments.
8396  The compiler will not generate any code to put the processor into 10 bit
8397  stack mode.
8398  It is important to ensure that the processor is in this mode before calling
8399  any re-entrant functions compiled with this option.
8400  In principle, this should work with the 
8401 \emph on
8402 -
8403 \begin_inset ERT
8404 status collapsed
8405
8406 \begin_layout Standard
8407
8408
8409 \backslash
8410 /
8411 \end_layout
8412
8413 \end_inset
8414
8415 -stack-auto
8416 \begin_inset LatexCommand \index{-\\/-stack-auto}
8417
8418 \end_inset
8419
8420
8421 \emph default
8422  option, but that has not been tested.
8423  It is incompatible with the 
8424 \emph on
8425 -
8426 \begin_inset ERT
8427 status collapsed
8428
8429 \begin_layout Standard
8430
8431
8432 \backslash
8433 /
8434 \end_layout
8435
8436 \end_inset
8437
8438 -xstack
8439 \begin_inset LatexCommand \index{-\\/-xstack}
8440
8441 \end_inset
8442
8443
8444 \emph default
8445  option.
8446  It also only makes sense if the processor is in 24 bit contiguous addressing
8447  mode (see the 
8448 \emph on
8449 -
8450 \begin_inset ERT
8451 status collapsed
8452
8453 \begin_layout Standard
8454
8455
8456 \backslash
8457 /
8458 \end_layout
8459
8460 \end_inset
8461
8462 -model-flat24 option
8463 \emph default
8464 ).
8465 \series bold
8466
8467 \begin_inset Note Note
8468 status collapsed
8469
8470 \begin_layout List
8471 \labelwidthstring 00.00.0000
8472
8473 \series bold
8474 -
8475 \begin_inset ERT
8476 status open
8477
8478 \begin_layout Standard
8479
8480
8481 \backslash
8482 /
8483 \end_layout
8484
8485 \end_inset
8486
8487 -stack-8-bit - switches off the 10-bit mode
8488 \end_layout
8489
8490 \end_inset
8491
8492
8493 \end_layout
8494
8495 \begin_layout List
8496 \labelwidthstring 00.00.0000
8497
8498 \series bold
8499 -
8500 \begin_inset ERT
8501 status collapsed
8502
8503 \begin_layout Standard
8504
8505
8506 \backslash
8507 /
8508 \end_layout
8509
8510 \end_inset
8511
8512 -stack-probe
8513 \begin_inset LatexCommand \index{DS390!Options!-\\/-stack-probe}
8514
8515 \end_inset
8516
8517
8518 \series default
8519  insert call to function __stack_probe at each function prologue.
8520 \end_layout
8521
8522 \begin_layout List
8523 \labelwidthstring 00.00.0000
8524
8525 \series bold
8526 -
8527 \begin_inset ERT
8528 status collapsed
8529
8530 \begin_layout Standard
8531
8532
8533 \backslash
8534 /
8535 \end_layout
8536
8537 \end_inset
8538
8539 -tini-libid
8540 \begin_inset LatexCommand \index{DS390!Options!-\\/-tini-libid}
8541
8542 \end_inset
8543
8544
8545 \series default
8546  <nnnn> LibraryID used in -mTININative.
8547  
8548 \end_layout
8549
8550 \begin_layout List
8551 \labelwidthstring 00.00.0000
8552
8553 \series bold
8554 -
8555 \begin_inset ERT
8556 status collapsed
8557
8558 \begin_layout Standard
8559
8560
8561 \backslash
8562 /
8563 \end_layout
8564
8565 \end_inset
8566
8567 -use-accelerator
8568 \begin_inset LatexCommand \index{DS390!Options!-\\/-use-accelerator}
8569
8570 \end_inset
8571
8572
8573 \series default
8574  generate code for DS390 Arithmetic Accelerator.
8575  
8576 \end_layout
8577
8578 \begin_layout Standard
8579 \begin_inset VSpace bigskip
8580 \end_inset
8581
8582
8583 \end_layout
8584
8585 \begin_layout Subsection
8586 Z80 Options
8587 \begin_inset LatexCommand \index{Options Z80}
8588
8589 \end_inset
8590
8591
8592 \begin_inset LatexCommand \index{Z80}
8593
8594 \end_inset
8595
8596
8597 \end_layout
8598
8599 \begin_layout List
8600 \labelwidthstring 00.00.0000
8601
8602 \series bold
8603 -
8604 \begin_inset ERT
8605 status collapsed
8606
8607 \begin_layout Standard
8608
8609
8610 \backslash
8611 /
8612 \end_layout
8613
8614 \end_inset
8615
8616 -callee-saves-bc
8617 \series default
8618
8619 \begin_inset LatexCommand \index{Z80!Options!-\\/-callee-saves-bc}
8620
8621 \end_inset
8622
8623
8624 \size large
8625  
8626 \size default
8627 Force a called function to always save BC.
8628 \end_layout
8629
8630 \begin_layout List
8631 \labelwidthstring 00.00.0000
8632
8633 \series bold
8634 -
8635 \begin_inset ERT
8636 status collapsed
8637
8638 \begin_layout Standard
8639
8640
8641 \backslash
8642 /
8643 \end_layout
8644
8645 \end_inset
8646
8647 -no-std-crt0
8648 \series default
8649
8650 \begin_inset LatexCommand \index{Z80!Options!-\\/-no-std-crt0}
8651
8652 \end_inset
8653
8654  When linking, skip the standard crt0.o object file.
8655  You must provide your own crt0.o for your system when linking.
8656 \end_layout
8657
8658 \begin_layout List
8659 \labelwidthstring 00.00.0000
8660
8661 \series bold
8662 -
8663 \begin_inset ERT
8664 status collapsed
8665
8666 \begin_layout Standard
8667
8668
8669 \backslash
8670 /
8671 \end_layout
8672
8673 \end_inset
8674
8675 -portmode=
8676 \series default
8677 <Value>
8678 \begin_inset LatexCommand \index{Z80!Options!-\\/-portmode=<Value>}
8679
8680 \end_inset
8681
8682  Determinate PORT I/O mode (<Value> is z80 or z180).
8683 \end_layout
8684
8685 \begin_layout List
8686 \labelwidthstring 00.00.0000
8687
8688 \series bold
8689 -
8690 \begin_inset ERT
8691 status collapsed
8692
8693 \begin_layout Standard
8694
8695
8696 \backslash
8697 /
8698 \end_layout
8699
8700 \end_inset
8701
8702 -asm=
8703 \series default
8704 <Value>
8705 \begin_inset LatexCommand \index{Z80!Options!-\\/-asm=<Value>}
8706
8707 \end_inset
8708
8709  Define assembler name (<Value> is rgbds, asxxxx, isas or z80asm).
8710 \end_layout
8711
8712 \begin_layout List
8713 \labelwidthstring 00.00.0000
8714
8715 \series bold
8716 -
8717 \begin_inset ERT
8718 status collapsed
8719
8720 \begin_layout Standard
8721
8722
8723 \backslash
8724 /
8725 \end_layout
8726
8727 \end_inset
8728
8729 -codeseg
8730 \series default
8731 \InsetSpace ~
8732 <Value>
8733 \begin_inset LatexCommand \index{Z80!Options!-\\/-codeseg <Value>}
8734
8735 \end_inset
8736
8737  Use <Value> for the code segment name.
8738 \end_layout
8739
8740 \begin_layout List
8741 \labelwidthstring 00.00.0000
8742
8743 \series bold
8744 -
8745 \begin_inset ERT
8746 status collapsed
8747
8748 \begin_layout Standard
8749
8750
8751 \backslash
8752 /
8753 \end_layout
8754
8755 \end_inset
8756
8757 -constseg
8758 \series default
8759 \InsetSpace ~
8760 <Value>
8761 \begin_inset LatexCommand \index{Z80!Options!-\\/-constseg <Value>}
8762
8763 \end_inset
8764
8765  Use <Value> for the const segment name.
8766 \end_layout
8767
8768 \begin_layout List
8769 \labelwidthstring 00.00.0000
8770 \begin_inset VSpace bigskip
8771 \end_inset
8772
8773
8774 \end_layout
8775
8776 \begin_layout Subsection
8777 GBZ80 Options
8778 \begin_inset LatexCommand \index{Options GBZ80}
8779
8780 \end_inset
8781
8782
8783 \begin_inset LatexCommand \index{GBZ80}
8784
8785 \end_inset
8786
8787
8788 \end_layout
8789
8790 \begin_layout List
8791 \labelwidthstring 00.00.0000
8792
8793 \series bold
8794 -
8795 \begin_inset ERT
8796 status collapsed
8797
8798 \begin_layout Standard
8799
8800
8801 \backslash
8802 /
8803 \end_layout
8804
8805 \end_inset
8806
8807 -callee-saves-bc
8808 \series default
8809
8810 \begin_inset LatexCommand \index{GBZ80!Options!-\\/-callee-saves-bc}
8811
8812 \end_inset
8813
8814
8815 \size large
8816  
8817 \size default
8818 Force a called function to always save BC.
8819 \end_layout
8820
8821 \begin_layout List
8822 \labelwidthstring 00.00.0000
8823
8824 \series bold
8825 -bo
8826 \series default
8827 \InsetSpace ~
8828 <Num>
8829 \begin_inset LatexCommand \index{GBZ80!Options!-bo <Num>}
8830
8831 \end_inset
8832
8833  Use code bank <Num>.
8834 \end_layout
8835
8836 \begin_layout List
8837 \labelwidthstring 00.00.0000
8838
8839 \series bold
8840 -ba
8841 \series default
8842 \InsetSpace ~
8843 <Num>
8844 \begin_inset LatexCommand \index{GBZ80!Options!-ba <Num>}
8845
8846 \end_inset
8847
8848  Use data bank <Num>.
8849 \end_layout
8850
8851 \begin_layout List
8852 \labelwidthstring 00.00.0000
8853
8854 \series bold
8855 -
8856 \begin_inset ERT
8857 status collapsed
8858
8859 \begin_layout Standard
8860
8861
8862 \backslash
8863 /
8864 \end_layout
8865
8866 \end_inset
8867
8868 -codeseg
8869 \series default
8870 \InsetSpace ~
8871 <Value>
8872 \begin_inset LatexCommand \index{GBZ80!Options!-\\/-codeseg <Value>}
8873
8874 \end_inset
8875
8876  Use <Value> for the code segment name.
8877 \end_layout
8878
8879 \begin_layout List
8880 \labelwidthstring 00.00.0000
8881
8882 \series bold
8883 -
8884 \begin_inset ERT
8885 status collapsed
8886
8887 \begin_layout Standard
8888
8889
8890 \backslash
8891 /
8892 \end_layout
8893
8894 \end_inset
8895
8896 -constseg
8897 \series default
8898 \InsetSpace ~
8899 <Value>
8900 \begin_inset LatexCommand \index{GBZ80!Options!-\\/-constseg <Value>}
8901
8902 \end_inset
8903
8904  Use <Value> for the const segment name.
8905 \end_layout
8906
8907 \begin_layout Standard
8908 \begin_inset VSpace bigskip
8909 \end_inset
8910
8911
8912 \end_layout
8913
8914 \begin_layout Subsection
8915 Optimization Options
8916 \begin_inset LatexCommand \index{Options optimization}
8917
8918 \end_inset
8919
8920
8921 \begin_inset LatexCommand \index{Optimization options}
8922
8923 \end_inset
8924
8925
8926 \end_layout
8927
8928 \begin_layout List
8929 \labelwidthstring 00.00.0000
8930
8931 \series bold
8932 -
8933 \begin_inset ERT
8934 status collapsed
8935
8936 \begin_layout Standard
8937
8938
8939 \backslash
8940 /
8941 \end_layout
8942
8943 \end_inset
8944
8945 -nogcse
8946 \begin_inset LatexCommand \index{-\\/-nogcse}
8947
8948 \end_inset
8949
8950
8951 \series default
8952  Will not do global subexpression elimination, this option may be used when
8953  the compiler creates undesirably large stack/data spaces to store compiler
8954  temporaries (
8955 \emph on
8956 s
8957 \emph default
8958 pill 
8959 \emph on
8960 loc
8961 \emph default
8962 ations, sloc
8963 \begin_inset LatexCommand \index{sloc (spill location)}
8964
8965 \end_inset
8966
8967 ).
8968  A warning message will be generated when this happens and the compiler
8969  will indicate the number of extra bytes it allocated.
8970  It is recommended that this option NOT be used, #pragma\InsetSpace ~
8971 nogcse
8972 \begin_inset LatexCommand \index{\\#pragma nogcse}
8973
8974 \end_inset
8975
8976  can be used to turn off global subexpression elimination
8977 \begin_inset LatexCommand \index{Subexpression elimination}
8978
8979 \end_inset
8980
8981  for a given function only.
8982 \end_layout
8983
8984 \begin_layout List
8985 \labelwidthstring 00.00.0000
8986
8987 \series bold
8988 -
8989 \begin_inset ERT
8990 status collapsed
8991
8992 \begin_layout Standard
8993
8994
8995 \backslash
8996 /
8997 \end_layout
8998
8999 \end_inset
9000
9001 -noinvariant
9002 \begin_inset LatexCommand \index{-\\/-noinvariant}
9003
9004 \end_inset
9005
9006
9007 \series default
9008  Will not do loop invariant optimizations, this may be turned off for reasons
9009  explained for the previous option.
9010  For more details of loop optimizations performed see Loop Invariants in
9011  section 
9012 \begin_inset LatexCommand \ref{sub:Loop-Optimizations}
9013
9014 \end_inset
9015
9016 .
9017  It is recommended that this option NOT be used, #pragma\InsetSpace ~
9018 noinvariant
9019 \begin_inset LatexCommand \index{\\#pragma noinvariant}
9020
9021 \end_inset
9022
9023  can be used to turn off invariant optimizations for a given function only.
9024 \end_layout
9025
9026 \begin_layout List
9027 \labelwidthstring 00.00.0000
9028
9029 \series bold
9030 -
9031 \begin_inset ERT
9032 status collapsed
9033
9034 \begin_layout Standard
9035
9036
9037 \backslash
9038 /
9039 \end_layout
9040
9041 \end_inset
9042
9043 -noinduction
9044 \begin_inset LatexCommand \index{-\\/-noinduction}
9045
9046 \end_inset
9047
9048
9049 \series default
9050  Will not do loop induction optimizations, see section strength reduction
9051  for more details.
9052  It is recommended that this option is NOT used, #pragma\InsetSpace ~
9053 noinduction
9054 \begin_inset LatexCommand \index{\\#pragma noinduction}
9055
9056 \end_inset
9057
9058  can be used to turn off induction optimizations for a given function only.
9059 \end_layout
9060
9061 \begin_layout List
9062 \labelwidthstring 00.00.0000
9063
9064 \series bold
9065 -
9066 \begin_inset ERT
9067 status collapsed
9068
9069 \begin_layout Standard
9070
9071
9072 \backslash
9073 /
9074 \end_layout
9075
9076 \end_inset
9077
9078 -nojtbound
9079 \begin_inset LatexCommand \index{-\\/-nojtbound}
9080
9081 \end_inset
9082
9083
9084 \size large
9085  
9086 \series default
9087 \size default
9088  Will not generate boundary condition check when switch statements
9089 \begin_inset LatexCommand \index{switch statement}
9090
9091 \end_inset
9092
9093  are implemented using jump-tables.
9094  See section 
9095 \begin_inset LatexCommand \ref{sub:'switch'-Statements}
9096
9097 \end_inset
9098
9099 \InsetSpace ~
9100 Switch Statements for more details.
9101  It is recommended that this option is NOT used, #pragma\InsetSpace ~
9102 nojtbound
9103 \begin_inset LatexCommand \index{\\#pragma nojtbound}
9104
9105 \end_inset
9106
9107  can be used to turn off boundary checking for jump tables for a given function
9108  only.
9109 \end_layout
9110
9111 \begin_layout List
9112 \labelwidthstring 00.00.0000
9113
9114 \series bold
9115 -
9116 \begin_inset ERT
9117 status collapsed
9118
9119 \begin_layout Standard
9120
9121
9122 \backslash
9123 /
9124 \end_layout
9125
9126 \end_inset
9127
9128 -noloopreverse
9129 \begin_inset LatexCommand \index{-\\/-noloopreverse}
9130
9131 \end_inset
9132
9133
9134 \series default
9135 \size large
9136  
9137 \size default
9138 Will not do loop reversal 
9139 \begin_inset LatexCommand \index{Loop reversing}
9140
9141 \end_inset
9142
9143 optimization.
9144 \end_layout
9145
9146 \begin_layout List
9147 \labelwidthstring 00.00.0000
9148 -
9149 \begin_inset ERT
9150 status collapsed
9151
9152 \begin_layout Standard
9153
9154
9155 \backslash
9156 /
9157 \end_layout
9158
9159 \end_inset
9160
9161 -
9162 \series bold
9163 nolabelopt
9164 \series default
9165  
9166 \begin_inset LatexCommand \index{-\\/-nolabelopt }
9167
9168 \end_inset
9169
9170 Will not optimize labels (makes the dumpfiles more readable).
9171 \end_layout
9172
9173 \begin_layout List
9174 \labelwidthstring 00.00.0000
9175
9176 \series bold
9177 -
9178 \begin_inset ERT
9179 status collapsed
9180
9181 \begin_layout Standard
9182
9183
9184 \backslash
9185 /
9186 \end_layout
9187
9188 \end_inset
9189
9190 -no-xinit-opt
9191 \begin_inset LatexCommand \index{-\\/-no-xinit-opt}
9192
9193 \end_inset
9194
9195
9196 \series default
9197  Will not memcpy initialized data from code space into xdata space.
9198  This saves a few bytes in code space if you don't have initialized data
9199 \begin_inset LatexCommand \index{Variable initialization}
9200
9201 \end_inset
9202
9203 .
9204 \end_layout
9205
9206 \begin_layout List
9207 \labelwidthstring 00.00.0000
9208
9209 \series bold
9210 -
9211 \begin_inset ERT
9212 status collapsed
9213
9214 \begin_layout Standard
9215
9216
9217 \backslash
9218 /
9219 \end_layout
9220
9221 \end_inset
9222
9223 -nooverlay
9224 \begin_inset LatexCommand \index{-\\/-nooverlay}
9225
9226 \end_inset
9227
9228
9229 \series default
9230   The compiler will not overlay parameters and local variables of any function,
9231  see section Parameters and local variables for more details.
9232 \end_layout
9233
9234 \begin_layout List
9235 \labelwidthstring 00.00.0000
9236
9237 \series bold
9238 -
9239 \begin_inset ERT
9240 status collapsed
9241
9242 \begin_layout Standard
9243
9244
9245 \backslash
9246 /
9247 \end_layout
9248
9249 \end_inset
9250
9251 -no-peep
9252 \begin_inset LatexCommand \index{-\\/-no-peep}
9253
9254 \end_inset
9255
9256
9257 \series default
9258  Disable peep-hole optimization with built-in rules.
9259 \end_layout
9260
9261 \begin_layout List
9262 \labelwidthstring 00.00.0000
9263
9264 \series bold
9265 -
9266 \begin_inset ERT
9267 status collapsed
9268
9269 \begin_layout Standard
9270
9271
9272 \backslash
9273 /
9274 \end_layout
9275
9276 \end_inset
9277
9278 -peep-file
9279 \series default
9280
9281 \begin_inset LatexCommand \index{-\\/-peep-file}
9282
9283 \end_inset
9284
9285 \InsetSpace ~
9286 <filename> This option can be used to use additional rules to be used by
9287  the peep hole optimizer.
9288  See section 
9289 \begin_inset LatexCommand \ref{sub:Peephole-Optimizer}
9290
9291 \end_inset
9292
9293 \InsetSpace ~
9294 Peep Hole optimizations for details on how to write these rules.
9295 \end_layout
9296
9297 \begin_layout List
9298 \labelwidthstring 00.00.0000
9299
9300 \series bold
9301 -
9302 \begin_inset ERT
9303 status collapsed
9304
9305 \begin_layout Standard
9306
9307
9308 \backslash
9309 /
9310 \end_layout
9311
9312 \end_inset
9313
9314 -peep-asm
9315 \begin_inset LatexCommand \index{-\\/-peep-asm}
9316
9317 \end_inset
9318
9319
9320 \series default
9321  Pass the inline assembler code through the peep hole optimizer.
9322  This can cause unexpected changes to inline assembler code, please go through
9323  the peephole optimizer
9324 \begin_inset LatexCommand \index{Peephole optimizer}
9325
9326 \end_inset
9327
9328  rules defined in the source file tree '<target>/peeph.def' before using
9329  this option.
9330 \end_layout
9331
9332 \begin_layout List
9333 \labelwidthstring 00.00.0000
9334
9335 \series bold
9336 -
9337 \begin_inset ERT
9338 status collapsed
9339
9340 \begin_layout Standard
9341
9342
9343 \backslash
9344 /
9345 \end_layout
9346
9347 \end_inset
9348
9349 -opt-code-speed
9350 \begin_inset LatexCommand \index{-\\/-opt-code-speed}
9351
9352 \end_inset
9353
9354
9355 \series default
9356  The compiler will optimize code generation towards fast code, possibly
9357  at the expense of code size.
9358 \end_layout
9359
9360 \begin_layout List
9361 \labelwidthstring 00.00.0000
9362
9363 \series bold
9364 -
9365 \begin_inset ERT
9366 status collapsed
9367
9368 \begin_layout Standard
9369
9370
9371 \backslash
9372 /
9373 \end_layout
9374
9375 \end_inset
9376
9377 -opt-code-size
9378 \begin_inset LatexCommand \index{-\\/-opt-code-size}
9379
9380 \end_inset
9381
9382
9383 \series default
9384  The compiler will optimize code generation towards compact code, possibly
9385  at the expense of code speed.
9386 \end_layout
9387
9388 \begin_layout Standard
9389 \begin_inset VSpace bigskip
9390 \end_inset
9391
9392
9393 \end_layout
9394
9395 \begin_layout Subsection
9396 Other Options
9397 \begin_inset LatexCommand \index{Options other}
9398
9399 \end_inset
9400
9401
9402 \end_layout
9403
9404 \begin_layout List
9405 \labelwidthstring 00.00.0000
9406
9407 \series bold
9408 -c\InsetSpace ~
9409 -
9410 \begin_inset ERT
9411 status collapsed
9412
9413 \begin_layout Standard
9414
9415
9416 \backslash
9417 /
9418 \end_layout
9419
9420 \end_inset
9421
9422 -compile-only
9423 \begin_inset LatexCommand \index{-\\/-compile-only}
9424
9425 \end_inset
9426
9427
9428 \begin_inset LatexCommand \index{-c -\\/-compile-only}
9429
9430 \end_inset
9431
9432
9433 \series default
9434  will compile and assemble the source, but will not call the linkage editor.
9435 \end_layout
9436
9437 \begin_layout List
9438 \labelwidthstring 00.00.0000
9439
9440 \series bold
9441 -
9442 \series default
9443
9444 \begin_inset ERT
9445 status collapsed
9446
9447 \begin_layout Standard
9448
9449
9450 \backslash
9451 /
9452 \end_layout
9453
9454 \end_inset
9455
9456
9457 \series bold
9458 -c1mode
9459 \begin_inset LatexCommand \index{-\\/-c1mode}
9460
9461 \end_inset
9462
9463
9464 \series default
9465  reads the preprocessed source from standard input and compiles it.
9466  The file name for the assembler output must be specified using the -o option.
9467 \end_layout
9468
9469 \begin_layout List
9470 \labelwidthstring 00.00.0000
9471
9472 \series bold
9473 -E
9474 \begin_inset LatexCommand \index{-E}
9475
9476 \end_inset
9477
9478
9479 \series default
9480  Run only the C preprocessor.
9481  Preprocess all the C source files specified and output the results to standard
9482  output.
9483 \end_layout
9484
9485 \begin_layout List
9486 \labelwidthstring 00.00.0000
9487
9488 \series bold
9489 -o\InsetSpace ~
9490 <path/file>
9491 \begin_inset LatexCommand \index{-o <path/file>}
9492
9493 \end_inset
9494
9495
9496 \series default
9497  The output path where everything will be placed or the file name used for
9498  all generated output files.
9499  If the parameter is a path, it must have a trailing slash (or backslash
9500  for the Windows binaries) to be recognized as a path.
9501  Note for Windows users: if the path contains spaces, it should be surrounded
9502  by quotes.
9503  The trailing backslash should be doubled in order to prevent escaping the
9504  final quote, for example: 
9505 \emph on
9506 -o 
9507 \begin_inset Quotes sld
9508 \end_inset
9509
9510 F:
9511 \backslash
9512 Projects
9513 \backslash
9514 test3
9515 \backslash
9516 output 1
9517 \backslash
9518
9519 \backslash
9520
9521 \begin_inset Quotes srd
9522 \end_inset
9523
9524
9525 \emph default
9526  or put after the final quote, for example: 
9527 \emph on
9528 -o 
9529 \begin_inset Quotes sld
9530 \end_inset
9531
9532 F:
9533 \backslash
9534 Projects
9535 \backslash
9536 test3
9537 \backslash
9538 output 1
9539 \begin_inset Quotes srd
9540 \end_inset
9541
9542
9543 \backslash
9544
9545 \emph default
9546 .
9547  The path using slashes for directory delimiters can be used too, for example:
9548  
9549 \emph on
9550 -o 
9551 \begin_inset Quotes sld
9552 \end_inset
9553
9554 F:/Projects/test3/output 1/
9555 \begin_inset Quotes srd
9556 \end_inset
9557
9558
9559 \emph default
9560 .
9561 \end_layout
9562
9563 \begin_layout List
9564 \labelwidthstring 00.00.0000
9565
9566 \series bold
9567 -
9568 \begin_inset ERT
9569 status collapsed
9570
9571 \begin_layout Standard
9572
9573
9574 \backslash
9575 /
9576 \end_layout
9577
9578 \end_inset
9579
9580 -stack-auto
9581 \begin_inset LatexCommand \index{-\\/-stack-auto}
9582
9583 \end_inset
9584
9585
9586 \series default
9587 \size large
9588  
9589 \size default
9590 All functions in the source file will be compiled as 
9591 \emph on
9592 reentrant
9593 \emph default
9594
9595 \begin_inset LatexCommand \index{reentrant}
9596
9597 \end_inset
9598
9599 , i.e.
9600  the parameters and local variables will be allocated on the stack
9601 \begin_inset LatexCommand \index{stack}
9602
9603 \end_inset
9604
9605 .
9606  See section 
9607 \begin_inset LatexCommand \ref{sec:Parameters-and-Local-Variables}
9608
9609 \end_inset
9610
9611  Parameters and Local Variables for more details.
9612  If this option is used all source files in the project should be compiled
9613  with this option.
9614  It automatically implies -
9615 \series bold
9616
9617 \begin_inset ERT
9618 status open
9619
9620 \begin_layout Standard
9621
9622
9623 \backslash
9624 /
9625 \end_layout
9626
9627 \end_inset
9628
9629
9630 \series default
9631 -int-long-reent and -
9632 \series bold
9633
9634 \begin_inset ERT
9635 status open
9636
9637 \begin_layout Standard
9638
9639
9640 \backslash
9641 /
9642 \end_layout
9643
9644 \end_inset
9645
9646
9647 \series default
9648 -float-reent.
9649  
9650 \end_layout
9651
9652 \begin_layout List
9653 \labelwidthstring 00.00.0000
9654
9655 \series bold
9656 -
9657 \begin_inset ERT
9658 status collapsed
9659
9660 \begin_layout Standard
9661
9662
9663 \backslash
9664 /
9665 \end_layout
9666
9667 \end_inset
9668
9669 -callee-saves
9670 \begin_inset LatexCommand \index{-\\/-callee-saves}
9671
9672 \end_inset
9673
9674  
9675 \begin_inset LatexCommand \label{lyx:--callee-saves-function1[,function2][,function3]...}
9676
9677 \end_inset
9678
9679 function1[,function2][,function3]....
9680
9681 \series default
9682  The compiler by default uses a caller saves convention for register saving
9683  across function calls, however this can cause unnecessary register pushing
9684  and popping when calling small functions from larger functions.
9685  This option can be used to switch the register saving convention for the
9686  function names specified.
9687  The compiler will not save registers when calling these functions, no extra
9688  code will be generated at the entry and exit (function prologue
9689 \series bold
9690
9691 \begin_inset LatexCommand \index{function prologue}
9692
9693 \end_inset
9694
9695
9696 \series default
9697  and epilogue
9698 \series bold
9699
9700 \begin_inset LatexCommand \index{function epilogue}
9701
9702 \end_inset
9703
9704
9705 \series default
9706 ) for these functions to save and restore the registers used by these functions,
9707  this can SUBSTANTIALLY reduce code and improve run time performance of
9708  the generated code.
9709  In the future the compiler (with inter procedural analysis) will be able
9710  to determine the appropriate scheme to use for each function call.
9711  DO NOT use this option for built-in functions such as _mulint..., if this
9712  option is used for a library function the appropriate library function
9713  needs to be recompiled with the same option.
9714  If the project consists of multiple source files then all the source file
9715  should be compiled with the same -
9716 \begin_inset ERT
9717 status collapsed
9718
9719 \begin_layout Standard
9720
9721
9722 \backslash
9723 /
9724 \end_layout
9725
9726 \end_inset
9727
9728 -callee-saves option string.
9729  Also see #pragma\InsetSpace ~
9730 callee_saves 
9731 \begin_inset LatexCommand \index{\\#pragma callee\\_saves}
9732
9733 \end_inset
9734
9735  
9736 \begin_inset LatexCommand \vpageref{ite:callee_saves-function1[,function2[,function3...]]--}
9737
9738 \end_inset
9739
9740 .
9741 \end_layout
9742
9743 \begin_layout List
9744 \labelwidthstring 00.00.0000
9745
9746 \series bold
9747 -
9748 \begin_inset ERT
9749 status collapsed
9750
9751 \begin_layout Standard
9752
9753
9754 \backslash
9755 /
9756 \end_layout
9757
9758 \end_inset
9759
9760 -all-callee-saves
9761 \begin_inset LatexCommand \index{-\\/-all-callee-saves}
9762
9763 \end_inset
9764
9765
9766 \series default
9767  Function of -
9768 \begin_inset ERT
9769 status collapsed
9770
9771 \begin_layout Standard
9772
9773
9774 \backslash
9775 /
9776 \end_layout
9777
9778 \end_inset
9779
9780 -callee-saves will be applied to all functions by default.
9781 \end_layout
9782
9783 \begin_layout List
9784 \labelwidthstring 00.00.0000
9785
9786 \series bold
9787 -
9788 \begin_inset ERT
9789 status collapsed
9790
9791 \begin_layout Standard
9792
9793
9794 \backslash
9795 /
9796 \end_layout
9797
9798 \end_inset
9799
9800 -debug
9801 \begin_inset LatexCommand \index{-\\/-debug}
9802
9803 \end_inset
9804
9805  
9806 \series default
9807 When this option is used the compiler will generate debug information.
9808  The debug information collected in a file with .cdb extension can be used
9809  with the SDCDB.
9810  For more information see documentation for SDCDB.
9811  Another file with no extension contains debug information in AOMF or AOMF51
9812 \begin_inset LatexCommand \index{AOMF, AOMF51}
9813
9814 \end_inset
9815
9816  format which is commonly used by third party tools.
9817 \end_layout
9818
9819 \begin_layout List
9820 \labelwidthstring 00.00.0000
9821
9822 \series bold
9823 -S
9824 \begin_inset LatexCommand \index{-S}
9825
9826 \end_inset
9827
9828
9829 \series default
9830 \size large
9831  
9832 \size default
9833 Stop after the stage of compilation proper; do not assemble.
9834  The output is an assembler code file for the input file specified.
9835 \end_layout
9836
9837 \begin_layout List
9838 \labelwidthstring 00.00.0000
9839
9840 \series bold
9841 -
9842 \begin_inset ERT
9843 status collapsed
9844
9845 \begin_layout Standard
9846
9847
9848 \backslash
9849 /
9850 \end_layout
9851
9852 \end_inset
9853
9854 -int-long-reent
9855 \begin_inset LatexCommand \index{-\\/-int-long-reent}
9856
9857 \end_inset
9858
9859
9860 \series default
9861  Integer (16 bit) and long (32 bit) libraries have been compiled as reentrant.
9862  Note by default these libraries are compiled as non-reentrant.
9863  See section Installation for more details.
9864 \end_layout
9865
9866 \begin_layout List
9867 \labelwidthstring 00.00.0000
9868
9869 \series bold
9870 -
9871 \begin_inset ERT
9872 status collapsed
9873
9874 \begin_layout Standard
9875
9876
9877 \backslash
9878 /
9879 \end_layout
9880
9881 \end_inset
9882
9883 -cyclomatic
9884 \begin_inset LatexCommand \index{-\\/-cyclomatic}
9885
9886 \end_inset
9887
9888  
9889 \series default
9890 This option will cause the compiler to generate an information message for
9891  each function in the source file.
9892  The message contains some 
9893 \emph on
9894 important
9895 \emph default
9896  information about the function.
9897  The number of edges and nodes the compiler detected in the control flow
9898  graph of the function, and most importantly the 
9899 \emph on
9900 cyclomatic complexity
9901 \begin_inset LatexCommand \index{Cyclomatic complexity}
9902
9903 \end_inset
9904
9905
9906 \emph default
9907  see section on Cyclomatic Complexity for more details.
9908 \end_layout
9909
9910 \begin_layout List
9911 \labelwidthstring 00.00.0000
9912
9913 \series bold
9914 -
9915 \begin_inset ERT
9916 status collapsed
9917
9918 \begin_layout Standard
9919
9920
9921 \backslash
9922 /
9923 \end_layout
9924
9925 \end_inset
9926
9927 -float-reent
9928 \begin_inset LatexCommand \index{-\\/-float-reent}
9929
9930 \end_inset
9931
9932
9933 \series default
9934  Floating point library is compiled as reentrant
9935 \begin_inset LatexCommand \index{reentrant}
9936
9937 \end_inset
9938
9939 .
9940  See section Installation for more details.
9941 \end_layout
9942
9943 \begin_layout List
9944 \labelwidthstring 00.00.0000
9945
9946 \series bold
9947 -
9948 \begin_inset ERT
9949 status collapsed
9950
9951 \begin_layout Standard
9952
9953
9954 \backslash
9955 /
9956 \end_layout
9957
9958 \end_inset
9959
9960 -funsigned-char
9961 \begin_inset LatexCommand \index{-\\/-funsigned-char}
9962
9963 \end_inset
9964
9965
9966 \series default
9967  The default signedness for every type is 
9968 \family typewriter
9969 signed
9970 \family default
9971 .
9972  In some embedded environments the default signedness of 
9973 \family typewriter
9974 char
9975 \family default
9976  is 
9977 \family typewriter
9978 unsigned
9979 \family default
9980 .
9981  To set the signess for characters to unsigned, use the option -
9982 \series bold
9983
9984 \begin_inset ERT
9985 status open
9986
9987 \begin_layout Standard
9988
9989
9990 \backslash
9991 /
9992 \end_layout
9993
9994 \end_inset
9995
9996
9997 \series default
9998 -funsigned-char.
9999  If this option is set and no signedness keyword (unsigned/signed) is given,
10000  a char will be signed.
10001  All other types are unaffected.
10002 \end_layout
10003
10004 \begin_layout List
10005 \labelwidthstring 00.00.0000
10006
10007 \series bold
10008 -
10009 \begin_inset ERT
10010 status collapsed
10011
10012 \begin_layout Standard
10013
10014
10015 \backslash
10016 /
10017 \end_layout
10018
10019 \end_inset
10020
10021 -main-return
10022 \begin_inset LatexCommand \index{-\\/-main-return}
10023
10024 \end_inset
10025
10026
10027 \series default
10028  This option can be used if the code generated is called by a monitor program
10029  or if the main routine includes an endless loop.
10030  This option results in slightly smaller code and saves two bytes of stack
10031  space.
10032  The return from the 'main'
10033 \begin_inset LatexCommand \index{main return}
10034
10035 \end_inset
10036
10037  function will return to the function calling main.
10038  The default setting is to lock up i.e.
10039  generate a '
10040 \family typewriter
10041 sjmp .
10042 \family default
10043 '.
10044 \end_layout
10045
10046 \begin_layout List
10047 \labelwidthstring 00.00.0000
10048
10049 \series bold
10050 -
10051 \begin_inset ERT
10052 status collapsed
10053
10054 \begin_layout Standard
10055
10056
10057 \backslash
10058 /
10059 \end_layout
10060
10061 \end_inset
10062
10063 -nostdinc
10064 \begin_inset LatexCommand \index{-\\/-nostdinc}
10065
10066 \end_inset
10067
10068
10069 \series default
10070  This will prevent the compiler from passing on the default include path
10071  to the preprocessor.
10072 \end_layout
10073
10074 \begin_layout List
10075 \labelwidthstring 00.00.0000
10076
10077 \series bold
10078 -
10079 \begin_inset ERT
10080 status collapsed
10081
10082 \begin_layout Standard
10083
10084
10085 \backslash
10086 /
10087 \end_layout
10088
10089 \end_inset
10090
10091 -nostdlib
10092 \begin_inset LatexCommand \index{-\\/-nostdlib}
10093
10094 \end_inset
10095
10096
10097 \series default
10098  This will prevent the compiler from passing on the default library
10099 \begin_inset LatexCommand \index{Libraries}
10100
10101 \end_inset
10102
10103  path to the linker.
10104 \end_layout
10105
10106 \begin_layout List
10107 \labelwidthstring 00.00.0000
10108
10109 \series bold
10110 -
10111 \begin_inset ERT
10112 status collapsed
10113
10114 \begin_layout Standard
10115
10116
10117 \backslash
10118 /
10119 \end_layout
10120
10121 \end_inset
10122
10123 -verbose
10124 \begin_inset LatexCommand \index{-\\/-verbose}
10125
10126 \end_inset
10127
10128
10129 \series default
10130  Shows the various actions the compiler is performing.
10131 \end_layout
10132
10133 \begin_layout List
10134 \labelwidthstring 00.00.0000
10135
10136 \series bold
10137 -V
10138 \begin_inset LatexCommand \index{-V}
10139
10140 \end_inset
10141
10142
10143 \series default
10144  Shows the actual commands the compiler is executing.
10145 \end_layout
10146
10147 \begin_layout List
10148 \labelwidthstring 00.00.0000
10149
10150 \series bold
10151 -
10152 \begin_inset ERT
10153 status collapsed
10154
10155 \begin_layout Standard
10156
10157
10158 \backslash
10159 /
10160 \end_layout
10161
10162 \end_inset
10163
10164 -no-c-code-in-asm
10165 \begin_inset LatexCommand \index{-\\/-no-c-code-in-asm}
10166
10167 \end_inset
10168
10169
10170 \series default
10171  Hides your ugly and inefficient c-code from the asm file, so you can always
10172  blame the compiler :)
10173 \end_layout
10174
10175 \begin_layout List
10176 \labelwidthstring 00.00.0000
10177
10178 \series bold
10179 -
10180 \begin_inset ERT
10181 status collapsed
10182
10183 \begin_layout Standard
10184
10185
10186 \backslash
10187 /
10188 \end_layout
10189
10190 \end_inset
10191
10192 -fverbose-asm
10193 \begin_inset LatexCommand \index{-\\/-no-gen-comments}
10194
10195 \end_inset
10196
10197
10198 \series default
10199  Include code generator and peep-hole comments in the generated asm files.
10200 \end_layout
10201
10202 \begin_layout List
10203 \labelwidthstring 00.00.0000
10204
10205 \series bold
10206 -
10207 \begin_inset ERT
10208 status collapsed
10209
10210 \begin_layout Standard
10211
10212
10213 \backslash
10214 /
10215 \end_layout
10216
10217 \end_inset
10218
10219 -no-peep-comments
10220 \begin_inset LatexCommand \index{-\\/-no-peep-comments}
10221
10222 \end_inset
10223
10224
10225 \series default
10226  Don't include peep-hole comments in the generated asm files even if -
10227 \series bold
10228
10229 \begin_inset ERT
10230 status open
10231
10232 \begin_layout Standard
10233
10234
10235 \backslash
10236 /
10237 \end_layout
10238
10239 \end_inset
10240
10241
10242 \series default
10243 -fverbose-asm option is specified.
10244 \end_layout
10245
10246 \begin_layout List
10247 \labelwidthstring 00.00.0000
10248
10249 \series bold
10250 -
10251 \begin_inset ERT
10252 status collapsed
10253
10254 \begin_layout Standard
10255
10256
10257 \backslash
10258 /
10259 \end_layout
10260
10261 \end_inset
10262
10263 -i-code-in-asm
10264 \begin_inset LatexCommand \index{-\\/-i-code-in-asm}
10265
10266 \end_inset
10267
10268
10269 \series default
10270  Include i-codes in the asm file.
10271  Sounds like noise but is most helpful for debugging the compiler itself.
10272 \end_layout
10273
10274 \begin_layout List
10275 \labelwidthstring 00.00.0000
10276
10277 \series bold
10278 -
10279 \begin_inset ERT
10280 status collapsed
10281
10282 \begin_layout Standard
10283
10284
10285 \backslash
10286 /
10287 \end_layout
10288
10289 \end_inset
10290
10291 -less-pedantic
10292 \begin_inset LatexCommand \index{pedantic}
10293
10294 \end_inset
10295
10296
10297 \begin_inset LatexCommand \index{-\\/-less-pedantic}
10298
10299 \end_inset
10300
10301
10302 \series default
10303
10304 \begin_inset LatexCommand \label{lyx:--less-pedantic}
10305
10306 \end_inset
10307
10308  Disable some of the more pedantic warnings
10309 \begin_inset LatexCommand \index{Warnings}
10310
10311 \end_inset
10312
10313 .
10314  For more details, see the less_pedantic pragma 
10315 \begin_inset LatexCommand \vpageref{ite:less_pedantic}
10316
10317 \end_inset
10318
10319 .
10320 \end_layout
10321
10322 \begin_layout List
10323 \labelwidthstring 00.00.0000
10324
10325 \series bold
10326 -
10327 \begin_inset ERT
10328 status collapsed
10329
10330 \begin_layout Standard
10331
10332
10333 \backslash
10334 /
10335 \end_layout
10336
10337 \end_inset
10338
10339 -disable-warning\InsetSpace ~
10340 <nnnn>
10341 \begin_inset LatexCommand \index{-\\/-disable-warning}
10342
10343 \end_inset
10344
10345
10346 \series default
10347  Disable specific warning with number <nnnn>.
10348 \end_layout
10349
10350 \begin_layout List
10351 \labelwidthstring 00.00.0000
10352
10353 \series bold
10354 -
10355 \begin_inset ERT
10356 status collapsed
10357
10358 \begin_layout Standard
10359
10360
10361 \backslash
10362 /
10363 \end_layout
10364
10365 \end_inset
10366
10367 -print-search-dirs
10368 \begin_inset LatexCommand \index{-\\/-print-search-dirs}
10369
10370 \end_inset
10371
10372
10373 \series default
10374  Display the directories in the compiler's search path
10375 \end_layout
10376
10377 \begin_layout List
10378 \labelwidthstring 00.00.0000
10379
10380 \series bold
10381 -
10382 \begin_inset ERT
10383 status collapsed
10384
10385 \begin_layout Standard
10386
10387
10388 \backslash
10389 /
10390 \end_layout
10391
10392 \end_inset
10393
10394 -vc
10395 \begin_inset LatexCommand \index{-\\/-vc}
10396
10397 \end_inset
10398
10399
10400 \series default
10401  Display errors and warnings using MSVC style, so you can use SDCC with
10402  the visual studio IDE
10403 \begin_inset LatexCommand \index{IDE}
10404
10405 \end_inset
10406
10407 .
10408  With SDCC both offering a GCC-like (the default) and a MSVC-like
10409 \begin_inset LatexCommand \index{MSVC output style}
10410
10411 \end_inset
10412
10413  output style, integration into most programming editors should be straightforwa
10414 rd.
10415 \end_layout
10416
10417 \begin_layout List
10418 \labelwidthstring 00.00.0000
10419
10420 \series bold
10421 -
10422 \begin_inset ERT
10423 status collapsed
10424
10425 \begin_layout Standard
10426
10427
10428 \backslash
10429 /
10430 \end_layout
10431
10432 \end_inset
10433
10434 -use-stdout
10435 \begin_inset LatexCommand \index{-\\/-use-stdout}
10436
10437 \end_inset
10438
10439
10440 \series default
10441  Send errors and warnings to stdout instead of stderr.
10442 \end_layout
10443
10444 \begin_layout List
10445 \labelwidthstring 00.00.0000
10446
10447 \series bold
10448 -Wa\InsetSpace ~
10449 asmOption[,asmOption]
10450 \series default
10451
10452 \begin_inset LatexCommand \index{-Wa asmOption[,asmOption]}
10453
10454 \end_inset
10455
10456 ...
10457  Pass the asmOption to the assembler
10458 \begin_inset LatexCommand \index{Options assembler}
10459
10460 \end_inset
10461
10462
10463 \begin_inset LatexCommand \index{Assembler options}
10464
10465 \end_inset
10466
10467 .
10468  See file sdcc/as/doc/asxhtm.html for assembler options.cd
10469 \end_layout
10470
10471 \begin_layout List
10472 \labelwidthstring 00.00.0000
10473
10474 \series bold
10475 -
10476 \begin_inset ERT
10477 status collapsed
10478
10479 \begin_layout Standard
10480
10481
10482 \backslash
10483 /
10484 \end_layout
10485
10486 \end_inset
10487
10488 -std-sdcc89
10489 \begin_inset LatexCommand \index{-\\/-std-sdcc89}
10490
10491 \end_inset
10492
10493
10494 \series default
10495  Generally follow the C89 standard, but allow SDCC features that conflict
10496  with the standard (default).
10497 \end_layout
10498
10499 \begin_layout List
10500 \labelwidthstring 00.00.0000
10501
10502 \series bold
10503 -
10504 \begin_inset ERT
10505 status collapsed
10506
10507 \begin_layout Standard
10508
10509
10510 \backslash
10511 /
10512 \end_layout
10513
10514 \end_inset
10515
10516 -std-c89
10517 \begin_inset LatexCommand \index{-\\/-std-c89}
10518
10519 \end_inset
10520
10521
10522 \series default
10523  Follow the C89 standard and disable SDCC features that conflict with the
10524  standard.
10525 \end_layout
10526
10527 \begin_layout List
10528 \labelwidthstring 00.00.0000
10529
10530 \series bold
10531 -
10532 \begin_inset ERT
10533 status collapsed
10534
10535 \begin_layout Standard
10536
10537
10538 \backslash
10539 /
10540 \end_layout
10541
10542 \end_inset
10543
10544 -std-sdcc99
10545 \begin_inset LatexCommand \index{-\\/-std-sdcc99}
10546
10547 \end_inset
10548
10549
10550 \series default
10551  Generally follow the C99 standard, but allow SDCC features that conflict
10552  with the standard (incomplete support).
10553 \end_layout
10554
10555 \begin_layout List
10556 \labelwidthstring 00.00.0000
10557
10558 \series bold
10559 -
10560 \begin_inset ERT
10561 status collapsed
10562
10563 \begin_layout Standard
10564
10565
10566 \backslash
10567 /
10568 \end_layout
10569
10570 \end_inset
10571
10572 -std-c99
10573 \begin_inset LatexCommand \index{-\\/-std-sdcc99}
10574
10575 \end_inset
10576
10577
10578 \series default
10579  Follow the C99 standard and disable SDCC features that conflict with the
10580  standard (incomplete support).
10581 \end_layout
10582
10583 \begin_layout List
10584 \labelwidthstring 00.00.0000
10585
10586 \series bold
10587 -
10588 \begin_inset ERT
10589 status collapsed
10590
10591 \begin_layout Standard
10592
10593
10594 \backslash
10595 /
10596 \end_layout
10597
10598 \end_inset
10599
10600 -codeseg
10601 \series default
10602
10603 \begin_inset LatexCommand \index{-\\/-codeseg <Value>}
10604
10605 \end_inset
10606
10607 \InsetSpace ~
10608 <Name> The name to be used for the code
10609 \begin_inset LatexCommand \index{code}
10610
10611 \end_inset
10612
10613  segment, default CSEG.
10614  This is useful if you need to tell the compiler to put the code in a special
10615  segment so you can later on tell the linker to put this segment in a special
10616  place in memory.
10617  Can be used for instance when using bank switching to put the code in a
10618  bank.
10619 \end_layout
10620
10621 \begin_layout List
10622 \labelwidthstring 00.00.0000
10623
10624 \series bold
10625 -
10626 \begin_inset ERT
10627 status collapsed
10628
10629 \begin_layout Standard
10630
10631
10632 \backslash
10633 /
10634 \end_layout
10635
10636 \end_inset
10637
10638 -constseg
10639 \series default
10640
10641 \begin_inset LatexCommand \index{-\\/-constseg <Value>}
10642
10643 \end_inset
10644
10645 \InsetSpace ~
10646 <Name> The name to be used for the const
10647 \begin_inset LatexCommand \index{const}
10648
10649 \end_inset
10650
10651  segment, default CONST.
10652  This is useful if you need to tell the compiler to put the const data in
10653  a special segment so you can later on tell the linker to put this segment
10654  in a special place in memory.
10655  Can be used for instance when using bank switching to put the const data
10656  in a bank.
10657 \end_layout
10658
10659 \begin_layout List
10660 \labelwidthstring 00.00.0000
10661
10662 \series bold
10663 -
10664 \begin_inset ERT
10665 status collapsed
10666
10667 \begin_layout Standard
10668
10669
10670 \backslash
10671 /
10672 \end_layout
10673
10674 \end_inset
10675
10676 -fdollars-in-identifiers
10677 \begin_inset LatexCommand \index{-\\/-fdollars-in-identifiers}
10678
10679 \end_inset
10680
10681
10682 \series default
10683  Permit '$' as an identifier character.
10684 \end_layout
10685
10686 \begin_layout List
10687 \labelwidthstring 00.00.0000
10688
10689 \series bold
10690 -
10691 \begin_inset ERT
10692 status collapsed
10693
10694 \begin_layout Standard
10695
10696
10697 \backslash
10698 /
10699 \end_layout
10700
10701 \end_inset
10702
10703 -more-pedantic
10704 \series default
10705
10706 \begin_inset LatexCommand \index{-\\/-more-pedantic}
10707
10708 \end_inset
10709
10710
10711 \begin_inset LatexCommand \index{pedantic}
10712
10713 \end_inset
10714
10715  Actually this is 
10716 \series bold
10717 \emph on
10718 not
10719 \series default
10720 \emph default
10721  a SDCC compiler option but if you want 
10722 \emph on
10723 more
10724 \emph default
10725  warnings you can use a separate tool dedicated to syntax checking like
10726  splint
10727 \begin_inset LatexCommand \label{lyx:more-pedantic-SPLINT}
10728
10729 \end_inset
10730
10731
10732 \begin_inset LatexCommand \index{lint (syntax checking tool)}
10733
10734 \end_inset
10735
10736  
10737 \begin_inset LatexCommand \url{http://www.splint.org}
10738
10739 \end_inset
10740
10741 .
10742  To make your source files parseable by splint you will have to include
10743  
10744 \family sans
10745 lint.h
10746 \family default
10747
10748 \begin_inset LatexCommand \index{splint (syntax checking tool)}
10749
10750 \end_inset
10751
10752  in your source file and add brackets around extended keywords (like 
10753 \family sans
10754
10755 \begin_inset Quotes sld
10756 \end_inset
10757
10758 __at\InsetSpace ~
10759
10760 \series bold
10761 (
10762 \series default
10763 0xab
10764 \series bold
10765 )
10766 \series default
10767
10768 \begin_inset Quotes srd
10769 \end_inset
10770
10771
10772 \family default
10773  and 
10774 \family sans
10775
10776 \begin_inset Quotes sld
10777 \end_inset
10778
10779 __interrupt\InsetSpace ~
10780 (2)
10781 \begin_inset Quotes srd
10782 \end_inset
10783
10784
10785 \family default
10786 ).
10787  
10788 \newline
10789 Splint has an excellent on line manual at 
10790 \begin_inset LatexCommand \url{http://www.splint.org/manual/}
10791
10792 \end_inset
10793
10794  and it's capabilities go beyond pure syntax checking.
10795  You'll need to tell splint the location of SDCC's include files so a typical
10796  command line could look like this: 
10797 \newline
10798
10799 \family sans
10800 splint\InsetSpace ~
10801 -I\InsetSpace ~
10802 /usr/local/share/sdcc/include/mcs51/\InsetSpace ~
10803 \InsetSpace ~
10804 myprogram.c
10805 \end_layout
10806
10807 \begin_layout List
10808 \labelwidthstring 00.00.0000
10809
10810 \series bold
10811 -
10812 \begin_inset ERT
10813 status collapsed
10814
10815 \begin_layout Standard
10816
10817
10818 \backslash
10819 /
10820 \end_layout
10821
10822 \end_inset
10823
10824 -short-is-8bits
10825 \series default
10826
10827 \begin_inset LatexCommand \index{-\\/-short-is-8bits}
10828
10829 \end_inset
10830
10831
10832 \begin_inset LatexCommand \label{lyx:--short-is-8bits}
10833
10834 \end_inset
10835
10836  Treat short as 8-bit (for backward compatibility with older versions of
10837  compiler - see section 
10838 \begin_inset LatexCommand \ref{sec:Compatibility-with-previous}
10839
10840 \end_inset
10841
10842 )
10843 \end_layout
10844
10845 \begin_layout Standard
10846 \begin_inset VSpace bigskip
10847 \end_inset
10848
10849
10850 \end_layout
10851
10852 \begin_layout Subsection
10853 Intermediate Dump Options
10854 \begin_inset LatexCommand \label{sub:Intermediate-Dump-Options}
10855
10856 \end_inset
10857
10858
10859 \begin_inset LatexCommand \index{Options intermediate dump}
10860
10861 \end_inset
10862
10863
10864 \begin_inset LatexCommand \index{Intermediate dump options}
10865
10866 \end_inset
10867
10868
10869 \end_layout
10870
10871 \begin_layout Standard
10872 The following options are provided for the purpose of retargetting and debugging
10873  the compiler.
10874  They provide a means to dump the intermediate code (iCode
10875 \begin_inset LatexCommand \index{iCode}
10876
10877 \end_inset
10878
10879 ) generated by the compiler in human readable form at various stages of
10880  the compilation process.
10881  More on iCodes see chapter 
10882 \begin_inset LatexCommand \ref{sub:The-anatomy-of}
10883
10884 \end_inset
10885
10886  
10887 \begin_inset Quotes srd
10888 \end_inset
10889
10890 The anatomy of the compiler
10891 \begin_inset Quotes srd
10892 \end_inset
10893
10894 .
10895 \end_layout
10896
10897 \begin_layout List
10898 \labelwidthstring 00.00.0000
10899
10900 \series bold
10901 -
10902 \begin_inset ERT
10903 status collapsed
10904
10905 \begin_layout Standard
10906
10907
10908 \backslash
10909 /
10910 \end_layout
10911
10912 \end_inset
10913
10914 -dumpraw
10915 \begin_inset LatexCommand \index{-\\/-dumpraw}
10916
10917 \end_inset
10918
10919
10920 \series default
10921  This option will cause the compiler to dump the intermediate code into
10922  a file of named 
10923 \emph on
10924 <source filename>.dumpraw
10925 \emph default
10926  just after the intermediate code has been generated for a function, i.e.
10927  before any optimizations are done.
10928  The basic blocks
10929 \begin_inset LatexCommand \index{Basic blocks}
10930
10931 \end_inset
10932
10933  at this stage ordered in the depth first number, so they may not be in
10934  sequence of execution.
10935 \end_layout
10936
10937 \begin_layout List
10938 \labelwidthstring 00.00.0000
10939
10940 \series bold
10941 -
10942 \begin_inset ERT
10943 status collapsed
10944
10945 \begin_layout Standard
10946
10947
10948 \backslash
10949 /
10950 \end_layout
10951
10952 \end_inset
10953
10954 -dumpgcse
10955 \begin_inset LatexCommand \index{-\\/-dumpgcse}
10956
10957 \end_inset
10958
10959
10960 \series default
10961  Will create a dump of iCodes, after global subexpression elimination
10962 \begin_inset LatexCommand \index{Global subexpression elimination}
10963
10964 \end_inset
10965
10966 , into a file named 
10967 \emph on
10968 <source filename>.dumpgcse.
10969 \end_layout
10970
10971 \begin_layout List
10972 \labelwidthstring 00.00.0000
10973
10974 \series bold
10975 -
10976 \begin_inset ERT
10977 status collapsed
10978
10979 \begin_layout Standard
10980
10981
10982 \backslash
10983 /
10984 \end_layout
10985
10986 \end_inset
10987
10988 -dumpdeadcode
10989 \begin_inset LatexCommand \index{-\\/-dumpdeadcode}
10990
10991 \end_inset
10992
10993
10994 \series default
10995  Will create a dump of iCodes, after deadcode elimination
10996 \begin_inset LatexCommand \index{Dead-code elimination}
10997
10998 \end_inset
10999
11000 , into a file named 
11001 \emph on
11002 <source filename>.dumpdeadcode.
11003 \end_layout
11004
11005 \begin_layout List
11006 \labelwidthstring 00.00.0000
11007
11008 \series bold
11009 -
11010 \begin_inset ERT
11011 status collapsed
11012
11013 \begin_layout Standard
11014
11015
11016 \backslash
11017 /
11018 \end_layout
11019
11020 \end_inset
11021
11022 -dumploop
11023 \begin_inset LatexCommand \index{-\\/-dumploop}
11024
11025 \end_inset
11026
11027
11028 \series default
11029 \size large
11030  
11031 \size default
11032 Will create a dump of iCodes, after loop optimizations
11033 \begin_inset LatexCommand \index{Loop optimization}
11034
11035 \end_inset
11036
11037 , into a file named 
11038 \emph on
11039 <source filename>.dumploop.
11040 \end_layout
11041
11042 \begin_layout List
11043 \labelwidthstring 00.00.0000
11044
11045 \series bold
11046 -
11047 \begin_inset ERT
11048 status collapsed
11049
11050 \begin_layout Standard
11051
11052
11053 \backslash
11054 /
11055 \end_layout
11056
11057 \end_inset
11058
11059 -dumprange
11060 \begin_inset LatexCommand \index{-\\/-dumprange}
11061
11062 \end_inset
11063
11064
11065 \series default
11066 \size large
11067  
11068 \size default
11069 Will create a dump of iCodes, after live range analysis
11070 \begin_inset LatexCommand \index{Live range analysis}
11071
11072 \end_inset
11073
11074 , into a file named 
11075 \emph on
11076 <source filename>.dumprange.
11077 \end_layout
11078
11079 \begin_layout List
11080 \labelwidthstring 00.00.0000
11081
11082 \series bold
11083 -
11084 \begin_inset ERT
11085 status collapsed
11086
11087 \begin_layout Standard
11088
11089
11090 \backslash
11091 /
11092 \end_layout
11093
11094 \end_inset
11095
11096 -dumlrange
11097 \begin_inset LatexCommand \index{-\\/-dumlrange}
11098
11099 \end_inset
11100
11101
11102 \series default
11103  Will dump the life ranges
11104 \begin_inset LatexCommand \index{Live range analysis}
11105
11106 \end_inset
11107
11108  for all symbols.
11109 \end_layout
11110
11111 \begin_layout List
11112 \labelwidthstring 00.00.0000
11113
11114 \series bold
11115 -
11116 \begin_inset ERT
11117 status collapsed
11118
11119 \begin_layout Standard
11120
11121
11122 \backslash
11123 /
11124 \end_layout
11125
11126 \end_inset
11127
11128 -dumpregassign
11129 \begin_inset LatexCommand \index{-\\/-dumpregassign}
11130
11131 \end_inset
11132
11133  
11134 \series default
11135 Will create a dump of iCodes, after register assignment
11136 \begin_inset LatexCommand \index{Register assignment}
11137
11138 \end_inset
11139
11140 , into a file named 
11141 \emph on
11142 <source filename>.dumprassgn.
11143 \end_layout
11144
11145 \begin_layout List
11146 \labelwidthstring 00.00.0000
11147
11148 \series bold
11149 -
11150 \begin_inset ERT
11151 status collapsed
11152
11153 \begin_layout Standard
11154
11155
11156 \backslash
11157 /
11158 \end_layout
11159
11160 \end_inset
11161
11162 -dumplrange
11163 \begin_inset LatexCommand \index{-\\/-dumplrange}
11164
11165 \end_inset
11166
11167
11168 \series default
11169  Will create a dump of the live ranges of iTemp's
11170 \end_layout
11171
11172 \begin_layout List
11173 \labelwidthstring 00.00.0000
11174
11175 \series bold
11176 -
11177 \begin_inset ERT
11178 status collapsed
11179
11180 \begin_layout Standard
11181
11182
11183 \backslash
11184 /
11185 \end_layout
11186
11187 \end_inset
11188
11189 -dumpall
11190 \begin_inset LatexCommand \index{-\\/-dumpall}
11191
11192 \end_inset
11193
11194
11195 \size large
11196  
11197 \series default
11198 \size default
11199 Will cause all the above mentioned dumps to be created.
11200 \end_layout
11201
11202 \begin_layout Standard
11203 \begin_inset VSpace bigskip
11204 \end_inset
11205
11206
11207 \end_layout
11208
11209 \begin_layout Subsection
11210 Redirecting output on Windows Shells
11211 \end_layout
11212
11213 \begin_layout Standard
11214 By default SDCC writes its error messages to 
11215 \begin_inset Quotes sld
11216 \end_inset
11217
11218 standard error
11219 \begin_inset Quotes srd
11220 \end_inset
11221
11222 .
11223  To force all messages to 
11224 \begin_inset Quotes sld
11225 \end_inset
11226
11227 standard output
11228 \begin_inset Quotes srd
11229 \end_inset
11230
11231  use 
11232 \series bold
11233 -
11234 \series default
11235 \emph on
11236
11237 \begin_inset ERT
11238 status collapsed
11239
11240 \begin_layout Standard
11241
11242
11243 \backslash
11244 /
11245 \end_layout
11246
11247 \end_inset
11248
11249
11250 \series bold
11251 \emph default
11252 -
11253 \series default
11254 use-stdout
11255 \begin_inset LatexCommand \index{-\\/-use-stdout}
11256
11257 \end_inset
11258
11259 .
11260  Additionally, if you happen to have visual studio installed in your windows
11261  machine, you can use it to compile your sources using a custom build and
11262  the SDCC -
11263 \emph on
11264
11265 \begin_inset ERT
11266 status collapsed
11267
11268 \begin_layout Standard
11269
11270
11271 \backslash
11272 /
11273 \end_layout
11274
11275 \end_inset
11276
11277
11278 \emph default
11279 -vc
11280 \begin_inset LatexCommand \index{-\\/-vc}
11281
11282 \end_inset
11283
11284  option.
11285  Something like this should work:
11286 \newline
11287
11288 \newline
11289
11290 \series bold
11291 c:
11292 \backslash
11293 sdcc
11294 \backslash
11295 bin
11296 \backslash
11297 sdcc.exe -
11298 \series default
11299 \emph on
11300
11301 \begin_inset ERT
11302 status collapsed
11303
11304 \begin_layout Standard
11305
11306
11307 \backslash
11308 /
11309 \end_layout
11310
11311 \end_inset
11312
11313
11314 \series bold
11315 \emph default
11316 -vc -
11317 \series default
11318 \emph on
11319
11320 \begin_inset ERT
11321 status collapsed
11322
11323 \begin_layout Standard
11324
11325
11326 \backslash
11327 /
11328 \end_layout
11329
11330 \end_inset
11331
11332
11333 \series bold
11334 \emph default
11335 -model-large -c $(InputPath)
11336 \series default
11337
11338 \begin_inset VSpace bigskip
11339 \end_inset
11340
11341
11342 \end_layout
11343
11344 \begin_layout Section
11345 Environment variables
11346 \begin_inset LatexCommand \index{Environment variables}
11347
11348 \end_inset
11349
11350
11351 \end_layout
11352
11353 \begin_layout Standard
11354 SDCC recognizes the following environment variables:
11355 \end_layout
11356
11357 \begin_layout List
11358 \labelwidthstring 00.00.0000
11359
11360 \series bold
11361 SDCC_LEAVE_SIGNALS
11362 \begin_inset LatexCommand \index{SDCC\\_LEAVE\\_SIGNALS}
11363
11364 \end_inset
11365
11366
11367 \series default
11368  SDCC installs a signal handler
11369 \begin_inset LatexCommand \index{signal handler}
11370
11371 \end_inset
11372
11373  to be able to delete temporary files after an user break (^C) or an exception.
11374  If this environment variable is set, SDCC won't install the signal handler
11375  in order to be able to debug SDCC.
11376 \end_layout
11377
11378 \begin_layout List
11379 \labelwidthstring 00.00.0000
11380
11381 \series bold
11382 TMP,\InsetSpace ~
11383 TEMP,\InsetSpace ~
11384 TMPDIR
11385 \begin_inset LatexCommand \index{TMP, TEMP, TMPDIR}
11386
11387 \end_inset
11388
11389
11390 \series default
11391  Path, where temporary files will be created.
11392  The order of the variables is the search order.
11393  In a standard *nix environment these variables are not set, and there's
11394  no need to set them.
11395  On Windows it's recommended to set one of them.
11396 \end_layout
11397
11398 \begin_layout List
11399 \labelwidthstring 00.00.0000
11400
11401 \series bold
11402 SDCC_HOME
11403 \begin_inset LatexCommand \index{SDCC\\_HOME}
11404
11405 \end_inset
11406
11407
11408 \series default
11409  Path, see section 
11410 \begin_inset LatexCommand \ref{sub:Install-paths}
11411
11412 \end_inset
11413
11414 \InsetSpace ~
11415
11416 \begin_inset Quotes sld
11417 \end_inset
11418
11419  Install Paths
11420 \begin_inset Quotes srd
11421 \end_inset
11422
11423 .
11424 \end_layout
11425
11426 \begin_layout List
11427 \labelwidthstring 00.00.0000
11428
11429 \series bold
11430 SDCC_INCLUDE
11431 \begin_inset LatexCommand \index{SDCC\\_INCLUDE}
11432
11433 \end_inset
11434
11435
11436 \series default
11437  Path, see section 
11438 \begin_inset LatexCommand \ref{sub:Search-Paths}
11439
11440 \end_inset
11441
11442 \InsetSpace ~
11443
11444 \begin_inset Quotes sld
11445 \end_inset
11446
11447 Search Paths
11448 \begin_inset Quotes srd
11449 \end_inset
11450
11451 .
11452 \end_layout
11453
11454 \begin_layout List
11455 \labelwidthstring 00.00.0000
11456
11457 \series bold
11458 SDCC_LIB
11459 \begin_inset LatexCommand \index{SDCC\\_LIB}
11460
11461 \end_inset
11462
11463
11464 \series default
11465  Path, see section 
11466 \begin_inset LatexCommand \ref{sub:Search-Paths}
11467
11468 \end_inset
11469
11470 \InsetSpace ~
11471
11472 \begin_inset Quotes sld
11473 \end_inset
11474
11475 Search Paths
11476 \begin_inset Quotes srd
11477 \end_inset
11478
11479 ..
11480 \end_layout
11481
11482 \begin_layout Standard
11483 There are some more environment variables recognized by SDCC, but these
11484  are solely used for debugging purposes.
11485  They can change or disappear very quickly, and will never be documented.
11486 \begin_inset VSpace bigskip
11487 \end_inset
11488
11489
11490 \end_layout
11491
11492 \begin_layout Section
11493 Storage Class Language Extensions
11494 \end_layout
11495
11496 \begin_layout Subsection
11497 MCS51/DS390 Storage Class
11498 \begin_inset LatexCommand \index{Storage class}
11499
11500 \end_inset
11501
11502  Language Extensions
11503 \end_layout
11504
11505 \begin_layout Standard
11506 In addition to the ANSI storage classes SDCC allows the following MCS51
11507  specific storage classes:
11508 \end_layout
11509
11510 \begin_layout Subsubsection
11511 data
11512 \begin_inset LatexCommand \index{data (mcs51, ds390 storage class)}
11513
11514 \end_inset
11515
11516
11517 \begin_inset LatexCommand \index{\\_\\_data (mcs51, ds390 storage class)}
11518
11519 \end_inset
11520
11521  / near
11522 \begin_inset LatexCommand \index{near (storage class)}
11523
11524 \end_inset
11525
11526
11527 \begin_inset LatexCommand \index{\\_\\_near (storage class)}
11528
11529 \end_inset
11530
11531
11532 \end_layout
11533
11534 \begin_layout Standard
11535 This is the 
11536 \series bold
11537 default
11538 \series default
11539  storage class for the Small Memory model (
11540 \emph on
11541 data
11542 \emph default
11543  and 
11544 \emph on
11545 near
11546 \emph default
11547  or the more ANSI-C compliant forms 
11548 \emph on
11549 __data
11550 \emph default
11551  and 
11552 \emph on
11553 __near
11554 \emph default
11555  can be used synonymously).
11556  Variables declared with this storage class will be allocated in the directly
11557  addressable portion of the internal RAM of a 8051, e.g.:
11558 \end_layout
11559
11560 \begin_layout Verse
11561
11562 \family typewriter
11563 __data unsigned char test_data;
11564 \end_layout
11565
11566 \begin_layout Standard
11567 Writing 0x01 to this variable generates the assembly code:
11568 \end_layout
11569
11570 \begin_layout Verse
11571
11572 \family typewriter
11573 75*00 01\InsetSpace ~
11574 \InsetSpace ~
11575 \InsetSpace ~
11576 mov\InsetSpace ~
11577 \InsetSpace ~
11578 _test_data,#0x01
11579 \end_layout
11580
11581 \begin_layout Subsubsection
11582 xdata
11583 \begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
11584
11585 \end_inset
11586
11587
11588 \begin_inset LatexCommand \index{\\_\\_xdata (mcs51, ds390 storage class)}
11589
11590 \end_inset
11591
11592  / far
11593 \begin_inset LatexCommand \index{far (storage class)}
11594
11595 \end_inset
11596
11597
11598 \begin_inset LatexCommand \index{\\_\\_far (storage class)}
11599
11600 \end_inset
11601
11602
11603 \end_layout
11604
11605 \begin_layout Standard
11606 Variables declared with this storage class will be placed in the external
11607  RAM.
11608  This is the 
11609 \series bold
11610 default
11611 \series default
11612  storage class for the Large Memory model, e.g.:
11613 \end_layout
11614
11615 \begin_layout Verse
11616
11617 \family typewriter
11618 __xdata unsigned char test_xdata;
11619 \end_layout
11620
11621 \begin_layout Standard
11622 Writing 0x01 to this variable generates the assembly code:
11623 \end_layout
11624
11625 \begin_layout Verse
11626
11627 \family typewriter
11628 90s00r00\InsetSpace ~
11629 \InsetSpace ~
11630 \InsetSpace ~
11631 mov\InsetSpace ~
11632 \InsetSpace ~
11633 dptr,#_test_xdata 
11634 \newline
11635 74\InsetSpace ~
11636 01\InsetSpace ~
11637 \InsetSpace ~
11638 \InsetSpace ~
11639 \InsetSpace ~
11640 \InsetSpace ~
11641 \InsetSpace ~
11642 mov\InsetSpace ~
11643 \InsetSpace ~
11644 a,#0x01 
11645 \newline
11646 F0\InsetSpace ~
11647 \InsetSpace ~
11648 \InsetSpace ~
11649 \InsetSpace ~
11650 \InsetSpace ~
11651 \InsetSpace ~
11652 \InsetSpace ~
11653 \InsetSpace ~
11654 \InsetSpace ~
11655 movx\InsetSpace ~
11656 @dptr,a 
11657 \end_layout
11658
11659 \begin_layout Subsubsection
11660 idata
11661 \begin_inset LatexCommand \index{idata (mcs51, ds390 storage class)}
11662
11663 \end_inset
11664
11665
11666 \begin_inset LatexCommand \index{\\_\\_idata (mcs51, ds390 storage class)}
11667
11668 \end_inset
11669
11670
11671 \end_layout
11672
11673 \begin_layout Standard
11674 Variables declared with this storage class will be allocated into the indirectly
11675  addressable portion of the internal ram of a 8051, e.g.:
11676 \end_layout
11677
11678 \begin_layout Verse
11679
11680 \family typewriter
11681 __idata unsigned char test_idata;
11682 \end_layout
11683
11684 \begin_layout Standard
11685 Writing 0x01 to this variable generates the assembly code:
11686 \end_layout
11687
11688 \begin_layout Verse
11689
11690 \family typewriter
11691 78r00\InsetSpace ~
11692 \InsetSpace ~
11693 \InsetSpace ~
11694 \InsetSpace ~
11695 \InsetSpace ~
11696 \InsetSpace ~
11697 \InsetSpace ~
11698 mov\InsetSpace ~
11699 \InsetSpace ~
11700 r0,#_test_idata
11701 \newline
11702 76\InsetSpace ~
11703 01\InsetSpace ~
11704 \InsetSpace ~
11705 \InsetSpace ~
11706 \InsetSpace ~
11707 \InsetSpace ~
11708 \InsetSpace ~
11709 \InsetSpace ~
11710 mov\InsetSpace ~
11711 \InsetSpace ~
11712 @r0,#0x01
11713 \end_layout
11714
11715 \begin_layout Standard
11716 Please note, the first 128 byte of idata physically access the same RAM
11717  as the data memory.
11718  The original 8051 had 128 byte idata memory, nowadays most devices have
11719  256 byte idata memory.
11720  The stack
11721 \begin_inset LatexCommand \index{stack}
11722
11723 \end_inset
11724
11725  is located in idata memory.
11726 \end_layout
11727
11728 \begin_layout Subsubsection
11729 pdata
11730 \begin_inset LatexCommand \index{pdata (mcs51, ds390 storage class)}
11731
11732 \end_inset
11733
11734
11735 \begin_inset LatexCommand \index{\\_\\_pdata (mcs51, ds390 storage class)}
11736
11737 \end_inset
11738
11739
11740 \end_layout
11741
11742 \begin_layout Standard
11743 Paged xdata access is just as straightforward as using the other addressing
11744  modes of a 8051.
11745  It is typically located at the start of xdata and has a maximum size of
11746  256 bytes.
11747  The following example writes 0x01 to the pdata variable.
11748  Please note, pdata access physically accesses xdata memory.
11749  The high byte of the address is determined by port P2 
11750 \begin_inset LatexCommand \index{P2 (mcs51 sfr)}
11751
11752 \end_inset
11753
11754 (or in case of some 8051 variants by a separate Special Function Register,
11755  see section 
11756 \begin_inset LatexCommand \ref{sub:MCS51-variants}
11757
11758 \end_inset
11759
11760 ).
11761  This is the 
11762 \series bold
11763 default
11764 \series default
11765  storage class for the Medium Memory model, e.g.:
11766 \end_layout
11767
11768 \begin_layout Verse
11769
11770 \family typewriter
11771 __pdata unsigned char test_pdata;
11772 \end_layout
11773
11774 \begin_layout Standard
11775 Writing 0x01 to this variable generates the assembly code:
11776 \end_layout
11777
11778 \begin_layout Verse
11779
11780 \family typewriter
11781 78r00\InsetSpace ~
11782 \InsetSpace ~
11783 \InsetSpace ~
11784 \InsetSpace ~
11785 \InsetSpace ~
11786 \InsetSpace ~
11787 mov r0,#_test_pdata
11788 \newline
11789 74 01\InsetSpace ~
11790 \InsetSpace ~
11791 \InsetSpace ~
11792 \InsetSpace ~
11793 \InsetSpace ~
11794 \InsetSpace ~
11795 mov a,#0x01 
11796 \newline
11797 F2\InsetSpace ~
11798 \InsetSpace ~
11799 \InsetSpace ~
11800 \InsetSpace ~
11801 \InsetSpace ~
11802 \InsetSpace ~
11803 \InsetSpace ~
11804 \InsetSpace ~
11805 \InsetSpace ~
11806 movx @r0,a
11807 \end_layout
11808
11809 \begin_layout Standard
11810 If the -
11811 \begin_inset ERT
11812 status collapsed
11813
11814 \begin_layout Standard
11815
11816
11817 \backslash
11818 /
11819 \end_layout
11820
11821 \end_inset
11822
11823 -xstack
11824 \begin_inset LatexCommand \index{-\\/-xstack}
11825
11826 \end_inset
11827
11828  option is used the pdata memory area is followed by the xstack memory area
11829  and the sum of their sizes is limited to 256 bytes.
11830 \end_layout
11831
11832 \begin_layout Subsubsection
11833 code
11834 \begin_inset LatexCommand \index{code}
11835
11836 \end_inset
11837
11838
11839 \begin_inset LatexCommand \index{\\_\\_code}
11840
11841 \end_inset
11842
11843
11844 \end_layout
11845
11846 \begin_layout Standard
11847 'Variables' declared with this storage class will be placed in the code
11848  memory:
11849 \end_layout
11850
11851 \begin_layout Verse
11852
11853 \family typewriter
11854 __code unsigned char test_code;
11855 \end_layout
11856
11857 \begin_layout Standard
11858 Read access to this variable generates the assembly code:
11859 \end_layout
11860
11861 \begin_layout Verse
11862
11863 \family typewriter
11864 90s00r6F\InsetSpace ~
11865 \InsetSpace ~
11866 \InsetSpace ~
11867 mov dptr,#_test_code
11868 \newline
11869 E4\InsetSpace ~
11870 \InsetSpace ~
11871 \InsetSpace ~
11872 \InsetSpace ~
11873 \InsetSpace ~
11874 \InsetSpace ~
11875 \InsetSpace ~
11876 \InsetSpace ~
11877 \InsetSpace ~
11878 clr a
11879 \newline
11880 93\InsetSpace ~
11881 \InsetSpace ~
11882 \InsetSpace ~
11883 \InsetSpace ~
11884 \InsetSpace ~
11885 \InsetSpace ~
11886 \InsetSpace ~
11887 \InsetSpace ~
11888 \InsetSpace ~
11889 movc a,@a+dptr 
11890 \end_layout
11891
11892 \begin_layout Standard
11893
11894 \family typewriter
11895 char
11896 \family default
11897  indexed arrays of characters in code memory can be accessed efficiently:
11898 \end_layout
11899
11900 \begin_layout Verse
11901
11902 \family typewriter
11903 __code char test_array[] = {'c','h','e','a','p'}; 
11904 \end_layout
11905
11906 \begin_layout Standard
11907 Read access to this array using an 8-bit unsigned index generates the assembly
11908  code:
11909 \end_layout
11910
11911 \begin_layout Verse
11912
11913 \family typewriter
11914 E5*00\InsetSpace ~
11915 \InsetSpace ~
11916 \InsetSpace ~
11917 \InsetSpace ~
11918 \InsetSpace ~
11919 \InsetSpace ~
11920 mov a,_index 
11921 \end_layout
11922
11923 \begin_layout Verse
11924
11925 \family typewriter
11926 90s00r41\InsetSpace ~
11927 \InsetSpace ~
11928 \InsetSpace ~
11929 mov dptr,#_test_array
11930 \end_layout
11931
11932 \begin_layout Verse
11933
11934 \family typewriter
11935 93\InsetSpace ~
11936 \InsetSpace ~
11937 \InsetSpace ~
11938 \InsetSpace ~
11939 \InsetSpace ~
11940 \InsetSpace ~
11941 \InsetSpace ~
11942 \InsetSpace ~
11943 \InsetSpace ~
11944 movc a,@a+dptr 
11945 \end_layout
11946
11947 \begin_layout Subsubsection
11948 bit
11949 \begin_inset LatexCommand \index{bit}
11950
11951 \end_inset
11952
11953
11954 \begin_inset LatexCommand \index{\\_\\_bit}
11955
11956 \end_inset
11957
11958
11959 \end_layout
11960
11961 \begin_layout Standard
11962 This is a data-type and a storage class specifier.
11963  When a variable is declared as a bit, it is allocated into the bit addressable
11964  memory of 8051, e.g.:
11965 \end_layout
11966
11967 \begin_layout Verse
11968
11969 \family typewriter
11970 __bit test_bit;
11971 \end_layout
11972
11973 \begin_layout Standard
11974 Writing 1 to this variable generates the assembly code:
11975 \end_layout
11976
11977 \begin_layout Verse
11978
11979 \family typewriter
11980 D2*00\InsetSpace ~
11981 \InsetSpace ~
11982 \InsetSpace ~
11983 \InsetSpace ~
11984 \InsetSpace ~
11985 \InsetSpace ~
11986 \InsetSpace ~
11987 setb\InsetSpace ~
11988 _test_bit
11989 \end_layout
11990
11991 \begin_layout Standard
11992 The bit addressable memory consists of 128 bits which are located from 0x20
11993  to 0x2f in data memory.
11994  
11995 \newline
11996 Apart from this 8051 specific storage class most architectures support
11997  ANSI-C bitfields
11998 \begin_inset LatexCommand \index{bitfields}
11999
12000 \end_inset
12001
12002
12003 \begin_inset Foot
12004 status open
12005
12006 \begin_layout Standard
12007 Not really meant as examples, but nevertheless showing what bitfields are
12008  about: device/include/mc68hc908qy.h and support/regression/tests/bitfields.c
12009 \end_layout
12010
12011 \end_inset
12012
12013 .
12014  In accordance with ISO/IEC 9899 bits and bitfields without an explicit
12015  signed modifier are implemented as unsigned.
12016 \end_layout
12017
12018 \begin_layout Subsubsection
12019 sfr
12020 \begin_inset LatexCommand \index{sfr}
12021
12022 \end_inset
12023
12024
12025 \begin_inset LatexCommand \index{\\_\\_sfr}
12026
12027 \end_inset
12028
12029  / sfr16
12030 \begin_inset LatexCommand \index{sfr16}
12031
12032 \end_inset
12033
12034
12035 \begin_inset LatexCommand \index{\\_\\_sfr16}
12036
12037 \end_inset
12038
12039  / sfr32
12040 \begin_inset LatexCommand \index{sfr32}
12041
12042 \end_inset
12043
12044
12045 \begin_inset LatexCommand \index{\\_\\_sfr32}
12046
12047 \end_inset
12048
12049  / sbit
12050 \begin_inset LatexCommand \index{\\_\\_sbit}
12051
12052 \end_inset
12053
12054
12055 \begin_inset LatexCommand \index{sbit}
12056
12057 \end_inset
12058
12059
12060 \end_layout
12061
12062 \begin_layout Standard
12063 Like the bit keyword, 
12064 \emph on
12065 sfr / sfr16 / sfr32 / sbit
12066 \emph default
12067  signify both a data-type and storage class, they are used to describe the
12068  
12069 \emph on
12070 s
12071 \emph default
12072 pecial 
12073 \emph on
12074 f
12075 \emph default
12076 unction 
12077 \emph on
12078 r
12079 \emph default
12080 egisters and 
12081 \emph on
12082 s
12083 \emph default
12084 pecial 
12085 \emph on
12086 bit
12087 \emph default
12088  variables of a 8051, eg:
12089 \end_layout
12090
12091 \begin_layout Verse
12092
12093 \family typewriter
12094 __sfr __at
12095 \begin_inset LatexCommand \index{at}
12096
12097 \end_inset
12098
12099
12100 \begin_inset LatexCommand \index{\\_\\_at}
12101
12102 \end_inset
12103
12104  (0x80) P0;\InsetSpace ~
12105  /* special function register P0 at location 0x80 */
12106 \newline
12107
12108 \newline
12109 /* 16 bit
12110  special function register combination for timer 0
12111 \newline
12112 \InsetSpace ~
12113 \InsetSpace ~
12114  with the high byte at
12115  location 0x8C and the low byte at location 0x8A */
12116 \newline
12117 __sfr16 __at (0x8C8A)
12118  TMR0;
12119 \newline
12120
12121 \newline
12122 __sbit __at
12123 \begin_inset LatexCommand \index{at}
12124
12125 \end_inset
12126
12127
12128 \begin_inset LatexCommand \index{\\_\\_at}
12129
12130 \end_inset
12131
12132  (0xd7) CY;\InsetSpace ~
12133  /* CY (Carry Flag
12134 \begin_inset LatexCommand \index{Flags}
12135
12136 \end_inset
12137
12138
12139 \begin_inset LatexCommand \index{Carry flag}
12140
12141 \end_inset
12142
12143 ) */
12144 \end_layout
12145
12146 \begin_layout Standard
12147 Special function registers which are located on an address dividable by
12148  8 are bit-addressable, an 
12149 \emph on
12150 sbit
12151 \emph default
12152  addresses a specific bit within these sfr.
12153 \newline
12154 16 Bit and 32 bit special function
12155  register combinations which require a certain access order are better not
12156  declared using 
12157 \emph on
12158 sfr16
12159 \emph default
12160  or 
12161 \emph on
12162 sfr32.
12163
12164 \emph default
12165  Allthough SDCC usually accesses them Least Significant Byte (LSB) first,
12166  this is not guaranteed.
12167 \newline
12168
12169 \end_layout
12170
12171 \begin_layout Standard
12172 Please note, if you use a header file which was written for another compiler
12173  then the sfr / sfr16 / sfr32 / sbit Storage Class extensions will most
12174  likely be 
12175 \emph on
12176 not
12177 \emph default
12178  compatible.
12179  Specifically the syntax 
12180 \family typewriter
12181 \InsetSpace ~
12182 sfr P0 = 0x80;\InsetSpace ~
12183
12184 \family default
12185  is compiled 
12186 \emph on
12187 without warning
12188 \emph default
12189  by SDCC to an assignment of 0x80 to a variable called P0 
12190 \family typewriter
12191
12192 \begin_inset Marginal
12193 status collapsed
12194
12195 \begin_layout Standard
12196
12197 \series bold
12198 \InsetSpace ~
12199 !
12200 \end_layout
12201
12202 \end_inset
12203
12204 .
12205
12206 \family default
12207  
12208 \series bold
12209 Nevertheless it is possible to write header files
12210 \begin_inset LatexCommand \index{Header files}
12211
12212 \end_inset
12213
12214
12215 \begin_inset LatexCommand \index{Include files}
12216
12217 \end_inset
12218
12219  which can be shared among different compilers (see section 
12220 \begin_inset LatexCommand \ref{sec:Porting-code-to-other-compilers}
12221
12222 \end_inset
12223
12224 ).
12225  
12226 \end_layout
12227
12228 \begin_layout Subsubsection
12229 Pointers
12230 \begin_inset LatexCommand \index{Pointer}
12231
12232 \end_inset
12233
12234  to MCS51/DS390 specific memory spaces
12235 \end_layout
12236
12237 \begin_layout Standard
12238 SDCC allows (via language extensions) pointers to explicitly point to any
12239  of the memory spaces
12240 \begin_inset LatexCommand \index{Memory model}
12241
12242 \end_inset
12243
12244  of the 8051.
12245  In addition to the explicit pointers, the compiler uses (by default) generic
12246  pointers which can be used to point to any of the memory spaces.
12247 \newline
12248
12249 \newline
12250 Pointer
12251  declaration examples:
12252 \end_layout
12253
12254 \begin_layout Verse
12255
12256 \family typewriter
12257 /* pointer physically in internal ram pointing to object in external ram
12258  */ 
12259 \newline
12260 __xdata unsigned char * __data p;
12261 \newline
12262
12263 \newline
12264 /* pointer physically in external ram
12265  pointing to object in internal ram */ 
12266 \newline
12267 __data unsigned char * __xdata p;
12268 \newline
12269
12270 \newline
12271 /*
12272  pointer physically in code rom pointing to data in xdata space */ 
12273 \newline
12274 __xdata
12275  unsigned char * __code p;
12276 \newline
12277
12278 \newline
12279 /* pointer physically in code space pointing to
12280  data in code space */ 
12281 \newline
12282 __code unsigned char * __code p;
12283 \newline
12284
12285 \newline
12286 /* generic pointer
12287  physically located in xdata space */
12288 \newline
12289 unsigned char * __xdata p;
12290 \newline
12291
12292 \newline
12293 /* generic
12294  pointer physically located in default memory space */
12295 \newline
12296 unsigned char * p;
12297 \newline
12298
12299 \newline
12300 /*
12301  the following is a function pointer
12302 \begin_inset LatexCommand \index{function pointer}
12303
12304 \end_inset
12305
12306  physically located in data space */
12307 \newline
12308 char (* __data fp)(void);
12309 \end_layout
12310
12311 \begin_layout Standard
12312 Well you get the idea.
12313  
12314 \newline
12315
12316 \newline
12317 All unqualified pointers are treated as 3-byte (4-byte for the ds390) 
12318 \emph on
12319 generic
12320 \emph default
12321  pointers.
12322  
12323 \size small
12324
12325 \newline
12326
12327 \newline
12328
12329 \size default
12330 The highest order byte of the 
12331 \emph on
12332 generic
12333 \emph default
12334  pointers contains the data space information.
12335  Assembler support routines are called whenever data is stored or retrieved
12336  using 
12337 \emph on
12338 generic
12339 \emph default
12340  pointers.
12341  These are useful for developing reusable library
12342 \begin_inset LatexCommand \index{Libraries}
12343
12344 \end_inset
12345
12346  routines.
12347  Explicitly specifying the pointer
12348 \begin_inset LatexCommand \index{pointer}
12349
12350 \end_inset
12351
12352  type will generate the most efficient code.
12353 \end_layout
12354
12355 \begin_layout Subsubsection
12356 Notes on MCS51 memory
12357 \begin_inset LatexCommand \index{MCS51 memory}
12358
12359 \end_inset
12360
12361  layout
12362 \end_layout
12363
12364 \begin_layout Standard
12365 The 8051 family of microcontrollers have a minimum of 128 bytes of internal
12366  RAM memory which is structured as follows:
12367 \newline
12368
12369 \newline
12370 - Bytes 00-1F - 32 bytes to hold
12371  up to 4 banks of the registers R0 to R7, 
12372 \newline
12373 - Bytes 20-2F - 16 bytes to hold
12374  128 bit
12375 \begin_inset LatexCommand \index{bit}
12376
12377 \end_inset
12378
12379  variables and, 
12380 \newline
12381 - Bytes 30-7F - 80 bytes for general purpose use.
12382 \newline
12383
12384 \end_layout
12385
12386 \begin_layout Standard
12387 Additionally some members of the MCS51 family may have up to 128 bytes of
12388  additional, indirectly addressable, internal RAM memory (
12389 \emph on
12390 idata
12391 \emph default
12392
12393 \begin_inset LatexCommand \index{idata (mcs51, ds390 storage class)}
12394
12395 \end_inset
12396
12397
12398 \begin_inset LatexCommand \index{\\_\\_idata (mcs51, ds390 storage class)}
12399
12400 \end_inset
12401
12402 ).
12403  Furthermore, some chips may have some built in external memory (
12404 \emph on
12405 xdata
12406 \emph default
12407
12408 \begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
12409
12410 \end_inset
12411
12412
12413 \begin_inset LatexCommand \index{\\_\\_xdata (mcs51, ds390 storage class)}
12414
12415 \end_inset
12416
12417 ) which should not be confused with the internal, directly addressable RAM
12418  memory (
12419 \emph on
12420 data
12421 \emph default
12422
12423 \begin_inset LatexCommand \index{data (mcs51, ds390 storage class)}
12424
12425 \end_inset
12426
12427
12428 \begin_inset LatexCommand \index{\\_\\_data (mcs51, ds390 storage class)}
12429
12430 \end_inset
12431
12432 ).
12433  Sometimes this built in 
12434 \emph on
12435 xdata
12436 \emph default
12437  memory has to be activated before using it (you can probably find this
12438  information on the datasheet of the microcontroller your are using, see
12439  also section 
12440 \begin_inset LatexCommand \ref{sub:Startup-Code}
12441
12442 \end_inset
12443
12444 \InsetSpace ~
12445 Startup-Code).
12446 \end_layout
12447
12448 \begin_layout Standard
12449 Normally SDCC will only use the first bank
12450 \begin_inset LatexCommand \index{register bank (mcs51, ds390)}
12451
12452 \end_inset
12453
12454  of registers (register bank 0), but it is possible to specify that other
12455  banks of registers (keyword 
12456 \emph on
12457 using
12458 \emph default
12459  
12460 \emph on
12461
12462 \begin_inset LatexCommand \index{using (mcs51, ds390 register bank)}
12463
12464 \end_inset
12465
12466
12467 \begin_inset LatexCommand \index{\\_\\_using (mcs51, ds390 register bank)}
12468
12469 \end_inset
12470
12471
12472 \emph default
12473 ) should be used for example in interrupt
12474 \begin_inset LatexCommand \index{interrupt}
12475
12476 \end_inset
12477
12478
12479 \begin_inset LatexCommand \index{\\_\\_interrupt}
12480
12481 \end_inset
12482
12483  routines.
12484  By default, the compiler will place the stack after the last byte of allocated
12485  memory for variables.
12486  For example, if the first 2 banks of registers are used, and only four
12487  bytes are used for 
12488 \emph on
12489 data
12490 \emph default
12491  variables, it will position the base of the internal stack at address 20
12492  (0x14).
12493  This implies that as the stack
12494 \begin_inset LatexCommand \index{stack}
12495
12496 \end_inset
12497
12498  grows, it will use up the remaining register banks, and the 16 bytes used
12499  by the 128 bit variables, and 80 bytes for general purpose use.
12500  If any bit variables are used, the data variables will be placed in unused
12501  register banks and after the byte holding the last bit variable.
12502  For example, if register banks 0 and 1 are used, and there are 9 bit variables
12503  (two bytes used), 
12504 \emph on
12505 data
12506 \emph default
12507  variables will be placed starting from address 0x10 to 0x20 and continue
12508  at address 0x22.
12509  You can also use -
12510 \begin_inset ERT
12511 status collapsed
12512
12513 \begin_layout Standard
12514
12515
12516 \backslash
12517 /
12518 \end_layout
12519
12520 \end_inset
12521
12522 -data-loc
12523 \begin_inset LatexCommand \index{-\\/-data-loc <Value>}
12524
12525 \end_inset
12526
12527  to specify the start address of the 
12528 \emph on
12529 data
12530 \emph default
12531  and -
12532 \begin_inset ERT
12533 status collapsed
12534
12535 \begin_layout Standard
12536
12537
12538 \backslash
12539 /
12540 \end_layout
12541
12542 \end_inset
12543
12544 -iram-size
12545 \begin_inset LatexCommand \index{-\\/-iram-size <Value>}
12546
12547 \end_inset
12548
12549  to specify the size of the total internal RAM (
12550 \emph on
12551 data
12552 \emph default
12553 +
12554 \emph on
12555 idata
12556 \emph default
12557 ).
12558  
12559 \newline
12560
12561 \end_layout
12562
12563 \begin_layout Standard
12564 By default the 8051 linker will place the stack after the last byte of (i)data
12565  variables.
12566  Option -
12567 \begin_inset ERT
12568 status collapsed
12569
12570 \begin_layout Standard
12571
12572
12573 \backslash
12574 /
12575 \end_layout
12576
12577 \end_inset
12578
12579 -stack-loc
12580 \begin_inset LatexCommand \index{-\\/-stack-loc <Value>}
12581
12582 \end_inset
12583
12584  allows you to specify the start of the stack, i.e.
12585  you could start it after any data in the general purpose area.
12586  If your microcontroller has additional indirectly addressable internal
12587  RAM (
12588 \emph on
12589 idata
12590 \emph default
12591 ) you can place the stack on it.
12592  You may also need to use -
12593 \begin_inset ERT
12594 status collapsed
12595
12596 \begin_layout Standard
12597
12598
12599 \backslash
12600 /
12601 \end_layout
12602
12603 \end_inset
12604
12605 -xdata-loc
12606 \begin_inset LatexCommand \index{-\\/-xdata-loc<Value>}
12607
12608 \end_inset
12609
12610  to set the start address of the external RAM (
12611 \emph on
12612 xdata
12613 \emph default
12614 ) and -
12615 \begin_inset ERT
12616 status collapsed
12617
12618 \begin_layout Standard
12619
12620
12621 \backslash
12622 /
12623 \end_layout
12624
12625 \end_inset
12626
12627 -xram-size
12628 \begin_inset LatexCommand \index{-\\/-xram-size <Value>}
12629
12630 \end_inset
12631
12632  to specify its size.
12633  Same goes for the code memory, using -
12634 \begin_inset ERT
12635 status collapsed
12636
12637 \begin_layout Standard
12638
12639
12640 \backslash
12641 /
12642 \end_layout
12643
12644 \end_inset
12645
12646 -code-loc
12647 \begin_inset LatexCommand \index{-\\/-code-loc <Value>}
12648
12649 \end_inset
12650
12651  and -
12652 \begin_inset ERT
12653 status collapsed
12654
12655 \begin_layout Standard
12656
12657
12658 \backslash
12659 /
12660 \end_layout
12661
12662 \end_inset
12663
12664 -code-size
12665 \begin_inset LatexCommand \index{-\\/-code-size <Value>}
12666
12667 \end_inset
12668
12669 .
12670  If in doubt, don't specify any options and see if the resulting memory
12671  layout is appropriate, then you can adjust it.
12672 \end_layout
12673
12674 \begin_layout Standard
12675 The linker generates two files with memory allocation information.
12676  The first, with extension .map
12677 \begin_inset LatexCommand \index{<file>.map}
12678
12679 \end_inset
12680
12681  shows all the variables and segments.
12682  The second with extension .mem
12683 \begin_inset LatexCommand \index{<file>.mem}
12684
12685 \end_inset
12686
12687  shows the final memory layout.
12688  The linker will complain either if memory segments overlap, there is not
12689  enough memory, or there is not enough space for stack.
12690  If you get any linking warnings and/or errors related to stack or segments
12691  allocation, take a look at either the .map or .mem files to find out what
12692  the problem is.
12693  The .mem file may even suggest a solution to the problem.
12694 \begin_inset VSpace bigskip
12695 \end_inset
12696
12697
12698 \end_layout
12699
12700 \begin_layout Subsection
12701 Z80/Z180 Storage Class
12702 \begin_inset LatexCommand \index{Z80!Storage class}
12703
12704 \end_inset
12705
12706  Language Extensions
12707 \end_layout
12708
12709 \begin_layout Subsubsection
12710 sfr
12711 \begin_inset LatexCommand \index{sfr}
12712
12713 \end_inset
12714
12715
12716 \begin_inset LatexCommand \index{\\_\\_sfr}
12717
12718 \end_inset
12719
12720  (in/out to 8-bit addresses)
12721 \end_layout
12722
12723 \begin_layout Standard
12724 The Z80
12725 \begin_inset LatexCommand \index{Z80}
12726
12727 \end_inset
12728
12729  family has separate address spaces for memory and 
12730 \emph on
12731 i
12732 \emph default
12733 nput/
12734 \emph on
12735 o
12736 \emph default
12737 utput memory.
12738  I/O memory
12739 \begin_inset LatexCommand \index{I/O memory (Z80, Z180)}
12740
12741 \end_inset
12742
12743
12744 \begin_inset LatexCommand \index{Z80!I/O memory}
12745
12746 \end_inset
12747
12748
12749 \begin_inset LatexCommand \index{Z180!I/O memory}
12750
12751 \end_inset
12752
12753  is accessed with special instructions, e.g.:
12754 \end_layout
12755
12756 \begin_layout Verse
12757
12758 \family typewriter
12759 sfr at 0x78 IoPort;\InsetSpace ~
12760 \InsetSpace ~
12761 /* define a var in I/O space at 78h called IoPort */
12762  
12763 \end_layout
12764
12765 \begin_layout Standard
12766 Writing 0x01 to this variable generates the assembly code:
12767 \end_layout
12768
12769 \begin_layout Verse
12770
12771 \family typewriter
12772 3E 01\InsetSpace ~
12773 \InsetSpace ~
12774 \InsetSpace ~
12775 \InsetSpace ~
12776 \InsetSpace ~
12777 \InsetSpace ~
12778 ld a,#0x01
12779 \newline
12780 D3 78\InsetSpace ~
12781 \InsetSpace ~
12782 \InsetSpace ~
12783 \InsetSpace ~
12784 \InsetSpace ~
12785 \InsetSpace ~
12786 out (_IoPort),a 
12787 \end_layout
12788
12789 \begin_layout Subsubsection
12790 banked sfr
12791 \begin_inset LatexCommand \index{sfr}
12792
12793 \end_inset
12794
12795
12796 \begin_inset LatexCommand \index{\\_\\_sfr}
12797
12798 \end_inset
12799
12800  (in/out to 16-bit addresses)
12801 \end_layout
12802
12803 \begin_layout Standard
12804 The keyword 
12805 \emph on
12806 banked
12807 \emph default
12808  is used to support 16 bit addresses in I/O memory e.g.:
12809 \end_layout
12810
12811 \begin_layout Verse
12812
12813 \family typewriter
12814 sfr banked at
12815 \begin_inset LatexCommand \index{at}
12816
12817 \end_inset
12818
12819
12820 \begin_inset LatexCommand \index{\\_\\_at}
12821
12822 \end_inset
12823
12824  0x123 IoPort; 
12825 \end_layout
12826
12827 \begin_layout Standard
12828 Writing 0x01 to this variable generates the assembly code:
12829 \end_layout
12830
12831 \begin_layout Verse
12832
12833 \family typewriter
12834 01 23 01\InsetSpace ~
12835 \InsetSpace ~
12836 \InsetSpace ~
12837 ld bc,#_IoPort
12838 \newline
12839 3E 01\InsetSpace ~
12840 \InsetSpace ~
12841 \InsetSpace ~
12842 \InsetSpace ~
12843 \InsetSpace ~
12844 \InsetSpace ~
12845 ld a,#0x01 
12846 \newline
12847 ED 79\InsetSpace ~
12848 \InsetSpace ~
12849 \InsetSpace ~
12850 \InsetSpace ~
12851 \InsetSpace ~
12852 \InsetSpace ~
12853 out (c),a 
12854 \end_layout
12855
12856 \begin_layout Subsubsection
12857 sfr
12858 \begin_inset LatexCommand \index{sfr}
12859
12860 \end_inset
12861
12862
12863 \begin_inset LatexCommand \index{\\_\\_sfr}
12864
12865 \end_inset
12866
12867  (in0/out0 to 8 bit addresses on Z180
12868 \begin_inset LatexCommand \index{Z180}
12869
12870 \end_inset
12871
12872 /HD64180
12873 \begin_inset LatexCommand \index{HD64180 (see Z180)}
12874
12875 \end_inset
12876
12877 )
12878 \end_layout
12879
12880 \begin_layout Standard
12881 The compiler option -
12882 \begin_inset ERT
12883 status collapsed
12884
12885 \begin_layout Standard
12886
12887
12888 \backslash
12889 /
12890 \end_layout
12891
12892 \end_inset
12893
12894 -portmode
12895 \begin_inset LatexCommand \index{Z180!Options!-\\/-portmode}
12896
12897 \end_inset
12898
12899 =180 (80) and a compiler #pragma\InsetSpace ~
12900 portmode
12901 \begin_inset LatexCommand \index{Z180!Pragmas!\\#pragma portmode}
12902
12903 \end_inset
12904
12905  z180 (z80) is used to turn on (off) the Z180/HD64180 port addressing instructio
12906 ns 
12907 \family typewriter
12908 in0/out0
12909 \family default
12910  instead of 
12911 \family typewriter
12912 in/out
12913 \family default
12914 .
12915  If you include the file z180.h this will be set automatically.
12916 \begin_inset VSpace bigskip
12917 \end_inset
12918
12919
12920 \end_layout
12921
12922 \begin_layout Subsection
12923 HC08 Storage Class
12924 \begin_inset LatexCommand \index{HC08!Storage class}
12925
12926 \end_inset
12927
12928  Language Extensions
12929 \end_layout
12930
12931 \begin_layout Subsubsection
12932 data
12933 \begin_inset LatexCommand \index{data (hc08 storage class)}
12934
12935 \end_inset
12936
12937
12938 \begin_inset LatexCommand \index{\\_\\_data (hc08 storage class)}
12939
12940 \end_inset
12941
12942  
12943 \end_layout
12944
12945 \begin_layout Standard
12946 The data storage class declares a variable that resides in the first 256
12947  bytes of memory (the direct page).
12948  The HC08
12949 \begin_inset LatexCommand \index{HC08}
12950
12951 \end_inset
12952
12953  is most efficient at accessing variables (especially pointers) stored here.
12954 \end_layout
12955
12956 \begin_layout Subsubsection
12957 xdata
12958 \begin_inset LatexCommand \index{xdata (hc08 storage class)}
12959
12960 \end_inset
12961
12962
12963 \begin_inset LatexCommand \index{\\_\\_xdata (hc08 storage class)}
12964
12965 \end_inset
12966
12967  
12968 \end_layout
12969
12970 \begin_layout Standard
12971 The xdata storage class declares a variable that can reside anywhere in
12972  memory.
12973  This is the default if no storage class is specified.
12974  
12975 \begin_inset VSpace bigskip
12976 \end_inset
12977
12978
12979 \end_layout
12980
12981 \begin_layout Section
12982 Absolute Addressing
12983 \begin_inset LatexCommand \index{Absolute addressing}
12984
12985 \end_inset
12986
12987
12988 \end_layout
12989
12990 \begin_layout Standard
12991 Data items can be assigned an absolute address with the 
12992 \emph on
12993 at
12994 \begin_inset LatexCommand \index{at}
12995
12996 \end_inset
12997
12998
12999 \begin_inset LatexCommand \index{\\_\\_at}
13000
13001 \end_inset
13002
13003  <address>
13004 \emph default
13005  keyword, in addition to a storage class, e.g.:
13006 \end_layout
13007
13008 \begin_layout Verse
13009
13010 \family typewriter
13011 xdata
13012 \begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
13013
13014 \end_inset
13015
13016
13017 \begin_inset LatexCommand \index{\\_\\_xdata (mcs51, ds390 storage class)}
13018
13019 \end_inset
13020
13021  at
13022 \begin_inset LatexCommand \index{at}
13023
13024 \end_inset
13025
13026
13027 \begin_inset LatexCommand \index{\\_\\_at}
13028
13029 \end_inset
13030
13031  0x7ffe unsigned int chksum;
13032 \end_layout
13033
13034 \begin_layout Standard
13035 or, better conforming to ISO/IEC 9899 C:
13036 \end_layout
13037
13038 \begin_layout Verse
13039
13040 \family typewriter
13041 __xdata __at (0x7ffe) unsigned int chksum;
13042 \end_layout
13043
13044 \begin_layout Standard
13045 In the above example the variable chksum will be located at 0x7ffe and 0x7fff
13046  of the external ram.
13047  The compiler does 
13048 \emph on
13049 not
13050 \emph default
13051  reserve any space for variables declared in this way
13052 \begin_inset Marginal
13053 status collapsed
13054
13055 \begin_layout Standard
13056
13057 \series bold
13058 \InsetSpace ~
13059 !
13060 \end_layout
13061
13062 \end_inset
13063
13064  (they are implemented with an equate in the assembler).
13065  Thus it is left to the programmer to make sure there are no overlaps with
13066  other variables that are declared without the absolute address.
13067  The assembler listing file (.lst
13068 \begin_inset LatexCommand \index{<file>.lst}
13069
13070 \end_inset
13071
13072 ) and the linker output files (.rst
13073 \begin_inset LatexCommand \index{<file>.rst}
13074
13075 \end_inset
13076
13077 ) and (.map
13078 \begin_inset LatexCommand \index{<file>.map}
13079
13080 \end_inset
13081
13082 ) are good places to look for such overlaps.
13083 \end_layout
13084
13085 \begin_layout Standard
13086 If however you provide an initializer
13087 \begin_inset LatexCommand \index{Variable initialization}
13088
13089 \end_inset
13090
13091  actual memory allocation will take place and overlaps will be detected
13092  by the linker.
13093  E.g.:
13094 \end_layout
13095
13096 \begin_layout Verse
13097
13098 \family typewriter
13099 __code __at (0x7ff0) char Id[5] = 
13100 \begin_inset Quotes sld
13101 \end_inset
13102
13103 SDCC
13104 \begin_inset Quotes srd
13105 \end_inset
13106
13107 ;
13108 \end_layout
13109
13110 \begin_layout Standard
13111 In the above example the variable Id will be located from 0x7ff0 to 0x7ff4
13112  in code memory.
13113 \end_layout
13114
13115 \begin_layout Standard
13116 In case of memory mapped I/O devices the keyword 
13117 \emph on
13118 volatile
13119 \emph default
13120  has to be used to tell the compiler that accesses might not be removed:
13121 \end_layout
13122
13123 \begin_layout Verse
13124
13125 \family typewriter
13126 volatile
13127 \begin_inset LatexCommand \index{volatile}
13128
13129 \end_inset
13130
13131  __xdata
13132 \begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
13133
13134 \end_inset
13135
13136  __at
13137 \begin_inset LatexCommand \index{at}
13138
13139 \end_inset
13140
13141  (0x8000) unsigned char PORTA_8255;
13142 \end_layout
13143
13144 \begin_layout Standard
13145 For some architectures (mcs51) array accesses are more efficient if an (xdata/fa
13146 r) array
13147 \family typewriter
13148 \size footnotesize
13149
13150 \begin_inset LatexCommand \index{Aligned array}
13151
13152 \end_inset
13153
13154
13155 \family default
13156 \size default
13157  starts at a block (256 byte) boundary
13158 \begin_inset LatexCommand \index{block boundary}
13159
13160 \end_inset
13161
13162  (section 
13163 \begin_inset LatexCommand \ref{sub:A-Step-by Assembler Introduction}
13164
13165 \end_inset
13166
13167  has an example).
13168 \newline
13169 Absolute addresses can be specified for variables in all
13170  storage classes, e.g.:
13171 \end_layout
13172
13173 \begin_layout Verse
13174
13175 \family typewriter
13176 __bit
13177 \begin_inset LatexCommand \index{bit}
13178
13179 \end_inset
13180
13181  __at
13182 \begin_inset LatexCommand \index{at}
13183
13184 \end_inset
13185
13186  (0x02) bvar;
13187 \end_layout
13188
13189 \begin_layout Standard
13190 The above example will allocate the variable at offset 0x02 in the bit-addressab
13191 le space.
13192  There is no real advantage to assigning absolute addresses to variables
13193  in this manner, unless you want strict control over all the variables allocated.
13194  One possible use would be to write hardware portable code.
13195  For example, if you have a routine that uses one or more of the microcontroller
13196  I/O pins, and such pins are different for two different hardwares, you
13197  can declare the I/O pins in your routine using:
13198 \end_layout
13199
13200 \begin_layout Verse
13201
13202 \family typewriter
13203 extern volatile
13204 \begin_inset LatexCommand \index{volatile}
13205
13206 \end_inset
13207
13208  __bit MOSI;\InsetSpace ~
13209 \InsetSpace ~
13210 \InsetSpace ~
13211 \InsetSpace ~
13212 /* master out, slave in */
13213 \newline
13214 extern volatile __bit MISO;\InsetSpace ~
13215 \InsetSpace ~
13216 \InsetSpace ~
13217 \InsetSpace ~
13218 /* master
13219  in, slave out */
13220 \newline
13221 extern volatile __bit MCLK;\InsetSpace ~
13222 \InsetSpace ~
13223 \InsetSpace ~
13224 \InsetSpace ~
13225 /* master clock */
13226 \newline
13227
13228 \newline
13229 /* Input and
13230  Output of a byte on a 3-wire serial bus.
13231 \newline
13232 \InsetSpace ~
13233 \InsetSpace ~
13234 \InsetSpace ~
13235 If needed adapt polarity of clock,
13236  polarity of data and bit order
13237 \newline
13238 \InsetSpace ~
13239 */
13240 \newline
13241 unsigned char spi_io(unsigned char out_byte)
13242  
13243 \newline
13244
13245 \newline
13246 \InsetSpace ~
13247 \InsetSpace ~
13248 \InsetSpace ~
13249 \InsetSpace ~
13250 unsigned char i=8;
13251 \newline
13252 \InsetSpace ~
13253 \InsetSpace ~
13254 \InsetSpace ~
13255 \InsetSpace ~
13256 do { 
13257 \newline
13258 \InsetSpace ~
13259 \InsetSpace ~
13260 \InsetSpace ~
13261 \InsetSpace ~
13262 \InsetSpace ~
13263 \InsetSpace ~
13264 \InsetSpace ~
13265 \InsetSpace ~
13266 MOSI = out_byte & 0x80; 
13267 \newline
13268 \InsetSpace ~
13269 \InsetSpace ~
13270 \InsetSpace ~
13271 \InsetSpace ~
13272 \InsetSpace ~
13273 \InsetSpace ~
13274 \InsetSpace ~
13275 \InsetSpace ~
13276 out_byte <<= 1;
13277 \newline
13278 \InsetSpace ~
13279 \InsetSpace ~
13280 \InsetSpace ~
13281 \InsetSpace ~
13282 \InsetSpace ~
13283 \InsetSpace ~
13284 \InsetSpace ~
13285 \InsetSpace ~
13286 MCLK =
13287  1; 
13288 \newline
13289 \InsetSpace ~
13290 \InsetSpace ~
13291 \InsetSpace ~
13292 \InsetSpace ~
13293 \InsetSpace ~
13294 \InsetSpace ~
13295 \InsetSpace ~
13296 \InsetSpace ~
13297 /* _asm nop _endasm; */\InsetSpace ~
13298 \InsetSpace ~
13299 \InsetSpace ~
13300 \InsetSpace ~
13301 \InsetSpace ~
13302 \InsetSpace ~
13303 \InsetSpace ~
13304 \InsetSpace ~
13305 /* for slow peripherals */
13306 \newline
13307 \InsetSpace ~
13308 \InsetSpace ~
13309 \InsetSpace ~
13310 \InsetSpace ~
13311 \InsetSpace ~
13312 \InsetSpace ~
13313 \InsetSpace ~
13314 \InsetSpace ~
13315 if(MISO) 
13316 \newline
13317 \InsetSpace ~
13318 \InsetSpace ~
13319 \InsetSpace ~
13320 \InsetSpace ~
13321 \InsetSpace ~
13322 \InsetSpace ~
13323 \InsetSpace ~
13324 \InsetSpace ~
13325 \InsetSpace ~
13326 \InsetSpace ~
13327 \InsetSpace ~
13328 \InsetSpace ~
13329 out_byte +=
13330  1; 
13331 \newline
13332 \InsetSpace ~
13333 \InsetSpace ~
13334 \InsetSpace ~
13335 \InsetSpace ~
13336 \InsetSpace ~
13337 \InsetSpace ~
13338 \InsetSpace ~
13339 \InsetSpace ~
13340 MCLK = 0; 
13341 \newline
13342 \InsetSpace ~
13343 \InsetSpace ~
13344 \InsetSpace ~
13345 \InsetSpace ~
13346 } while(--i);
13347 \newline
13348 \InsetSpace ~
13349 \InsetSpace ~
13350 \InsetSpace ~
13351 \InsetSpace ~
13352 return out_byte; 
13353 \newline
13354 }
13355 \end_layout
13356
13357 \begin_layout Standard
13358 Then, someplace in the code for the first hardware you would use
13359 \end_layout
13360
13361 \begin_layout Verse
13362
13363 \family typewriter
13364 __bit __at
13365 \begin_inset LatexCommand \index{at}
13366
13367 \end_inset
13368
13369
13370 \begin_inset LatexCommand \index{\\_\\_at}
13371
13372 \end_inset
13373
13374  (0x80) MOSI;\InsetSpace ~
13375 \InsetSpace ~
13376 \InsetSpace ~
13377 \InsetSpace ~
13378 /* I/O port 0, bit 0 */
13379 \newline
13380 __bit __at (0x81) MISO;\InsetSpace ~
13381 \InsetSpace ~
13382 \InsetSpace ~
13383 \InsetSpace ~
13384 /* I/O port 0,
13385  bit 1 */
13386 \newline
13387 __bit __at (0x82) MCLK;\InsetSpace ~
13388 \InsetSpace ~
13389 \InsetSpace ~
13390 \InsetSpace ~
13391 /* I/O port 0, bit 2 */
13392 \end_layout
13393
13394 \begin_layout Standard
13395 Similarly, for the second hardware you would use
13396 \end_layout
13397
13398 \begin_layout Verse
13399
13400 \family typewriter
13401 __bit __at (0x83) MOSI;\InsetSpace ~
13402 \InsetSpace ~
13403 \InsetSpace ~
13404 \InsetSpace ~
13405 /* I/O port 0, bit 3 */
13406 \newline
13407 __bit __at (0x91) MISO;\InsetSpace ~
13408 \InsetSpace ~
13409 \InsetSpace ~
13410 \InsetSpace ~
13411 /*
13412  I/O port 1, bit 1 */
13413 \newline
13414 __bit
13415 \begin_inset LatexCommand \index{bit}
13416
13417 \end_inset
13418
13419  __at (0x92) MCLK;\InsetSpace ~
13420 \InsetSpace ~
13421 \InsetSpace ~
13422 \InsetSpace ~
13423 /* I/O port 1, bit 2 */
13424 \end_layout
13425
13426 \begin_layout Standard
13427 and you can use the same hardware dependent routine without changes, as
13428  for example in a library.
13429  This is somehow similar to sbit, but only one absolute address has to be
13430  specified in the whole project.
13431 \begin_inset VSpace bigskip
13432 \end_inset
13433
13434
13435 \end_layout
13436
13437 \begin_layout Section
13438 Parameters
13439 \begin_inset LatexCommand \index{Parameters}
13440
13441 \end_inset
13442
13443
13444 \begin_inset LatexCommand \index{function parameter}
13445
13446 \end_inset
13447
13448  & Local Variables
13449 \begin_inset LatexCommand \index{local variables}
13450
13451 \end_inset
13452
13453
13454 \begin_inset LatexCommand \label{sec:Parameters-and-Local-Variables}
13455
13456 \end_inset
13457
13458
13459 \end_layout
13460
13461 \begin_layout Standard
13462 Automatic (local) variables and parameters to functions can either be placed
13463  on the stack or in data-space.
13464  The default action of the compiler is to place these variables in the internal
13465  RAM (for small model) or external RAM (for medium or large model).
13466  This in fact makes them similar to 
13467 \emph on
13468 static
13469 \begin_inset LatexCommand \index{static}
13470
13471 \end_inset
13472
13473
13474 \emph default
13475  so by default functions are non-reentrant
13476 \begin_inset LatexCommand \index{reentrant}
13477
13478 \end_inset
13479
13480 .
13481  
13482 \newline
13483
13484 \newline
13485 They can be placed on the stack
13486 \begin_inset LatexCommand \index{stack}
13487
13488 \end_inset
13489
13490  by using the 
13491 \emph on
13492 -
13493 \begin_inset ERT
13494 status collapsed
13495
13496 \begin_layout Standard
13497
13498
13499 \backslash
13500 /
13501 \end_layout
13502
13503 \end_inset
13504
13505 -stack-auto
13506 \begin_inset LatexCommand \index{-\\/-stack-auto}
13507
13508 \end_inset
13509
13510
13511 \emph default
13512  option, by using 
13513 \emph on
13514 #pragma\InsetSpace ~
13515 stackauto
13516 \emph default
13517
13518 \begin_inset LatexCommand \index{\\#pragma stackauto}
13519
13520 \end_inset
13521
13522  or by using the 
13523 \emph on
13524 reentrant
13525 \begin_inset LatexCommand \index{reentrant}
13526
13527 \end_inset
13528
13529
13530 \emph default
13531  keyword in the function declaration, e.g.:
13532 \end_layout
13533
13534 \begin_layout Verse
13535
13536 \family typewriter
13537 unsigned char foo(char i) __reentrant 
13538 \newline
13539
13540 \newline
13541 \InsetSpace ~
13542 \InsetSpace ~
13543 \InsetSpace ~
13544 \InsetSpace ~
13545 ...
13546  
13547 \newline
13548 }
13549 \end_layout
13550
13551 \begin_layout Standard
13552 Since stack space on 8051 is limited, the 
13553 \emph on
13554 reentrant
13555 \emph default
13556  keyword or the 
13557 \emph on
13558 -
13559 \begin_inset ERT
13560 status collapsed
13561
13562 \begin_layout Standard
13563
13564
13565 \backslash
13566 /
13567 \end_layout
13568
13569 \end_inset
13570
13571 -stack-auto
13572 \emph default
13573  option should be used sparingly.
13574  Note that the reentrant keyword just means that the parameters & local
13575  variables will be allocated to the stack, it 
13576 \emph on
13577 does not
13578 \emph default
13579  mean that the function is register bank
13580 \begin_inset LatexCommand \index{register bank (mcs51, ds390)}
13581
13582 \end_inset
13583
13584  independent.
13585 \newline
13586
13587 \newline
13588 Local variables
13589 \begin_inset LatexCommand \index{local variables}
13590
13591 \end_inset
13592
13593  can be assigned storage classes and absolute
13594 \begin_inset LatexCommand \index{Absolute addressing}
13595
13596 \end_inset
13597
13598  addresses, e.g.: 
13599 \end_layout
13600
13601 \begin_layout Verse
13602
13603 \family typewriter
13604 unsigned char foo() 
13605 \newline
13606 {
13607 \newline
13608 \InsetSpace ~
13609 \InsetSpace ~
13610 \InsetSpace ~
13611 \InsetSpace ~
13612 __xdata unsigned char i;
13613 \newline
13614 \InsetSpace ~
13615 \InsetSpace ~
13616 \InsetSpace ~
13617 \InsetSpace ~
13618 __bit bvar;
13619 \newline
13620 \InsetSpace ~
13621 \InsetSpace ~
13622 \InsetSpace ~
13623 \InsetSpace ~
13624 __data __at
13625 \begin_inset LatexCommand \index{at}
13626
13627 \end_inset
13628
13629  (0x31) unsigned char j;
13630 \newline
13631 \InsetSpace ~
13632 \InsetSpace ~
13633 \InsetSpace ~
13634 \InsetSpace ~
13635 ...
13636  
13637 \newline
13638 }
13639 \end_layout
13640
13641 \begin_layout Standard
13642 In the above example the variable 
13643 \emph on
13644 i
13645 \emph default
13646  will be allocated in the external ram, 
13647 \emph on
13648 bvar
13649 \emph default
13650  in bit addressable space and 
13651 \emph on
13652 j
13653 \emph default
13654  in internal ram.
13655  When compiled with 
13656 \emph on
13657 -
13658 \begin_inset ERT
13659 status collapsed
13660
13661 \begin_layout Standard
13662
13663
13664 \backslash
13665 /
13666 \end_layout
13667
13668 \end_inset
13669
13670 -stack-auto
13671 \emph default
13672  or when a function is declared as 
13673 \emph on
13674 reentrant
13675 \emph default
13676  this should only be done for static variables.
13677 \end_layout
13678
13679 \begin_layout Standard
13680 Parameters
13681 \begin_inset LatexCommand \index{function parameter}
13682
13683 \end_inset
13684
13685  however are not allowed any storage class
13686 \begin_inset LatexCommand \index{Storage class}
13687
13688 \end_inset
13689
13690 , (storage classes for parameters will be ignored), their allocation is
13691  governed by the memory model in use, and the reentrancy options.
13692 \end_layout
13693
13694 \begin_layout Standard
13695 It is however allowed to use bit parameters in reentrant functions and also
13696  non-static local bit variables are supported.
13697  Efficient use is limited to 8 semi-bitregisters in bit space.
13698  They are pushed and popped to stack
13699 \begin_inset LatexCommand \index{stack}
13700
13701 \end_inset
13702
13703  as a single byte just like the normal registers.
13704 \end_layout
13705
13706 \begin_layout Section
13707 Overlaying
13708 \begin_inset LatexCommand \label{sub:Overlaying}
13709
13710 \end_inset
13711
13712
13713 \begin_inset LatexCommand \index{Overlaying}
13714
13715 \end_inset
13716
13717
13718 \end_layout
13719
13720 \begin_layout Standard
13721 For non-reentrant
13722 \begin_inset LatexCommand \index{reentrant}
13723
13724 \end_inset
13725
13726  functions SDCC will try to reduce internal ram space usage by overlaying
13727  parameters and local variables of a function (if possible).
13728  Parameters and local variables
13729 \begin_inset LatexCommand \index{local variables}
13730
13731 \end_inset
13732
13733  of a function will be allocated to an overlayable segment if the function
13734  has 
13735 \emph on
13736 no other function calls and the function is non-reentrant and the memory
13737  model
13738 \begin_inset LatexCommand \index{Memory model}
13739
13740 \end_inset
13741
13742  is small.
13743
13744 \emph default
13745  If an explicit storage class
13746 \begin_inset LatexCommand \index{Storage class}
13747
13748 \end_inset
13749
13750  is specified for a local variable, it will NOT be overlayed.
13751 \end_layout
13752
13753 \begin_layout Standard
13754 Note that the compiler (not the linkage editor) makes the decision for overlayin
13755 g the data items.
13756  Functions that are called from an interrupt service routine
13757 \begin_inset Marginal
13758 status collapsed
13759
13760 \begin_layout Standard
13761
13762 \series bold
13763 !
13764 \end_layout
13765
13766 \end_inset
13767
13768  should be preceded by a #pragma\InsetSpace ~
13769 nooverlay
13770 \begin_inset LatexCommand \index{\\#pragma nooverlay}
13771
13772 \end_inset
13773
13774  if they are not reentrant.
13775 \end_layout
13776
13777 \begin_layout Standard
13778 Also note that the compiler does not do any processing of inline assembler
13779  code, so the compiler might incorrectly assign local variables and parameters
13780  of a function into the overlay segment if the inline assembler code calls
13781  other c-functions that might use the overlay.
13782  In that case the #pragma\InsetSpace ~
13783 nooverlay should be used.
13784 \end_layout
13785
13786 \begin_layout Standard
13787 Parameters and local variables of functions that contain 16 or 32 bit multiplica
13788 tion
13789 \begin_inset LatexCommand \index{Multiplication}
13790
13791 \end_inset
13792
13793  or division
13794 \begin_inset LatexCommand \index{Division}
13795
13796 \end_inset
13797
13798  will NOT be overlayed since these are implemented using external functions,
13799  e.g.:
13800 \end_layout
13801
13802 \begin_layout Verse
13803
13804 \family typewriter
13805 #pragma save 
13806 \newline
13807 #pragma nooverlay
13808 \begin_inset LatexCommand \index{\\#pragma nooverlay}
13809
13810 \end_inset
13811
13812  
13813 \newline
13814 void set_error(unsigned char errcd) 
13815 \newline
13816 {
13817 \newline
13818 \InsetSpace ~
13819 \InsetSpace ~
13820 \InsetSpace ~
13821 \InsetSpace ~
13822 P3 = errcd;
13823 \newline
13824
13825 \newline
13826 #pragma restore 
13827 \newline
13828
13829 \newline
13830 void
13831  some_isr () __interrupt
13832 \begin_inset LatexCommand \index{interrupt}
13833
13834 \end_inset
13835
13836  (2)
13837 \newline
13838 {
13839 \newline
13840 \InsetSpace ~
13841 \InsetSpace ~
13842 \InsetSpace ~
13843 \InsetSpace ~
13844 ...
13845 \newline
13846 \InsetSpace ~
13847 \InsetSpace ~
13848 \InsetSpace ~
13849 \InsetSpace ~
13850 set_error(10);
13851 \newline
13852 \InsetSpace ~
13853 \InsetSpace ~
13854 \InsetSpace ~
13855 \InsetSpace ~
13856 ...
13857  
13858 \newline
13859 }
13860 \end_layout
13861
13862 \begin_layout Standard
13863 In the above example the parameter 
13864 \emph on
13865 errcd
13866 \emph default
13867  for the function 
13868 \emph on
13869 set_error
13870 \emph default
13871  would be assigned to the overlayable segment if the #pragma\InsetSpace ~
13872 nooverlay was
13873  not present, this could cause unpredictable runtime behavior when called
13874  from an interrupt service routine.
13875  The #pragma\InsetSpace ~
13876 nooverlay ensures that the parameters and local variables for
13877  the function are NOT overlayed.
13878 \begin_inset VSpace bigskip
13879 \end_inset
13880
13881
13882 \end_layout
13883
13884 \begin_layout Section
13885 Interrupt Service Routines
13886 \begin_inset LatexCommand \label{sub:Interrupt-Service-Routines}
13887
13888 \end_inset
13889
13890
13891 \end_layout
13892
13893 \begin_layout Subsection
13894 General Information
13895 \end_layout
13896
13897 \begin_layout Standard
13898 SDCC allows 
13899 \emph on
13900 i
13901 \emph default
13902 nterrupt 
13903 \emph on
13904 s
13905 \emph default
13906 ervice 
13907 \emph on
13908 r
13909 \emph default
13910 outines to be coded in C, with some extended keywords.
13911 \end_layout
13912
13913 \begin_layout Verse
13914
13915 \family typewriter
13916 void timer_isr (void) __interrupt (1) __using (1) 
13917 \newline
13918
13919 \newline
13920 \InsetSpace ~
13921 \InsetSpace ~
13922 \InsetSpace ~
13923 \InsetSpace ~
13924 ...
13925  
13926 \newline
13927 }
13928 \end_layout
13929
13930 \begin_layout Standard
13931 The optional number following the 
13932 \emph on
13933 interrupt
13934 \begin_inset LatexCommand \index{interrupt}
13935
13936 \end_inset
13937
13938
13939 \begin_inset LatexCommand \index{\\_\\_interrupt}
13940
13941 \end_inset
13942
13943
13944 \emph default
13945  keyword is the interrupt number this routine will service.
13946  When present, the compiler will insert a call to this routine in the interrupt
13947  vector table
13948 \begin_inset LatexCommand \index{interrupt vector table}
13949
13950 \end_inset
13951
13952  for the interrupt number specified.
13953  If you have multiple source files in your project, interrupt service routines
13954  can be present in any of them, but a prototype of the isr MUST be present
13955  or included in the file that contains the function 
13956 \emph on
13957 main
13958 \emph default
13959 .
13960  The optional (8051 specific) keyword 
13961 \emph on
13962 using
13963 \begin_inset LatexCommand \index{using (mcs51, ds390 register bank)}
13964
13965 \end_inset
13966
13967
13968 \begin_inset LatexCommand \index{\\_\\_using (mcs51, ds390 register bank)}
13969
13970 \end_inset
13971
13972
13973 \emph default
13974  can be used to tell the compiler to use the specified register bank when
13975  generating code for this function.
13976  
13977 \newline
13978 Interrupt service routines open the door for some very interesting bugs:
13979 \end_layout
13980
13981 \begin_layout Subsubsection
13982 \begin_inset LatexCommand \label{sub:Common-interrupt-pitfall-volatile}
13983
13984 \end_inset
13985
13986 Common interrupt pitfall: variable not declared 
13987 \emph on
13988 volatile
13989 \end_layout
13990
13991 \begin_layout Standard
13992 If an interrupt service routine changes variables which are accessed by
13993  other functions these variables have to be declared 
13994 \emph on
13995 volatile
13996 \emph default
13997
13998 \begin_inset LatexCommand \index{volatile}
13999
14000 \end_inset
14001
14002 .
14003  See 
14004 \begin_inset LatexCommand \url{http://en.wikipedia.org/wiki/Volatile_variable}
14005
14006 \end_inset
14007
14008  .
14009 \end_layout
14010
14011 \begin_layout Subsubsection
14012 \begin_inset LatexCommand \label{sub:Common-interrupt-pitfall-non-atomic}
14013
14014 \end_inset
14015
14016 Common interrupt pitfall: 
14017 \emph on
14018 non-atomic access
14019 \end_layout
14020
14021 \begin_layout Standard
14022 If the access to these variables is not 
14023 \emph on
14024 atomic
14025 \begin_inset LatexCommand \index{atomic}
14026
14027 \end_inset
14028
14029
14030 \emph default
14031  (i.e.
14032  the processor needs more than one instruction for the access and could
14033  be interrupted while accessing the variable) the interrupt must be disabled
14034  during the access to avoid inconsistent data.
14035  
14036 \newline
14037 Access to 16 or 32 bit variables is obviously not atomic on 8 bit CPUs
14038  and should be protected by disabling interrupts.
14039  You're not automatically on the safe side if you use 8 bit variables though.
14040  We need an example here: f.e.
14041  on the 8051 the harmless looking 
14042 \begin_inset Quotes srd
14043 \end_inset
14044
14045
14046 \family typewriter
14047 flags\InsetSpace ~
14048 |=\InsetSpace ~
14049 0x80;
14050 \family default
14051
14052 \begin_inset Quotes sld
14053 \end_inset
14054
14055  is not atomic if 
14056 \family typewriter
14057 flags
14058 \family default
14059  resides in xdata.
14060  Setting 
14061 \begin_inset Quotes srd
14062 \end_inset
14063
14064
14065 \family typewriter
14066 flags\InsetSpace ~
14067 |=\InsetSpace ~
14068 0x40;
14069 \family default
14070
14071 \begin_inset Quotes sld
14072 \end_inset
14073
14074  from within an interrupt routine might get lost if the interrupt occurs
14075  at the wrong time.
14076  
14077 \begin_inset Quotes sld
14078 \end_inset
14079
14080
14081 \family typewriter
14082 counter\InsetSpace ~
14083 +=\InsetSpace ~
14084 8;
14085 \family default
14086
14087 \begin_inset Quotes srd
14088 \end_inset
14089
14090  is not atomic on the 8051 even if 
14091 \family typewriter
14092 counter
14093 \family default
14094  is located in data memory.
14095 \newline
14096 Bugs like these are hard to reproduce and can
14097  cause a lot of trouble.
14098  
14099 \end_layout
14100
14101 \begin_layout Subsubsection
14102 \begin_inset LatexCommand \label{sub:Common-interrupt-pitfall-stack-overflow}
14103
14104 \end_inset
14105
14106 Common interrupt pitfall: 
14107 \emph on
14108 stack overflow
14109 \end_layout
14110
14111 \begin_layout Standard
14112 The return address and the registers used in the interrupt service routine
14113  are saved on the stack
14114 \begin_inset LatexCommand \index{stack}
14115
14116 \end_inset
14117
14118  so there must be sufficient stack space.
14119  If there isn't variables or registers (or even the return address itself)
14120  will be corrupted.
14121  This 
14122 \emph on
14123 stack overflow
14124 \emph default
14125
14126 \begin_inset LatexCommand \index{stack overflow}
14127
14128 \end_inset
14129
14130  is most likely to happen if the interrupt occurs during the 
14131 \begin_inset Quotes sld
14132 \end_inset
14133
14134 deepest
14135 \begin_inset Quotes srd
14136 \end_inset
14137
14138  subroutine when the stack is already in use for f.e.
14139  many return addresses.
14140 \end_layout
14141
14142 \begin_layout Subsubsection
14143 \begin_inset LatexCommand \label{sub:Common-interrupt-pitfall-non-reentrant}
14144
14145 \end_inset
14146
14147 Common interrupt pitfall: 
14148 \emph on
14149 use of non-reentrant functions
14150 \end_layout
14151
14152 \begin_layout Standard
14153 A special note here, int (16 bit) and long (32 bit) integer division
14154 \begin_inset LatexCommand \index{Division}
14155
14156 \end_inset
14157
14158 , multiplication
14159 \begin_inset LatexCommand \index{Multiplication}
14160
14161 \end_inset
14162
14163  & modulus
14164 \begin_inset LatexCommand \index{Modulus}
14165
14166 \end_inset
14167
14168  and floating-point
14169 \begin_inset LatexCommand \index{Floating point support}
14170
14171 \end_inset
14172
14173  operations are implemented using external support routines.
14174  If an interrupt service routine needs to do any of these operations then
14175  the support routines (as mentioned in a following section) will have to
14176  be recompiled using the 
14177 \emph on
14178 -
14179 \begin_inset ERT
14180 status collapsed
14181
14182 \begin_layout Standard
14183
14184
14185 \backslash
14186 /
14187 \end_layout
14188
14189 \end_inset
14190
14191 -stack-auto
14192 \begin_inset LatexCommand \index{-\\/-stack-auto}
14193
14194 \end_inset
14195
14196
14197 \emph default
14198  option and the source file will need to be compiled using the 
14199 \emph on
14200 -
14201 \begin_inset ERT
14202 status collapsed
14203
14204 \begin_layout Standard
14205
14206
14207 \backslash
14208 /
14209 \end_layout
14210
14211 \end_inset
14212
14213 -int-long-reent
14214 \emph default
14215
14216 \begin_inset LatexCommand \index{-\\/-int-long-reent}
14217
14218 \end_inset
14219
14220  compiler option.
14221  
14222 \newline
14223 Note, the type promotion
14224 \begin_inset LatexCommand \index{type promotion}
14225
14226 \end_inset
14227
14228  required by ANSI C can cause 16 bit routines to be used
14229 \begin_inset Marginal
14230 status collapsed
14231
14232 \begin_layout Standard
14233
14234 \series bold
14235 \InsetSpace ~
14236 !
14237 \end_layout
14238
14239 \end_inset
14240
14241  without the programmer being aware of it.
14242  See f.e.
14243  the cast 
14244 \family typewriter
14245 \series bold
14246 (unsigned char)(tail-1)
14247 \family default
14248 \series default
14249  
14250 \series bold
14251 within the if clause in section 
14252 \begin_inset LatexCommand \ref{sub:A-Step-by Assembler Introduction}
14253
14254 \end_inset
14255
14256 .
14257 \end_layout
14258
14259 \begin_layout Standard
14260 Calling other functions from an interrupt service routine is not recommended,
14261  avoid it if possible.
14262  Note that when some function is called from an interrupt service routine
14263  it should be preceded by a #pragma\InsetSpace ~
14264 nooverlay
14265 \begin_inset LatexCommand \index{\\#pragma nooverlay}
14266
14267 \end_inset
14268
14269  if it is not reentrant.
14270  Furthermore nonreentrant functions should not be called from the main program
14271  while the interrupt service routine might be active.
14272  They also must not be called from low priority interrupt service routines
14273  while a high priority interrupt service routine might be active.
14274  You could use semaphores or make the function 
14275 \emph on
14276 critical
14277 \emph default
14278  if all parameters are passed in registers.
14279 \newline
14280  Also see section 
14281 \begin_inset LatexCommand \ref{sub:Overlaying}
14282
14283 \end_inset
14284
14285 \InsetSpace ~
14286 about Overlaying and section 
14287 \begin_inset LatexCommand \ref{sub:Functions-using-private-banks}
14288
14289 \end_inset
14290
14291 \InsetSpace ~
14292 about Functions using private register banks.
14293 \begin_inset VSpace bigskip
14294 \end_inset
14295
14296
14297 \end_layout
14298
14299 \begin_layout Subsection
14300 MCS51/DS390 Interrupt Service Routines
14301 \end_layout
14302
14303 \begin_layout Standard
14304 Interrupt
14305 \begin_inset LatexCommand \index{interrupt}
14306
14307 \end_inset
14308
14309  numbers and the corresponding address & descriptions for the Standard 8051/8052
14310  are listed below.
14311  SDCC will automatically adjust the 
14312 \begin_inset LatexCommand \index{interrupt vector table}
14313
14314 \end_inset
14315
14316  to the maximum interrupt number specified.
14317 \newline
14318
14319 \end_layout
14320
14321 \begin_layout Standard
14322 \align center
14323 \begin_inset Tabular
14324 <lyxtabular version="3" rows="9" columns="3">
14325 <features>
14326 <column alignment="center" valignment="top" leftline="true" width="0in">
14327 <column alignment="left" valignment="top" leftline="true" width="0in">
14328 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0in">
14329 <row topline="true" bottomline="true">
14330 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14331 \begin_inset Text
14332
14333 \begin_layout Standard
14334 Interrupt #
14335 \end_layout
14336
14337 \end_inset
14338 </cell>
14339 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14340 \begin_inset Text
14341
14342 \begin_layout Standard
14343 Description
14344 \end_layout
14345
14346 \end_inset
14347 </cell>
14348 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14349 \begin_inset Text
14350
14351 \begin_layout Standard
14352 Vector Address
14353 \end_layout
14354
14355 \end_inset
14356 </cell>
14357 </row>
14358 <row topline="true">
14359 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14360 \begin_inset Text
14361
14362 \begin_layout Standard
14363 0
14364 \end_layout
14365
14366 \end_inset
14367 </cell>
14368 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14369 \begin_inset Text
14370
14371 \begin_layout Standard
14372 External 0
14373 \end_layout
14374
14375 \end_inset
14376 </cell>
14377 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14378 \begin_inset Text
14379
14380 \begin_layout Standard
14381 0x0003
14382 \end_layout
14383
14384 \end_inset
14385 </cell>
14386 </row>
14387 <row topline="true">
14388 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14389 \begin_inset Text
14390
14391 \begin_layout Standard
14392 1
14393 \end_layout
14394
14395 \end_inset
14396 </cell>
14397 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14398 \begin_inset Text
14399
14400 \begin_layout Standard
14401 Timer 0
14402 \end_layout
14403
14404 \end_inset
14405 </cell>
14406 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14407 \begin_inset Text
14408
14409 \begin_layout Standard
14410 0x000b
14411 \end_layout
14412
14413 \end_inset
14414 </cell>
14415 </row>
14416 <row topline="true">
14417 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14418 \begin_inset Text
14419
14420 \begin_layout Standard
14421 2
14422 \end_layout
14423
14424 \end_inset
14425 </cell>
14426 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14427 \begin_inset Text
14428
14429 \begin_layout Standard
14430 External 1
14431 \end_layout
14432
14433 \end_inset
14434 </cell>
14435 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14436 \begin_inset Text
14437
14438 \begin_layout Standard
14439 0x0013
14440 \end_layout
14441
14442 \end_inset
14443 </cell>
14444 </row>
14445 <row topline="true">
14446 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14447 \begin_inset Text
14448
14449 \begin_layout Standard
14450 3
14451 \end_layout
14452
14453 \end_inset
14454 </cell>
14455 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14456 \begin_inset Text
14457
14458 \begin_layout Standard
14459 Timer 1
14460 \end_layout
14461
14462 \end_inset
14463 </cell>
14464 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14465 \begin_inset Text
14466
14467 \begin_layout Standard
14468 0x001b
14469 \end_layout
14470
14471 \end_inset
14472 </cell>
14473 </row>
14474 <row topline="true">
14475 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14476 \begin_inset Text
14477
14478 \begin_layout Standard
14479 4
14480 \end_layout
14481
14482 \end_inset
14483 </cell>
14484 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14485 \begin_inset Text
14486
14487 \begin_layout Standard
14488 Serial
14489 \end_layout
14490
14491 \end_inset
14492 </cell>
14493 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14494 \begin_inset Text
14495
14496 \begin_layout Standard
14497 0x0023
14498 \end_layout
14499
14500 \end_inset
14501 </cell>
14502 </row>
14503 <row topline="true">
14504 <cell multicolumn="1" alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14505 \begin_inset Text
14506
14507 \begin_layout Standard
14508 5
14509 \end_layout
14510
14511 \end_inset
14512 </cell>
14513 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14514 \begin_inset Text
14515
14516 \begin_layout Standard
14517 Timer 2 (8052)
14518 \end_layout
14519
14520 \end_inset
14521 </cell>
14522 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14523 \begin_inset Text
14524
14525 \begin_layout Standard
14526 0x002b
14527 \end_layout
14528
14529 \end_inset
14530 </cell>
14531 </row>
14532 <row topline="true">
14533 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14534 \begin_inset Text
14535
14536 \begin_layout Standard
14537 ...
14538 \end_layout
14539
14540 \end_inset
14541 </cell>
14542 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14543 \begin_inset Text
14544
14545 \begin_layout Standard
14546
14547 \end_layout
14548
14549 \end_inset
14550 </cell>
14551 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14552 \begin_inset Text
14553
14554 \begin_layout Standard
14555 ...
14556 \end_layout
14557
14558 \end_inset
14559 </cell>
14560 </row>
14561 <row topline="true" bottomline="true">
14562 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14563 \begin_inset Text
14564
14565 \begin_layout Standard
14566 n
14567 \end_layout
14568
14569 \end_inset
14570 </cell>
14571 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
14572 \begin_inset Text
14573
14574 \begin_layout Standard
14575
14576 \end_layout
14577
14578 \end_inset
14579 </cell>
14580 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
14581 \begin_inset Text
14582
14583 \begin_layout Standard
14584 0x0003 + 8*n
14585 \end_layout
14586
14587 \end_inset
14588 </cell>
14589 </row>
14590 </lyxtabular>
14591
14592 \end_inset
14593
14594
14595 \newline
14596
14597 \end_layout
14598
14599 \begin_layout Standard
14600 If the interrupt service routine is defined without 
14601 \emph on
14602 using
14603 \begin_inset LatexCommand \index{using (mcs51, ds390 register bank)}
14604
14605 \end_inset
14606
14607
14608 \begin_inset LatexCommand \index{\\_\\_using (mcs51, ds390 register bank)}
14609
14610 \end_inset
14611
14612
14613 \emph default
14614  a register bank or with register bank 0 (
14615 \emph on
14616 using
14617 \emph default
14618  0), the compiler will save the registers used by itself on the stack upon
14619  entry and restore them at exit, however if such an interrupt service routine
14620  calls another function then the entire register bank will be saved on the
14621  stack.
14622  This scheme may be advantageous for small interrupt service routines which
14623  have low register usage.
14624 \end_layout
14625
14626 \begin_layout Standard
14627 If the interrupt service routine is defined to be using a specific register
14628  bank then only 
14629 \emph on
14630 a, b, dptr
14631 \emph default
14632  & psw are saved and restored, if such an interrupt service routine calls
14633  another function (using another register bank) then the entire register
14634  bank of the called function will be saved on the stack
14635 \begin_inset LatexCommand \index{stack}
14636
14637 \end_inset
14638
14639 .
14640  This scheme is recommended for larger interrupt service routines.
14641 \begin_inset VSpace bigskip
14642 \end_inset
14643
14644
14645 \end_layout
14646
14647 \begin_layout Subsection
14648 HC08
14649 \begin_inset LatexCommand \index{HC08}
14650
14651 \end_inset
14652
14653  Interrupt Service Routines
14654 \end_layout
14655
14656 \begin_layout Standard
14657 Since the number of interrupts
14658 \begin_inset LatexCommand \index{HC08!interrupt}
14659
14660 \end_inset
14661
14662  available is chip specific and the interrupt vector table always ends at
14663  the last byte of memory, the interrupt numbers corresponds to the interrupt
14664  vectors in reverse order of address.
14665  For example, interrupt 1 will use the interrupt vector at 0xfffc, interrupt
14666  2 will use the interrupt vector at 0xfffa, and so on.
14667  However, interrupt 0 (the reset vector at 0xfffe) is not redefinable in
14668  this way; instead see section 
14669 \begin_inset LatexCommand \ref{sub:Startup-Code}
14670
14671 \end_inset
14672
14673  for details on customizing startup.
14674 \begin_inset VSpace bigskip
14675 \end_inset
14676
14677
14678 \end_layout
14679
14680 \begin_layout Subsection
14681 Z80 Interrupt Service Routines
14682 \end_layout
14683
14684 \begin_layout Standard
14685 The Z80
14686 \begin_inset LatexCommand \index{Z80}
14687
14688 \end_inset
14689
14690  uses several different methods for determining the correct interrupt
14691 \begin_inset LatexCommand \index{Z80!interrupt}
14692
14693 \end_inset
14694
14695  vector depending on the hardware implementation.
14696  Therefore, SDCC ignores the optional interrupt number and does not attempt
14697  to generate an interrupt vector table.
14698 \end_layout
14699
14700 \begin_layout Standard
14701 By default, SDCC generates code for a maskable interrupt, which uses a RETI
14702  instruction to return from the interrupt.
14703  To write an interrupt handler for the non-maskable interrupt, which needs
14704  a RETN instruction instead, add the 
14705 \emph on
14706 critical
14707 \emph default
14708  keyword:
14709 \end_layout
14710
14711 \begin_layout Verse
14712
14713 \family typewriter
14714 void nmi_isr (void) critical interrupt
14715 \newline
14716
14717 \newline
14718 \InsetSpace ~
14719 \InsetSpace ~
14720 \InsetSpace ~
14721 \InsetSpace ~
14722 ...
14723  
14724 \newline
14725 }
14726 \end_layout
14727
14728 \begin_layout Standard
14729 However if you need to create a non-interruptable interrupt service routine
14730  you would also require the 
14731 \emph on
14732 critical
14733 \emph default
14734  keyword.
14735  To distinguish between this and an nmi_isr you must provide an interrupt
14736  number.
14737 \begin_inset VSpace bigskip
14738 \end_inset
14739
14740
14741 \end_layout
14742
14743 \begin_layout Section
14744 Enabling and Disabling Interrupts
14745 \end_layout
14746
14747 \begin_layout Subsection
14748 Critical Functions and Critical Statements
14749 \end_layout
14750
14751 \begin_layout Standard
14752 A special keyword may be associated with a block or a function declaring
14753  it as 
14754 \emph on
14755 critical
14756 \emph default
14757 .
14758  SDCC will generate code to disable all interrupts
14759 \begin_inset LatexCommand \index{interrupt}
14760
14761 \end_inset
14762
14763  upon entry to a critical function and restore the interrupt enable to the
14764  previous state before returning.
14765  Nesting critical functions will need one additional byte on the stack
14766 \begin_inset LatexCommand \index{stack}
14767
14768 \end_inset
14769
14770  for each call.
14771 \end_layout
14772
14773 \begin_layout Verse
14774
14775 \family typewriter
14776 int foo () __critical
14777 \begin_inset LatexCommand \index{critical}
14778
14779 \end_inset
14780
14781
14782 \begin_inset LatexCommand \index{\\_\\_critical}
14783
14784 \end_inset
14785
14786  
14787 \newline
14788
14789 \newline
14790 \InsetSpace ~
14791 \InsetSpace ~
14792 \InsetSpace ~
14793 \InsetSpace ~
14794 ...
14795  
14796 \newline
14797 \InsetSpace ~
14798 \InsetSpace ~
14799 \InsetSpace ~
14800 \InsetSpace ~
14801 ...
14802  
14803 \newline
14804 }
14805 \end_layout
14806
14807 \begin_layout Standard
14808 The critical attribute maybe used with other attributes like 
14809 \emph on
14810 reentrant.
14811 \emph default
14812
14813 \newline
14814 The keyword 
14815 \emph on
14816 critical
14817 \emph default
14818  may also be used to disable interrupts more locally:
14819 \end_layout
14820
14821 \begin_layout Verse
14822
14823 \family typewriter
14824 __critical{ i++; }
14825 \end_layout
14826
14827 \begin_layout Standard
14828 More than one statement could have been included in the block.
14829 \end_layout
14830
14831 \begin_layout Subsection
14832 Enabling and Disabling Interrupts directly
14833 \end_layout
14834
14835 \begin_layout Standard
14836 Interrupts
14837 \begin_inset LatexCommand \index{interrupt}
14838
14839 \end_inset
14840
14841  can also be disabled and enabled directly (8051):
14842 \end_layout
14843
14844 \begin_layout Verse
14845
14846 \family typewriter
14847 EA = 0;\InsetSpace ~
14848 \InsetSpace ~
14849 \InsetSpace ~
14850 \InsetSpace ~
14851 \InsetSpace ~
14852 \InsetSpace ~
14853 \InsetSpace ~
14854 \InsetSpace ~
14855 \InsetSpace ~
14856 \InsetSpace ~
14857 \InsetSpace ~
14858 \InsetSpace ~
14859 or:\InsetSpace ~
14860 \InsetSpace ~
14861 \InsetSpace ~
14862 \InsetSpace ~
14863 \InsetSpace ~
14864 \InsetSpace ~
14865 \InsetSpace ~
14866 \InsetSpace ~
14867 \InsetSpace ~
14868 \InsetSpace ~
14869 \InsetSpace ~
14870 EA_SAVE = EA;
14871 \end_layout
14872
14873 \begin_layout Verse
14874
14875 \family typewriter
14876 ...\InsetSpace ~
14877 \InsetSpace ~
14878 \InsetSpace ~
14879 \InsetSpace ~
14880 \InsetSpace ~
14881 \InsetSpace ~
14882 \InsetSpace ~
14883 \InsetSpace ~
14884 \InsetSpace ~
14885 \InsetSpace ~
14886 \InsetSpace ~
14887 \InsetSpace ~
14888 \InsetSpace ~
14889 \InsetSpace ~
14890 \InsetSpace ~
14891 \InsetSpace ~
14892 \InsetSpace ~
14893 \InsetSpace ~
14894 \InsetSpace ~
14895 \InsetSpace ~
14896 \InsetSpace ~
14897 \InsetSpace ~
14898 \InsetSpace ~
14899 \InsetSpace ~
14900 \InsetSpace ~
14901 \InsetSpace ~
14902 \InsetSpace ~
14903 \InsetSpace ~
14904 \InsetSpace ~
14905 \InsetSpace ~
14906 EA = 0;
14907 \end_layout
14908
14909 \begin_layout Verse
14910
14911 \family typewriter
14912 EA = 1;\InsetSpace ~
14913 \InsetSpace ~
14914 \InsetSpace ~
14915 \InsetSpace ~
14916 \InsetSpace ~
14917 \InsetSpace ~
14918 \InsetSpace ~
14919 \InsetSpace ~
14920 \InsetSpace ~
14921 \InsetSpace ~
14922 \InsetSpace ~
14923 \InsetSpace ~
14924 \InsetSpace ~
14925 \InsetSpace ~
14926 \InsetSpace ~
14927 \InsetSpace ~
14928 \InsetSpace ~
14929 \InsetSpace ~
14930 \InsetSpace ~
14931 \InsetSpace ~
14932 \InsetSpace ~
14933 \InsetSpace ~
14934 \InsetSpace ~
14935 \InsetSpace ~
14936 \InsetSpace ~
14937 \InsetSpace ~
14938 ...
14939 \end_layout
14940
14941 \begin_layout Verse
14942
14943 \family typewriter
14944 \InsetSpace ~
14945 \InsetSpace ~
14946 \InsetSpace ~
14947 \InsetSpace ~
14948 \InsetSpace ~
14949 \InsetSpace ~
14950 \InsetSpace ~
14951 \InsetSpace ~
14952 \InsetSpace ~
14953 \InsetSpace ~
14954 \InsetSpace ~
14955 \InsetSpace ~
14956 \InsetSpace ~
14957 \InsetSpace ~
14958 \InsetSpace ~
14959 \InsetSpace ~
14960 \InsetSpace ~
14961 \InsetSpace ~
14962 \InsetSpace ~
14963 \InsetSpace ~
14964 \InsetSpace ~
14965 \InsetSpace ~
14966 \InsetSpace ~
14967 \InsetSpace ~
14968 \InsetSpace ~
14969 \InsetSpace ~
14970 \InsetSpace ~
14971 \InsetSpace ~
14972 \InsetSpace ~
14973 \InsetSpace ~
14974 \InsetSpace ~
14975 \InsetSpace ~
14976 \InsetSpace ~
14977 EA = EA_SAVE;
14978 \end_layout
14979
14980 \begin_layout Standard
14981 On other architectures which have seperate opcodes for enabling and disabling
14982  interrupts you might want to make use of defines with inline assembly
14983 \begin_inset LatexCommand \index{Assembler routines}
14984
14985 \end_inset
14986
14987  (HC08
14988 \begin_inset LatexCommand \index{HC08!interrupt}
14989
14990 \end_inset
14991
14992 ):
14993 \end_layout
14994
14995 \begin_layout Verse
14996
14997 \family typewriter
14998 #define CLI _asm
14999 \begin_inset LatexCommand \index{\\_asm}
15000
15001 \end_inset
15002
15003 \InsetSpace ~
15004 \InsetSpace ~
15005 cli\InsetSpace ~
15006 \InsetSpace ~
15007 _endasm
15008 \begin_inset LatexCommand \index{\\_endasm}
15009
15010 \end_inset
15011
15012
15013 \end_layout
15014
15015 \begin_layout Verse
15016
15017 \family typewriter
15018 #define SEI _asm\InsetSpace ~
15019 \InsetSpace ~
15020 sei\InsetSpace ~
15021 \InsetSpace ~
15022 _endasm; 
15023 \end_layout
15024
15025 \begin_layout Verse
15026
15027 \family typewriter
15028 ...
15029 \end_layout
15030
15031 \begin_layout Standard
15032 Note: it is sometimes sufficient to disable only a specific interrupt source
15033  like f.e.
15034  a timer or serial interrupt by manipulating an 
15035 \emph on
15036 interrupt mask
15037 \begin_inset LatexCommand \index{interrupt mask}
15038
15039 \end_inset
15040
15041
15042 \emph default
15043  register.
15044  
15045 \end_layout
15046
15047 \begin_layout Standard
15048 Usually the time during which interrupts are disabled should be kept as
15049  short as possible.
15050  This minimizes both 
15051 \emph on
15052 interrupt latency
15053 \emph default
15054
15055 \begin_inset LatexCommand \index{interrupt latency}
15056
15057 \end_inset
15058
15059  (the time between the occurrence of the interrupt and the execution of
15060  the first code in the interrupt routine) and 
15061 \emph on
15062 interrupt jitter
15063 \emph default
15064
15065 \begin_inset LatexCommand \index{interrupt jitter}
15066
15067 \end_inset
15068
15069  (the difference between the shortest and the longest interrupt latency).
15070  These really are something different, f.e.
15071  a serial interrupt has to be served before its buffer overruns so it cares
15072  for the maximum interrupt latency, whereas it does not care about jitter.
15073  On a loudspeaker driven via a digital to analog converter which is fed
15074  by an interrupt a latency of a few milliseconds might be tolerable, whereas
15075  a much smaller jitter will be very audible.
15076 \end_layout
15077
15078 \begin_layout Standard
15079 You can reenable interrupts within an interrupt routine and on some architecture
15080 s you can make use of two (or more) levels of 
15081 \emph on
15082 interrupt priorities
15083 \emph default
15084
15085 \begin_inset LatexCommand \index{interrupt priority}
15086
15087 \end_inset
15088
15089 .
15090  On some architectures which don't support interrupt priorities these can
15091  be implemented by manipulating the interrupt mask and reenabling interrupts
15092  within the interrupt routine.
15093  Check there is sufficient space on the stack
15094 \begin_inset LatexCommand \index{stack}
15095
15096 \end_inset
15097
15098  and don't add complexity unless you have to.
15099  
15100 \end_layout
15101
15102 \begin_layout Subsection
15103 Semaphore
15104 \begin_inset LatexCommand \index{semaphore}
15105
15106 \end_inset
15107
15108  locking (mcs51/ds390)
15109 \end_layout
15110
15111 \begin_layout Standard
15112 Some architectures (mcs51/ds390) have an atomic
15113 \begin_inset LatexCommand \index{atomic}
15114
15115 \end_inset
15116
15117  bit test and clear instruction.
15118  These type of instructions are typically used in preemptive multitasking
15119  systems, where a routine f.e.
15120  claims the use of a data structure ('acquires a lock
15121 \begin_inset LatexCommand \index{lock}
15122
15123 \end_inset
15124
15125  on it'), makes some modifications and then releases the lock when the data
15126  structure is consistent again.
15127  The instruction may also be used if interrupt and non-interrupt code have
15128  to compete for a resource.
15129  With the atomic bit test and clear instruction interrupts
15130 \begin_inset LatexCommand \index{interrupt}
15131
15132 \end_inset
15133
15134  don't have to be disabled for the locking operation.
15135  
15136 \end_layout
15137
15138 \begin_layout Standard
15139 SDCC generates this instruction if the source follows this pattern:
15140 \end_layout
15141
15142 \begin_layout Verse
15143
15144 \family typewriter
15145 volatile
15146 \begin_inset LatexCommand \index{volatile}
15147
15148 \end_inset
15149
15150  bit resource_is_free; 
15151 \newline
15152
15153 \newline
15154 if (resource_is_free) 
15155 \newline
15156 \InsetSpace ~
15157 \InsetSpace ~
15158
15159 \newline
15160 \InsetSpace ~
15161 \InsetSpace ~
15162 \InsetSpace ~
15163 \InsetSpace ~
15164 resource_is_free=0; 
15165 \newline
15166 \InsetSpace ~
15167 \InsetSpace ~
15168 \InsetSpace ~
15169 \InsetSpace ~
15170 ...
15171  
15172 \newline
15173 \InsetSpace ~
15174 \InsetSpace ~
15175 \InsetSpace ~
15176 \InsetSpace ~
15177 resource_is_free=1;
15178 \newline
15179 \InsetSpace ~
15180 \InsetSpace ~
15181
15182 \end_layout
15183
15184 \begin_layout Standard
15185 Note, mcs51 and ds390 support only an atomic
15186 \begin_inset LatexCommand \index{atomic}
15187
15188 \end_inset
15189
15190  bit test and 
15191 \emph on
15192 clear
15193 \emph default
15194  instruction (as opposed to atomic bit test and 
15195 \emph on
15196 set).
15197 \end_layout
15198
15199 \begin_layout Section
15200 Functions using private register banks
15201 \begin_inset LatexCommand \label{sub:Functions-using-private-banks}
15202
15203 \end_inset
15204
15205  (mcs51/ds390)
15206 \end_layout
15207
15208 \begin_layout Standard
15209 Some architectures have support for quickly changing register sets.
15210  SDCC supports this feature with the 
15211 \emph on
15212 using
15213 \begin_inset LatexCommand \index{using (mcs51, ds390 register bank)}
15214
15215 \end_inset
15216
15217
15218 \begin_inset LatexCommand \index{\\_\\_using (mcs51, ds390 register bank)}
15219
15220 \end_inset
15221
15222
15223 \emph default
15224  attribute (which tells the compiler to use a register bank
15225 \begin_inset LatexCommand \index{register bank (mcs51, ds390)}
15226
15227 \end_inset
15228
15229  other than the default bank zero).
15230  It should only be applied to 
15231 \emph on
15232 interrupt
15233 \begin_inset LatexCommand \index{interrupt}
15234
15235 \end_inset
15236
15237
15238 \emph default
15239  functions (see footnote below).
15240  This will in most circumstances make the generated ISR code more efficient
15241  since it will not have to save registers on the stack.
15242 \end_layout
15243
15244 \begin_layout Standard
15245 The 
15246 \emph on
15247 using
15248 \emph default
15249  attribute will have no effect on the generated code for a 
15250 \emph on
15251 non-interrupt
15252 \emph default
15253  function (but may occasionally be useful anyway
15254 \begin_inset Foot
15255 status open
15256
15257 \begin_layout Standard
15258 possible exception: if a function is called ONLY from 'interrupt' functions
15259  using a particular bank, it can be declared with the same 'using' attribute
15260  as the calling 'interrupt' functions.
15261  For instance, if you have several ISRs using bank one, and all of them
15262  call memcpy(), it might make sense to create a specialized version of memcpy()
15263  'using 1', since this would prevent the ISR from having to save bank zero
15264  to the stack on entry and switch to bank zero before calling the function
15265 \end_layout
15266
15267 \end_inset
15268
15269 ).
15270 \newline
15271
15272 \emph on
15273 (pending: Note, nowadays the
15274 \emph default
15275  using 
15276 \emph on
15277 attribute has an effect on
15278 \emph default
15279  
15280 \emph on
15281 the generated code for a
15282 \emph default
15283  non-interrupt 
15284 \emph on
15285 function
15286 \emph default
15287 .
15288 \emph on
15289 )
15290 \end_layout
15291
15292 \begin_layout Standard
15293 An 
15294 \emph on
15295 interrupt
15296 \emph default
15297  function using a non-zero bank will assume that it can trash that register
15298  bank, and will not save it.
15299  Since high-priority interrupts
15300 \begin_inset LatexCommand \index{interrupts}
15301
15302 \end_inset
15303
15304
15305 \begin_inset LatexCommand \index{interrupt priority}
15306
15307 \end_inset
15308
15309  can interrupt low-priority ones on the 8051 and friends, this means that
15310  if a high-priority ISR 
15311 \emph on
15312 using
15313 \emph default
15314  a particular bank occurs while processing a low-priority ISR 
15315 \emph on
15316 using
15317 \emph default
15318  the same bank, terrible and bad things can happen.
15319  To prevent this, no single register bank should be 
15320 \emph on
15321 used
15322 \emph default
15323  by both a high priority and a low priority ISR.
15324  This is probably most easily done by having all high priority ISRs use
15325  one bank and all low priority ISRs use another.
15326  If you have an ISR which can change priority at runtime, you're on your
15327  own: I suggest using the default bank zero and taking the small performance
15328  hit.
15329 \end_layout
15330
15331 \begin_layout Standard
15332 It is most efficient if your ISR calls no other functions.
15333  If your ISR must call other functions, it is most efficient if those functions
15334  use the same bank as the ISR (see note 1 below); the next best is if the
15335  called functions use bank zero.
15336  It is very inefficient to call a function using a different, non-zero bank
15337  from an ISR.
15338  
15339 \begin_inset VSpace bigskip
15340 \end_inset
15341
15342
15343 \end_layout
15344
15345 \begin_layout Section
15346 Startup Code
15347 \begin_inset LatexCommand \label{sub:Startup-Code}
15348
15349 \end_inset
15350
15351
15352 \begin_inset LatexCommand \index{Startup code}
15353
15354 \end_inset
15355
15356
15357 \end_layout
15358
15359 \begin_layout Subsection
15360 MCS51/DS390 Startup Code
15361 \end_layout
15362
15363 \begin_layout Standard
15364 The compiler triggers the linker to link certain initialization modules
15365  from the runtime library
15366 \begin_inset LatexCommand \index{Runtime library}
15367
15368 \end_inset
15369
15370  called crt<something>.
15371  Only the necessary ones are linked, for instance crtxstack.asm (GSINIT1,
15372  GSINIT5) is not linked unless the -
15373 \series bold
15374
15375 \begin_inset ERT
15376 status open
15377
15378 \begin_layout Standard
15379
15380
15381 \backslash
15382 /
15383 \end_layout
15384
15385 \end_inset
15386
15387
15388 \series default
15389 -xstack option is used.
15390  These modules are highly entangled by the use of special segments/areas,
15391  but a common layout is shown below:
15392 \end_layout
15393
15394 \begin_layout Verse
15395
15396 \family typewriter
15397 \series bold
15398 \size footnotesize
15399 (main.asm)
15400 \end_layout
15401
15402 \begin_layout Verse
15403
15404 \family typewriter
15405 \size footnotesize
15406 \InsetSpace ~
15407 \InsetSpace ~
15408 \InsetSpace ~
15409 \InsetSpace ~
15410 \InsetSpace ~
15411 \InsetSpace ~
15412 \InsetSpace ~
15413 \InsetSpace ~
15414 .area HOME (CODE)
15415 \newline
15416 __interrupt_vect:
15417 \newline
15418 \InsetSpace ~
15419 \InsetSpace ~
15420 \InsetSpace ~
15421 \InsetSpace ~
15422 \InsetSpace ~
15423 \InsetSpace ~
15424 \InsetSpace ~
15425 \InsetSpace ~
15426 ljmp __sdcc_gsinit_startup
15427 \end_layout
15428
15429 \begin_layout Verse
15430
15431 \family typewriter
15432 \series bold
15433 \size footnotesize
15434 (crtstart.asm)
15435 \end_layout
15436
15437 \begin_layout Verse
15438
15439 \family typewriter
15440 \size footnotesize
15441 \InsetSpace ~
15442 \InsetSpace ~
15443 \InsetSpace ~
15444 \InsetSpace ~
15445 \InsetSpace ~
15446 \InsetSpace ~
15447 \InsetSpace ~
15448 \InsetSpace ~
15449 .area GSINIT0 (CODE)
15450 \newline
15451 __sdcc_gsinit_startup::
15452 \newline
15453 \InsetSpace ~
15454 \InsetSpace ~
15455 \InsetSpace ~
15456 \InsetSpace ~
15457 \InsetSpace ~
15458 \InsetSpace ~
15459 \InsetSpace ~
15460 \InsetSpace ~
15461 mov sp,#__start__stack - 1
15462 \end_layout
15463
15464 \begin_layout Verse
15465
15466 \family typewriter
15467 \series bold
15468 \size footnotesize
15469 (crtxstack.asm)
15470 \end_layout
15471
15472 \begin_layout Verse
15473
15474 \family typewriter
15475 \size footnotesize
15476 \InsetSpace ~
15477 \InsetSpace ~
15478 \InsetSpace ~
15479 \InsetSpace ~
15480 \InsetSpace ~
15481 \InsetSpace ~
15482 \InsetSpace ~
15483 \InsetSpace ~
15484 .area GSINIT1 (CODE)
15485 \newline
15486 __sdcc_init_xstack::
15487 \newline
15488 ; Need to initialize in GSINIT1 in
15489  case the user's __sdcc_external_startup uses the xstack.
15490 \newline
15491 \InsetSpace ~
15492 \InsetSpace ~
15493 \InsetSpace ~
15494 \InsetSpace ~
15495 \InsetSpace ~
15496 \InsetSpace ~
15497 \InsetSpace ~
15498 \InsetSpace ~
15499 mov __XPAGE,#(__start__x
15500 stack >> 8)
15501 \newline
15502 \InsetSpace ~
15503 \InsetSpace ~
15504 \InsetSpace ~
15505 \InsetSpace ~
15506 \InsetSpace ~
15507 \InsetSpace ~
15508 \InsetSpace ~
15509 \InsetSpace ~
15510 mov _spx,#__start__xstack
15511 \end_layout
15512
15513 \begin_layout Verse
15514
15515 \family typewriter
15516 \series bold
15517 \size footnotesize
15518 (crtstart.asm)
15519 \end_layout
15520
15521 \begin_layout Verse
15522
15523 \family typewriter
15524 \size footnotesize
15525 \InsetSpace ~
15526 \InsetSpace ~
15527 \InsetSpace ~
15528 \InsetSpace ~
15529 \InsetSpace ~
15530 \InsetSpace ~
15531 \InsetSpace ~
15532 \InsetSpace ~
15533 .area GSINIT2 (CODE)
15534 \newline
15535 \InsetSpace ~
15536 \InsetSpace ~
15537 \InsetSpace ~
15538 \InsetSpace ~
15539 \InsetSpace ~
15540 \InsetSpace ~
15541 \InsetSpace ~
15542 \InsetSpace ~
15543 lcall __sdcc_external_startup
15544 \newline
15545 \InsetSpace ~
15546 \InsetSpace ~
15547 \InsetSpace ~
15548 \InsetSpace ~
15549 \InsetSpace ~
15550 \InsetSpace ~
15551 \InsetSpace ~
15552 \InsetSpace ~
15553 mov a,dpl
15554 \newline
15555 \InsetSpace ~
15556 \InsetSpace ~
15557 \InsetSpace ~
15558 \InsetSpace ~
15559 \InsetSpace ~
15560 \InsetSpace ~
15561 \InsetSpace ~
15562 \InsetSpace ~
15563 jz __sdcc_init_data
15564 \newline
15565 \InsetSpace ~
15566 \InsetSpace ~
15567 \InsetSpace ~
15568 \InsetSpace ~
15569 \InsetSpace ~
15570 \InsetSpace ~
15571 \InsetSpace ~
15572 \InsetSpace ~
15573 ljmp
15574  __sdcc_program_startup
15575 \newline
15576 __sdcc_init_data:
15577 \end_layout
15578
15579 \begin_layout Verse
15580
15581 \family typewriter
15582 \series bold
15583 \size footnotesize
15584 (crtxinit.asm)
15585 \end_layout
15586
15587 \begin_layout Verse
15588
15589 \family typewriter
15590 \size footnotesize
15591 \InsetSpace ~
15592 \InsetSpace ~
15593 \InsetSpace ~
15594 \InsetSpace ~
15595 \InsetSpace ~
15596 \InsetSpace ~
15597 \InsetSpace ~
15598 \InsetSpace ~
15599 .area GSINIT3 (CODE)
15600 \newline
15601 __mcs51_genXINIT::
15602 \newline
15603 \InsetSpace ~
15604 \InsetSpace ~
15605 \InsetSpace ~
15606 \InsetSpace ~
15607 \InsetSpace ~
15608 \InsetSpace ~
15609 \InsetSpace ~
15610 \InsetSpace ~
15611 mov r1,#l_XINIT
15612 \newline
15613 \InsetSpace ~
15614 \InsetSpace ~
15615 \InsetSpace ~
15616 \InsetSpace ~
15617 \InsetSpace ~
15618 \InsetSpace ~
15619 \InsetSpace ~
15620 \InsetSpace ~
15621 mov a,r1
15622 \newline
15623 \InsetSpace ~
15624 \InsetSpace ~
15625 \InsetSpace ~
15626 \InsetSpace ~
15627 \InsetSpace ~
15628 \InsetSpace ~
15629 \InsetSpace ~
15630 \InsetSpace ~
15631 orl a,#(l_XINIT
15632  >> 8)
15633 \newline
15634 \InsetSpace ~
15635 \InsetSpace ~
15636 \InsetSpace ~
15637 \InsetSpace ~
15638 \InsetSpace ~
15639 \InsetSpace ~
15640 \InsetSpace ~
15641 \InsetSpace ~
15642 jz 00003$
15643 \newline
15644 \InsetSpace ~
15645 \InsetSpace ~
15646 \InsetSpace ~
15647 \InsetSpace ~
15648 \InsetSpace ~
15649 \InsetSpace ~
15650 \InsetSpace ~
15651 \InsetSpace ~
15652 mov r2,#((l_XINIT+255) >> 8)
15653 \newline
15654 \InsetSpace ~
15655 \InsetSpace ~
15656 \InsetSpace ~
15657 \InsetSpace ~
15658 \InsetSpace ~
15659 \InsetSpace ~
15660 \InsetSpace ~
15661 \InsetSpace ~
15662 mov dptr,#s_XINIT
15663 \newline
15664 \InsetSpace ~
15665 \InsetSpace ~
15666 \InsetSpace ~
15667 \InsetSpace ~
15668 \InsetSpace ~
15669 \InsetSpace ~
15670 \InsetSpace ~
15671 \InsetSpace ~
15672 mov r0,#s_XISEG
15673 \newline
15674 \InsetSpace ~
15675 \InsetSpace ~
15676 \InsetSpace ~
15677 \InsetSpace ~
15678 \InsetSpace ~
15679 \InsetSpace ~
15680 \InsetSpace ~
15681 \InsetSpace ~
15682 mov
15683  __XPAGE,#(s_XISEG >> 8)
15684 \newline
15685 00001$:\InsetSpace ~
15686 clr a
15687 \newline
15688 \InsetSpace ~
15689 \InsetSpace ~
15690 \InsetSpace ~
15691 \InsetSpace ~
15692 \InsetSpace ~
15693 \InsetSpace ~
15694 \InsetSpace ~
15695 \InsetSpace ~
15696 movc a,@a+dptr
15697 \newline
15698 \InsetSpace ~
15699 \InsetSpace ~
15700 \InsetSpace ~
15701 \InsetSpace ~
15702 \InsetSpace ~
15703 \InsetSpace ~
15704 \InsetSpace ~
15705 \InsetSpace ~
15706 movx @r0,a
15707 \newline
15708 \InsetSpace ~
15709 \InsetSpace ~
15710 \InsetSpace ~
15711 \InsetSpace ~
15712 \InsetSpace ~
15713 \InsetSpace ~
15714 \InsetSpace ~
15715 \InsetSpace ~
15716 inc dptr
15717 \newline
15718 \InsetSpace ~
15719 \InsetSpace ~
15720 \InsetSpace ~
15721 \InsetSpace ~
15722 \InsetSpace ~
15723 \InsetSpace ~
15724 \InsetSpace ~
15725 \InsetSpace ~
15726 inc
15727  r0
15728 \newline
15729 \InsetSpace ~
15730 \InsetSpace ~
15731 \InsetSpace ~
15732 \InsetSpace ~
15733 \InsetSpace ~
15734 \InsetSpace ~
15735 \InsetSpace ~
15736 \InsetSpace ~
15737 cjne r0,#0,00002$
15738 \newline
15739 \InsetSpace ~
15740 \InsetSpace ~
15741 \InsetSpace ~
15742 \InsetSpace ~
15743 \InsetSpace ~
15744 \InsetSpace ~
15745 \InsetSpace ~
15746 \InsetSpace ~
15747 inc __XPAGE
15748 \newline
15749 00002$:\InsetSpace ~
15750 djnz r1,00001$
15751 \newline
15752 \InsetSpace ~
15753 \InsetSpace ~
15754 \InsetSpace ~
15755 \InsetSpace ~
15756 \InsetSpace ~
15757 \InsetSpace ~
15758 \InsetSpace ~
15759 \InsetSpace ~
15760 djnz r2,00001$
15761 \newline
15762 \InsetSpace ~
15763 \InsetSpace ~
15764 \InsetSpace ~
15765 \InsetSpace ~
15766 \InsetSpace ~
15767 \InsetSpace ~
15768 \InsetSpace ~
15769 \InsetSpace ~
15770 mov __XPAGE,#0
15771 xFF
15772 \newline
15773 00003$:
15774 \end_layout
15775
15776 \begin_layout Verse
15777
15778 \family typewriter
15779 \series bold
15780 \size footnotesize
15781 (crtclear.asm)
15782 \end_layout
15783
15784 \begin_layout Verse
15785
15786 \family typewriter
15787 \size footnotesize
15788 \InsetSpace ~
15789 \InsetSpace ~
15790 \InsetSpace ~
15791 \InsetSpace ~
15792 \InsetSpace ~
15793 \InsetSpace ~
15794 \InsetSpace ~
15795 \InsetSpace ~
15796 .area GSINIT4 (CODE)
15797 \newline
15798 __mcs51_genRAMCLEAR::
15799 \newline
15800 \InsetSpace ~
15801 \InsetSpace ~
15802 \InsetSpace ~
15803 \InsetSpace ~
15804 \InsetSpace ~
15805 \InsetSpace ~
15806 \InsetSpace ~
15807 \InsetSpace ~
15808 clr a
15809 \newline
15810 \InsetSpace ~
15811 \InsetSpace ~
15812 \InsetSpace ~
15813 \InsetSpace ~
15814 \InsetSpace ~
15815 \InsetSpace ~
15816 \InsetSpace ~
15817 \InsetSpace ~
15818 mov r0,#(l_IRAM-1)
15819 \newline
15820 00004$:\InsetSpace ~
15821 mov
15822  @r0,a
15823 \newline
15824 \InsetSpace ~
15825 \InsetSpace ~
15826 \InsetSpace ~
15827 \InsetSpace ~
15828 \InsetSpace ~
15829 \InsetSpace ~
15830 \InsetSpace ~
15831 \InsetSpace ~
15832 djnz r0,00004$
15833 \newline
15834 ; _mcs51_genRAMCLEAR() end
15835 \end_layout
15836
15837 \begin_layout Verse
15838
15839 \family typewriter
15840 \series bold
15841 \size footnotesize
15842 (crtxclear.asm)
15843 \end_layout
15844
15845 \begin_layout Verse
15846
15847 \family typewriter
15848 \size footnotesize
15849 \InsetSpace ~
15850 \InsetSpace ~
15851 \InsetSpace ~
15852 \InsetSpace ~
15853 \InsetSpace ~
15854 \InsetSpace ~
15855 \InsetSpace ~
15856 \InsetSpace ~
15857 .area GSINIT4 (CODE)
15858 \newline
15859 __mcs51_genXRAMCLEAR::
15860 \newline
15861 \InsetSpace ~
15862 \InsetSpace ~
15863 \InsetSpace ~
15864 \InsetSpace ~
15865 \InsetSpace ~
15866 \InsetSpace ~
15867 \InsetSpace ~
15868 \InsetSpace ~
15869 mov r0,#l_PSEG
15870 \newline
15871 \InsetSpace ~
15872 \InsetSpace ~
15873 \InsetSpace ~
15874 \InsetSpace ~
15875 \InsetSpace ~
15876 \InsetSpace ~
15877 \InsetSpace ~
15878 \InsetSpace ~
15879 mov a,r0
15880 \newline
15881 \InsetSpace ~
15882 \InsetSpace ~
15883 \InsetSpace ~
15884 \InsetSpace ~
15885 \InsetSpace ~
15886 \InsetSpace ~
15887 \InsetSpace ~
15888 \InsetSpace ~
15889 jz 00006$
15890 \newline
15891 \InsetSpace ~
15892 \InsetSpace ~
15893 \InsetSpace ~
15894 \InsetSpace ~
15895 \InsetSpace ~
15896 \InsetSpace ~
15897 \InsetSpace ~
15898 \InsetSpace ~
15899 mov
15900  r1,#s_PSEG
15901 \newline
15902 \InsetSpace ~
15903 \InsetSpace ~
15904 \InsetSpace ~
15905 \InsetSpace ~
15906 \InsetSpace ~
15907 \InsetSpace ~
15908 \InsetSpace ~
15909 \InsetSpace ~
15910 mov __XPAGE,#(s_PSEG >> 8)
15911 \newline
15912 \InsetSpace ~
15913 \InsetSpace ~
15914 \InsetSpace ~
15915 \InsetSpace ~
15916 \InsetSpace ~
15917 \InsetSpace ~
15918 \InsetSpace ~
15919 \InsetSpace ~
15920 clr a
15921 \newline
15922 00005$:\InsetSpace ~
15923 movx @r1,a
15924 \newline
15925 \InsetSpace ~
15926 \InsetSpace ~
15927 \InsetSpace ~
15928 \InsetSpace ~
15929 \InsetSpace ~
15930 \InsetSpace ~
15931 \InsetSpace ~
15932 \InsetSpace ~
15933 inc r1
15934 \newline
15935 \InsetSpace ~
15936 \InsetSpace ~
15937 \InsetSpace ~
15938 \InsetSpace ~
15939 \InsetSpace ~
15940 \InsetSpace ~
15941 \InsetSpace ~
15942 \InsetSpace ~
15943 djnz r0,00005$
15944 \newline
15945 0
15946 0006$:
15947 \newline
15948 \InsetSpace ~
15949 \InsetSpace ~
15950 \InsetSpace ~
15951 \InsetSpace ~
15952 \InsetSpace ~
15953 \InsetSpace ~
15954 \InsetSpace ~
15955 \InsetSpace ~
15956 mov r0,#l_XSEG
15957 \newline
15958 \InsetSpace ~
15959 \InsetSpace ~
15960 \InsetSpace ~
15961 \InsetSpace ~
15962 \InsetSpace ~
15963 \InsetSpace ~
15964 \InsetSpace ~
15965 \InsetSpace ~
15966 mov a,r0
15967 \newline
15968 \InsetSpace ~
15969 \InsetSpace ~
15970 \InsetSpace ~
15971 \InsetSpace ~
15972 \InsetSpace ~
15973 \InsetSpace ~
15974 \InsetSpace ~
15975 \InsetSpace ~
15976 orl a,#(l_XSEG >> 8)
15977 \newline
15978 \InsetSpace ~
15979 \InsetSpace ~
15980 \InsetSpace ~
15981 \InsetSpace ~
15982 \InsetSpace ~
15983 \InsetSpace ~
15984 \InsetSpace ~
15985 \InsetSpace ~
15986 jz 00008$
15987 \newline
15988 \InsetSpace ~
15989 \InsetSpace ~
15990 \InsetSpace ~
15991 \InsetSpace ~
15992 \InsetSpace ~
15993 \InsetSpace ~
15994 \InsetSpace ~
15995 \InsetSpace ~
15996 mov r1,#((l_XSEG
15997  + 255) >> 8)
15998 \newline
15999 \InsetSpace ~
16000 \InsetSpace ~
16001 \InsetSpace ~
16002 \InsetSpace ~
16003 \InsetSpace ~
16004 \InsetSpace ~
16005 \InsetSpace ~
16006 \InsetSpace ~
16007 mov dptr,#s_XSEG
16008 \newline
16009 \InsetSpace ~
16010 \InsetSpace ~
16011 \InsetSpace ~
16012 \InsetSpace ~
16013 \InsetSpace ~
16014 \InsetSpace ~
16015 \InsetSpace ~
16016 \InsetSpace ~
16017 clr a
16018 \newline
16019 00007$:\InsetSpace ~
16020 movx @dptr,a
16021 \newline
16022 \InsetSpace ~
16023 \InsetSpace ~
16024 \InsetSpace ~
16025 \InsetSpace ~
16026 \InsetSpace ~
16027 \InsetSpace ~
16028 \InsetSpace ~
16029 \InsetSpace ~
16030 inc dptr
16031 \newline
16032 \InsetSpace ~
16033 \InsetSpace ~
16034 \InsetSpace ~
16035 \InsetSpace ~
16036 \InsetSpace ~
16037 \InsetSpace ~
16038 \InsetSpace ~
16039 \InsetSpace ~
16040 djnz r0,00007$
16041 \newline
16042 \InsetSpace ~
16043 \InsetSpace ~
16044 \InsetSpace ~
16045 \InsetSpace ~
16046 \InsetSpace ~
16047 \InsetSpace ~
16048 \InsetSpace ~
16049 \InsetSpace ~
16050 djnz
16051  r1,00007$
16052 \newline
16053 00008$:
16054 \end_layout
16055
16056 \begin_layout Verse
16057
16058 \family typewriter
16059 \series bold
16060 \size footnotesize
16061 (crtxstack.asm)
16062 \end_layout
16063
16064 \begin_layout Verse
16065
16066 \family typewriter
16067 \size footnotesize
16068 \InsetSpace ~
16069 \InsetSpace ~
16070 \InsetSpace ~
16071 \InsetSpace ~
16072 \InsetSpace ~
16073 \InsetSpace ~
16074 \InsetSpace ~
16075 \InsetSpace ~
16076 .area GSINIT5 (CODE)
16077 \newline
16078 ; Need to initialize in GSINIT5 because __mcs51_genXINIT
16079  modifies __XPAGE
16080 \newline
16081 ; and __mcs51_genRAMCLEAR modifies _spx.
16082 \newline
16083 \InsetSpace ~
16084 \InsetSpace ~
16085 \InsetSpace ~
16086 \InsetSpace ~
16087 \InsetSpace ~
16088 \InsetSpace ~
16089 \InsetSpace ~
16090 \InsetSpace ~
16091 mov __XPAGE,#(__start__x
16092 stack >> 8)
16093 \newline
16094 \InsetSpace ~
16095 \InsetSpace ~
16096 \InsetSpace ~
16097 \InsetSpace ~
16098 \InsetSpace ~
16099 \InsetSpace ~
16100 \InsetSpace ~
16101 \InsetSpace ~
16102 mov _spx,#__start__xstack
16103 \end_layout
16104
16105 \begin_layout Verse
16106
16107 \family typewriter
16108 \series bold
16109 \size footnotesize
16110 (application modules)
16111 \end_layout
16112
16113 \begin_layout Verse
16114
16115 \family typewriter
16116 \size footnotesize
16117 \InsetSpace ~
16118 \InsetSpace ~
16119 \InsetSpace ~
16120 \InsetSpace ~
16121 \InsetSpace ~
16122 \InsetSpace ~
16123 \InsetSpace ~
16124 \InsetSpace ~
16125 .area GSINIT (CODE)
16126 \end_layout
16127
16128 \begin_layout Verse
16129
16130 \family typewriter
16131 \series bold
16132 \size footnotesize
16133 (main.asm)
16134 \end_layout
16135
16136 \begin_layout Verse
16137
16138 \family typewriter
16139 \size footnotesize
16140 \InsetSpace ~
16141 \InsetSpace ~
16142 \InsetSpace ~
16143 \InsetSpace ~
16144 \InsetSpace ~
16145 \InsetSpace ~
16146 \InsetSpace ~
16147 \InsetSpace ~
16148 .area GSFINAL (CODE)
16149 \newline
16150 \InsetSpace ~
16151 \InsetSpace ~
16152 \InsetSpace ~
16153 \InsetSpace ~
16154 \InsetSpace ~
16155 \InsetSpace ~
16156 \InsetSpace ~
16157 \InsetSpace ~
16158 ljmp __sdcc_program_startup
16159 \newline
16160 ;---------------------------------
16161 -----------------------
16162 \newline
16163 ; Home
16164 \newline
16165 ;--------------------------------------------------
16166 ------
16167 \newline
16168 \InsetSpace ~
16169 \InsetSpace ~
16170 \InsetSpace ~
16171 \InsetSpace ~
16172 \InsetSpace ~
16173 \InsetSpace ~
16174 \InsetSpace ~
16175 \InsetSpace ~
16176 .area HOME (CODE)
16177 \newline
16178 \InsetSpace ~
16179 \InsetSpace ~
16180 \InsetSpace ~
16181 \InsetSpace ~
16182 \InsetSpace ~
16183 \InsetSpace ~
16184 \InsetSpace ~
16185 \InsetSpace ~
16186 .area CSEG (CODE)
16187 \newline
16188 __sdcc_program_startup:
16189 \newline
16190 \InsetSpace ~
16191 \InsetSpace ~
16192 \InsetSpace ~
16193 \InsetSpace ~
16194 \InsetSpace ~
16195 \InsetSpace ~
16196 \InsetSpace ~
16197 \InsetSpace ~
16198 lcall _main
16199 \newline
16200 ;
16201  return from main will lock up
16202 \newline
16203 \InsetSpace ~
16204 \InsetSpace ~
16205 \InsetSpace ~
16206 \InsetSpace ~
16207 \InsetSpace ~
16208 \InsetSpace ~
16209 \InsetSpace ~
16210 \InsetSpace ~
16211 sjmp .
16212 \end_layout
16213
16214 \begin_layout Standard
16215 One of these modules (crtstart.asm) contains a call to the C routine 
16216 \emph on
16217 _sdcc_external_startup()
16218 \begin_inset LatexCommand \index{\\_sdcc\\_external\\_startup()}
16219
16220 \end_inset
16221
16222
16223 \emph default
16224  at the start of the CODE area.
16225  This routine is also in the runtime library
16226 \begin_inset LatexCommand \index{Runtime library}
16227
16228 \end_inset
16229
16230  and returns 0 by default.
16231  If this routine returns a non-zero value, the static & global variable
16232  initialization will be skipped and the function main will be invoked.
16233  Otherwise static & global variables will be initialized before the function
16234  main is invoked.
16235  You could add an 
16236 \emph on
16237 _sdcc_external_startup()
16238 \emph default
16239  routine to your program to override the default if you need to setup hardware
16240  or perform some other critical operation prior to static & global variable
16241  initialization
16242 \begin_inset LatexCommand \index{Variable initialization}
16243
16244 \end_inset
16245
16246 .
16247  On some mcs51 variants xdata
16248 \begin_inset LatexCommand \index{xdata (mcs51, ds390 storage class)}
16249
16250 \end_inset
16251
16252  memory has to be explicitly enabled before it can be accessed or if the
16253  watchdog
16254 \begin_inset LatexCommand \index{watchdog}
16255
16256 \end_inset
16257
16258  needs to be disabled, this is the place to do it.
16259  The startup code clears all internal data memory, 256 bytes by default,
16260  but from 0 to n-1 if 
16261 \emph on
16262 -
16263 \begin_inset ERT
16264 status collapsed
16265
16266 \begin_layout Standard
16267
16268
16269 \backslash
16270 /
16271 \end_layout
16272
16273 \end_inset
16274
16275 -iram-size
16276 \begin_inset LatexCommand \index{-\\/-iram-size <Value>}
16277
16278 \end_inset
16279
16280 n
16281 \emph default
16282  is used.
16283  (recommended for Chipcon CC1010).
16284 \end_layout
16285
16286 \begin_layout Standard
16287 See also the compiler options 
16288 \emph on
16289 -
16290 \begin_inset ERT
16291 status collapsed
16292
16293 \begin_layout Standard
16294
16295
16296 \backslash
16297 /
16298 \end_layout
16299
16300 \end_inset
16301
16302 -no-xinit
16303 \emph default
16304 -
16305 \emph on
16306 opt
16307 \emph default
16308
16309 \begin_inset LatexCommand \index{-\\/-no-xinit-opt}
16310
16311 \end_inset
16312
16313
16314 \emph on
16315 -
16316 \begin_inset ERT
16317 status collapsed
16318
16319 \begin_layout Standard
16320
16321
16322 \backslash
16323 /
16324 \end_layout
16325
16326 \end_inset
16327
16328 -main-return
16329 \emph default
16330
16331 \begin_inset LatexCommand \index{-\\/-main-return}
16332
16333 \end_inset
16334
16335  and section 
16336 \begin_inset LatexCommand \ref{sub:MCS51-variants}
16337
16338 \end_inset
16339
16340  about MCS51-variants.
16341 \begin_inset VSpace bigskip
16342 \end_inset
16343
16344
16345 \end_layout
16346
16347 \begin_layout Subsection
16348 HC08 Startup Code
16349 \end_layout
16350
16351 \begin_layout Standard
16352 The HC08
16353 \begin_inset LatexCommand \index{HC08}
16354
16355 \end_inset
16356
16357  startup code follows the same scheme as the MCS51 startup code.
16358 \begin_inset VSpace bigskip
16359 \end_inset
16360
16361
16362 \end_layout
16363
16364 \begin_layout Subsection
16365 Z80 Startup Code
16366 \end_layout
16367
16368 \begin_layout Standard
16369 On the Z80
16370 \begin_inset LatexCommand \index{Z80}
16371
16372 \end_inset
16373
16374  the startup code is inserted by linking with crt0.o which is generated from
16375  sdcc/device/lib/z80/crt0.s.
16376  If you need a different startup code you can use the compiler option 
16377 \emph on
16378 -
16379 \series bold
16380 \emph default
16381
16382 \begin_inset ERT
16383 status collapsed
16384
16385 \begin_layout Standard
16386
16387
16388 \backslash
16389 /
16390 \end_layout
16391
16392 \end_inset
16393
16394
16395 \series default
16396 \emph on
16397 -no-std-crt0
16398 \emph default
16399
16400 \begin_inset LatexCommand \index{-\\/-no-std-crt0}
16401
16402 \end_inset
16403
16404  and provide your own crt0.o.
16405  
16406 \begin_inset VSpace bigskip
16407 \end_inset
16408
16409
16410 \end_layout
16411
16412 \begin_layout Section
16413 Inline Assembler Code
16414 \begin_inset LatexCommand \index{Assembler routines}
16415
16416 \end_inset
16417
16418
16419 \end_layout
16420
16421 \begin_layout Subsection
16422 A Step by Step Introduction
16423 \begin_inset LatexCommand \label{sub:A-Step-by Assembler Introduction}
16424
16425 \end_inset
16426
16427
16428 \end_layout
16429
16430 \begin_layout Standard
16431 Starting from a small snippet of c-code this example shows for the MCS51
16432  how to use inline assembly, access variables, a function parameter and
16433  an array in xdata memory.
16434  The example uses an MCS51 here but is easily adapted for other architectures.
16435  This is a buffer routine which should be optimized:
16436 \end_layout
16437
16438 \begin_layout Verse
16439
16440 \family typewriter
16441 \size footnotesize
16442 unsigned char __far
16443 \begin_inset LatexCommand \index{far (storage class)}
16444
16445 \end_inset
16446
16447
16448 \begin_inset LatexCommand \index{\\_\\_far (storage class)}
16449
16450 \end_inset
16451
16452  __at
16453 \begin_inset LatexCommand \index{at}
16454
16455 \end_inset
16456
16457
16458 \begin_inset LatexCommand \index{\\_\\_at}
16459
16460 \end_inset
16461
16462 (0x7f00) buf[0x100];
16463 \begin_inset LatexCommand \index{Aligned array}
16464
16465 \end_inset
16466
16467
16468 \newline
16469 unsigned char head, tail;\InsetSpace ~
16470 \InsetSpace ~
16471 \InsetSpace ~
16472 \InsetSpace ~
16473 \InsetSpace ~
16474 \InsetSpace ~
16475 \InsetSpace ~
16476 \InsetSpace ~
16477 \InsetSpace ~
16478 \InsetSpace ~
16479 \InsetSpace ~
16480 \InsetSpace ~
16481 \InsetSpace ~
16482 \InsetSpace ~
16483 \InsetSpace ~
16484 \InsetSpace ~
16485 \InsetSpace ~
16486 /* if interrupts
16487 \begin_inset LatexCommand \index{interrupt}
16488
16489 \end_inset
16490
16491  are involved see
16492 \newline
16493 \InsetSpace ~
16494 \InsetSpace ~
16495 \InsetSpace ~
16496 \InsetSpace ~
16497 \InsetSpace ~
16498 \InsetSpace ~
16499 \InsetSpace ~
16500 \InsetSpace ~
16501 \InsetSpace ~
16502 \InsetSpace ~
16503 \InsetSpace ~
16504 \InsetSpace ~
16505 \InsetSpace ~
16506 \InsetSpace ~
16507 \InsetSpace ~
16508 \InsetSpace ~
16509 \InsetSpace ~
16510 \InsetSpace ~
16511 \InsetSpace ~
16512 \InsetSpace ~
16513 \InsetSpace ~
16514 \InsetSpace ~
16515 \InsetSpace ~
16516 \InsetSpace ~
16517 \InsetSpace ~
16518 \InsetSpace ~
16519 \InsetSpace ~
16520 \InsetSpace ~
16521 \InsetSpace ~
16522 \InsetSpace ~
16523 \InsetSpace ~
16524 \InsetSpace ~
16525 \InsetSpace ~
16526 \InsetSpace ~
16527 \InsetSpace ~
16528 \InsetSpace ~
16529 \InsetSpace ~
16530 \InsetSpace ~
16531 \InsetSpace ~
16532 \InsetSpace ~
16533 \InsetSpace ~
16534 \InsetSpace ~
16535 \InsetSpace ~
16536 \InsetSpace ~
16537 \InsetSpace ~
16538 section 
16539 \begin_inset LatexCommand \ref{sub:Common-interrupt-pitfall-volatile}
16540
16541 \end_inset
16542
16543  about
16544 \family default
16545  
16546 \family typewriter
16547 \series bold
16548 volatile
16549 \family default
16550 \series default
16551  
16552 \family typewriter
16553 */
16554 \newline
16555
16556 \newline
16557 void to_buffer( unsigned char c ) 
16558 \newline
16559 {
16560 \newline
16561 \InsetSpace ~
16562 \InsetSpace ~
16563 \InsetSpace ~
16564 \InsetSpace ~
16565 if( head != (unsigned char)(tail-1)
16566  )\InsetSpace ~
16567 /* cast
16568 \family default
16569  
16570 \family typewriter
16571 \series bold
16572 needed
16573 \family default
16574 \series default
16575  
16576 \family typewriter
16577 to avoid promotion
16578 \begin_inset LatexCommand \index{promotion to signed int}
16579
16580 \end_inset
16581
16582
16583 \begin_inset LatexCommand \index{type promotion}
16584
16585 \end_inset
16586
16587  to integer */
16588 \begin_inset Marginal
16589 status collapsed
16590
16591 \begin_layout Standard
16592
16593 \series bold
16594 \InsetSpace ~
16595 !
16596 \end_layout
16597
16598 \end_inset
16599
16600
16601 \newline
16602 \InsetSpace ~
16603 \InsetSpace ~
16604 \InsetSpace ~
16605 \InsetSpace ~
16606 \InsetSpace ~
16607 \InsetSpace ~
16608 \InsetSpace ~
16609 \InsetSpace ~
16610 buf[ head++ ] = c;\InsetSpace ~
16611 \InsetSpace ~
16612 \InsetSpace ~
16613 \InsetSpace ~
16614 \InsetSpace ~
16615 \InsetSpace ~
16616 \InsetSpace ~
16617 \InsetSpace ~
16618 \InsetSpace ~
16619 \InsetSpace ~
16620 \InsetSpace ~
16621 \InsetSpace ~
16622 \InsetSpace ~
16623 \InsetSpace ~
16624 \InsetSpace ~
16625 \InsetSpace ~
16626 /* access to a 256 byte aligned array */
16627 \newline
16628
16629 \end_layout
16630
16631 \begin_layout Standard
16632 If the code snippet (assume it is saved in buffer.c) is compiled with SDCC
16633  then a corresponding buffer.asm file is generated.
16634  We define a new function 
16635 \family typewriter
16636 to_buffer_asm()
16637 \family default
16638  in file buffer.c in which we cut and paste the generated code, removing
16639  unwanted comments and some ':'.
16640  Then add 
16641 \begin_inset Quotes sld
16642 \end_inset
16643
16644
16645 \series bold
16646 _asm
16647 \series default
16648
16649 \begin_inset Quotes srd
16650 \end_inset
16651
16652  and 
16653 \begin_inset Quotes sld
16654 \end_inset
16655
16656
16657 \series bold
16658 _endasm;
16659 \series default
16660
16661 \begin_inset Quotes srd
16662 \end_inset
16663
16664
16665 \begin_inset Foot
16666 status open
16667
16668 \begin_layout Standard
16669 Note, that the single underscore form (_asm and _endasm) are not C99-compatible,
16670  and for C-99 compatibility, the double-underscore form (__asm and __endasm)
16671  has to be used.
16672  The latter is also used in the library functions.
16673 \end_layout
16674
16675 \end_inset
16676
16677  to the beginning and the end of the function body:
16678 \end_layout
16679
16680 \begin_layout Verse
16681
16682 \family typewriter
16683 \size footnotesize
16684 /* With a cut and paste from the .asm file, we have something to start with.
16685 \newline
16686 \InsetSpace ~
16687 \InsetSpace ~
16688 \InsetSpace ~
16689 The
16690  function is not yet OK! (registers aren't saved) */ 
16691 \newline
16692 void to_buffer_asm(
16693  unsigned char c ) 
16694 \newline
16695
16696 \newline
16697 \InsetSpace ~
16698 \InsetSpace ~
16699 \InsetSpace ~
16700 \InsetSpace ~
16701 _asm
16702 \begin_inset LatexCommand \index{\\_asm}
16703
16704 \end_inset
16705
16706
16707 \begin_inset LatexCommand \index{\\_\\_asm}
16708
16709 \end_inset
16710
16711
16712 \newline
16713 \InsetSpace ~
16714 \InsetSpace ~
16715 \InsetSpace ~
16716 \InsetSpace ~
16717 mov\InsetSpace ~
16718 \InsetSpace ~
16719 r2,dpl 
16720 \newline
16721 ;buffer.c if( head != (unsigned char)(tail-1) ) \InsetSpace ~
16722 /* cast
16723 \family default
16724  
16725 \family typewriter
16726 \series bold
16727 needed
16728 \family default
16729 \series default
16730  
16731 \family typewriter
16732 to avoid promotion
16733 \begin_inset LatexCommand \index{promotion to signed int}
16734
16735 \end_inset
16736
16737
16738 \begin_inset LatexCommand \index{type promotion}
16739
16740 \end_inset
16741
16742  to integer */
16743 \newline
16744 \InsetSpace ~
16745 \InsetSpace ~
16746 \InsetSpace ~
16747 \InsetSpace ~
16748 mov\InsetSpace ~
16749 \InsetSpace ~
16750 a,_tail 
16751 \newline
16752 \InsetSpace ~
16753 \InsetSpace ~
16754 \InsetSpace ~
16755 \InsetSpace ~
16756 dec\InsetSpace ~
16757 \InsetSpace ~
16758
16759 \newline
16760 \InsetSpace ~
16761 \InsetSpace ~
16762 \InsetSpace ~
16763 \InsetSpace ~
16764 mov\InsetSpace ~
16765 \InsetSpace ~
16766 r3,a 
16767 \newline
16768 \InsetSpace ~
16769 \InsetSpace ~
16770 \InsetSpace ~
16771 \InsetSpace ~
16772 mov\InsetSpace ~
16773 \InsetSpace ~
16774 a,_head 
16775 \newline
16776 \InsetSpace ~
16777 \InsetSpace ~
16778 \InsetSpace ~
16779 \InsetSpace ~
16780 cjne a,ar3,00106$ 
16781 \newline
16782 \InsetSpace ~
16783 \InsetSpace ~
16784 \InsetSpace ~
16785 \InsetSpace ~
16786 ret
16787 \newline
16788 00106$:
16789  
16790 \newline
16791 ;buffer.c buf[ head++ ] = c; /* access to a 256 byte aligned array */
16792 \begin_inset LatexCommand \index{Aligned array}
16793
16794 \end_inset
16795
16796
16797 \newline
16798 \InsetSpace ~
16799 \InsetSpace ~
16800 \InsetSpace ~
16801 \InsetSpace ~
16802 mov\InsetSpace ~
16803 \InsetSpace ~
16804 r3,_head 
16805 \newline
16806 \InsetSpace ~
16807 \InsetSpace ~
16808 \InsetSpace ~
16809 \InsetSpace ~
16810 inc\InsetSpace ~
16811 \InsetSpace ~
16812 _head 
16813 \newline
16814 \InsetSpace ~
16815 \InsetSpace ~
16816 \InsetSpace ~
16817 \InsetSpace ~
16818 mov\InsetSpace ~
16819 \InsetSpace ~
16820 dpl,r3 
16821 \newline
16822 \InsetSpace ~
16823 \InsetSpace ~
16824 \InsetSpace ~
16825 \InsetSpace ~
16826 mov\InsetSpace ~
16827 \InsetSpace ~
16828 dph,#(_buf >> 8) 
16829 \newline
16830 \InsetSpace ~
16831 \InsetSpace ~
16832 \InsetSpace ~
16833 \InsetSpace ~
16834 mov\InsetSpace ~
16835 \InsetSpace ~
16836 a,r2 
16837 \newline
16838 \InsetSpace ~
16839 \InsetSpace ~
16840 \InsetSpace ~
16841 \InsetSpace ~
16842 movx @dptr,a
16843  
16844 \newline
16845 00103$: 
16846 \newline
16847 \InsetSpace ~
16848 \InsetSpace ~
16849 \InsetSpace ~
16850 \InsetSpace ~
16851 ret
16852 \newline
16853 \InsetSpace ~
16854 \InsetSpace ~
16855 \InsetSpace ~
16856 \InsetSpace ~
16857 _endasm
16858 \begin_inset LatexCommand \index{\\_endasm}
16859
16860 \end_inset
16861
16862
16863 \begin_inset LatexCommand \index{\\_\\_endasm}
16864
16865 \end_inset
16866
16867 ;
16868 \newline
16869
16870 \end_layout
16871
16872 \begin_layout Standard
16873 The new file buffer.c should compile with only one warning about the unreferenced
16874  function argument 'c'.
16875  Now we hand-optimize the assembly code and insert an #define USE_ASSEMBLY
16876  (1) and finally have:
16877 \end_layout
16878
16879 \begin_layout Verse
16880
16881 \family typewriter
16882 \size footnotesize
16883 unsigned char __far __at(0x7f00) buf[0x100];
16884 \newline
16885 unsigned char head, tail;
16886 \newline
16887 #define
16888  USE_ASSEMBLY (1)
16889 \newline
16890
16891 \newline
16892 #if !USE_ASSEMBLY
16893 \newline
16894
16895 \newline
16896 void to_buffer( unsigned char c )
16897 \newline
16898 {
16899 \newline
16900 \InsetSpace ~
16901 \InsetSpace ~
16902 \InsetSpace ~
16903 \InsetSpace ~
16904 if(
16905  head != (unsigned char)(tail-1) )
16906 \newline
16907 \InsetSpace ~
16908 \InsetSpace ~
16909 \InsetSpace ~
16910 \InsetSpace ~
16911 \InsetSpace ~
16912 \InsetSpace ~
16913 \InsetSpace ~
16914 \InsetSpace ~
16915 buf[ head++ ] = c;
16916 \newline
16917 }
16918 \newline
16919
16920 \newline
16921 #else
16922 \newline
16923
16924 \newline
16925 void to_buffer(
16926  unsigned char c )
16927 \newline
16928 {
16929 \newline
16930 \InsetSpace ~
16931 \InsetSpace ~
16932 \InsetSpace ~
16933 \InsetSpace ~
16934 c; // to avoid warning: unreferenced function argument
16935 \newline
16936 \InsetSpace ~
16937 \InsetSpace ~
16938 \InsetSpace ~
16939 \InsetSpace ~
16940 _asm
16941 \begin_inset LatexCommand \index{\\_asm}
16942
16943 \end_inset
16944
16945
16946 \begin_inset LatexCommand \index{\\_\\_asm}
16947
16948 \end_inset
16949
16950
16951 \newline
16952 \InsetSpace ~
16953 \InsetSpace ~
16954 \InsetSpace ~
16955 \InsetSpace ~
16956 \InsetSpace ~
16957 \InsetSpace ~
16958 \InsetSpace ~
16959 \InsetSpace ~
16960 ; save used registers here.
16961  
16962 \newline
16963 \InsetSpace ~
16964 \InsetSpace ~
16965 \InsetSpace ~
16966 \InsetSpace ~
16967 \InsetSpace ~
16968 \InsetSpace ~
16969 \InsetSpace ~
16970 \InsetSpace ~
16971 ; If we were still using r2,r3 we would have to push them here.
16972  
16973 \newline
16974 ; if( head != (unsigned char)(tail-1) )
16975 \newline
16976 \InsetSpace ~
16977 \InsetSpace ~
16978 \InsetSpace ~
16979 \InsetSpace ~
16980 \InsetSpace ~
16981 \InsetSpace ~
16982 \InsetSpace ~
16983 \InsetSpace ~
16984 mov\InsetSpace ~
16985  a,_tail
16986 \newline
16987 \InsetSpace ~
16988 \InsetSpace ~
16989 \InsetSpace ~
16990 \InsetSpace ~
16991 \InsetSpace ~
16992 \InsetSpace ~
16993 \InsetSpace ~
16994 \InsetSpace ~
16995 dec\InsetSpace ~
16996  a
16997 \newline
16998 \InsetSpace ~
16999 \InsetSpace ~
17000 \InsetSpace ~
17001 \InsetSpace ~
17002 \InsetSpace ~
17003 \InsetSpace ~
17004 \InsetSpace ~
17005 \InsetSpace ~
17006 xrl\InsetSpace ~
17007  a,_head
17008 \newline
17009 \InsetSpace ~
17010 \InsetSpace ~
17011 \InsetSpace ~
17012 \InsetSpace ~
17013 \InsetSpace ~
17014 \InsetSpace ~
17015 \InsetSpace ~
17016 \InsetSpace ~
17017 ; we
17018  could do an ANL a,#0x0f here to use a smaller buffer (see below)
17019 \newline
17020 \InsetSpace ~
17021 \InsetSpace ~
17022 \InsetSpace ~
17023 \InsetSpace ~
17024 \InsetSpace ~
17025 \InsetSpace ~
17026 \InsetSpace ~
17027 \InsetSpace ~
17028 jz\InsetSpace ~
17029 \InsetSpace ~
17030  t_b_end$
17031 \newline
17032 \InsetSpace ~
17033 \InsetSpace ~
17034 \InsetSpace ~
17035 \InsetSpace ~
17036 \InsetSpace ~
17037 \InsetSpace ~
17038 \InsetSpace ~
17039 \InsetSpace ~
17040 ;
17041 \newline
17042 ;
17043  buf[ head++ ] = c;
17044 \newline
17045 \InsetSpace ~
17046 \InsetSpace ~
17047 \InsetSpace ~
17048 \InsetSpace ~
17049 \InsetSpace ~
17050 \InsetSpace ~
17051 \InsetSpace ~
17052 \InsetSpace ~
17053 mov\InsetSpace ~
17054  a,dpl \InsetSpace ~
17055 \InsetSpace ~
17056 \InsetSpace ~
17057 \InsetSpace ~
17058 \InsetSpace ~
17059 \InsetSpace ~
17060 \InsetSpace ~
17061 ; dpl holds lower byte of function argument
17062 \newline
17063 \InsetSpace ~
17064 \InsetSpace ~
17065 \InsetSpace ~
17066 \InsetSpace ~
17067 \InsetSpace ~
17068 \InsetSpace ~
17069 \InsetSpace ~
17070 \InsetSpace ~
17071 mov\InsetSpace ~
17072
17073  dpl,_head \InsetSpace ~
17074 \InsetSpace ~
17075 \InsetSpace ~
17076 ; buf is 0x100 byte aligned so head can be used directly
17077 \newline
17078 \InsetSpace ~
17079 \InsetSpace ~
17080 \InsetSpace ~
17081 \InsetSpace ~
17082 \InsetSpace ~
17083 \InsetSpace ~
17084 \InsetSpace ~
17085 \InsetSpace ~
17086 mov\InsetSpace ~
17087  dph,#(_bu
17088 f>>8)
17089 \newline
17090 \InsetSpace ~
17091 \InsetSpace ~
17092 \InsetSpace ~
17093 \InsetSpace ~
17094 \InsetSpace ~
17095 \InsetSpace ~
17096 \InsetSpace ~
17097 \InsetSpace ~
17098 movx @dptr,a
17099 \newline
17100 \InsetSpace ~
17101 \InsetSpace ~
17102 \InsetSpace ~
17103 \InsetSpace ~
17104 \InsetSpace ~
17105 \InsetSpace ~
17106 \InsetSpace ~
17107 \InsetSpace ~
17108 inc \InsetSpace ~
17109 _head
17110 \newline
17111 \InsetSpace ~
17112 \InsetSpace ~
17113 \InsetSpace ~
17114 \InsetSpace ~
17115 \InsetSpace ~
17116 \InsetSpace ~
17117 \InsetSpace ~
17118 \InsetSpace ~
17119 ; we could do an ANL _head,#0x0f here to use a
17120  smaller buffer (see above)
17121 \newline
17122 t_b_end$:
17123 \newline
17124 \InsetSpace ~
17125 \InsetSpace ~
17126 \InsetSpace ~
17127 \InsetSpace ~
17128 \InsetSpace ~
17129 \InsetSpace ~
17130 \InsetSpace ~
17131 \InsetSpace ~
17132 ; restore used registers here 
17133 \newline
17134 \InsetSpace ~
17135 \InsetSpace ~
17136 \InsetSpace ~
17137 \InsetSpace ~
17138 _endasm
17139 \begin_inset LatexCommand \index{\\_endasm}
17140
17141 \end_inset
17142
17143
17144 \begin_inset LatexCommand \index{\\_\\_endasm}
17145
17146 \end_inset
17147
17148 ;
17149 \newline
17150 }
17151 \newline
17152 #endif
17153 \end_layout
17154
17155 \begin_layout Standard
17156 The inline assembler code can contain any valid code understood by the assembler
17157 , this includes any assembler directives and comment lines.
17158  The assembler does not like some characters like ':' or ''' in comments.
17159  You'll find an 100+ pages assembler manual in sdcc/as/doc/asxhtm.html
17160 \begin_inset LatexCommand \index{asXXXX (as-gbz80, as-hc08, asx8051, as-z80)}
17161
17162 \end_inset
17163
17164
17165 \begin_inset LatexCommand \index{Assembler documentation}
17166
17167 \end_inset
17168
17169  or online at 
17170 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/as/doc/asxhtm.html}
17171
17172 \end_inset
17173
17174 \InsetSpace ~
17175 .
17176 \end_layout
17177
17178 \begin_layout Standard
17179 The compiler does not do any validation of the code within the 
17180 \family typewriter
17181 _asm
17182 \begin_inset LatexCommand \index{\\_asm}
17183
17184 \end_inset
17185
17186
17187 \begin_inset LatexCommand \index{\\_\\_asm}
17188
17189 \end_inset
17190
17191  ...
17192  _endasm
17193 \size footnotesize
17194
17195 \begin_inset LatexCommand \index{\\_endasm}
17196
17197 \end_inset
17198
17199
17200 \begin_inset LatexCommand \index{\\_\\_endasm}
17201
17202 \end_inset
17203
17204
17205 \size default
17206 ;
17207 \family default
17208  keyword pair.
17209  Specifically it will not know which registers are used and thus register
17210  pushing/popping
17211 \begin_inset LatexCommand \index{push/pop}
17212
17213 \end_inset
17214
17215  has to be done manually.
17216  
17217 \end_layout
17218
17219 \begin_layout Standard
17220 It is recommended that each assembly instruction (including labels) be placed
17221  in a separate line (as the example shows).
17222  When the -
17223 \begin_inset ERT
17224 status collapsed
17225
17226 \begin_layout Standard
17227
17228
17229 \backslash
17230 /
17231 \end_layout
17232
17233 \end_inset
17234
17235 -
17236 \emph on
17237 peep-asm
17238 \begin_inset LatexCommand \index{-\\/-peep-asm}
17239
17240 \end_inset
17241
17242
17243 \emph default
17244  command line option is used, the inline assembler code will be passed through
17245  the peephole optimizer
17246 \begin_inset LatexCommand \index{Peephole optimizer}
17247
17248 \end_inset
17249
17250 .
17251  There are only a few (if any) cases where this option makes sense, it might
17252  cause some unexpected changes in the inline assembler code.
17253  Please go through the peephole optimizer rules defined in file 
17254 \emph on
17255 SDCCpeeph.def
17256 \emph default
17257  before using this option.
17258 \end_layout
17259
17260 \begin_layout Subsection
17261 Naked Functions
17262 \begin_inset LatexCommand \label{sub:Naked-Functions}
17263
17264 \end_inset
17265
17266
17267 \begin_inset LatexCommand \index{Naked functions}
17268
17269 \end_inset
17270
17271
17272 \end_layout
17273
17274 \begin_layout Standard
17275 A special keyword may be associated with a function declaring it as 
17276 \emph on
17277 _naked
17278 \begin_inset LatexCommand \index{\\_naked}
17279
17280 \end_inset
17281
17282
17283 \begin_inset LatexCommand \index{\\_\\_naked}
17284
17285 \end_inset
17286
17287 .
17288
17289 \emph default
17290  The 
17291 \emph on
17292 _naked
17293 \emph default
17294  function modifier attribute prevents the compiler from generating prologue
17295 \begin_inset LatexCommand \index{function prologue}
17296
17297 \end_inset
17298
17299  and epilogue
17300 \begin_inset LatexCommand \index{function epilogue}
17301
17302 \end_inset
17303
17304  code for that function.
17305  This means that the user is entirely responsible for such things as saving
17306  any registers that may need to be preserved, selecting the proper register
17307  bank, generating the 
17308 \emph on
17309 return
17310 \emph default
17311  instruction at the end, etc.
17312  Practically, this means that the contents of the function must be written
17313  in inline assembler.
17314  This is particularly useful for interrupt functions, which can have a large
17315  (and often unnecessary) prologue/epilogue.
17316  For example, compare the code generated by these two functions:
17317 \end_layout
17318
17319 \begin_layout Verse
17320
17321 \family typewriter
17322 volatile
17323 \begin_inset LatexCommand \index{volatile}
17324
17325 \end_inset
17326
17327  data unsigned char counter;
17328 \newline
17329
17330 \newline
17331 void simpleInterrupt(void) __interrupt
17332 \begin_inset LatexCommand \index{interrupt}
17333
17334 \end_inset
17335
17336
17337 \begin_inset LatexCommand \index{\\_\\_interrupt}
17338
17339 \end_inset
17340
17341  (1)
17342 \newline
17343 {
17344 \newline
17345 \InsetSpace ~
17346 \InsetSpace ~
17347 \InsetSpace ~
17348 \InsetSpace ~
17349 counter++;
17350 \newline
17351 }
17352 \newline
17353
17354 \newline
17355 void nakedInterrupt(void) __interrupt (2) __naked
17356 \newline
17357 {
17358 \newline
17359 \InsetSpace ~
17360 \InsetSpace ~
17361 \InsetSpace ~
17362 \InsetSpace ~
17363 _asm
17364 \begin_inset LatexCommand \index{\\_asm}
17365
17366 \end_inset
17367
17368
17369 \begin_inset LatexCommand \index{\\_\\_asm}
17370
17371 \end_inset
17372
17373
17374 \newline
17375 \InsetSpace ~
17376 \InsetSpace ~
17377 \InsetSpace ~
17378 \InsetSpace ~
17379 \InsetSpace ~
17380 \InsetSpace ~
17381 inc\InsetSpace ~
17382 \InsetSpace ~
17383 \InsetSpace ~
17384 \InsetSpace ~
17385 \InsetSpace ~
17386 _counter ; does not change flags, no need to save psw
17387 \newline
17388 \InsetSpace ~
17389 \InsetSpace ~
17390 \InsetSpace ~
17391 \InsetSpace ~
17392 \InsetSpace ~
17393 \InsetSpace ~
17394 reti\InsetSpace ~
17395 \InsetSpace ~
17396 \InsetSpace ~
17397 \InsetSpace ~
17398 ; MUST explicitly
17399  include ret or reti in _naked function.
17400 \newline
17401 \InsetSpace ~
17402 \InsetSpace ~
17403 \InsetSpace ~
17404 \InsetSpace ~
17405 _endasm
17406 \begin_inset LatexCommand \index{\\_endasm}
17407
17408 \end_inset
17409
17410
17411 \begin_inset LatexCommand \index{\\_\\_endasm}
17412
17413 \end_inset
17414
17415 ;
17416 \newline
17417 }
17418 \end_layout
17419
17420 \begin_layout Standard
17421 For an 8051 target, the generated simpleInterrupt looks like:
17422 \end_layout
17423
17424 \begin_layout Verse
17425
17426 \family typewriter
17427 Note, this is an
17428 \family default
17429  
17430 \family typewriter
17431 \emph on
17432 outdated
17433 \family default
17434 \emph default
17435  
17436 \family typewriter
17437 example, recent versions of SDCC generate
17438 \newline
17439 the
17440 \family default
17441  
17442 \family typewriter
17443 \emph on
17444 same
17445 \family default
17446 \emph default
17447  
17448 \family typewriter
17449 code for simpleInterrupt() and nakedInterrupt()!
17450 \newline
17451
17452 \newline
17453 _simpleInterrupt:
17454 \newline
17455 \InsetSpace ~
17456 \InsetSpace ~
17457 \InsetSpace ~
17458 \InsetSpace ~
17459 push\InsetSpace ~
17460 \InsetSpace ~
17461 \InsetSpace ~
17462 \InsetSpace ~
17463 acc
17464 \newline
17465 \InsetSpace ~
17466 \InsetSpace ~
17467 \InsetSpace ~
17468 \InsetSpace ~
17469 push\InsetSpace ~
17470 \InsetSpace ~
17471 \InsetSpace ~
17472 \InsetSpace ~
17473 b
17474 \newline
17475 \InsetSpace ~
17476 \InsetSpace ~
17477 \InsetSpace ~
17478 \InsetSpace ~
17479 pus
17480 h\InsetSpace ~
17481 \InsetSpace ~
17482 \InsetSpace ~
17483 \InsetSpace ~
17484 dpl
17485 \newline
17486 \InsetSpace ~
17487 \InsetSpace ~
17488 \InsetSpace ~
17489 \InsetSpace ~
17490 push\InsetSpace ~
17491 \InsetSpace ~
17492 \InsetSpace ~
17493 \InsetSpace ~
17494 dph
17495 \newline
17496 \InsetSpace ~
17497 \InsetSpace ~
17498 \InsetSpace ~
17499 \InsetSpace ~
17500 push\InsetSpace ~
17501 \InsetSpace ~
17502 \InsetSpace ~
17503 \InsetSpace ~
17504 psw
17505 \newline
17506 \InsetSpace ~
17507 \InsetSpace ~
17508 \InsetSpace ~
17509 \InsetSpace ~
17510 mov\InsetSpace ~
17511 \InsetSpace ~
17512 \InsetSpace ~
17513 \InsetSpace ~
17514 \InsetSpace ~
17515 psw,#0x00
17516 \newline
17517 \InsetSpace ~
17518 \InsetSpace ~
17519 \InsetSpace ~
17520 \InsetSpace ~
17521 inc\InsetSpace ~
17522 \InsetSpace ~
17523 \InsetSpace ~
17524 \InsetSpace ~
17525 \InsetSpace ~
17526 _counter
17527 \newline
17528 \InsetSpace ~
17529 \InsetSpace ~
17530 \InsetSpace ~
17531 \InsetSpace ~
17532 pop\InsetSpace ~
17533 \InsetSpace ~
17534 \InsetSpace ~
17535 \InsetSpace ~
17536 \InsetSpace ~
17537 psw
17538 \newline
17539 \InsetSpace ~
17540 \InsetSpace ~
17541 \InsetSpace ~
17542 \InsetSpace ~
17543 pop\InsetSpace ~
17544 \InsetSpace ~
17545 \InsetSpace ~
17546 \InsetSpace ~
17547 \InsetSpace ~
17548 dph
17549 \newline
17550 \InsetSpace ~
17551 \InsetSpace ~
17552 \InsetSpace ~
17553 \InsetSpace ~
17554 pop\InsetSpace ~
17555 \InsetSpace ~
17556 \InsetSpace ~
17557 \InsetSpace ~
17558 \InsetSpace ~
17559 dpl
17560 \newline
17561 \InsetSpace ~
17562 \InsetSpace ~
17563 \InsetSpace ~
17564 \InsetSpace ~
17565 pop\InsetSpace ~
17566 \InsetSpace ~
17567 \InsetSpace ~
17568 \InsetSpace ~
17569 \InsetSpace ~
17570 b
17571 \newline
17572 \InsetSpace ~
17573 \InsetSpace ~
17574 \InsetSpace ~
17575 \InsetSpace ~
17576 pop\InsetSpace ~
17577 \InsetSpace ~
17578 \InsetSpace ~
17579 \InsetSpace ~
17580 \InsetSpace ~
17581 acc
17582 \newline
17583 \InsetSpace ~
17584 \InsetSpace ~
17585 \InsetSpace ~
17586 \InsetSpace ~
17587 reti
17588 \end_layout
17589
17590 \begin_layout Standard
17591 whereas nakedInterrupt looks like:
17592 \end_layout
17593
17594 \begin_layout Verse
17595
17596 \family typewriter
17597 _nakedInterrupt:
17598 \newline
17599 \InsetSpace ~
17600 \InsetSpace ~
17601 \InsetSpace ~
17602 \InsetSpace ~
17603 inc\InsetSpace ~
17604 \InsetSpace ~
17605 \InsetSpace ~
17606 \InsetSpace ~
17607 _counter ; does not change flags, no need to save psw
17608 \newline
17609 \InsetSpace ~
17610 \InsetSpace ~
17611 \InsetSpace ~
17612 \InsetSpace ~
17613 reti\InsetSpace ~
17614 \InsetSpace ~
17615 \InsetSpace ~
17616 \InsetSpace ~
17617 \InsetSpace ~
17618 \InsetSpace ~
17619 \InsetSpace ~
17620 \InsetSpace ~
17621 \InsetSpace ~
17622 \InsetSpace ~
17623 \InsetSpace ~
17624 \InsetSpace ~
17625 ;
17626  MUST explicitly include ret or reti in _naked function
17627 \end_layout
17628
17629 \begin_layout Standard
17630 The related directive #pragma exclude
17631 \begin_inset LatexCommand \index{\\#pragma exclude}
17632
17633 \end_inset
17634
17635  allows a more fine grained control over pushing & popping
17636 \begin_inset LatexCommand \index{push/pop}
17637
17638 \end_inset
17639
17640  the registers.
17641 \end_layout
17642
17643 \begin_layout Standard
17644 While there is nothing preventing you from writing C code inside a 
17645 \family typewriter
17646 _naked
17647 \family default
17648  function, there are many ways to shoot yourself in the foot doing this,
17649  and it is recommended that you stick to inline assembler.
17650 \end_layout
17651
17652 \begin_layout Subsection
17653 Use of Labels within Inline Assembler
17654 \end_layout
17655
17656 \begin_layout Standard
17657 SDCC allows the use of in-line assembler with a few restrictions regarding
17658  labels.
17659  All labels defined within inline assembler code have to be of the form
17660  
17661 \emph on
17662 nnnnn$
17663 \emph default
17664  where nnnnn is a number less than 100 (which implies a limit of utmost
17665  100 inline assembler labels 
17666 \emph on
17667 per function
17668 \emph default
17669 \noun on
17670 )
17671 \noun default
17672 .
17673 \begin_inset Foot
17674 status open
17675
17676 \begin_layout Standard
17677 This is a slightly more stringent rule than absolutely necessary, but stays
17678  always on the safe side.
17679  Labels in the form of nnnnn$ are local labels in the assembler, locality
17680  of which is confined within two labels of the standard form.
17681  The compiler uses the same form for labels within a function (but starting
17682  from nnnnn=00100); and places always a standard label at the beginning
17683  of a function, thus limiting the locality of labels within the scope of
17684  the function.
17685  So, if the inline assembler part would be embedded into C-code, an improperly
17686  placed non-local label in the assembler would break up the reference space
17687  for labels created by the compiler for the C-code, leading to an assembling
17688  error.
17689 \end_layout
17690
17691 \begin_layout Standard
17692 The numeric part of local labels does not need to have 5 digits (although
17693  this is the form of labels output by the compiler), any valid integer will
17694  do.
17695  Please refer to the assemblers documentation for further details.
17696 \end_layout
17697
17698 \end_inset
17699
17700  
17701 \end_layout
17702
17703 \begin_layout Verse
17704
17705 \family typewriter
17706 _asm
17707 \begin_inset LatexCommand \index{\\_asm}
17708
17709 \end_inset
17710
17711
17712 \begin_inset LatexCommand \index{\\_\\_asm}
17713
17714 \end_inset
17715
17716  
17717 \newline
17718 \InsetSpace ~
17719 \InsetSpace ~
17720 \InsetSpace ~
17721 \InsetSpace ~
17722 mov\InsetSpace ~
17723 \InsetSpace ~
17724 \InsetSpace ~
17725 \InsetSpace ~
17726 \InsetSpace ~
17727 b,#10 
17728 \newline
17729 00001$: 
17730 \newline
17731 \InsetSpace ~
17732 \InsetSpace ~
17733 \InsetSpace ~
17734 \InsetSpace ~
17735 djnz\InsetSpace ~
17736 \InsetSpace ~
17737 \InsetSpace ~
17738 \InsetSpace ~
17739 b,00001$ 
17740 \newline
17741 _endasm
17742 \begin_inset LatexCommand \index{\\_endasm}
17743
17744 \end_inset
17745
17746
17747 \begin_inset LatexCommand \index{\\_\\_endasm}
17748
17749 \end_inset
17750
17751  ;
17752 \end_layout
17753
17754 \begin_layout Standard
17755 Inline assembler code cannot reference any C-labels, however it can reference
17756  labels
17757 \begin_inset LatexCommand \index{Labels}
17758
17759 \end_inset
17760
17761  defined by the inline assembler, e.g.:
17762 \end_layout
17763
17764 \begin_layout Verse
17765
17766 \family typewriter
17767 foo() { 
17768 \newline
17769 \InsetSpace ~
17770 \InsetSpace ~
17771 \InsetSpace ~
17772 \InsetSpace ~
17773 /* some c code */ 
17774 \newline
17775 \InsetSpace ~
17776 \InsetSpace ~
17777 \InsetSpace ~
17778 \InsetSpace ~
17779 _asm 
17780 \newline
17781 \InsetSpace ~
17782 \InsetSpace ~
17783 \InsetSpace ~
17784 \InsetSpace ~
17785 \InsetSpace ~
17786 \InsetSpace ~
17787 ; some assembler code 
17788 \newline
17789 \InsetSpace ~
17790 \InsetSpace ~
17791 \InsetSpace ~
17792 \InsetSpace ~
17793 \InsetSpace ~
17794 \InsetSpace ~
17795 ljmp 0003$ 
17796 \newline
17797 \InsetSpace ~
17798 \InsetSpace ~
17799 \InsetSpace ~
17800 \InsetSpace ~
17801 _endasm;
17802  
17803 \newline
17804 \InsetSpace ~
17805 \InsetSpace ~
17806 \InsetSpace ~
17807 \InsetSpace ~
17808 /* some more c code */ 
17809 \newline
17810 clabel:\InsetSpace ~
17811 \InsetSpace ~
17812 /* inline assembler cannot reference this
17813  label */ 
17814 \begin_inset Foot
17815 status open
17816
17817 \begin_layout Standard
17818 Here, the C-label 
17819 \family typewriter
17820 clabel
17821 \family default
17822  is translated by the compiler into a local label, so the locality of labels
17823  within the function is not broken.
17824 \end_layout
17825
17826 \end_inset
17827
17828
17829 \newline
17830 \InsetSpace ~
17831 \InsetSpace ~
17832 \InsetSpace ~
17833 \InsetSpace ~
17834 _asm
17835 \newline
17836 \InsetSpace ~
17837 \InsetSpace ~
17838 \InsetSpace ~
17839 \InsetSpace ~
17840 0003$: ;label (can be referenced by inline assembler only) 
17841 \newline
17842 \InsetSpace ~
17843 \InsetSpace ~
17844 \InsetSpace ~
17845 \InsetSpace ~
17846 _endasm
17847 \begin_inset LatexCommand \index{\\_endasm}
17848
17849 \end_inset
17850
17851
17852 \begin_inset LatexCommand \index{\\_\\_endasm}
17853
17854 \end_inset
17855
17856  ; 
17857 \newline
17858 \InsetSpace ~
17859 \InsetSpace ~
17860 \InsetSpace ~
17861 \InsetSpace ~
17862 /* some more c code */
17863 \newline
17864 }
17865 \end_layout
17866
17867 \begin_layout Standard
17868 In other words inline assembly code can access labels defined in inline
17869  assembly within the scope of the function.
17870  The same goes the other way, i.e.
17871  labels defines in inline assembly can not be accessed by C statements.
17872 \end_layout
17873
17874 \begin_layout Section
17875 Interfacing with Assembler Code
17876 \begin_inset LatexCommand \index{Assembler routines}
17877
17878 \end_inset
17879
17880
17881 \end_layout
17882
17883 \begin_layout Subsection
17884 Global Registers used for Parameter Passing
17885 \begin_inset LatexCommand \index{Parameter passing}
17886
17887 \end_inset
17888
17889
17890 \end_layout
17891
17892 \begin_layout Standard
17893 The compiler always uses the global registers 
17894 \emph on
17895 DPL, DPH
17896 \begin_inset LatexCommand \index{DPTR, DPH, DPL}
17897
17898 \end_inset
17899
17900
17901 \begin_inset LatexCommand \index{DPTR}
17902
17903 \end_inset
17904
17905 , B
17906 \begin_inset LatexCommand \index{B (mcs51, ds390 register)}
17907
17908 \end_inset
17909
17910
17911 \emph default
17912  and 
17913 \emph on
17914 ACC
17915 \begin_inset LatexCommand \index{ACC (mcs51, ds390 register)}
17916
17917 \end_inset
17918
17919
17920 \emph default
17921  to pass the first (non-bit) parameter to a function, and also to pass the
17922  return value 
17923 \begin_inset LatexCommand \index{return value}
17924
17925 \end_inset
17926
17927 of function; according to the following scheme: one byte return value in
17928  
17929 \emph on
17930 DPL
17931 \emph default
17932 , two byte value in 
17933 \emph on
17934 DPL
17935 \emph default
17936  (LSB) and 
17937 \emph on
17938 DPH
17939 \emph default
17940  (MSB).
17941  three byte values (generic pointers) in 
17942 \emph on
17943 DPH
17944 \emph default
17945
17946 \emph on
17947 DPL
17948 \emph default
17949  and 
17950 \emph on
17951 B
17952 \emph default
17953 , and four byte values in 
17954 \emph on
17955 DPH
17956 \emph default
17957
17958 \emph on
17959 DPL
17960 \emph default
17961
17962 \emph on
17963 B
17964 \emph default
17965  and 
17966 \emph on
17967 ACC
17968 \emph default
17969 .
17970  Generic pointers
17971 \begin_inset LatexCommand \index{generic pointer}
17972
17973 \end_inset
17974
17975  contain type of accessed memory in 
17976 \emph on
17977 B
17978 \emph default
17979
17980 \series bold
17981 0x00
17982 \series default
17983  -- xdata/far, 
17984 \series bold
17985 0x40
17986 \series default
17987  -- idata/near -- , 
17988 \series bold
17989 0x60
17990 \series default
17991  -- pdata, 
17992 \series bold
17993 0x80
17994 \series default
17995  -- code
17996 \begin_inset Note Note
17997 status collapsed
17998
17999 \begin_layout Standard
18000 This might not be the case of certain memory models (medium???)
18001 \end_layout
18002
18003 \end_inset
18004
18005 .
18006 \end_layout
18007
18008 \begin_layout Standard
18009 The second parameter onwards is either allocated on the stack (for reentrant
18010  routines or if -
18011 \begin_inset ERT
18012 status collapsed
18013
18014 \begin_layout Standard
18015
18016
18017 \backslash
18018 /
18019 \end_layout
18020
18021 \end_inset
18022
18023 -stack-auto is used) or in data/xdata memory (depending on the memory model).
18024 \end_layout
18025
18026 \begin_layout Standard
18027 Bit parameters are passed in a virtual register called 'bits' in bit-addressable
18028  space for reentrant functions or allocated directly in bit memory otherwise.
18029 \end_layout
18030
18031 \begin_layout Standard
18032 Functions (with two or more parameters or bit parameters) that are called
18033  through function pointers
18034 \begin_inset LatexCommand \index{function pointers}
18035
18036 \end_inset
18037
18038  must therefor be reentrant so the compiler knows how to pass the parameters.
18039 \end_layout
18040
18041 \begin_layout Subsection
18042 Registers usage
18043 \end_layout
18044
18045 \begin_layout Standard
18046 Unless the called function is declared as 
18047 \family typewriter
18048 _naked
18049 \family default
18050
18051 \begin_inset LatexCommand \index{naked}
18052
18053 \end_inset
18054
18055 , or the -
18056 \begin_inset ERT
18057 status collapsed
18058
18059 \begin_layout Standard
18060
18061
18062 \backslash
18063 /
18064 \end_layout
18065
18066 \end_inset
18067
18068 -callee-saves
18069 \begin_inset LatexCommand \index{-\\/-callee-saves}
18070
18071 \end_inset
18072
18073 /-
18074 \begin_inset ERT
18075 status collapsed
18076
18077 \begin_layout Standard
18078
18079
18080 \backslash
18081 /
18082 \end_layout
18083
18084 \end_inset
18085
18086 -all-callee-saves command line option or the corresponding callee_saves
18087  pragma are used, the caller will save the registers (
18088 \emph on
18089 R0-R7
18090 \emph default
18091 ) around the call, so the called function can destroy they content freely.
18092 \end_layout
18093
18094 \begin_layout Standard
18095 If the called function is not declared as 
18096 \family typewriter
18097 _naked
18098 \family default
18099 , the caller will swap register banks around the call, if caller and callee
18100  use different register banks (having them defined by the 
18101 \family typewriter
18102 _using
18103 \family default
18104  modifier).
18105  
18106 \end_layout
18107
18108 \begin_layout Standard
18109 The called function can also use 
18110 \emph on
18111 DPL
18112 \emph default
18113
18114 \emph on
18115 DPH
18116 \emph default
18117
18118 \emph on
18119 B
18120 \emph default
18121  and 
18122 \emph on
18123 ACC
18124 \emph default
18125  observing that they are used for parameter/return value passing.
18126 \end_layout
18127
18128 \begin_layout Subsection
18129 Assembler Routine (non-reentrant)
18130 \end_layout
18131
18132 \begin_layout Standard
18133 In the following example
18134 \begin_inset LatexCommand \index{reentrant}
18135
18136 \end_inset
18137
18138
18139 \begin_inset LatexCommand \index{Assembler routines (non-reentrant)}
18140
18141 \end_inset
18142
18143  the function c_func calls an assembler routine asm_func, which takes two
18144  parameters
18145 \begin_inset LatexCommand \index{function parameter}
18146
18147 \end_inset
18148
18149 .
18150 \end_layout
18151
18152 \begin_layout Verse
18153
18154 \family typewriter
18155 extern int asm_func(unsigned char, unsigned char);
18156 \newline
18157
18158 \newline
18159 int c_func (unsigned char
18160  i, unsigned char j)
18161 \newline
18162 {
18163 \newline
18164 \InsetSpace ~
18165 \InsetSpace ~
18166 \InsetSpace ~
18167 \InsetSpace ~
18168 return asm_func(i,j);
18169 \newline
18170 }
18171 \newline
18172
18173 \newline
18174 int main()
18175 \newline
18176 {
18177 \newline
18178 \InsetSpace ~
18179 \InsetSpace ~
18180 \InsetSpace ~
18181 \InsetSpace ~
18182 return c_func(10,9);
18183 \newline
18184 }
18185 \end_layout
18186
18187 \begin_layout Standard
18188 The corresponding assembler function is:
18189 \end_layout
18190
18191 \begin_layout Verse
18192
18193 \family typewriter
18194 .globl _asm_func_PARM_2 
18195 \newline
18196 \InsetSpace ~
18197 \InsetSpace ~
18198 \InsetSpace ~
18199 \InsetSpace ~
18200 \InsetSpace ~
18201 \InsetSpace ~
18202 \InsetSpace ~
18203 \InsetSpace ~
18204 .globl _asm_func 
18205 \newline
18206 \InsetSpace ~
18207 \InsetSpace ~
18208 \InsetSpace ~
18209 \InsetSpace ~
18210 \InsetSpace ~
18211 \InsetSpace ~
18212 \InsetSpace ~
18213 \InsetSpace ~
18214 .area OSEG 
18215 \newline
18216 _asm_func_PARM_2:
18217 \newline
18218 \InsetSpace ~
18219 \InsetSpace ~
18220 \InsetSpace ~
18221 \InsetSpace ~
18222 \InsetSpace ~
18223 \InsetSpace ~
18224 \InsetSpace ~
18225 \InsetSpace ~
18226 .ds   
18227  1 
18228 \newline
18229 \InsetSpace ~
18230 \InsetSpace ~
18231 \InsetSpace ~
18232 \InsetSpace ~
18233 \InsetSpace ~
18234 \InsetSpace ~
18235 \InsetSpace ~
18236 \InsetSpace ~
18237 .area CSEG 
18238 \newline
18239 _asm_func: 
18240 \newline
18241 \InsetSpace ~
18242 \InsetSpace ~
18243 \InsetSpace ~
18244 \InsetSpace ~
18245 \InsetSpace ~
18246 \InsetSpace ~
18247 \InsetSpace ~
18248 \InsetSpace ~
18249 mov\InsetSpace ~
18250 \InsetSpace ~
18251 \InsetSpace ~
18252 \InsetSpace ~
18253 a,dpl 
18254 \newline
18255 \InsetSpace ~
18256 \InsetSpace ~
18257 \InsetSpace ~
18258 \InsetSpace ~
18259 \InsetSpace ~
18260 \InsetSpace ~
18261 \InsetSpace ~
18262 \InsetSpace ~
18263 add\InsetSpace ~
18264 \InsetSpace ~
18265 \InsetSpace ~
18266 \InsetSpace ~
18267 a,_asm_func_PARM_2 
18268 \newline
18269 \InsetSpace ~
18270 \InsetSpace ~
18271 \InsetSpace ~
18272 \InsetSpace ~
18273 \InsetSpace ~
18274 \InsetSpace ~
18275 \InsetSpace ~
18276 \InsetSpace ~
18277 mov\InsetSpace ~
18278 \InsetSpace ~
18279 \InsetSpace ~
18280 \InsetSpace ~
18281 dpl,a 
18282 \newline
18283 \InsetSpace ~
18284 \InsetSpace ~
18285 \InsetSpace ~
18286 \InsetSpace ~
18287 \InsetSpace ~
18288 \InsetSpace ~
18289 \InsetSpace ~
18290 \InsetSpace ~
18291 mov\InsetSpace ~
18292 \InsetSpace ~
18293 \InsetSpace ~
18294 \InsetSpace ~
18295 dph
18296 \begin_inset LatexCommand \index{DPTR, DPH, DPL}
18297
18298 \end_inset
18299
18300 ,#0x00 
18301 \newline
18302 \InsetSpace ~
18303 \InsetSpace ~
18304 \InsetSpace ~
18305 \InsetSpace ~
18306 \InsetSpace ~
18307 \InsetSpace ~
18308 \InsetSpace ~
18309 \InsetSpace ~
18310 ret
18311 \end_layout
18312
18313 \begin_layout Standard
18314 The parameter naming convention is _<function_name>_PARM_<n>, where n is
18315  the parameter number starting from 1, and counting from the left.
18316  The first parameter is passed in 
18317 \emph on
18318 DPH
18319 \emph default
18320
18321 \emph on
18322 DPL
18323 \emph default
18324
18325 \emph on
18326 B
18327 \emph default
18328  and 
18329 \emph on
18330 ACC
18331 \emph default
18332  according to the description above.
18333  The variable name for the second parameter will be _<function_name>_PARM_2.
18334 \newline
18335
18336 \newline
18337 Assem
18338 ble the assembler routine with the following command:
18339 \newline
18340
18341 \newline
18342
18343 \family sans
18344 \series bold
18345 asx8051 -losg asmfunc.asm
18346 \newline
18347
18348 \newline
18349
18350 \family default
18351 \series default
18352 Then compile and link the assembler routine to the C source file with the
18353  following command:
18354 \newline
18355
18356 \newline
18357
18358 \family sans
18359 \series bold
18360 sdcc cfunc.c asmfunc.rel
18361 \end_layout
18362
18363 \begin_layout Subsection
18364 Assembler Routine (reentrant)
18365 \end_layout
18366
18367 \begin_layout Standard
18368 In this case
18369 \begin_inset LatexCommand \index{reentrant}
18370
18371 \end_inset
18372
18373
18374 \begin_inset LatexCommand \index{Assembler routines (reentrant)}
18375
18376 \end_inset
18377
18378  the second parameter
18379 \begin_inset LatexCommand \index{function parameter}
18380
18381 \end_inset
18382
18383  onwards will be passed on the stack, the parameters are pushed from right
18384  to left i.e.
18385  before the call the second leftmost parameter will be on the top of the
18386  stack (the leftmost parameter is passed in registers).
18387  Here is an example:
18388 \end_layout
18389
18390 \begin_layout Verse
18391
18392 \family typewriter
18393 extern int asm_func(unsigned char, unsigned char, unsigned char) reentrant;
18394 \newline
18395
18396 \newline
18397 int
18398  c_func (unsigned char i, unsigned char j, unsigned char k) reentrant 
18399 \newline
18400 {
18401  
18402 \newline
18403 \InsetSpace ~
18404 \InsetSpace ~
18405 \InsetSpace ~
18406 \InsetSpace ~
18407 return asm_func(i,j,k); 
18408 \newline
18409
18410 \newline
18411
18412 \newline
18413 int main() 
18414 \newline
18415
18416 \newline
18417 \InsetSpace ~
18418 \InsetSpace ~
18419 \InsetSpace ~
18420 \InsetSpace ~
18421 return c_func(10,9,8); 
18422 \newline
18423 }
18424 \end_layout
18425
18426 \begin_layout Standard
18427 The corresponding (unoptimized) assembler routine is:
18428 \end_layout
18429
18430 \begin_layout Verse
18431
18432 \family typewriter
18433 .globl _asm_func 
18434 \newline
18435 _asm_func: 
18436 \newline
18437 \InsetSpace ~
18438 \InsetSpace ~
18439 \InsetSpace ~
18440 \InsetSpace ~
18441 push\InsetSpace ~
18442 _bp 
18443 \newline
18444 \InsetSpace ~
18445 \InsetSpace ~
18446 \InsetSpace ~
18447 \InsetSpace ~
18448 mov\InsetSpace ~
18449 \InsetSpace ~
18450 _bp,sp\InsetSpace ~
18451 \InsetSpace ~
18452 \InsetSpace ~
18453 \InsetSpace ~
18454 \InsetSpace ~
18455 \InsetSpace ~
18456 ;stack contains: _bp, return
18457  address, second parameter, third parameter
18458 \newline
18459 \InsetSpace ~
18460 \InsetSpace ~
18461 \InsetSpace ~
18462 \InsetSpace ~
18463 mov\InsetSpace ~
18464 \InsetSpace ~
18465 r2,dpl
18466 \newline
18467 \InsetSpace ~
18468 \InsetSpace ~
18469 \InsetSpace ~
18470 \InsetSpace ~
18471 mov\InsetSpace ~
18472 \InsetSpace ~
18473 a,_bp
18474 \newline
18475 \InsetSpace ~
18476 \InsetSpace ~
18477 \InsetSpace ~
18478 \InsetSpace ~
18479 add\InsetSpace ~
18480 \InsetSpace ~
18481 a,#0xfd\InsetSpace ~
18482 \InsetSpace ~
18483 \InsetSpace ~
18484 \InsetSpace ~
18485 \InsetSpace ~
18486 ;calculate
18487  pointer to the second parameter
18488 \newline
18489 \InsetSpace ~
18490 \InsetSpace ~
18491 \InsetSpace ~
18492 \InsetSpace ~
18493 mov\InsetSpace ~
18494 \InsetSpace ~
18495 r0,a 
18496 \newline
18497 \InsetSpace ~
18498 \InsetSpace ~
18499 \InsetSpace ~
18500 \InsetSpace ~
18501 mov\InsetSpace ~
18502 \InsetSpace ~
18503 a,_bp 
18504 \newline
18505 \InsetSpace ~
18506 \InsetSpace ~
18507 \InsetSpace ~
18508 \InsetSpace ~
18509 add\InsetSpace ~
18510 \InsetSpace ~
18511 a,#0xfc\InsetSpace ~
18512 \InsetSpace ~
18513 \InsetSpace ~
18514 \InsetSpace ~
18515 \InsetSpace ~
18516 ;calculate pointer
18517  to the rightmost parameter
18518 \newline
18519 \InsetSpace ~
18520 \InsetSpace ~
18521 \InsetSpace ~
18522 \InsetSpace ~
18523 mov\InsetSpace ~
18524 \InsetSpace ~
18525 r1,a 
18526 \newline
18527 \InsetSpace ~
18528 \InsetSpace ~
18529 \InsetSpace ~
18530 \InsetSpace ~
18531 mov\InsetSpace ~
18532 \InsetSpace ~
18533 a,@r0
18534 \newline
18535 \InsetSpace ~
18536 \InsetSpace ~
18537 \InsetSpace ~
18538 \InsetSpace ~
18539 add\InsetSpace ~
18540 \InsetSpace ~
18541 a,@r1
18542 \newline
18543 \InsetSpace ~
18544 \InsetSpace ~
18545 \InsetSpace ~
18546 \InsetSpace ~
18547 add\InsetSpace ~
18548 \InsetSpace ~
18549 a,r2\InsetSpace ~
18550 \InsetSpace ~
18551 \InsetSpace ~
18552 \InsetSpace ~
18553 \InsetSpace ~
18554 \InsetSpace ~
18555 \InsetSpace ~
18556 \InsetSpace ~
18557 ;calculate the
18558  result (= sum of all three parameters)
18559 \newline
18560 \InsetSpace ~
18561 \InsetSpace ~
18562 \InsetSpace ~
18563 \InsetSpace ~
18564 mov\InsetSpace ~
18565 \InsetSpace ~
18566 dpl,a\InsetSpace ~
18567 \InsetSpace ~
18568 \InsetSpace ~
18569 \InsetSpace ~
18570 \InsetSpace ~
18571 \InsetSpace ~
18572 \InsetSpace ~
18573 ;return value goes into dptr
18574  (cast into int)
18575 \newline
18576 \InsetSpace ~
18577 \InsetSpace ~
18578 \InsetSpace ~
18579 \InsetSpace ~
18580 mov\InsetSpace ~
18581 \InsetSpace ~
18582 dph,#0x00 
18583 \newline
18584 \InsetSpace ~
18585 \InsetSpace ~
18586 \InsetSpace ~
18587 \InsetSpace ~
18588 mov\InsetSpace ~
18589 \InsetSpace ~
18590 sp,_bp 
18591 \newline
18592 \InsetSpace ~
18593 \InsetSpace ~
18594 \InsetSpace ~
18595 \InsetSpace ~
18596 pop\InsetSpace ~
18597 \InsetSpace ~
18598 _bp 
18599 \newline
18600 \InsetSpace ~
18601 \InsetSpace ~
18602 \InsetSpace ~
18603 \InsetSpace ~
18604 ret
18605 \end_layout
18606
18607 \begin_layout Standard
18608 The compiling and linking procedure remains the same, however note the extra
18609  entry & exit linkage required for the assembler code, _bp is the stack
18610  frame pointer and is used to compute the offset into the stack for parameters
18611  and local variables.
18612 \begin_inset VSpace bigskip
18613 \end_inset
18614
18615
18616 \end_layout
18617
18618 \begin_layout Section
18619 int (16 bit)
18620 \begin_inset LatexCommand \index{int (16 bit)}
18621
18622 \end_inset
18623
18624  and long (32 bit)
18625 \begin_inset LatexCommand \index{long (32 bit)}
18626
18627 \end_inset
18628
18629  Support
18630 \end_layout
18631
18632 \begin_layout Standard
18633 For signed & unsigned int (16 bit) and long (32 bit) variables, division,
18634  multiplication and modulus operations are implemented by support routines.
18635  These support routines are all developed in ANSI-C to facilitate porting
18636  to other MCUs, although some model specific assembler optimizations are
18637  used.
18638  The following files contain the described routines, all of them can be
18639  found in <installdir>/share/sdcc/lib.
18640 \newline
18641
18642 \end_layout
18643
18644 \begin_layout Standard
18645 \align center
18646 \begin_inset Tabular
18647 <lyxtabular version="3" rows="11" columns="2">
18648 <features>
18649 <column alignment="left" valignment="top" leftline="true" width="0">
18650 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0">
18651 <row topline="true" bottomline="true">
18652 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18653 \begin_inset Text
18654
18655 \begin_layout Standard
18656
18657 \series bold
18658 Function
18659 \end_layout
18660
18661 \end_inset
18662 </cell>
18663 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18664 \begin_inset Text
18665
18666 \begin_layout Standard
18667
18668 \series bold
18669 Description
18670 \end_layout
18671
18672 \end_inset
18673 </cell>
18674 </row>
18675 <row topline="true">
18676 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18677 \begin_inset Text
18678
18679 \begin_layout Standard
18680 _mulint.c 
18681 \end_layout
18682
18683 \end_inset
18684 </cell>
18685 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18686 \begin_inset Text
18687
18688 \begin_layout Standard
18689 16 bit multiplication
18690 \end_layout
18691
18692 \end_inset
18693 </cell>
18694 </row>
18695 <row topline="true">
18696 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18697 \begin_inset Text
18698
18699 \begin_layout Standard
18700 _divsint.c 
18701 \end_layout
18702
18703 \end_inset
18704 </cell>
18705 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18706 \begin_inset Text
18707
18708 \begin_layout Standard
18709  signed 16 bit division (calls _divuint)
18710 \end_layout
18711
18712 \end_inset
18713 </cell>
18714 </row>
18715 <row topline="true">
18716 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18717 \begin_inset Text
18718
18719 \begin_layout Standard
18720 _divuint.c 
18721 \end_layout
18722
18723 \end_inset
18724 </cell>
18725 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18726 \begin_inset Text
18727
18728 \begin_layout Standard
18729  unsigned 16 bit division
18730 \end_layout
18731
18732 \end_inset
18733 </cell>
18734 </row>
18735 <row topline="true">
18736 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18737 \begin_inset Text
18738
18739 \begin_layout Standard
18740 _modsint.c
18741 \end_layout
18742
18743 \end_inset
18744 </cell>
18745 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18746 \begin_inset Text
18747
18748 \begin_layout Standard
18749 signed 16 bit modulus (calls _moduint)
18750 \end_layout
18751
18752 \end_inset
18753 </cell>
18754 </row>
18755 <row topline="true">
18756 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18757 \begin_inset Text
18758
18759 \begin_layout Standard
18760 _moduint.c
18761 \end_layout
18762
18763 \end_inset
18764 </cell>
18765 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18766 \begin_inset Text
18767
18768 \begin_layout Standard
18769 unsigned 16 bit modulus
18770 \end_layout
18771
18772 \end_inset
18773 </cell>
18774 </row>
18775 <row topline="true">
18776 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18777 \begin_inset Text
18778
18779 \begin_layout Standard
18780 _mullong.c
18781 \end_layout
18782
18783 \end_inset
18784 </cell>
18785 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18786 \begin_inset Text
18787
18788 \begin_layout Standard
18789 32 bit multiplication
18790 \end_layout
18791
18792 \end_inset
18793 </cell>
18794 </row>
18795 <row topline="true">
18796 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18797 \begin_inset Text
18798
18799 \begin_layout Standard
18800 _divslong.c 
18801 \end_layout
18802
18803 \end_inset
18804 </cell>
18805 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18806 \begin_inset Text
18807
18808 \begin_layout Standard
18809  signed 32 division (calls _divulong)
18810 \end_layout
18811
18812 \end_inset
18813 </cell>
18814 </row>
18815 <row topline="true">
18816 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18817 \begin_inset Text
18818
18819 \begin_layout Standard
18820 _divulong.c 
18821 \end_layout
18822
18823 \end_inset
18824 </cell>
18825 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18826 \begin_inset Text
18827
18828 \begin_layout Standard
18829 unsigned 32 division
18830 \end_layout
18831
18832 \end_inset
18833 </cell>
18834 </row>
18835 <row topline="true">
18836 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18837 \begin_inset Text
18838
18839 \begin_layout Standard
18840 _modslong.c
18841 \end_layout
18842
18843 \end_inset
18844 </cell>
18845 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18846 \begin_inset Text
18847
18848 \begin_layout Standard
18849  signed 32 bit modulus (calls _modulong)
18850 \end_layout
18851
18852 \end_inset
18853 </cell>
18854 </row>
18855 <row topline="true" bottomline="true">
18856 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18857 \begin_inset Text
18858
18859 \begin_layout Standard
18860 _modulong.c
18861 \end_layout
18862
18863 \end_inset
18864 </cell>
18865 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18866 \begin_inset Text
18867
18868 \begin_layout Standard
18869 unsigned 32 bit modulus
18870 \end_layout
18871
18872 \end_inset
18873 </cell>
18874 </row>
18875 </lyxtabular>
18876
18877 \end_inset
18878
18879
18880 \newline
18881
18882 \end_layout
18883
18884 \begin_layout Standard
18885 Since they are compiled as 
18886 \emph on
18887 non-reentrant
18888 \emph default
18889
18890 \begin_inset LatexCommand \index{reentrant}
18891
18892 \end_inset
18893
18894 , interrupt
18895 \begin_inset LatexCommand \index{interrupt}
18896
18897 \end_inset
18898
18899  service routines should not do any of the above operations.
18900  If this is unavoidable then the above routines will need to be compiled
18901  with the 
18902 \emph on
18903 -
18904 \begin_inset ERT
18905 status collapsed
18906
18907 \begin_layout Standard
18908
18909
18910 \backslash
18911 /
18912 \end_layout
18913
18914 \end_inset
18915
18916 -stack-auto
18917 \begin_inset LatexCommand \index{-\\/-stack-auto}
18918
18919 \end_inset
18920
18921
18922 \emph default
18923  option, after which the source program will have to be compiled with 
18924 \emph on
18925 -
18926 \begin_inset ERT
18927 status collapsed
18928
18929 \begin_layout Standard
18930
18931
18932 \backslash
18933 /
18934 \end_layout
18935
18936 \end_inset
18937
18938 -int-long-reent
18939 \begin_inset LatexCommand \index{-\\/-int-long-reent}
18940
18941 \end_inset
18942
18943
18944 \emph default
18945  option.
18946  Notice that you don't have to call these routines directly.
18947  The compiler will use them automatically every time an integer operation
18948  is required.
18949 \end_layout
18950
18951 \begin_layout Section
18952 Floating Point Support
18953 \begin_inset LatexCommand \index{Floating point support}
18954
18955 \end_inset
18956
18957
18958 \end_layout
18959
18960 \begin_layout Standard
18961 SDCC supports IEEE (single precision 4 bytes) floating point numbers.
18962  The floating point support routines are derived from gcc's floatlib.c and
18963  consist of the following routines:
18964 \newline
18965
18966 \end_layout
18967
18968 \begin_layout Standard
18969 \align center
18970
18971 \size footnotesize
18972 \begin_inset Tabular
18973 <lyxtabular version="3" rows="17" columns="2">
18974 <features>
18975 <column alignment="left" valignment="top" leftline="true" width="0">
18976 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0">
18977 <row topline="true" bottomline="true">
18978 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
18979 \begin_inset Text
18980
18981 \begin_layout Standard
18982
18983 \family roman
18984 \series medium
18985 \shape up
18986 \size normal
18987 \emph off
18988 \bar no
18989 \noun off
18990 \color none
18991 Function 
18992 \end_layout
18993
18994 \end_inset
18995 </cell>
18996 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
18997 \begin_inset Text
18998
18999 \begin_layout Standard
19000 Description
19001 \end_layout
19002
19003 \end_inset
19004 </cell>
19005 </row>
19006 <row topline="true">
19007 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19008 \begin_inset Text
19009
19010 \begin_layout Standard
19011
19012 \family roman
19013 \series medium
19014 \shape up
19015 \size normal
19016 \emph off
19017 \bar no
19018 \noun off
19019 \color none
19020 _fsadd.c
19021 \end_layout
19022
19023 \end_inset
19024 </cell>
19025 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19026 \begin_inset Text
19027
19028 \begin_layout Standard
19029
19030 \family roman
19031 \series medium
19032 \shape up
19033 \size normal
19034 \emph off
19035 \bar no
19036 \noun off
19037 \color none
19038 add floating point numbers
19039 \end_layout
19040
19041 \end_inset
19042 </cell>
19043 </row>
19044 <row topline="true">
19045 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19046 \begin_inset Text
19047
19048 \begin_layout Standard
19049
19050 \family roman
19051 \series medium
19052 \shape up
19053 \size normal
19054 \emph off
19055 \bar no
19056 \noun off
19057 \color none
19058 _fssub.c 
19059 \end_layout
19060
19061 \end_inset
19062 </cell>
19063 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19064 \begin_inset Text
19065
19066 \begin_layout Standard
19067
19068 \family roman
19069 \series medium
19070 \shape up
19071 \size normal
19072 \emph off
19073 \bar no
19074 \noun off
19075 \color none
19076 subtract floating point numbers 
19077 \end_layout
19078
19079 \end_inset
19080 </cell>
19081 </row>
19082 <row topline="true">
19083 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19084 \begin_inset Text
19085
19086 \begin_layout Standard
19087
19088 \family roman
19089 \series medium
19090 \shape up
19091 \size normal
19092 \emph off
19093 \bar no
19094 \noun off
19095 \color none
19096 _fsdiv.c 
19097 \end_layout
19098
19099 \end_inset
19100 </cell>
19101 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19102 \begin_inset Text
19103
19104 \begin_layout Standard
19105
19106 \family roman
19107 \series medium
19108 \shape up
19109 \size normal
19110 \emph off
19111 \bar no
19112 \noun off
19113 \color none
19114 divide floating point numbers 
19115 \end_layout
19116
19117 \end_inset
19118 </cell>
19119 </row>
19120 <row topline="true">
19121 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19122 \begin_inset Text
19123
19124 \begin_layout Standard
19125
19126 \family roman
19127 \series medium
19128 \shape up
19129 \size normal
19130 \emph off
19131 \bar no
19132 \noun off
19133 \color none
19134 _fsmul.c 
19135 \end_layout
19136
19137 \end_inset
19138 </cell>
19139 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19140 \begin_inset Text
19141
19142 \begin_layout Standard
19143
19144 \family roman
19145 \series medium
19146 \shape up
19147 \size normal
19148 \emph off
19149 \bar no
19150 \noun off
19151 \color none
19152 multiply floating point numbers 
19153 \end_layout
19154
19155 \end_inset
19156 </cell>
19157 </row>
19158 <row topline="true">
19159 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19160 \begin_inset Text
19161
19162 \begin_layout Standard
19163
19164 \family roman
19165 \series medium
19166 \shape up
19167 \size normal
19168 \emph off
19169 \bar no
19170 \noun off
19171 \color none
19172 _fs2uchar.c
19173 \end_layout
19174
19175 \end_inset
19176 </cell>
19177 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19178 \begin_inset Text
19179
19180 \begin_layout Standard
19181
19182 \family roman
19183 \series medium
19184 \shape up
19185 \size normal
19186 \emph off
19187 \bar no
19188 \noun off
19189 \color none
19190 convert floating point to unsigned char
19191 \end_layout
19192
19193 \end_inset
19194 </cell>
19195 </row>
19196 <row topline="true">
19197 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19198 \begin_inset Text
19199
19200 \begin_layout Standard
19201
19202 \family roman
19203 \series medium
19204 \shape up
19205 \size normal
19206 \emph off
19207 \bar no
19208 \noun off
19209 \color none
19210 _fs2char.c
19211 \end_layout
19212
19213 \end_inset
19214 </cell>
19215 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19216 \begin_inset Text
19217
19218 \begin_layout Standard
19219
19220 \family roman
19221 \series medium
19222 \shape up
19223 \size normal
19224 \emph off
19225 \bar no
19226 \noun off
19227 \color none
19228 convert floating point to signed char
19229 \end_layout
19230
19231 \end_inset
19232 </cell>
19233 </row>
19234 <row topline="true">
19235 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19236 \begin_inset Text
19237
19238 \begin_layout Standard
19239
19240 \family roman
19241 \series medium
19242 \shape up
19243 \size normal
19244 \emph off
19245 \bar no
19246 \noun off
19247 \color none
19248 _fs2uint.c
19249 \end_layout
19250
19251 \end_inset
19252 </cell>
19253 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19254 \begin_inset Text
19255
19256 \begin_layout Standard
19257
19258 \family roman
19259 \series medium
19260 \shape up
19261 \size normal
19262 \emph off
19263 \bar no
19264 \noun off
19265 \color none
19266 convert floating point to unsigned int
19267 \end_layout
19268
19269 \end_inset
19270 </cell>
19271 </row>
19272 <row topline="true">
19273 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19274 \begin_inset Text
19275
19276 \begin_layout Standard
19277
19278 \family roman
19279 \series medium
19280 \shape up
19281 \size normal
19282 \emph off
19283 \bar no
19284 \noun off
19285 \color none
19286 _fs2int.c
19287 \end_layout
19288
19289 \end_inset
19290 </cell>
19291 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19292 \begin_inset Text
19293
19294 \begin_layout Standard
19295
19296 \family roman
19297 \series medium
19298 \shape up
19299 \size normal
19300 \emph off
19301 \bar no
19302 \noun off
19303 \color none
19304 convert floating point to signed int
19305 \end_layout
19306
19307 \end_inset
19308 </cell>
19309 </row>
19310 <row topline="true">
19311 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19312 \begin_inset Text
19313
19314 \begin_layout Standard
19315
19316 \family roman
19317 \series medium
19318 \shape up
19319 \size normal
19320 \emph off
19321 \bar no
19322 \noun off
19323 \color none
19324 _fs2ulong.
19325 \family default
19326 \series default
19327 \shape default
19328 \size default
19329 \emph default
19330 \bar default
19331 \noun default
19332 c
19333 \end_layout
19334
19335 \end_inset
19336 </cell>
19337 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19338 \begin_inset Text
19339
19340 \begin_layout Standard
19341
19342 \family roman
19343 \series medium
19344 \shape up
19345 \size normal
19346 \emph off
19347 \bar no
19348 \noun off
19349 \color none
19350 convert floating point to unsigned long
19351 \end_layout
19352
19353 \end_inset
19354 </cell>
19355 </row>
19356 <row topline="true">
19357 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19358 \begin_inset Text
19359
19360 \begin_layout Standard
19361
19362 \family roman
19363 \series medium
19364 \shape up
19365 \size normal
19366 \emph off
19367 \bar no
19368 \noun off
19369 \color none
19370 _fs2long.c
19371 \end_layout
19372
19373 \end_inset
19374 </cell>
19375 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19376 \begin_inset Text
19377
19378 \begin_layout Standard
19379
19380 \family roman
19381 \series medium
19382 \shape up
19383 \size normal
19384 \emph off
19385 \bar no
19386 \noun off
19387 \color none
19388 convert floating point to signed long
19389 \end_layout
19390
19391 \end_inset
19392 </cell>
19393 </row>
19394 <row topline="true">
19395 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19396 \begin_inset Text
19397
19398 \begin_layout Standard
19399
19400 \family roman
19401 \series medium
19402 \shape up
19403 \size normal
19404 \emph off
19405 \bar no
19406 \noun off
19407 \color none
19408 _uchar2fs.c
19409 \end_layout
19410
19411 \end_inset
19412 </cell>
19413 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19414 \begin_inset Text
19415
19416 \begin_layout Standard
19417
19418 \family roman
19419 \series medium
19420 \shape up
19421 \size normal
19422 \emph off
19423 \bar no
19424 \noun off
19425 \color none
19426 convert unsigned char to floating point
19427 \end_layout
19428
19429 \end_inset
19430 </cell>
19431 </row>
19432 <row topline="true">
19433 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19434 \begin_inset Text
19435
19436 \begin_layout Standard
19437
19438 \family roman
19439 \series medium
19440 \shape up
19441 \size normal
19442 \emph off
19443 \bar no
19444 \noun off
19445 \color none
19446 _char2fs.c
19447 \end_layout
19448
19449 \end_inset
19450 </cell>
19451 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19452 \begin_inset Text
19453
19454 \begin_layout Standard
19455
19456 \family roman
19457 \series medium
19458 \shape up
19459 \size normal
19460 \emph off
19461 \bar no
19462 \noun off
19463 \color none
19464 convert char to floating point number
19465 \end_layout
19466
19467 \end_inset
19468 </cell>
19469 </row>
19470 <row topline="true">
19471 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19472 \begin_inset Text
19473
19474 \begin_layout Standard
19475
19476 \family roman
19477 \series medium
19478 \shape up
19479 \size normal
19480 \emph off
19481 \bar no
19482 \noun off
19483 \color none
19484 _uint2fs.c
19485 \end_layout
19486
19487 \end_inset
19488 </cell>
19489 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19490 \begin_inset Text
19491
19492 \begin_layout Standard
19493
19494 \family roman
19495 \series medium
19496 \shape up
19497 \size normal
19498 \emph off
19499 \bar no
19500 \noun off
19501 \color none
19502 convert unsigned int to floating point
19503 \end_layout
19504
19505 \end_inset
19506 </cell>
19507 </row>
19508 <row topline="true">
19509 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19510 \begin_inset Text
19511
19512 \begin_layout Standard
19513
19514 \family roman
19515 \series medium
19516 \shape up
19517 \size normal
19518 \emph off
19519 \bar no
19520 \noun off
19521 \color none
19522 _int2fs.c
19523 \end_layout
19524
19525 \end_inset
19526 </cell>
19527 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19528 \begin_inset Text
19529
19530 \begin_layout Standard
19531
19532 \family roman
19533 \series medium
19534 \shape up
19535 \size normal
19536 \emph off
19537 \bar no
19538 \noun off
19539 \color none
19540 convert int to floating point numbers
19541 \end_layout
19542
19543 \end_inset
19544 </cell>
19545 </row>
19546 <row topline="true">
19547 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19548 \begin_inset Text
19549
19550 \begin_layout Standard
19551
19552 \family roman
19553 \series medium
19554 \shape up
19555 \size normal
19556 \emph off
19557 \bar no
19558 \noun off
19559 \color none
19560 _ulong2fs.c
19561 \end_layout
19562
19563 \end_inset
19564 </cell>
19565 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19566 \begin_inset Text
19567
19568 \begin_layout Standard
19569
19570 \family roman
19571 \series medium
19572 \shape up
19573 \size normal
19574 \emph off
19575 \bar no
19576 \noun off
19577 \color none
19578 convert unsigned long to floating point number
19579 \end_layout
19580
19581 \end_inset
19582 </cell>
19583 </row>
19584 <row topline="true" bottomline="true">
19585 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19586 \begin_inset Text
19587
19588 \begin_layout Standard
19589
19590 \family roman
19591 \series medium
19592 \shape up
19593 \size normal
19594 \emph off
19595 \bar no
19596 \noun off
19597 \color none
19598 _long2fs.c
19599 \end_layout
19600
19601 \end_inset
19602 </cell>
19603 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19604 \begin_inset Text
19605
19606 \begin_layout Standard
19607
19608 \family roman
19609 \series medium
19610 \shape up
19611 \size normal
19612 \emph off
19613 \bar no
19614 \noun off
19615 \color none
19616 convert long to floating point number
19617 \end_layout
19618
19619 \end_inset
19620 </cell>
19621 </row>
19622 </lyxtabular>
19623
19624 \end_inset
19625
19626
19627 \newline
19628
19629 \end_layout
19630
19631 \begin_layout Standard
19632 These support routines are developed in ANSI-C so there is room for space
19633  and speed improvement
19634 \begin_inset Foot
19635 status open
19636
19637 \begin_layout Standard
19638 These floating point routines (
19639 \emph on
19640 not
19641 \emph default
19642  sinf(), cosf(), ...) for the mcs51 are implemented in assembler.
19643  
19644 \end_layout
19645
19646 \end_inset
19647
19648 .
19649  Note if all these routines are used simultaneously the data space might
19650  overflow.
19651  For serious floating point usage the large model might be needed.
19652  Also notice that you don't have to call this routines directly.
19653  The compiler will use them automatically every time a floating point operation
19654  is required.
19655 \begin_inset VSpace bigskip
19656 \end_inset
19657
19658
19659 \end_layout
19660
19661 \begin_layout Section
19662 Library Routines
19663 \begin_inset LatexCommand \index{Libraries}
19664
19665 \end_inset
19666
19667
19668 \end_layout
19669
19670 \begin_layout Standard
19671
19672 \emph on
19673 <pending: this is messy and incomplete - a little more information is in
19674  sdcc/doc/libdoc.txt
19675 \emph default
19676  >
19677 \end_layout
19678
19679 \begin_layout Subsection
19680 Compiler support routines (_gptrget, _mulint etc.)
19681 \end_layout
19682
19683 \begin_layout Subsection
19684 Stdclib functions (puts, printf, strcat etc.)
19685 \end_layout
19686
19687 \begin_layout Subsubsection
19688 <stdio.h>
19689 \end_layout
19690
19691 \begin_layout Paragraph
19692 getchar(), putchar()
19693 \end_layout
19694
19695 \begin_layout Standard
19696 \begin_inset LatexCommand \index{<stdio.h>}
19697
19698 \end_inset
19699
19700 As usual on embedded systems you have to provide your own 
19701 \family typewriter
19702 getchar()
19703 \begin_inset LatexCommand \index{getchar()}
19704
19705 \end_inset
19706
19707
19708 \family default
19709  and 
19710 \family typewriter
19711 putchar()
19712 \begin_inset LatexCommand \index{putchar()}
19713
19714 \end_inset
19715
19716
19717 \family default
19718  routines.
19719  SDCC does not know whether the system connects to a serial line with or
19720  without handshake, LCD, keyboard or other device.
19721  And whether a 
19722 \family typewriter
19723 lf
19724 \family default
19725  to 
19726 \family typewriter
19727 crlf
19728 \family default
19729  conversion within 
19730 \family typewriter
19731 putchar()
19732 \family default
19733  is intended.
19734  You'll find examples for serial routines f.e.
19735  in sdcc/device/lib.
19736  For the mcs51 this minimalistic polling 
19737 \family typewriter
19738 putchar()
19739 \family default
19740  routine might be a start:
19741 \end_layout
19742
19743 \begin_layout Verse
19744
19745 \family typewriter
19746 void putchar (char c) { 
19747 \newline
19748 \InsetSpace ~
19749 \InsetSpace ~
19750 \InsetSpace ~
19751 \InsetSpace ~
19752 while (!TI)\InsetSpace ~
19753 \InsetSpace ~
19754 \InsetSpace ~
19755  /* assumes UART is initialized */
19756 \newline
19757 \InsetSpace ~
19758 \InsetSpace ~
19759 \InsetSpace ~
19760 \InsetSpace ~
19761 \InsetSpace ~
19762 \InsetSpace ~
19763 \InsetSpace ~
19764 \InsetSpace ~
19765 ;
19766 \newline
19767 \InsetSpace ~
19768 \InsetSpace ~
19769 \InsetSpace ~
19770 \InsetSpace ~
19771 TI
19772  = 0;
19773 \newline
19774 \InsetSpace ~
19775 \InsetSpace ~
19776 \InsetSpace ~
19777 \InsetSpace ~
19778 SBUF = c;
19779 \newline
19780 }
19781 \end_layout
19782
19783 \begin_layout Paragraph
19784 printf()
19785 \end_layout
19786
19787 \begin_layout Standard
19788 The default 
19789 \family typewriter
19790 printf()
19791 \begin_inset LatexCommand \index{printf()}
19792
19793 \end_inset
19794
19795
19796 \family default
19797  implementation in 
19798 \family typewriter
19799 printf_large.c
19800 \family default
19801  does not support float (except on ds390).
19802  To enable this recompile it with the option 
19803 \emph on
19804 -
19805 \begin_inset ERT
19806 status collapsed
19807
19808 \begin_layout Standard
19809
19810
19811 \backslash
19812 /
19813 \end_layout
19814
19815 \end_inset
19816
19817 DUSE_FLOATS=1
19818 \begin_inset LatexCommand \index{USE\\_FLOATS}
19819
19820 \end_inset
19821
19822
19823 \emph default
19824  on the command line.
19825  Use 
19826 \emph on
19827 -
19828 \begin_inset ERT
19829 status collapsed
19830
19831 \begin_layout Standard
19832
19833
19834 \backslash
19835 /
19836 \end_layout
19837
19838 \end_inset
19839
19840 -model-large
19841 \begin_inset LatexCommand \index{-\\/-model-large}
19842
19843 \end_inset
19844
19845
19846 \emph default
19847  for the mcs51 port, since this uses a lot of memory.
19848 \end_layout
19849
19850 \begin_layout Standard
19851 If you're short on code memory you might want to use 
19852 \family typewriter
19853 printf_small()
19854 \begin_inset LatexCommand \index{printf\\_small()}
19855
19856 \end_inset
19857
19858
19859 \family default
19860  
19861 \emph on
19862 instead
19863 \emph default
19864  of 
19865 \family typewriter
19866 printf().
19867
19868 \family default
19869  For the mcs51 there additionally are assembly versions 
19870 \family typewriter
19871 printf_tiny()
19872 \begin_inset LatexCommand \index{printf\\_tiny() (mcs51)}
19873
19874 \end_inset
19875
19876
19877 \family default
19878  (subset of printf using less than 270 bytes) and 
19879 \family typewriter
19880 printf_fast()
19881 \begin_inset LatexCommand \index{printf\\_fast() (mcs51)}
19882
19883 \end_inset
19884
19885
19886 \family default
19887  and 
19888 \family typewriter
19889 printf_fast_f()
19890 \begin_inset LatexCommand \index{printf\\_fast\\_f() (mcs51)}
19891
19892 \end_inset
19893
19894
19895 \family default
19896  (floating-point aware version of printf_fast) which should fit the requirements
19897  of many embedded systems (printf_fast() can be customized by unsetting
19898  #defines to 
19899 \emph on
19900 not
19901 \emph default
19902  support long variables and field widths).
19903  Be sure to use only one of these printf options within a project.
19904 \newline
19905
19906 \end_layout
19907
19908 \begin_layout Standard
19909 Feature matrix of different 
19910 \emph on
19911 printf
19912 \emph default
19913  options on mcs51.
19914 \end_layout
19915
19916 \begin_layout Standard
19917 \begin_inset Tabular
19918 <lyxtabular version="3" rows="14" columns="7">
19919 <features islongtable="true">
19920 <column alignment="left" valignment="middle" leftline="true" width="14col%">
19921 <column alignment="center" valignment="top" leftline="true" width="0">
19922 <column alignment="center" valignment="top" leftline="true" width="12col%">
19923 <column alignment="center" valignment="top" leftline="true" width="10col%">
19924 <column alignment="center" valignment="top" leftline="true" width="0">
19925 <column alignment="center" valignment="top" leftline="true" rightline="true" width="12col%">
19926 <column alignment="center" valignment="top" rightline="true" width="0">
19927 <row topline="true" bottomline="true" endhead="true">
19928 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19929 \begin_inset Text
19930
19931 \begin_layout Standard
19932
19933 \series bold
19934 \size large
19935 mcs51
19936 \end_layout
19937
19938 \end_inset
19939 </cell>
19940 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19941 \begin_inset Text
19942
19943 \begin_layout Standard
19944 printf
19945 \begin_inset LatexCommand \index{printf}
19946
19947 \end_inset
19948
19949
19950 \end_layout
19951
19952 \end_inset
19953 </cell>
19954 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19955 \begin_inset Text
19956
19957 \begin_layout Standard
19958 printf 
19959 \size scriptsize
19960 USE_FLOATS=1
19961 \end_layout
19962
19963 \end_inset
19964 </cell>
19965 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19966 \begin_inset Text
19967
19968 \begin_layout Standard
19969 printf_small
19970 \end_layout
19971
19972 \end_inset
19973 </cell>
19974 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19975 \begin_inset Text
19976
19977 \begin_layout Standard
19978 printf_fast
19979 \end_layout
19980
19981 \end_inset
19982 </cell>
19983 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19984 \begin_inset Text
19985
19986 \begin_layout Standard
19987 printf_fast_f
19988 \end_layout
19989
19990 \end_inset
19991 </cell>
19992 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
19993 \begin_inset Text
19994
19995 \begin_layout Standard
19996 printf_tiny
19997 \end_layout
19998
19999 \end_inset
20000 </cell>
20001 </row>
20002 <row topline="true" endhead="true">
20003 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20004 \begin_inset Text
20005
20006 \begin_layout Standard
20007 filename
20008 \end_layout
20009
20010 \end_inset
20011 </cell>
20012 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20013 \begin_inset Text
20014
20015 \begin_layout Standard
20016
20017 \size scriptsize
20018 printf_large.c
20019 \end_layout
20020
20021 \end_inset
20022 </cell>
20023 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20024 \begin_inset Text
20025
20026 \begin_layout Standard
20027
20028 \size scriptsize
20029 printf_large.c
20030 \end_layout
20031
20032 \end_inset
20033 </cell>
20034 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20035 \begin_inset Text
20036
20037 \begin_layout Standard
20038
20039 \size scriptsize
20040 printfl.c
20041 \end_layout
20042
20043 \end_inset
20044 </cell>
20045 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20046 \begin_inset Text
20047
20048 \begin_layout Standard
20049
20050 \size scriptsize
20051 printf_fast.c
20052 \end_layout
20053
20054 \end_inset
20055 </cell>
20056 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20057 \begin_inset Text
20058
20059 \begin_layout Standard
20060
20061 \size scriptsize
20062 printf_fast_f.c
20063 \end_layout
20064
20065 \end_inset
20066 </cell>
20067 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20068 \begin_inset Text
20069
20070 \begin_layout Standard
20071
20072 \size scriptsize
20073 printf_tiny.c
20074 \end_layout
20075
20076 \end_inset
20077 </cell>
20078 </row>
20079 <row topline="true" endhead="true">
20080 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20081 \begin_inset Text
20082
20083 \begin_layout Standard
20084 \begin_inset Quotes sld
20085 \end_inset
20086
20087 Hello World
20088 \begin_inset Quotes srd
20089 \end_inset
20090
20091  size
20092 \end_layout
20093
20094 \begin_layout Standard
20095 small / large
20096 \end_layout
20097
20098 \end_inset
20099 </cell>
20100 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20101 \begin_inset Text
20102
20103 \begin_layout Standard
20104 1.7k / 2.4k
20105 \end_layout
20106
20107 \end_inset
20108 </cell>
20109 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20110 \begin_inset Text
20111
20112 \begin_layout Standard
20113 4.3k / 5.6k
20114 \end_layout
20115
20116 \end_inset
20117 </cell>
20118 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20119 \begin_inset Text
20120
20121 \begin_layout Standard
20122 1.2k / 1.8k
20123 \end_layout
20124
20125 \end_inset
20126 </cell>
20127 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20128 \begin_inset Text
20129
20130 \begin_layout Standard
20131 1.3k / 1.3k
20132 \end_layout
20133
20134 \end_inset
20135 </cell>
20136 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20137 \begin_inset Text
20138
20139 \begin_layout Standard
20140 1.9k / 1.9k
20141 \end_layout
20142
20143 \end_inset
20144 </cell>
20145 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20146 \begin_inset Text
20147
20148 \begin_layout Standard
20149 0.44k / 0.44k
20150 \end_layout
20151
20152 \end_inset
20153 </cell>
20154 </row>
20155 <row topline="true" endhead="true">
20156 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20157 \begin_inset Text
20158
20159 \begin_layout Standard
20160 code size
20161 \end_layout
20162
20163 \begin_layout Standard
20164 small / large
20165 \end_layout
20166
20167 \end_inset
20168 </cell>
20169 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20170 \begin_inset Text
20171
20172 \begin_layout Standard
20173 1.4k / 2.0k
20174 \end_layout
20175
20176 \end_inset
20177 </cell>
20178 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20179 \begin_inset Text
20180
20181 \begin_layout Standard
20182 2.8k / 3.7k
20183 \end_layout
20184
20185 \end_inset
20186 </cell>
20187 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20188 \begin_inset Text
20189
20190 \begin_layout Standard
20191 0.45k / 0.47k (+ _ltoa)
20192 \end_layout
20193
20194 \end_inset
20195 </cell>
20196 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20197 \begin_inset Text
20198
20199 \begin_layout Standard
20200 1.2k / 1.2k
20201 \end_layout
20202
20203 \end_inset
20204 </cell>
20205 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20206 \begin_inset Text
20207
20208 \begin_layout Standard
20209 1.6k / 1.6k
20210 \end_layout
20211
20212 \end_inset
20213 </cell>
20214 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20215 \begin_inset Text
20216
20217 \begin_layout Standard
20218 0.26k / 0.26k
20219 \end_layout
20220
20221 \end_inset
20222 </cell>
20223 </row>
20224 <row topline="true">
20225 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20226 \begin_inset Text
20227
20228 \begin_layout Standard
20229 formats
20230 \end_layout
20231
20232 \end_inset
20233 </cell>
20234 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20235 \begin_inset Text
20236
20237 \begin_layout Standard
20238 cdi
20239 \emph on
20240 o
20241 \emph default
20242 psux
20243 \end_layout
20244
20245 \end_inset
20246 </cell>
20247 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20248 \begin_inset Text
20249
20250 \begin_layout Standard
20251
20252 \family roman
20253 \series medium
20254 \shape up
20255 \size normal
20256 \emph off
20257 \bar no
20258 \noun off
20259 \color none
20260 cd
20261 \family default
20262 \series default
20263 \shape default
20264 \size default
20265 \emph default
20266 \bar default
20267 \noun default
20268 f
20269 \family roman
20270 \series medium
20271 \shape up
20272 \size normal
20273 \emph off
20274 \bar no
20275 \noun off
20276 i
20277 \family default
20278 \series default
20279 \shape default
20280 \size default
20281 \emph on
20282 \bar default
20283 \noun default
20284 o
20285 \family roman
20286 \series medium
20287 \shape up
20288 \size normal
20289 \emph off
20290 \bar no
20291 \noun off
20292 psux
20293 \end_layout
20294
20295 \end_inset
20296 </cell>
20297 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20298 \begin_inset Text
20299
20300 \begin_layout Standard
20301 c
20302 \family roman
20303 \series medium
20304 \shape up
20305 \size normal
20306 \emph off
20307 \bar no
20308 \noun off
20309 \color none
20310 d
20311 \family default
20312 \series default
20313 \shape default
20314 \size default
20315 \emph on
20316 \bar default
20317 \noun default
20318 o
20319 \family roman
20320 \series medium
20321 \shape up
20322 \size normal
20323 \emph off
20324 \bar no
20325 \noun off
20326 s
20327 \family default
20328 \series default
20329 \shape default
20330 \size default
20331 \emph default
20332 \bar default
20333 \noun default
20334 x
20335 \end_layout
20336
20337 \end_inset
20338 </cell>
20339 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20340 \begin_inset Text
20341
20342 \begin_layout Standard
20343 cdsux
20344 \end_layout
20345
20346 \end_inset
20347 </cell>
20348 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20349 \begin_inset Text
20350
20351 \begin_layout Standard
20352 cdfsux
20353 \end_layout
20354
20355 \end_inset
20356 </cell>
20357 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20358 \begin_inset Text
20359
20360 \begin_layout Standard
20361 cdsux
20362 \end_layout
20363
20364 \end_inset
20365 </cell>
20366 </row>
20367 <row topline="true">
20368 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20369 \begin_inset Text
20370
20371 \begin_layout Standard
20372 long (32 bit) support
20373 \end_layout
20374
20375 \end_inset
20376 </cell>
20377 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20378 \begin_inset Text
20379
20380 \begin_layout Standard
20381 x
20382 \end_layout
20383
20384 \end_inset
20385 </cell>
20386 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20387 \begin_inset Text
20388
20389 \begin_layout Standard
20390 x
20391 \end_layout
20392
20393 \end_inset
20394 </cell>
20395 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20396 \begin_inset Text
20397
20398 \begin_layout Standard
20399 x
20400 \end_layout
20401
20402 \end_inset
20403 </cell>
20404 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20405 \begin_inset Text
20406
20407 \begin_layout Standard
20408 x
20409 \end_layout
20410
20411 \end_inset
20412 </cell>
20413 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20414 \begin_inset Text
20415
20416 \begin_layout Standard
20417
20418 \family roman
20419 \series medium
20420 \shape up
20421 \size normal
20422 \emph off
20423 \bar no
20424 \noun off
20425 \color none
20426 x
20427 \end_layout
20428
20429 \end_inset
20430 </cell>
20431 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20432 \begin_inset Text
20433
20434 \begin_layout Standard
20435 -
20436 \end_layout
20437
20438 \end_inset
20439 </cell>
20440 </row>
20441 <row topline="true">
20442 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20443 \begin_inset Text
20444
20445 \begin_layout Standard
20446 byte arguments on stack
20447 \end_layout
20448
20449 \end_inset
20450 </cell>
20451 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20452 \begin_inset Text
20453
20454 \begin_layout Standard
20455 b
20456 \end_layout
20457
20458 \end_inset
20459 </cell>
20460 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20461 \begin_inset Text
20462
20463 \begin_layout Standard
20464 b
20465 \end_layout
20466
20467 \end_inset
20468 </cell>
20469 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20470 \begin_inset Text
20471
20472 \begin_layout Standard
20473 -
20474 \end_layout
20475
20476 \end_inset
20477 </cell>
20478 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20479 \begin_inset Text
20480
20481 \begin_layout Standard
20482 -
20483 \end_layout
20484
20485 \end_inset
20486 </cell>
20487 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20488 \begin_inset Text
20489
20490 \begin_layout Standard
20491 -
20492 \end_layout
20493
20494 \end_inset
20495 </cell>
20496 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20497 \begin_inset Text
20498
20499 \begin_layout Standard
20500 -
20501 \end_layout
20502
20503 \end_inset
20504 </cell>
20505 </row>
20506 <row topline="true">
20507 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20508 \begin_inset Text
20509
20510 \begin_layout Standard
20511 float format
20512 \begin_inset LatexCommand \index{Floating point support}
20513
20514 \end_inset
20515
20516
20517 \end_layout
20518
20519 \end_inset
20520 </cell>
20521 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20522 \begin_inset Text
20523
20524 \begin_layout Standard
20525 -
20526 \end_layout
20527
20528 \end_inset
20529 </cell>
20530 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20531 \begin_inset Text
20532
20533 \begin_layout Standard
20534 %f
20535 \end_layout
20536
20537 \end_inset
20538 </cell>
20539 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20540 \begin_inset Text
20541
20542 \begin_layout Standard
20543 -
20544 \end_layout
20545
20546 \end_inset
20547 </cell>
20548 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20549 \begin_inset Text
20550
20551 \begin_layout Standard
20552 -
20553 \end_layout
20554
20555 \end_inset
20556 </cell>
20557 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20558 \begin_inset Text
20559
20560 \begin_layout Standard
20561 %f
20562 \begin_inset Foot
20563 status collapsed
20564
20565 \begin_layout Standard
20566 Range limited to +/- 4294967040, precision limited to 8 digits past decimal
20567 \end_layout
20568
20569 \end_inset
20570
20571
20572 \end_layout
20573
20574 \end_inset
20575 </cell>
20576 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20577 \begin_inset Text
20578
20579 \begin_layout Standard
20580 -
20581 \end_layout
20582
20583 \end_inset
20584 </cell>
20585 </row>
20586 <row topline="true">
20587 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20588 \begin_inset Text
20589
20590 \begin_layout Standard
20591 float formats %e %g
20592 \end_layout
20593
20594 \end_inset
20595 </cell>
20596 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20597 \begin_inset Text
20598
20599 \begin_layout Standard
20600 -
20601 \end_layout
20602
20603 \end_inset
20604 </cell>
20605 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20606 \begin_inset Text
20607
20608 \begin_layout Standard
20609 -
20610 \end_layout
20611
20612 \end_inset
20613 </cell>
20614 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20615 \begin_inset Text
20616
20617 \begin_layout Standard
20618 -
20619 \end_layout
20620
20621 \end_inset
20622 </cell>
20623 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20624 \begin_inset Text
20625
20626 \begin_layout Standard
20627 -
20628 \end_layout
20629
20630 \end_inset
20631 </cell>
20632 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20633 \begin_inset Text
20634
20635 \begin_layout Standard
20636 -
20637 \end_layout
20638
20639 \end_inset
20640 </cell>
20641 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20642 \begin_inset Text
20643
20644 \begin_layout Standard
20645 -
20646 \end_layout
20647
20648 \end_inset
20649 </cell>
20650 </row>
20651 <row topline="true" bottomline="true">
20652 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20653 \begin_inset Text
20654
20655 \begin_layout Standard
20656 field width
20657 \end_layout
20658
20659 \end_inset
20660 </cell>
20661 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20662 \begin_inset Text
20663
20664 \begin_layout Standard
20665 x
20666 \end_layout
20667
20668 \end_inset
20669 </cell>
20670 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20671 \begin_inset Text
20672
20673 \begin_layout Standard
20674 x
20675 \end_layout
20676
20677 \end_inset
20678 </cell>
20679 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20680 \begin_inset Text
20681
20682 \begin_layout Standard
20683 -
20684 \end_layout
20685
20686 \end_inset
20687 </cell>
20688 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20689 \begin_inset Text
20690
20691 \begin_layout Standard
20692 x
20693 \end_layout
20694
20695 \end_inset
20696 </cell>
20697 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20698 \begin_inset Text
20699
20700 \begin_layout Standard
20701 x
20702 \end_layout
20703
20704 \end_inset
20705 </cell>
20706 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20707 \begin_inset Text
20708
20709 \begin_layout Standard
20710 -
20711 \end_layout
20712
20713 \end_inset
20714 </cell>
20715 </row>
20716 <row bottomline="true">
20717 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20718 \begin_inset Text
20719
20720 \begin_layout Standard
20721 string speed
20722 \begin_inset Foot
20723 status collapsed
20724
20725 \begin_layout Standard
20726 Execution time of printf("%s%c%s%c%c%c", "Hello", ' ', "World", '!', '
20727 \backslash
20728 r', '
20729 \backslash
20730 n'); standard 8051 @ 22.1184 MHz, empty putchar()
20731 \end_layout
20732
20733 \end_inset
20734
20735 ,
20736 \end_layout
20737
20738 \begin_layout Standard
20739 small / large
20740 \end_layout
20741
20742 \end_inset
20743 </cell>
20744 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20745 \begin_inset Text
20746
20747 \begin_layout Standard
20748 1.52 / 2.59 ms
20749 \end_layout
20750
20751 \end_inset
20752 </cell>
20753 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20754 \begin_inset Text
20755
20756 \begin_layout Standard
20757 1.53 / 2.62 ms
20758 \end_layout
20759
20760 \end_inset
20761 </cell>
20762 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20763 \begin_inset Text
20764
20765 \begin_layout Standard
20766 0.92 / 0.93 ms
20767 \end_layout
20768
20769 \end_inset
20770 </cell>
20771 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20772 \begin_inset Text
20773
20774 \begin_layout Standard
20775 0.45 / 0.45 ms
20776 \end_layout
20777
20778 \end_inset
20779 </cell>
20780 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20781 \begin_inset Text
20782
20783 \begin_layout Standard
20784 0.46 / 0.46 ms
20785 \end_layout
20786
20787 \end_inset
20788 </cell>
20789 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20790 \begin_inset Text
20791
20792 \begin_layout Standard
20793 0.45 / 0.45 ms
20794 \end_layout
20795
20796 \end_inset
20797 </cell>
20798 </row>
20799 <row bottomline="true">
20800 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20801 \begin_inset Text
20802
20803 \begin_layout Standard
20804 int speed
20805 \begin_inset Foot
20806 status collapsed
20807
20808 \begin_layout Standard
20809 Execution time of printf("%d", -12345); standard 8051 @ 22.1184 MHz, empty
20810  putchar()
20811 \end_layout
20812
20813 \end_inset
20814
20815 ,
20816 \end_layout
20817
20818 \begin_layout Standard
20819 small / large
20820 \end_layout
20821
20822 \end_inset
20823 </cell>
20824 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20825 \begin_inset Text
20826
20827 \begin_layout Standard
20828 3.01 / 3.61 ms
20829 \end_layout
20830
20831 \end_inset
20832 </cell>
20833 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20834 \begin_inset Text
20835
20836 \begin_layout Standard
20837 3.01 / 3.61 ms
20838 \end_layout
20839
20840 \end_inset
20841 </cell>
20842 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20843 \begin_inset Text
20844
20845 \begin_layout Standard
20846 3.51 / 18.13 ms
20847 \end_layout
20848
20849 \end_inset
20850 </cell>
20851 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20852 \begin_inset Text
20853
20854 \begin_layout Standard
20855 0.22 / 0.22 ms
20856 \end_layout
20857
20858 \end_inset
20859 </cell>
20860 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20861 \begin_inset Text
20862
20863 \begin_layout Standard
20864 0.23 / 0.23 ms
20865 \end_layout
20866
20867 \end_inset
20868 </cell>
20869 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20870 \begin_inset Text
20871
20872 \begin_layout Standard
20873 0.25 / 0.25 ms
20874 \begin_inset Foot
20875 status collapsed
20876
20877 \begin_layout Standard
20878 printf_tiny integer speed is data dependent, worst case is 0.33 ms
20879 \end_layout
20880
20881 \end_inset
20882
20883
20884 \end_layout
20885
20886 \end_inset
20887 </cell>
20888 </row>
20889 <row bottomline="true">
20890 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20891 \begin_inset Text
20892
20893 \begin_layout Standard
20894 long speed
20895 \begin_inset Foot
20896 status collapsed
20897
20898 \begin_layout Standard
20899 Execution time of printf("%ld", -123456789); standard 8051 @ 22.1184 MHz,
20900  empty putchar()
20901 \end_layout
20902
20903 \end_inset
20904
20905 ,
20906 \end_layout
20907
20908 \begin_layout Standard
20909 small / large
20910 \end_layout
20911
20912 \end_inset
20913 </cell>
20914 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20915 \begin_inset Text
20916
20917 \begin_layout Standard
20918 5.37 / 6.31 ms
20919 \end_layout
20920
20921 \end_inset
20922 </cell>
20923 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20924 \begin_inset Text
20925
20926 \begin_layout Standard
20927 5.37 / 6.31 ms
20928 \end_layout
20929
20930 \end_inset
20931 </cell>
20932 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20933 \begin_inset Text
20934
20935 \begin_layout Standard
20936 8.71 / 40.65 ms
20937 \end_layout
20938
20939 \end_inset
20940 </cell>
20941 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20942 \begin_inset Text
20943
20944 \begin_layout Standard
20945 0.40 / 0.40 ms
20946 \end_layout
20947
20948 \end_inset
20949 </cell>
20950 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20951 \begin_inset Text
20952
20953 \begin_layout Standard
20954 0.40 / 0.40 ms
20955 \end_layout
20956
20957 \end_inset
20958 </cell>
20959 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20960 \begin_inset Text
20961
20962 \begin_layout Standard
20963 -
20964 \end_layout
20965
20966 \end_inset
20967 </cell>
20968 </row>
20969 <row bottomline="true">
20970 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20971 \begin_inset Text
20972
20973 \begin_layout Standard
20974 float speed
20975 \begin_inset Foot
20976 status collapsed
20977
20978 \begin_layout Standard
20979 Execution time of printf("%.3f", -12345.678); standard 8051 @ 22.1184 MHz,
20980  empty putchar()
20981 \end_layout
20982
20983 \end_inset
20984
20985 ,
20986 \end_layout
20987
20988 \begin_layout Standard
20989 small / large
20990 \end_layout
20991
20992 \end_inset
20993 </cell>
20994 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20995 \begin_inset Text
20996
20997 \begin_layout Standard
20998 -
20999 \end_layout
21000
21001 \end_inset
21002 </cell>
21003 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21004 \begin_inset Text
21005
21006 \begin_layout Standard
21007 7.49 / 22.47 ms
21008 \end_layout
21009
21010 \end_inset
21011 </cell>
21012 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21013 \begin_inset Text
21014
21015 \begin_layout Standard
21016 -
21017 \end_layout
21018
21019 \end_inset
21020 </cell>
21021 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21022 \begin_inset Text
21023
21024 \begin_layout Standard
21025 -
21026 \end_layout
21027
21028 \end_inset
21029 </cell>
21030 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21031 \begin_inset Text
21032
21033 \begin_layout Standard
21034 1.04 / 1.04 ms
21035 \end_layout
21036
21037 \end_inset
21038 </cell>
21039 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21040 \begin_inset Text
21041
21042 \begin_layout Standard
21043 -
21044 \end_layout
21045
21046 \end_inset
21047 </cell>
21048 </row>
21049 </lyxtabular>
21050
21051 \end_inset
21052
21053
21054 \end_layout
21055
21056 \begin_layout Subsubsection
21057 <malloc.h>
21058 \begin_inset LatexCommand \index{malloc.h}
21059
21060 \end_inset
21061
21062
21063 \end_layout
21064
21065 \begin_layout Standard
21066 As of SDCC 2.6.2 you no longer need to call an initialization routine before
21067  using dynamic memory allocation
21068 \begin_inset LatexCommand \index{dynamic memory allocation (malloc)}
21069
21070 \end_inset
21071
21072  and a default heap
21073 \begin_inset LatexCommand \index{heap (malloc)}
21074
21075 \end_inset
21076
21077  space of 1024 bytes is provided for malloc to allocate memory from.
21078  If you need a different heap size you need to recompile _heap.c with the
21079  required size defined in HEAP_SIZE.
21080  It is recommended to make a copy of this file into your project directory
21081  and compile it there with:
21082 \end_layout
21083
21084 \begin_layout Verse
21085
21086 \family typewriter
21087 sdcc -c _heap.c -D HEAD_SIZE=2048
21088 \end_layout
21089
21090 \begin_layout Standard
21091 And then link it with:
21092 \end_layout
21093
21094 \begin_layout Verse
21095
21096 \family typewriter
21097 sdcc main.rel _heap.rel
21098 \end_layout
21099
21100 \begin_layout Subsection
21101 Math functions (sinf, powf, sqrtf etc.)
21102 \end_layout
21103
21104 \begin_layout Subsubsection
21105 <math.h>
21106 \end_layout
21107
21108 \begin_layout Standard
21109 See definitions in file <math.h>.
21110 \end_layout
21111
21112 \begin_layout Subsection
21113 Other libraries
21114 \end_layout
21115
21116 \begin_layout Standard
21117 Libraries
21118 \begin_inset LatexCommand \index{Libraries}
21119
21120 \end_inset
21121
21122  included in SDCC should have a license at least as liberal as the GNU Lesser
21123  General Public License
21124 \begin_inset LatexCommand \index{GNU Lesser General Public License, LGPL}
21125
21126 \end_inset
21127
21128  
21129 \emph on
21130 LGPL
21131 \emph default
21132 .
21133 \end_layout
21134
21135 \begin_layout Standard
21136 \begin_inset Note Note
21137 status collapsed
21138
21139 \begin_layout Standard
21140 license statements for the libraries are missing.
21141  sdcc/device/lib/ser_ir.c
21142 \end_layout
21143
21144 \begin_layout Standard
21145 or _decdptr f.e.
21146  come with a GPL (as opposed to LGPL) License - this will not be liberal
21147  enough for many embedded programmers.
21148 \end_layout
21149
21150 \end_inset
21151
21152
21153 \end_layout
21154
21155 \begin_layout Standard
21156 If you have ported some library or want to share experience about some code
21157  which f.e.
21158  falls into any of these categories Busses (I
21159 \begin_inset Formula $^{\textrm{2}}$
21160 \end_inset
21161
21162 C, CAN, Ethernet, Profibus, Modbus, USB, SPI, JTAG ...), Media (IDE, Memory
21163  cards, eeprom, flash...), En-/Decryption, Remote debugging, Realtime kernel,
21164  Keyboard, LCD, RTC, FPGA, PID then the sdcc-user mailing list 
21165 \begin_inset LatexCommand \url{http://sourceforge.net/mail/?group_id=599}
21166
21167 \end_inset
21168
21169 \InsetSpace ~
21170 would certainly like to hear about it.
21171 \end_layout
21172
21173 \begin_layout Standard
21174 Programmers coding for embedded systems are not especially famous for being
21175  enthusiastic, so don't expect a big hurray but as the mailing list is searchabl
21176 e these references are very valuable.
21177  Let's help to create a climate where information is shared.
21178 \begin_inset VSpace bigskip
21179 \end_inset
21180
21181
21182 \end_layout
21183
21184 \begin_layout Section
21185 Memory Models
21186 \end_layout
21187
21188 \begin_layout Subsection
21189 MCS51 Memory Models
21190 \begin_inset LatexCommand \index{Memory model}
21191
21192 \end_inset
21193
21194
21195 \begin_inset LatexCommand \index{MCS51 memory model}
21196
21197 \end_inset
21198
21199
21200 \end_layout
21201
21202 \begin_layout Subsubsection
21203 Small, Medium and Large
21204 \end_layout
21205
21206 \begin_layout Standard
21207 SDCC allows three memory models for MCS51 code, 
21208 \shape slanted
21209 small, medium
21210 \shape default
21211  and 
21212 \shape slanted
21213 large
21214 \shape default
21215 .
21216  Modules compiled with different memory models should 
21217 \emph on
21218 never
21219 \emph default
21220  be combined together or the results would be unpredictable.
21221  The library routines supplied with the compiler are compiled as small,
21222  medium and large.
21223  The compiled library modules are contained in separate directories as small,
21224  medium and large so that you can link to the appropriate set.
21225 \end_layout
21226
21227 \begin_layout Standard
21228 When the medium or large model is used all variables declared without a
21229  storage class will be allocated into the external ram, this includes all
21230  parameters and local variables (for non-reentrant
21231 \begin_inset LatexCommand \index{reentrant}
21232
21233 \end_inset
21234
21235  functions).
21236  When the small model is used variables without storage class are allocated
21237  in the internal ram.
21238 \end_layout
21239
21240 \begin_layout Standard
21241 Judicious usage of the processor specific storage classes
21242 \begin_inset LatexCommand \index{Storage class}
21243
21244 \end_inset
21245
21246  and the 'reentrant' function type will yield much more efficient code,
21247  than using the large model.
21248  Several optimizations are disabled when the program is compiled using the
21249  large model, it is therefore recommended that the small model be used unless
21250  absolutely required.
21251 \end_layout
21252
21253 \begin_layout Subsubsection
21254 External Stack
21255 \begin_inset LatexCommand \label{sub:External-Stack}
21256
21257 \end_inset
21258
21259
21260 \begin_inset LatexCommand \index{stack}
21261
21262 \end_inset
21263
21264
21265 \begin_inset LatexCommand \index{External stack (mcs51)}
21266
21267 \end_inset
21268
21269
21270 \end_layout
21271
21272 \begin_layout Standard
21273 The external stack (-
21274 \begin_inset ERT
21275 status collapsed
21276
21277 \begin_layout Standard
21278
21279
21280 \backslash
21281 /
21282 \end_layout
21283
21284 \end_inset
21285
21286 -xstack option
21287 \begin_inset LatexCommand \index{-\\/-xstack}
21288
21289 \end_inset
21290
21291 ) is located in pdata
21292 \begin_inset LatexCommand \index{pdata (mcs51, ds390 storage class)}
21293
21294 \end_inset
21295
21296  memory (usually at the start of the external ram segment) and uses all
21297  unused space in pdata (max.
21298  256 bytes).
21299  When -
21300 \begin_inset ERT
21301 status collapsed
21302
21303 \begin_layout Standard
21304
21305
21306 \backslash
21307 /
21308 \end_layout
21309
21310 \end_inset
21311
21312 -xstack option is used to compile the program, the parameters and local
21313  variables
21314 \begin_inset LatexCommand \index{local variables}
21315
21316 \end_inset
21317
21318  of all reentrant functions are allocated in this area.
21319  This option is provided for programs with large stack space requirements.
21320  When used with the -
21321 \begin_inset ERT
21322 status collapsed
21323
21324 \begin_layout Standard
21325
21326
21327 \backslash
21328 /
21329 \end_layout
21330
21331 \end_inset
21332
21333 -stack-auto
21334 \begin_inset LatexCommand \index{-\\/-stack-auto}
21335
21336 \end_inset
21337
21338  option, all parameters and local variables are allocated on the external
21339  stack (note: support libraries will need to be recompiled with the same
21340  options.
21341  There is a predefined target in the library makefile).
21342 \end_layout
21343
21344 \begin_layout Standard
21345 The compiler outputs the higher order address byte of the external ram segment
21346  into port P2
21347 \begin_inset LatexCommand \index{P2 (mcs51 sfr)}
21348
21349 \end_inset
21350
21351  (see also section 
21352 \begin_inset LatexCommand \ref{sub:MCS51-variants}
21353
21354 \end_inset
21355
21356 ), therefore when using the External Stack option, this port 
21357 \emph on
21358 may not
21359 \emph default
21360  be used by the application program.
21361 \end_layout
21362
21363 \begin_layout Subsection
21364 DS390 Memory Model
21365 \begin_inset LatexCommand \index{Memory model}
21366
21367 \end_inset
21368
21369
21370 \begin_inset LatexCommand \index{DS390 memory model}
21371
21372 \end_inset
21373
21374
21375 \end_layout
21376
21377 \begin_layout Standard
21378 The only model supported is Flat 24
21379 \begin_inset LatexCommand \index{Flat 24 (DS390 memory model)}
21380
21381 \end_inset
21382
21383 .
21384  This generates code for the 24 bit contiguous addressing mode of the Dallas
21385  DS80C390 part.
21386  In this mode, up to four meg of external RAM or code space can be directly
21387  addressed.
21388  See the data sheets at www.dalsemi.com for further information on this part.
21389 \newline
21390
21391 \newline
21392 Note
21393  that the compiler does not generate any code to place the processor into
21394  24 bitmode (although 
21395 \emph on
21396 tinibios
21397 \emph default
21398  in the ds390 libraries will do that for you).
21399  If you don't use 
21400 \emph on
21401 tinibios
21402 \emph default
21403
21404 \begin_inset LatexCommand \index{Tinibios (DS390)}
21405
21406 \end_inset
21407
21408 , the boot loader or similar code must ensure that the processor is in 24
21409  bit contiguous addressing mode before calling the SDCC startup code.
21410 \newline
21411
21412 \newline
21413 Like
21414  the 
21415 \emph on
21416 -
21417 \begin_inset ERT
21418 status collapsed
21419
21420 \begin_layout Standard
21421
21422
21423 \backslash
21424 /
21425 \end_layout
21426
21427 \end_inset
21428
21429 -model-large
21430 \emph default
21431  option, variables will by default be placed into the XDATA segment.
21432  
21433 \newline
21434
21435 \newline
21436 Segments may be placed anywhere in the 4 meg address space using the usual
21437  -
21438 \begin_inset ERT
21439 status collapsed
21440
21441 \begin_layout Standard
21442
21443
21444 \backslash
21445 /
21446 \end_layout
21447
21448 \end_inset
21449
21450 -*-loc options.
21451  Note that if any segments are located above 64K, the -r flag must be passed
21452  to the linker to generate the proper segment relocations, and the Intel
21453  HEX output format must be used.
21454  The -r flag can be passed to the linker by using the option 
21455 \emph on
21456 -Wl-r
21457 \emph default
21458  on the SDCC command line.
21459  However, currently the linker can not handle code segments > 64k.
21460 \end_layout
21461
21462 \begin_layout Section
21463 Pragmas
21464 \begin_inset LatexCommand \label{sec:Pragmas}
21465
21466 \end_inset
21467
21468
21469 \begin_inset LatexCommand \index{Pragmas}
21470
21471 \end_inset
21472
21473
21474 \end_layout
21475
21476 \begin_layout Standard
21477 Pragmas are used to turn on and/or off certain compiler options.
21478  Some of them are closely related to corresponding command-line options
21479  (see section 
21480 \begin_inset LatexCommand \vref{sec:Command-Line-Options}
21481
21482 \end_inset
21483
21484 ).
21485 \newline
21486 Pragmas should be placed before and/or after a function, placing pragmas
21487  inside a function body could have unpredictable results.
21488 \newline
21489
21490 \newline
21491 SDCC supports the
21492  following #pragma directives:
21493 \end_layout
21494
21495 \begin_layout Itemize
21496
21497 \series bold
21498 save
21499 \series default
21500
21501 \begin_inset LatexCommand \index{\\#pragma save}
21502
21503 \end_inset
21504
21505  - this will save most current options to the save/restore stack.
21506  See #pragma\InsetSpace ~
21507 restore.
21508 \end_layout
21509
21510 \begin_layout Itemize
21511
21512 \series bold
21513 restore
21514 \series default
21515
21516 \begin_inset LatexCommand \index{\\#pragma restore}
21517
21518 \end_inset
21519
21520  - will restore saved options from the last save.
21521  saves & restores can be nested.
21522  SDCC uses a save/restore stack: save pushes current options to the stack,
21523  restore pulls current options from the stack.
21524  See #pragma\InsetSpace ~
21525 save.
21526 \newline
21527
21528 \end_layout
21529
21530 \begin_layout Itemize
21531
21532 \series bold
21533 callee_saves
21534 \series default
21535
21536 \begin_inset LatexCommand \index{\\#pragma callee\\_saves}
21537
21538 \end_inset
21539
21540
21541 \begin_inset LatexCommand \index{function prologue}
21542
21543 \end_inset
21544
21545  function1[,function2[,function3...]] 
21546 \begin_inset LatexCommand \label{ite:callee_saves-function1[,function2[,function3...]]--}
21547
21548 \end_inset
21549
21550 - The compiler by default uses a caller saves convention for register saving
21551  across function calls, however this can cause unnecessary register pushing
21552  and popping
21553 \begin_inset LatexCommand \index{push/pop}
21554
21555 \end_inset
21556
21557  when calling small functions from larger functions.
21558  This option can be used to switch off the register saving convention for
21559  the function names specified.
21560  The compiler will not save registers when calling these functions, extra
21561  code need to be manually inserted at the entry and exit for these functions
21562  to save and restore the registers used by these functions, this can SUBSTANTIAL
21563 LY reduce code and improve run time performance of the generated code.
21564  In the future the compiler (with inter procedural analysis) may be able
21565  to determine the appropriate scheme to use for each function call.
21566  If -
21567 \begin_inset ERT
21568 status collapsed
21569
21570 \begin_layout Standard
21571
21572
21573 \backslash
21574 /
21575 \end_layout
21576
21577 \end_inset
21578
21579 -callee-saves command line option is used (see page 
21580 \begin_inset LatexCommand \vpageref{lyx:--callee-saves-function1[,function2][,function3]...}
21581
21582 \end_inset
21583
21584 ), the function names specified in #pragma\InsetSpace ~
21585 callee_saves
21586 \begin_inset LatexCommand \index{\\#pragma callee\\_saves}
21587
21588 \end_inset
21589
21590  is appended to the list of functions specified in the command line.
21591 \end_layout
21592
21593 \begin_layout Itemize
21594
21595 \series bold
21596 exclude
21597 \series default
21598
21599 \begin_inset LatexCommand \index{\\#pragma exclude}
21600
21601 \end_inset
21602
21603  none | {acc[,b[,dpl[,dph]]] - The exclude pragma disables the generation
21604  of pairs of push/pop
21605 \begin_inset LatexCommand \index{push/pop}
21606
21607 \end_inset
21608
21609  instructions in 
21610 \emph on
21611 I
21612 \emph default
21613 nterrupt
21614 \begin_inset LatexCommand \index{interrupt}
21615
21616 \end_inset
21617
21618  
21619 \emph on
21620 S
21621 \emph default
21622 ervice 
21623 \emph on
21624 R
21625 \emph default
21626 outines.
21627  The directive should be placed immediately before the ISR function definition
21628  and it affects ALL ISR functions following it.
21629  To enable the normal register saving for ISR functions use #pragma\InsetSpace ~
21630 exclude\InsetSpace ~
21631 none
21632 \begin_inset LatexCommand \index{\\#pragma exclude}
21633
21634 \end_inset
21635
21636 .
21637  See also the related keyword _naked
21638 \begin_inset LatexCommand \index{\\_naked}
21639
21640 \end_inset
21641
21642
21643 \begin_inset LatexCommand \index{\\_\\_naked}
21644
21645 \end_inset
21646
21647 .
21648 \end_layout
21649
21650 \begin_layout Itemize
21651
21652 \series bold
21653 less_pedantic
21654 \series default
21655
21656 \begin_inset LatexCommand \index{pedantic}
21657
21658 \end_inset
21659
21660
21661 \begin_inset LatexCommand \index{\\#pragma less\\_pedantic}
21662
21663 \end_inset
21664
21665  
21666 \begin_inset LatexCommand \label{ite:less_pedantic}
21667
21668 \end_inset
21669
21670 - the compiler will not warn you anymore for obvious mistakes, you're on
21671  your own now ;-( .
21672  See also the command line option -
21673 \begin_inset ERT
21674 status collapsed
21675
21676 \begin_layout Standard
21677
21678
21679 \backslash
21680 /
21681 \end_layout
21682
21683 \end_inset
21684
21685 -less-pedantic 
21686 \begin_inset LatexCommand \vpageref{lyx:--less-pedantic}
21687
21688 \end_inset
21689
21690 .
21691  
21692 \newline
21693 More specifically, the following warnings will be disabled: 
21694 \shape italic
21695 comparison is always [true/false] due to limited range of data type
21696 \shape default
21697  (94); 
21698 \shape italic
21699 overflow in implicit constant conversion
21700 \shape default
21701  (158); [the (in)famous] 
21702 \shape italic
21703 conditional flow changed by optimizer: so said EVELYN the modified DOG
21704 \shape default
21705  (110); 
21706 \shape italic
21707 function '[function name]' must return value
21708 \shape default
21709  (59).
21710  
21711 \newline
21712 Furthermore, warnings of less importance (of PEDANTIC and INFO warning
21713  level) are disabled, too, namely: 
21714 \shape italic
21715 constant value '[
21716 \begin_inset Note Note
21717 status collapsed
21718
21719 \begin_layout Standard
21720 dunno what comes here - this warning appears to be unused altogether
21721 \end_layout
21722
21723 \end_inset
21724
21725 ]', out of range
21726 \shape default
21727  (81); 
21728 \shape italic
21729 [left/right] shifting more than size of object changed to zero
21730 \shape default
21731  (116); 
21732 \shape italic
21733 unreachable code
21734 \shape default
21735  (126); 
21736 \shape italic
21737 integer overflow in expression
21738 \shape default
21739  (165); 
21740 \shape italic
21741 unmatched #pragma save and #pragma restore
21742 \shape default
21743  (170); 
21744 \shape italic
21745 comparison of 'signed char' with 'unsigned char' requires promotion to int
21746 \shape default
21747  (185); 
21748 \shape italic
21749 ISO C90 does not support flexible array members
21750 \shape default
21751  (187); 
21752 \shape italic
21753 extended stack by [number] bytes for compiler temp(s) :in function '[function\InsetSpace ~
21754 nam
21755 e]':\InsetSpace ~
21756 [
21757 \begin_inset Note Note
21758 status collapsed
21759
21760 \begin_layout Standard
21761 appears to be always blank - what was supposed to be here?
21762 \end_layout
21763
21764 \end_inset
21765
21766 ]
21767 \shape default
21768  (114); 
21769 \shape italic
21770 function '[function name]', # edges [number] , # nodes [number] , cyclomatic
21771  complexity [number]
21772 \shape default
21773  (121).
21774 \end_layout
21775
21776 \begin_layout Itemize
21777
21778 \series bold
21779 disable_warning
21780 \series default
21781  <nnnn>
21782 \begin_inset LatexCommand \index{\\#pragma disable\\_warning}
21783
21784 \end_inset
21785
21786  - the compiler will not warn you anymore about warning number <nnnn>.
21787 \end_layout
21788
21789 \begin_layout Itemize
21790
21791 \series bold
21792 nogcse
21793 \series default
21794
21795 \begin_inset LatexCommand \index{\\#pragma nogcse}
21796
21797 \end_inset
21798
21799  - will stop global common subexpression elimination.
21800 \end_layout
21801
21802 \begin_layout Itemize
21803
21804 \series bold
21805 noinduction
21806 \series default
21807
21808 \begin_inset LatexCommand \index{\\#pragma noinduction}
21809
21810 \end_inset
21811
21812  - will stop loop induction optimizations.
21813 \end_layout
21814
21815 \begin_layout Itemize
21816
21817 \series bold
21818 noinvariant
21819 \series default
21820
21821 \begin_inset LatexCommand \index{\\#pragma noinvariant}
21822
21823 \end_inset
21824
21825  - will not do loop invariant optimizations.
21826  For more details see Loop Invariants in section
21827 \begin_inset LatexCommand \ref{sub:Loop-Optimizations}
21828
21829 \end_inset
21830
21831 .
21832 \end_layout
21833
21834 \begin_layout Itemize
21835
21836 \series bold
21837 noiv
21838 \series default
21839
21840 \begin_inset LatexCommand \index{\\#pragma noiv}
21841
21842 \end_inset
21843
21844  - Do not generate interrupt
21845 \begin_inset LatexCommand \index{interrupt}
21846
21847 \end_inset
21848
21849  vector table
21850 \begin_inset LatexCommand \index{interrupt vector table}
21851
21852 \end_inset
21853
21854  entries for all ISR functions defined after the pragma.
21855  This is useful in cases where the interrupt vector table must be defined
21856  manually, or when there is a secondary, manually defined interrupt vector
21857  table (e.g.
21858  for the autovector feature of the Cypress EZ-USB FX2).
21859  More elegantly this can be achieved by obmitting the optional interrupt
21860  number after the interrupt keyword, see section 
21861 \begin_inset LatexCommand \ref{sub:Interrupt-Service-Routines}
21862
21863 \end_inset
21864
21865 \InsetSpace ~
21866 about interrupts.
21867 \end_layout
21868
21869 \begin_layout Itemize
21870
21871 \series bold
21872 nojtbound
21873 \series default
21874
21875 \begin_inset LatexCommand \index{\\#pragma nojtbound}
21876
21877 \end_inset
21878
21879  - will not generate code for boundary value checking, when switch statements
21880  are turned into jump-tables (dangerous).
21881  For more details see section 
21882 \begin_inset LatexCommand \ref{sub:'switch'-Statements}
21883
21884 \end_inset
21885
21886 .
21887 \end_layout
21888
21889 \begin_layout Itemize
21890
21891 \series bold
21892 noloopreverse
21893 \series default
21894
21895 \begin_inset LatexCommand \index{\\#pragma noloopreverse}
21896
21897 \end_inset
21898
21899  - Will not do loop reversal optimization
21900 \end_layout
21901
21902 \begin_layout Itemize
21903
21904 \series bold
21905 nooverlay
21906 \series default
21907
21908 \begin_inset LatexCommand \index{\\#pragma nooverlay}
21909
21910 \end_inset
21911
21912  - the compiler will not overlay the parameters and local variables of a
21913  function.
21914 \end_layout
21915
21916 \begin_layout Itemize
21917
21918 \series bold
21919 stackauto
21920 \series default
21921
21922 \begin_inset LatexCommand \index{\\#pragma stackauto}
21923
21924 \end_inset
21925
21926 - See option -
21927 \begin_inset ERT
21928 status collapsed
21929
21930 \begin_layout Standard
21931
21932
21933 \backslash
21934 /
21935 \end_layout
21936
21937 \end_inset
21938
21939 -stack-auto
21940 \begin_inset LatexCommand \index{-\\/-stack-auto}
21941
21942 \end_inset
21943
21944  and section 
21945 \begin_inset LatexCommand \ref{sec:Parameters-and-Local-Variables}
21946
21947 \end_inset
21948
21949  Parameters and Local Variables.
21950 \end_layout
21951
21952 \begin_layout Itemize
21953
21954 \series bold
21955 opt_code_speed
21956 \series default
21957  
21958 \begin_inset LatexCommand \index{\\#pragma opt\\_code\\_speed}
21959
21960 \end_inset
21961
21962 - The compiler will optimize code generation towards fast code, possibly
21963  at the expense of code size.
21964  Currently this has little effect.
21965 \end_layout
21966
21967 \begin_layout Itemize
21968
21969 \series bold
21970 opt_code_size
21971 \series default
21972  
21973 \begin_inset LatexCommand \index{\\#pragma opt\\_code\\_size}
21974
21975 \end_inset
21976
21977 - The compiler will optimize code generation towards compact code, possibly
21978  at the expense of code speed.
21979  Currently this has little effect.
21980 \end_layout
21981
21982 \begin_layout Itemize
21983
21984 \series bold
21985 opt_code_balanced
21986 \series default
21987  
21988 \begin_inset LatexCommand \index{\\#pragma opt\\_code\\_balanced}
21989
21990 \end_inset
21991
21992 - The compiler will attempt to generate code that is both compact and fast,
21993  as long as meeting one goal is not a detriment to the other (this is the
21994  default).
21995  
21996 \end_layout
21997
21998 \begin_layout Itemize
21999
22000 \series bold
22001 std_sdcc89
22002 \series default
22003  
22004 \begin_inset LatexCommand \index{\\#pragma std\\_sdcc89}
22005
22006 \end_inset
22007
22008 - Generally follow the C89 standard, but allow SDCC features that conflict
22009  with the standard (default).
22010 \end_layout
22011
22012 \begin_layout Itemize
22013
22014 \series bold
22015 std_c89
22016 \series default
22017  
22018 \begin_inset LatexCommand \index{\\#pragma std\\_c89}
22019
22020 \end_inset
22021
22022 - Follow the C89 standard and disable SDCC features that conflict with the
22023  standard.
22024 \end_layout
22025
22026 \begin_layout Itemize
22027
22028 \series bold
22029 std_sdcc99
22030 \series default
22031  
22032 \begin_inset LatexCommand \index{\\#pragma std\\_sdcc99}
22033
22034 \end_inset
22035
22036 - Generally follow the C99 standard, but allow SDCC features that conflict
22037  with the standard (incomplete support).
22038 \end_layout
22039
22040 \begin_layout Itemize
22041
22042 \series bold
22043 std_c99
22044 \series default
22045  
22046 \begin_inset LatexCommand \index{\\#pragma std\\_c99}
22047
22048 \end_inset
22049
22050 - Follow the C99 standard and disable SDCC features that conflict with the
22051  standard (incomplete support).
22052 \end_layout
22053
22054 \begin_layout Itemize
22055
22056 \series bold
22057 codeseg
22058 \series default
22059  <name>
22060 \begin_inset LatexCommand \index{\\#pragma codeseg}
22061
22062 \end_inset
22063
22064 - Use this name (max.
22065  8 characters) for the code segment.
22066  See option -
22067 \begin_inset ERT
22068 status collapsed
22069
22070 \begin_layout Standard
22071
22072
22073 \backslash
22074 /
22075 \end_layout
22076
22077 \end_inset
22078
22079 -codeseg.
22080 \end_layout
22081
22082 \begin_layout Itemize
22083
22084 \series bold
22085 constseg
22086 \series default
22087  <name>
22088 \begin_inset LatexCommand \index{\\#pragma constseg}
22089
22090 \end_inset
22091
22092 - Use this name (max.
22093  8 characters) for the const segment.
22094  See option -
22095 \begin_inset ERT
22096 status collapsed
22097
22098 \begin_layout Standard
22099
22100
22101 \backslash
22102 /
22103 \end_layout
22104
22105 \end_inset
22106
22107 -constseg.
22108 \end_layout
22109
22110 \begin_layout Standard
22111 The preprocessor SDCPP
22112 \begin_inset LatexCommand \index{sdcpp (preprocessor)}
22113
22114 \end_inset
22115
22116  supports the following #pragma directives:
22117 \end_layout
22118
22119 \begin_layout Itemize
22120
22121 \series bold
22122 pedantic_parse_number
22123 \series default
22124
22125 \begin_inset LatexCommand \index{pedantic}
22126
22127 \end_inset
22128
22129
22130 \begin_inset LatexCommand \index{\\#pragma pedantic\\_parse\\_number}
22131
22132 \end_inset
22133
22134  (+ | -) 
22135 \begin_inset LatexCommand \label{ite:pedantic_parse_number}
22136
22137 \end_inset
22138
22139 - Pedantic parse numbers so that situations like 0xfe-LO_B(3) are parsed
22140  properly and the macro LO_B(3) gets expanded.
22141  Default is off.
22142  See also the -
22143 \begin_inset ERT
22144 status collapsed
22145
22146 \begin_layout Standard
22147
22148
22149 \backslash
22150 /
22151 \end_layout
22152
22153 \end_inset
22154
22155 -pedantic-parse-number command line option 
22156 \begin_inset LatexCommand \vpageref{lyx:-pedantic-parse-number}
22157
22158 \end_inset
22159
22160 .
22161  
22162 \newline
22163 Below is an example on how to use this pragma.
22164  
22165 \emph on
22166 Note: this functionality is not in conformance with standard!
22167 \end_layout
22168
22169 \begin_layout Verse
22170
22171 \family typewriter
22172 #pragma pedantic_parse_number +
22173 \begin_inset LatexCommand \index{\\#pragma pedantic\\_parse\\_number}
22174
22175 \end_inset
22176
22177
22178 \newline
22179
22180 \newline
22181 #define LO_B(x) ((x) & 0xff)
22182 \newline
22183
22184 \newline
22185 unsigned char foo(void)
22186 \newline
22187 {
22188 \newline
22189 \InsetSpace ~
22190 \InsetSpace ~
22191 \InsetSpace ~
22192 unsigned char c=0xfe-LO_B(3)
22193 ;
22194 \newline
22195
22196 \newline
22197 \InsetSpace ~
22198 \InsetSpace ~
22199 \InsetSpace ~
22200 return c;
22201 \newline
22202 }
22203 \newline
22204
22205 \end_layout
22206
22207 \begin_layout Itemize
22208
22209 \series bold
22210 preproc_asm
22211 \series default
22212
22213 \begin_inset LatexCommand \index{\\#pragma preproc\\_asm}
22214
22215 \end_inset
22216
22217  (+ | -) - switch _asm _endasm block preprocessing on / off.
22218  Default is on.
22219  You use this prama to define multilines of assembly code.
22220  This will prevent the preprocessor from changing the formating required
22221  by assembly code.
22222  Below is an example on how to use this pragma.
22223 \end_layout
22224
22225 \begin_layout Verse
22226
22227 \family typewriter
22228 #pragma preproc_asm -
22229 \begin_inset LatexCommand \index{\\#pragma preproc\\_asm}
22230
22231 \end_inset
22232
22233
22234 \newline
22235 #define MYDELAY _asm
22236 \newline
22237 \InsetSpace ~
22238 \InsetSpace ~
22239 \InsetSpace ~
22240 nop ;my assembly comment...
22241 \newline
22242 \InsetSpace ~
22243 \InsetSpace ~
22244 \InsetSpace ~
22245 nop
22246 \newline
22247 \InsetSpace ~
22248 \InsetSpace ~
22249 \InsetSpace ~
22250 nop
22251 \newline
22252 _endasm
22253 \newline
22254 #pragma preproc_asm
22255  +
22256 \newline
22257
22258 \newline
22259 void foo (void) 
22260 \newline
22261
22262 \newline
22263 \InsetSpace ~
22264 \InsetSpace ~
22265 \InsetSpace ~
22266  ...
22267  
22268 \newline
22269 \InsetSpace ~
22270 \InsetSpace ~
22271 \InsetSpace ~
22272  MYDELAY;
22273 \newline
22274 \InsetSpace ~
22275 \InsetSpace ~
22276 \InsetSpace ~
22277  ...
22278  
22279 \newline
22280
22281 \newline
22282
22283 \end_layout
22284
22285 \begin_layout Itemize
22286
22287 \series bold
22288 sdcc_hash
22289 \series default
22290
22291 \begin_inset LatexCommand \index{\\#pragma sdcc\\_hash}
22292
22293 \end_inset
22294
22295  (+ | -) - Allow "naked" hash in macro definition, for example:
22296 \newline
22297
22298 \family typewriter
22299 #define DIR_LO(x) #(x & 0xff)
22300 \family default
22301
22302 \newline
22303 Default is off.
22304  Below is an example on how to use this pragma.
22305 \end_layout
22306
22307 \begin_layout Verse
22308
22309 \family typewriter
22310 #pragma preproc_asm +
22311 \newline
22312 #pragma sdcc_hash +
22313 \begin_inset LatexCommand \index{\\#pragma sdcc\\_hash}
22314
22315 \end_inset
22316
22317
22318 \newline
22319
22320 \newline
22321 #define ROMCALL(x) 
22322 \backslash
22323
22324 \newline
22325 \InsetSpace ~
22326 \InsetSpace ~
22327 \InsetSpace ~
22328 mov R6_B3, #(x & 0xff) 
22329 \backslash
22330
22331 \newline
22332 \InsetSpace ~
22333 \InsetSpace ~
22334 \InsetSpace ~
22335 mov R7_B3, #((x >> 8) & 0xff) 
22336 \backslash
22337
22338 \newline
22339 \InsetSpace ~
22340 \InsetSpace ~
22341 \InsetSpace ~
22342 lcall __romcall
22343 \newline
22344
22345 \newline
22346 ...
22347 \newline
22348 _asm
22349 \newline
22350 ROMCALL(72)
22351 \newline
22352 _endasm;
22353 \newline
22354 ...
22355 \newline
22356
22357 \end_layout
22358
22359 \begin_layout Standard
22360 Some of the pragmas are intended to be used to turn-on or off certain optimizati
22361 ons which might cause the compiler to generate extra stack and/or data space
22362  to store compiler generated temporary variables.
22363  This usually happens in large functions.
22364  Pragma directives should be used as shown in the following example, they
22365  are used to control options and optimizations for a given function.
22366  
22367 \end_layout
22368
22369 \begin_layout Verse
22370
22371 \family typewriter
22372 #pragma save
22373 \begin_inset LatexCommand \index{\\#pragma save}
22374
22375 \end_inset
22376
22377  \InsetSpace ~
22378 \InsetSpace ~
22379 \InsetSpace ~
22380 \InsetSpace ~
22381 \InsetSpace ~
22382 \InsetSpace ~
22383 \InsetSpace ~
22384 /* save the current settings */ 
22385 \newline
22386 #pragma nogcse
22387 \begin_inset LatexCommand \index{\\#pragma nogcse}
22388
22389 \end_inset
22390
22391  \InsetSpace ~
22392 \InsetSpace ~
22393 \InsetSpace ~
22394 \InsetSpace ~
22395 \InsetSpace ~
22396 /* turnoff global subexpression elimination */ 
22397 \newline
22398 #pragma noinduction
22399 \begin_inset LatexCommand \index{\\#pragma noinduction}
22400
22401 \end_inset
22402
22403  /* turn off induction optimizations */ 
22404 \newline
22405 int foo () 
22406 \newline
22407
22408 \newline
22409 \InsetSpace ~
22410  \InsetSpace ~
22411  ...
22412  
22413 \newline
22414 \InsetSpace ~
22415  \InsetSpace ~
22416  /* large code */ 
22417 \newline
22418 \InsetSpace ~
22419  \InsetSpace ~
22420  ...
22421  
22422 \newline
22423
22424 \newline
22425 #pragma restore
22426 \begin_inset LatexCommand \index{\\#pragma restore}
22427
22428 \end_inset
22429
22430  /* turn the optimizations back on */
22431 \end_layout
22432
22433 \begin_layout Standard
22434 The compiler will generate a warning message when extra space is allocated.
22435  It is strongly recommended that the save and restore pragmas be used when
22436  changing options for a function.
22437 \newline
22438
22439 \newline
22440
22441 \newline
22442
22443 \end_layout
22444
22445 \begin_layout Section
22446 Defines Created by the Compiler
22447 \end_layout
22448
22449 \begin_layout Standard
22450 The compiler creates the following #defines
22451 \begin_inset LatexCommand \index{\\#defines}
22452
22453 \end_inset
22454
22455
22456 \begin_inset LatexCommand \index{Defines created by the compiler}
22457
22458 \end_inset
22459
22460 :
22461 \newline
22462
22463 \end_layout
22464
22465 \begin_layout Standard
22466 \begin_inset Tabular
22467 <lyxtabular version="3" rows="11" columns="2">
22468 <features>
22469 <column alignment="left" valignment="top" leftline="true" width="3in">
22470 <column alignment="left" valignment="top" leftline="true" rightline="true" width="3in">
22471 <row topline="true" bottomline="true">
22472 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22473 \begin_inset Text
22474
22475 \begin_layout Standard
22476
22477 \series bold
22478 #define
22479 \end_layout
22480
22481 \end_inset
22482 </cell>
22483 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22484 \begin_inset Text
22485
22486 \begin_layout Standard
22487
22488 \series bold
22489 Description
22490 \end_layout
22491
22492 \end_inset
22493 </cell>
22494 </row>
22495 <row topline="true">
22496 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22497 \begin_inset Text
22498
22499 \begin_layout Standard
22500 SDCC
22501 \begin_inset LatexCommand \index{SDCC}
22502
22503 \end_inset
22504
22505  
22506 \end_layout
22507
22508 \end_inset
22509 </cell>
22510 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22511 \begin_inset Text
22512
22513 \begin_layout Standard
22514 Always defined.
22515  Since version 2.5.6 the version number as an int (ex.
22516  256)
22517 \end_layout
22518
22519 \end_inset
22520 </cell>
22521 </row>
22522 <row topline="true">
22523 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22524 \begin_inset Text
22525
22526 \begin_layout Standard
22527 SDCC_mcs51
22528 \begin_inset LatexCommand \index{SDCC\\_mcs51}
22529
22530 \end_inset
22531
22532  or SDCC_ds390
22533 \begin_inset LatexCommand \index{SDCC\\_ds390}
22534
22535 \end_inset
22536
22537  or SDCC_z80
22538 \begin_inset LatexCommand \index{SDCC\\_z80}
22539
22540 \end_inset
22541
22542 , etc.
22543 \end_layout
22544
22545 \end_inset
22546 </cell>
22547 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22548 \begin_inset Text
22549
22550 \begin_layout Standard
22551 depending on the model used (e.g.: -mds390)
22552 \end_layout
22553
22554 \end_inset
22555 </cell>
22556 </row>
22557 <row topline="true">
22558 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22559 \begin_inset Text
22560
22561 \begin_layout Standard
22562 __mcs51
22563 \begin_inset LatexCommand \index{\\_\\_mcs51}
22564
22565 \end_inset
22566
22567 , __ds390
22568 \begin_inset LatexCommand \index{\\_\\_ds390}
22569
22570 \end_inset
22571
22572 , __hc08
22573 \begin_inset LatexCommand \index{\\_\\_hc08}
22574
22575 \end_inset
22576
22577 , __z80
22578 \begin_inset LatexCommand \index{\\_\\_z80}
22579
22580 \end_inset
22581
22582 , etc
22583 \end_layout
22584
22585 \end_inset
22586 </cell>
22587 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22588 \begin_inset Text
22589
22590 \begin_layout Standard
22591 depending on the model used (e.g.
22592  -mz80)
22593 \end_layout
22594
22595 \end_inset
22596 </cell>
22597 </row>
22598 <row topline="true">
22599 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22600 \begin_inset Text
22601
22602 \begin_layout Standard
22603 SDCC_STACK_AUTO
22604 \begin_inset LatexCommand \index{SDCC\\_STACK\\_AUTO}
22605
22606 \end_inset
22607
22608
22609 \end_layout
22610
22611 \end_inset
22612 </cell>
22613 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22614 \begin_inset Text
22615
22616 \begin_layout Standard
22617 when 
22618 \emph on
22619 -
22620 \begin_inset ERT
22621 status collapsed
22622
22623 \begin_layout Standard
22624
22625
22626 \backslash
22627 /
22628 \end_layout
22629
22630 \end_inset
22631
22632 -stack-auto
22633 \emph default
22634  option is used
22635 \end_layout
22636
22637 \end_inset
22638 </cell>
22639 </row>
22640 <row topline="true">
22641 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22642 \begin_inset Text
22643
22644 \begin_layout Standard
22645 SDCC_MODEL_SMALL
22646 \begin_inset LatexCommand \index{SDCC\\_MODEL\\_SMALL}
22647
22648 \end_inset
22649
22650
22651 \end_layout
22652
22653 \end_inset
22654 </cell>
22655 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22656 \begin_inset Text
22657
22658 \begin_layout Standard
22659 when 
22660 \emph on
22661 -
22662 \begin_inset ERT
22663 status collapsed
22664
22665 \begin_layout Standard
22666
22667
22668 \backslash
22669 /
22670 \end_layout
22671
22672 \end_inset
22673
22674 -model-small
22675 \emph default
22676  is used
22677 \end_layout
22678
22679 \end_inset
22680 </cell>
22681 </row>
22682 <row topline="true">
22683 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22684 \begin_inset Text
22685
22686 \begin_layout Standard
22687 SDCC_MODEL_MEDIUM
22688 \begin_inset LatexCommand \index{SDCC\\_MODEL\\_MEDIUM}
22689
22690 \end_inset
22691
22692
22693 \end_layout
22694
22695 \end_inset
22696 </cell>
22697 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22698 \begin_inset Text
22699
22700 \begin_layout Standard
22701 when 
22702 \emph on
22703 -
22704 \begin_inset ERT
22705 status collapsed
22706
22707 \begin_layout Standard
22708
22709
22710 \backslash
22711 /
22712 \end_layout
22713
22714 \end_inset
22715
22716 -model-medium
22717 \emph default
22718  is used
22719 \end_layout
22720
22721 \end_inset
22722 </cell>
22723 </row>
22724 <row topline="true">
22725 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22726 \begin_inset Text
22727
22728 \begin_layout Standard
22729 SDCC_MODEL_LARGE
22730 \begin_inset LatexCommand \index{SDCC\\_MODEL\\_LARGE}
22731
22732 \end_inset
22733
22734
22735 \end_layout
22736
22737 \end_inset
22738 </cell>
22739 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22740 \begin_inset Text
22741
22742 \begin_layout Standard
22743 when 
22744 \emph on
22745 -
22746 \begin_inset ERT
22747 status collapsed
22748
22749 \begin_layout Standard
22750
22751
22752 \backslash
22753 /
22754 \end_layout
22755
22756 \end_inset
22757
22758 -model-large
22759 \emph default
22760  is used
22761 \end_layout
22762
22763 \end_inset
22764 </cell>
22765 </row>
22766 <row topline="true">
22767 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22768 \begin_inset Text
22769
22770 \begin_layout Standard
22771 SDCC_USE_XSTACK
22772 \begin_inset LatexCommand \index{SDCC\\_USE\\_XSTACK}
22773
22774 \end_inset
22775
22776
22777 \end_layout
22778
22779 \end_inset
22780 </cell>
22781 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22782 \begin_inset Text
22783
22784 \begin_layout Standard
22785 when 
22786 \emph on
22787 -
22788 \begin_inset ERT
22789 status collapsed
22790
22791 \begin_layout Standard
22792
22793
22794 \backslash
22795 /
22796 \end_layout
22797
22798 \end_inset
22799
22800 -xstack
22801 \emph default
22802  option is used
22803 \end_layout
22804
22805 \end_inset
22806 </cell>
22807 </row>
22808 <row topline="true">
22809 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22810 \begin_inset Text
22811
22812 \begin_layout Standard
22813 SDCC_STACK_TENBIT
22814 \begin_inset LatexCommand \index{SDCC\\_STACK\\_TENBIT}
22815
22816 \end_inset
22817
22818  
22819 \end_layout
22820
22821 \end_inset
22822 </cell>
22823 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22824 \begin_inset Text
22825
22826 \begin_layout Standard
22827 when 
22828 \emph on
22829 -mds390
22830 \emph default
22831  is used
22832 \end_layout
22833
22834 \end_inset
22835 </cell>
22836 </row>
22837 <row topline="true" bottomline="true">
22838 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22839 \begin_inset Text
22840
22841 \begin_layout Standard
22842 SDCC_MODEL_FLAT24
22843 \begin_inset LatexCommand \index{SDCC\\_MODEL\\_FLAT24}
22844
22845 \end_inset
22846
22847
22848 \end_layout
22849
22850 \end_inset
22851 </cell>
22852 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22853 \begin_inset Text
22854
22855 \begin_layout Standard
22856 when 
22857 \emph on
22858 -mds390
22859 \emph default
22860  is used
22861 \end_layout
22862
22863 \end_inset
22864 </cell>
22865 </row>
22866 </lyxtabular>
22867
22868 \end_inset
22869
22870
22871 \end_layout
22872
22873 \begin_layout Chapter
22874 Notes on supported Processors
22875 \end_layout
22876
22877 \begin_layout Section
22878 MCS51 variants
22879 \begin_inset LatexCommand \label{sub:MCS51-variants}
22880
22881 \end_inset
22882
22883
22884 \begin_inset LatexCommand \index{MCS51 variants}
22885
22886 \end_inset
22887
22888
22889 \end_layout
22890
22891 \begin_layout Standard
22892 MCS51 processors are available from many vendors and come in many different
22893  flavours.
22894  While they might differ considerably in respect to Special Function Registers
22895  the core MCS51 is usually not modified or is kept compatible.
22896  
22897 \end_layout
22898
22899 \begin_layout Subsection
22900 pdata access by SFR 
22901 \end_layout
22902
22903 \begin_layout Standard
22904 With the upcome of devices with internal xdata and flash memory devices
22905  using port P2
22906 \begin_inset LatexCommand \index{P2 (mcs51 sfr)}
22907
22908 \end_inset
22909
22910  as dedicated I/O port is becoming more popular.
22911  Switching the high byte for pdata
22912 \begin_inset LatexCommand \index{pdata (mcs51, ds390 storage class)}
22913
22914 \end_inset
22915
22916  access which was formerly done by port P2 is then achieved by a Special
22917  Function Register
22918 \begin_inset LatexCommand \index{sfr}
22919
22920 \end_inset
22921
22922 .
22923  In well-established MCS51 tradition the address of this 
22924 \emph on
22925 sfr
22926 \emph default
22927  is where the chip designers decided to put it.
22928  Needless to say that they didn't agree on a common name either.
22929  So that the startup code can correctly initialize xdata variables, you
22930  should define an sfr with the name _XPAGE
22931 \family typewriter
22932
22933 \begin_inset LatexCommand \index{\\_XPAGE (mcs51)}
22934
22935 \end_inset
22936
22937
22938 \family default
22939  at the appropriate location if the default, port P2, is not used for this.
22940  Some examples are:
22941 \end_layout
22942
22943 \begin_layout Verse
22944
22945 \family typewriter
22946 __sfr __at (0x85) _XPAGE; /* Ramtron VRS51 family a.k.a.
22947  MPAGE */
22948 \end_layout
22949
22950 \begin_layout Verse
22951
22952 \family typewriter
22953 __sfr __at (0x92) _XPAGE; /* Cypress EZ-USB family, Texas Instruments (Chipcon)
22954  a.k.a.
22955  MPAGE */
22956 \end_layout
22957
22958 \begin_layout Verse
22959
22960 \family typewriter
22961 __sfr __at (0x91) _XPAGE; /* Infineon (Siemens) C500 family a.k.a.
22962  XPAGE */
22963 \end_layout
22964
22965 \begin_layout Verse
22966
22967 \family typewriter
22968 __sfr __at (0xaf) _XPAGE; /* some Silicon Labs (Cygnal) chips a.k.a.
22969  EMI0CN */
22970 \end_layout
22971
22972 \begin_layout Verse
22973
22974 \family typewriter
22975 __sfr __at (0xaa) _XPAGE; /* some Silicon Labs (Cygnal) chips a.k.a.
22976  EMI0CN */
22977 \end_layout
22978
22979 \begin_layout Standard
22980 For more exotic implementations further customizations may be needed.
22981  See section 
22982 \begin_inset LatexCommand \ref{sub:Startup-Code}
22983
22984 \end_inset
22985
22986  for other possibilities.
22987 \end_layout
22988
22989 \begin_layout Subsection
22990 Other Features available by SFR
22991 \end_layout
22992
22993 \begin_layout Standard
22994 Some MCS51 variants offer features like Double DPTR
22995 \begin_inset LatexCommand \index{DPTR}
22996
22997 \end_inset
22998
22999 , multiple DPTR, decrementing DPTR, 16x16 Multiply.
23000  These are currently not used for the MCS51 port.
23001  If you absolutely need them you can fall back to inline assembly or submit
23002  a patch to SDCC.
23003 \begin_inset VSpace bigskip
23004 \end_inset
23005
23006
23007 \end_layout
23008
23009 \begin_layout Section
23010 DS400 port
23011 \end_layout
23012
23013 \begin_layout Standard
23014 The DS80C400
23015 \begin_inset LatexCommand \index{DS80C400}
23016
23017 \end_inset
23018
23019
23020 \begin_inset LatexCommand \index{DS400}
23021
23022 \end_inset
23023
23024  microcontroller has a rich set of peripherals.
23025  In its built-in ROM library it includes functions to access some of the
23026  features, among them is a TCP stack with IP4 and IP6 support.
23027  Library headers (currently in beta status) and other files are provided
23028  at 
23029 \size footnotesize
23030
23031 \begin_inset LatexCommand \url{ftp://ftp.dalsemi.com/pub/tini/ds80c400/c_libraries/sdcc/index.html}
23032
23033 \end_inset
23034
23035 .
23036  
23037 \begin_inset VSpace bigskip
23038 \end_inset
23039
23040
23041 \end_layout
23042
23043 \begin_layout Section
23044 The Z80 and gbz80 port
23045 \end_layout
23046
23047 \begin_layout Standard
23048 SDCC can target both the Zilog Z80
23049 \begin_inset LatexCommand \index{Z80}
23050
23051 \end_inset
23052
23053  and the Nintendo Gameboy's Z80-like gbz80
23054 \begin_inset LatexCommand \index{gbz80 (GameBoy Z80)}
23055
23056 \end_inset
23057
23058 .
23059  The Z80 port is passed through the same 
23060 \emph on
23061 regressions tests
23062 \begin_inset LatexCommand \index{Regression test}
23063
23064 \end_inset
23065
23066
23067 \emph default
23068  (see section 
23069 \begin_inset LatexCommand \ref{sec:Quality-control}
23070
23071 \end_inset
23072
23073 ) as the MCS51 and DS390 ports, so floating point support, support for long
23074  variables and bitfield support is fine.
23075  See mailing lists and forums about interrupt routines.
23076 \end_layout
23077
23078 \begin_layout Standard
23079 As always, the code is the authoritative reference - see z80/ralloc.c and
23080  z80/gen.c.
23081  The stack
23082 \begin_inset LatexCommand \index{Z80!stack}
23083
23084 \end_inset
23085
23086  frame is similar to that generated by the IAR Z80 compiler.
23087  IX is used as the base pointer, HL and IY are used as a temporary registers,
23088  and BC and DE are available for holding variables.
23089  Return values
23090 \begin_inset LatexCommand \index{Z80!return value}
23091
23092 \end_inset
23093
23094  for the Z80 port are stored in L (one byte), HL (two bytes), or DEHL (four
23095  bytes).
23096  The gbz80 port use the same set of registers for the return values, but
23097  in a different order of significance: E (one byte), DE (two bytes), or
23098  HLDE (four bytes).
23099 \begin_inset VSpace bigskip
23100 \end_inset
23101
23102
23103 \end_layout
23104
23105 \begin_layout Section
23106 The HC08 port
23107 \end_layout
23108
23109 \begin_layout Standard
23110 The port to the Freescale/Motorola HC08
23111 \begin_inset LatexCommand \index{HC08}
23112
23113 \end_inset
23114
23115  family has been added in October 2003, and is still undergoing some basic
23116  development.
23117  The code generator is complete, but the register allocation is still quite
23118  unoptimized.
23119  Some of the SDCC's standard C library functions have embedded non-HC08
23120  inline assembly and so are not yet usable.
23121 \end_layout
23122
23123 \begin_layout Standard
23124 The HC08 port passes the regression test suite (see section 
23125 \begin_inset LatexCommand \ref{sec:Quality-control}
23126
23127 \end_inset
23128
23129 ).
23130 \begin_inset VSpace bigskip
23131 \end_inset
23132
23133
23134 \newpage
23135
23136 \end_layout
23137
23138 \begin_layout Section
23139 The PIC14
23140 \begin_inset LatexCommand \index{PIC14}
23141
23142 \end_inset
23143
23144  port
23145 \end_layout
23146
23147 \begin_layout Standard
23148 The PIC14 port adds support for Microchip
23149 \begin_inset LatexCommand \index{Microchip}
23150
23151 \end_inset
23152
23153
23154 \begin_inset Formula $^{\text{TM}}$
23155 \end_inset
23156
23157  PIC
23158 \begin_inset LatexCommand \index{PIC14}
23159
23160 \end_inset
23161
23162
23163 \begin_inset Formula $^{\text{TM}}$
23164 \end_inset
23165
23166  MCUs with 14 bit wide instructions.
23167  This port is not yet mature and still lacks many features.
23168  However, it can work for simple code.
23169 \end_layout
23170
23171 \begin_layout Standard
23172 Currently supported devices include:
23173 \end_layout
23174
23175 \begin_layout Standard
23176 12F: 629, 635, 675, 683
23177 \end_layout
23178
23179 \begin_layout Standard
23180 16C: 432, 433
23181 \end_layout
23182
23183 \begin_layout Standard
23184 16C: 554, 557, 558
23185 \end_layout
23186
23187 \begin_layout Standard
23188 16C: 62, 620, 620a, 621, 621a, 622, 622a, 63a, 65b
23189 \end_layout
23190
23191 \begin_layout Standard
23192 16C: 71, 710, 711, 715, 717, 72, 73b, 745, 74b, 765, 770, 771, 773, 774,
23193  781, 782
23194 \end_layout
23195
23196 \begin_layout Standard
23197 16C: 925, 926
23198 \end_layout
23199
23200 \begin_layout Standard
23201 16F: 627, 627a, 628, 628a, 630, 636, 639, 648a, 676, 684, 685, 687, 688,
23202  689, 690
23203 \end_layout
23204
23205 \begin_layout Standard
23206 16F: 716, 72, 73, 737, 74, 76, 767, 77, 777, 785
23207 \end_layout
23208
23209 \begin_layout Standard
23210 16F: 818, 819, 84, 84a, 87, 870, 871, 872, 873, 873a, 874, 874a, 876, 876a,
23211  877, 877a, 88
23212 \end_layout
23213
23214 \begin_layout Standard
23215 16F: 913, 914, 916, 917
23216 \end_layout
23217
23218 \begin_layout Standard
23219 An up-to-date list of currently supported devices can be obtained via 
23220 \family typewriter
23221 sdcc -mpic14 -phelp foo.c
23222 \family default
23223  (foo.c must exist...).
23224 \end_layout
23225
23226 \begin_layout Subsection
23227 PIC Code Pages
23228 \begin_inset LatexCommand \index{code page (pic14)}
23229
23230 \end_inset
23231
23232  and Memory Banks
23233 \begin_inset LatexCommand \index{Memory bank (pic14)}
23234
23235 \end_inset
23236
23237
23238 \end_layout
23239
23240 \begin_layout Standard
23241 The linker organizes allocation for the code page and RAM banks.
23242  It does not have intimate knowledge of the code flow.
23243  It will put all the code section of a single .asm file into a single code
23244  page.
23245  In order to make use of multiple code pages, separate asm files must be
23246  used.
23247  The compiler assigns all 
23248 \emph on
23249 static
23250 \emph default
23251  functions of a single .c file into the same code page.
23252 \newline
23253
23254 \newline
23255 To get the best results,
23256  follow these guidelines:
23257 \end_layout
23258
23259 \begin_layout Enumerate
23260 Make local functions static, as non static functions require code page selection
23261  overhead.
23262 \newline
23263 Due to the way sdcc handles functions, place called functions prior
23264  to calling functions in the file wherever possible: Otherwise sdcc will
23265  insert unneccessary pagesel directives around the call, believing that
23266  the called function is externally defined.
23267 \end_layout
23268
23269 \begin_layout Enumerate
23270 For devices that have multiple code pages it is more efficient to use the
23271  same number of files as pages: Use up to 4 separate .c files for the 16F877,
23272  but only 2 files for the 16F874.
23273  This way the linker can put the code for each file into different code
23274  pages and there will be less page selection overhead.
23275 \end_layout
23276
23277 \begin_layout Enumerate
23278 And as for any 8 bit micro (especially for PIC14 as they have a very simple
23279  instruction set), use `unsigned char' wherever possible instead of `int'.
23280 \end_layout
23281
23282 \begin_layout Subsection
23283 Adding New Devices to the Port 
23284 \end_layout
23285
23286 \begin_layout Standard
23287 Adding support for a new 14
23288 \begin_inset ERT
23289 status open
23290
23291 \begin_layout Standard
23292
23293
23294 \backslash
23295 ,
23296 \end_layout
23297
23298 \end_inset
23299
23300 bit PIC MCU requires the following steps:
23301 \end_layout
23302
23303 \begin_layout Enumerate
23304 Create a new device description.
23305 \newline
23306 Each device is described in two files: pic16f*.h
23307  and pic16f*.c.
23308  These files primarily define SFRs, structs to access their bits, and symbolic
23309  configuration options.
23310  Both files can be generated from gputils' .inc files using the perl script
23311  
23312 \family typewriter
23313 support/scripts/inc2h.pl
23314 \family default
23315 .
23316  This file also contains further instructions on how to proceed.
23317 \end_layout
23318
23319 \begin_layout Enumerate
23320 Copy the .h file into SDCC's include path and either add the .c file to your
23321  project or copy it to 
23322 \family typewriter
23323 device/lib/pic/libdev
23324 \family default
23325 .
23326  Afterwards, rebuild and install the libraries.
23327 \end_layout
23328
23329 \begin_layout Enumerate
23330 Edit pic14devices.txt in SDCC's include path (
23331 \family typewriter
23332 device/include/pic/
23333 \family default
23334  in the source tree or 
23335 \family typewriter
23336 /usr/local/share/sdcc/include/pic
23337 \family default
23338  after installation).
23339 \newline
23340 You need to add a device specification here to make
23341  the memory layout (code banks, RAM, aliased memory regions, ...) known to
23342  the compiler.
23343  Probably you can copy and modify an existing entry.
23344  The file format is documented at the top of the file.
23345 \end_layout
23346
23347 \begin_layout Subsection
23348 Interrupt Code
23349 \end_layout
23350
23351 \begin_layout Standard
23352 For the interrupt function, use the keyword `__interrupt'
23353 \begin_inset LatexCommand \index{PIC14!interrupt}
23354
23355 \end_inset
23356
23357  with level number of 0 (PIC14 only has 1 interrupt so this number is only
23358  there to avoid a syntax error - it ought to be fixed).
23359  E.g.:
23360 \end_layout
23361
23362 \begin_layout Verse
23363
23364 \family typewriter
23365 void Intr(void) __interrupt 0
23366 \newline
23367 {
23368 \newline
23369 \InsetSpace ~
23370 \InsetSpace ~
23371 T0IF = 0; /* Clear timer interrupt */
23372 \newline
23373 }
23374 \end_layout
23375
23376 \begin_layout Subsection
23377 Linking and Assembling
23378 \end_layout
23379
23380 \begin_layout Standard
23381 For assembling you can use either GPUTILS'
23382 \begin_inset LatexCommand \index{gputils (pic tools)}
23383
23384 \end_inset
23385
23386  gpasm.exe or MPLAB's mpasmwin.exe.
23387  GPUTILS are available from 
23388 \begin_inset LatexCommand \url{http://sourceforge.net/projects/gputils}
23389
23390 \end_inset
23391
23392 .
23393  For linking you can use either GPUTILS' gplink or MPLAB's mplink.exe.
23394  If you use MPLAB and an interrupt function then the linker script file
23395  vectors section will need to be enlarged to link with mplink.
23396 \newline
23397
23398 \newline
23399 Here is a 
23400 \family typewriter
23401 Makefile
23402 \family default
23403  using GPUTILS:
23404 \end_layout
23405
23406 \begin_layout Verse
23407
23408 \family typewriter
23409 .c.o:
23410 \newline
23411 \InsetSpace ~
23412 \InsetSpace ~
23413 \InsetSpace ~
23414 \InsetSpace ~
23415 \InsetSpace ~
23416 \InsetSpace ~
23417 \InsetSpace ~
23418 \InsetSpace ~
23419 sdcc -V -mpic14 -p16f877 -c $< 
23420 \newline
23421
23422 \newline
23423 $(PRJ).hex: $(OBJS) 
23424 \newline
23425 \InsetSpace ~
23426 \InsetSpace ~
23427 \InsetSpace ~
23428 \InsetSpace ~
23429 \InsetSpace ~
23430 \InsetSpace ~
23431 \InsetSpace ~
23432 \InsetSpace ~
23433 gplink -m -s $(PRJ).lkr
23434  -o $(PRJ).hex $(OBJS) libsdcc.lib
23435 \end_layout
23436
23437 \begin_layout Standard
23438 Here is a 
23439 \family typewriter
23440 Makefile
23441 \family default
23442  using MPLAB:
23443 \end_layout
23444
23445 \begin_layout Verse
23446
23447 \family typewriter
23448 .c.o: 
23449 \newline
23450 \InsetSpace ~
23451 \InsetSpace ~
23452 \InsetSpace ~
23453 \InsetSpace ~
23454 \InsetSpace ~
23455 \InsetSpace ~
23456 \InsetSpace ~
23457 \InsetSpace ~
23458 sdcc -S -V -mpic14 -p16f877 $< 
23459 \newline
23460 \InsetSpace ~
23461 \InsetSpace ~
23462 \InsetSpace ~
23463 \InsetSpace ~
23464 \InsetSpace ~
23465 \InsetSpace ~
23466 \InsetSpace ~
23467 \InsetSpace ~
23468 mpasmwin /q /o $*.asm
23469 \newline
23470
23471 \newline
23472 $(PRJ).hex: $(OBJS)
23473  
23474 \newline
23475 \InsetSpace ~
23476 \InsetSpace ~
23477 \InsetSpace ~
23478 \InsetSpace ~
23479 \InsetSpace ~
23480 \InsetSpace ~
23481 \InsetSpace ~
23482 \InsetSpace ~
23483 mplink /v $(PRJ).lkr /m $(PRJ).map /o $(PRJ).hex $(OBJS) libsdcc.lib
23484 \end_layout
23485
23486 \begin_layout Standard
23487 Please note that indentations within a 
23488 \family typewriter
23489 Makefile
23490 \family default
23491  have to be done with a tabulator character.
23492 \end_layout
23493
23494 \begin_layout Subsection
23495 Command-Line Options
23496 \end_layout
23497
23498 \begin_layout Standard
23499 Besides the switches common to all SDCC backends, the PIC14 port accepts
23500  the following options (for an updated list see sdcc -
23501 \begin_inset ERT
23502 status collapsed
23503
23504 \begin_layout Standard
23505
23506
23507 \backslash
23508 /
23509 \end_layout
23510
23511 \end_inset
23512
23513 -help):
23514 \end_layout
23515
23516 \begin_layout Description
23517 -
23518 \begin_inset ERT
23519 status collapsed
23520
23521 \begin_layout Standard
23522
23523
23524 \backslash
23525 /
23526 \end_layout
23527
23528 \end_inset
23529
23530 -debug-xtra
23531 \begin_inset LatexCommand \index{PIC14!Options!-\\/-debug-extra}
23532
23533 \end_inset
23534
23535  emit debug info in assembly output
23536 \end_layout
23537
23538 \begin_layout Description
23539 -
23540 \begin_inset ERT
23541 status collapsed
23542
23543 \begin_layout Standard
23544
23545
23546 \backslash
23547 /
23548 \end_layout
23549
23550 \end_inset
23551
23552 -no-pcode-opt
23553 \begin_inset LatexCommand \index{PIC14!Options!-\\/-no-pcode-opt}
23554
23555 \end_inset
23556
23557  disable (slightly faulty) optimization on pCode
23558 \end_layout
23559
23560 \begin_layout Description
23561 -
23562 \begin_inset ERT
23563 status collapsed
23564
23565 \begin_layout Standard
23566
23567
23568 \backslash
23569 /
23570 \end_layout
23571
23572 \end_inset
23573
23574 -stack-loc
23575 \begin_inset LatexCommand \index{PIC14!Options!-\\/-stack-loc}
23576
23577 \end_inset
23578
23579  sets the lowest address of the argument passing stack (defaults to a suitably
23580  large shared databank to reduce BANKSEL overhead)
23581 \end_layout
23582
23583 \begin_layout Description
23584 -
23585 \begin_inset ERT
23586 status collapsed
23587
23588 \begin_layout Standard
23589
23590
23591 \backslash
23592 /
23593 \end_layout
23594
23595 \end_inset
23596
23597 -stack-size
23598 \begin_inset LatexCommand \index{PIC14!Options!-\\/-stack-size}
23599
23600 \end_inset
23601
23602  sets the size if the argument passing stack (default: 16, minimum: 4)
23603 \end_layout
23604
23605 \begin_layout Subsection
23606 Environment Variables
23607 \end_layout
23608
23609 \begin_layout Standard
23610 The PIC14 port recognizes the following environment variables:
23611 \end_layout
23612
23613 \begin_layout Description
23614 SDCC_PIC14_SPLIT_LOCALS If set and not empty, sdcc will allocate each temporary
23615  register (the ones called r0xNNNN) in a section of its own.
23616  By default (if this variable is unset), sdcc tries to cluster registers
23617  in sections in order to reduce the BANKSEL overhead when accessing them.
23618 \end_layout
23619
23620 \begin_layout Subsection
23621 The Library
23622 \end_layout
23623
23624 \begin_layout Standard
23625 The PIC14 library currently only contains support routines required by the
23626  compiler to implement multiplication, division, and floating point support.
23627  No libc-like replacement is available at the moment, though many of the
23628  common sdcc library sources (in 
23629 \family typewriter
23630 device/lib
23631 \family default
23632 ) should also compile with the PIC14 port.
23633 \end_layout
23634
23635 \begin_layout Subsubsection
23636 error: missing definition for symbol ``__gptrget1''
23637 \end_layout
23638
23639 \begin_layout Standard
23640 The PIC14 port uses library routines to provide more complex operations
23641  like multiplication, division/modulus and (generic) pointer dereferencing.
23642  In order to add these routines to your project, you must link with PIC14's
23643  
23644 \family typewriter
23645 libsdcc.lib
23646 \family default
23647 .
23648  For single source file projects this is done automatically, more complex
23649  projects must add 
23650 \family typewriter
23651 libsdcc.lib
23652 \family default
23653  to the linker's arguments.
23654  Make sure you also add an include path for the library (using the -I switch
23655  to the linker)!
23656 \end_layout
23657
23658 \begin_layout Subsubsection
23659 Processor mismatch in file ``XXX''.
23660 \end_layout
23661
23662 \begin_layout Standard
23663 This warning can usually be ignored due to the very good compatibility amongst
23664  14
23665 \begin_inset ERT
23666 status open
23667
23668 \begin_layout Standard
23669
23670
23671 \backslash
23672 ,
23673 \end_layout
23674
23675 \end_inset
23676
23677 bit PIC
23678 \begin_inset LatexCommand \index{PIC14}
23679
23680 \end_inset
23681
23682  devices.
23683 \end_layout
23684
23685 \begin_layout Standard
23686 You might also consider recompiling the library for your specific device
23687  by changing the ARCH=p16f877 (default target) entry in 
23688 \family typewriter
23689 device/lib/pic/Makefile.in
23690 \family default
23691  and 
23692 \family typewriter
23693 device/lib/pic/Makefile
23694 \family default
23695  to reflect your device.
23696  This might even improve performance for smaller devices as unneccesary
23697  BANKSELs might be removed.
23698 \end_layout
23699
23700 \begin_layout Subsection
23701 Known Bugs
23702 \end_layout
23703
23704 \begin_layout Subsubsection
23705 Function arguments
23706 \end_layout
23707
23708 \begin_layout Standard
23709 Functions with variable argument lists (like printf) are not yet supported.
23710  Similarly, taking the argument of the first argument passed into a function
23711  does not work: It is currently passed in WREG and has no address...
23712 \end_layout
23713
23714 \begin_layout Subsubsection
23715 Regression tests fail
23716 \end_layout
23717
23718 \begin_layout Standard
23719 Though the small subset of regression tests in src/regression passes, SDCC
23720  regression test suite does not, indicating that there are still major bugs
23721  in the port.
23722  However, many smaller projects have successfully used SDCC in the past...
23723 \end_layout
23724
23725 \begin_layout Standard
23726
23727 \size footnotesize
23728
23729 \newpage
23730
23731 \end_layout
23732
23733 \begin_layout Section
23734 The PIC16
23735 \begin_inset LatexCommand \index{PIC16}
23736
23737 \end_inset
23738
23739  port
23740 \end_layout
23741
23742 \begin_layout Standard
23743 The PIC16 port adds support for Microchip
23744 \begin_inset LatexCommand \index{Microchip}
23745
23746 \end_inset
23747
23748
23749 \begin_inset Formula $^{\text{TM}}$
23750 \end_inset
23751
23752  PIC
23753 \begin_inset LatexCommand \index{PIC}
23754
23755 \end_inset
23756
23757
23758 \begin_inset Formula $^{\text{TM}}$
23759 \end_inset
23760
23761  MCUs with 16 bit wide instructions.
23762  Currently this family of microcontrollers contains the PIC18Fxxx and PIC18Fxxxx
23763 ; devices supported by the port include:
23764 \end_layout
23765
23766 \begin_layout Standard
23767 18F: 242, 248, 252, 258, 442, 448, 452, 458
23768 \end_layout
23769
23770 \begin_layout Standard
23771 18F: 1220, 1320
23772 \end_layout
23773
23774 \begin_layout Standard
23775 18F: 2220, 2221, 2320, 2321, 2331, 2431, 2455, 24j10, 2525, 2550, 25j10,
23776  2620
23777 \end_layout
23778
23779 \begin_layout Standard
23780 18F: 4220, 4221, 4320, 4321, 4331, 4431, 4455, 44j10, 4520, 4525, 4550,
23781  45j10, 4620
23782 \end_layout
23783
23784 \begin_layout Standard
23785 18F: 6520, 6620, 6680, 6720
23786 \end_layout
23787
23788 \begin_layout Standard
23789 18F: 8520, 8620, 8680, 8720
23790 \end_layout
23791
23792 \begin_layout Subsection
23793 Global Options
23794 \end_layout
23795
23796 \begin_layout Standard
23797 PIC16 port supports the standard command line arguments as supposed, with
23798  the exception of certain cases that will be mentioned in the following
23799  list:
23800 \end_layout
23801
23802 \begin_layout Description
23803 -
23804 \begin_inset ERT
23805 status collapsed
23806
23807 \begin_layout Standard
23808
23809
23810 \backslash
23811 /
23812 \end_layout
23813
23814 \end_inset
23815
23816 -callee-saves
23817 \begin_inset LatexCommand \index{PIC16!Options!-\\/-callee-saves}
23818
23819 \end_inset
23820
23821  See -
23822 \begin_inset ERT
23823 status collapsed
23824
23825 \begin_layout Standard
23826
23827
23828 \backslash
23829 /
23830 \end_layout
23831
23832 \end_inset
23833
23834 -all-callee-saves
23835 \end_layout
23836
23837 \begin_layout Description
23838 -
23839 \begin_inset ERT
23840 status collapsed
23841
23842 \begin_layout Standard
23843
23844
23845 \backslash
23846 /
23847 \end_layout
23848
23849 \end_inset
23850
23851 -fommit-frame-pointer
23852 \begin_inset LatexCommand \index{PIC16!Options!-\\/-fommit-frame-pointer}
23853
23854 \end_inset
23855
23856  Frame pointer will be omitted when the function uses no local variables.
23857 \end_layout
23858
23859 \begin_layout Subsection
23860 Port Specific Options
23861 \begin_inset LatexCommand \index{Options PIC16}
23862
23863 \end_inset
23864
23865
23866 \end_layout
23867
23868 \begin_layout Standard
23869 The port specific options appear after the global options in the sdcc -
23870 \begin_inset ERT
23871 status collapsed
23872
23873 \begin_layout Standard
23874
23875
23876 \backslash
23877 /
23878 \end_layout
23879
23880 \end_inset
23881
23882 -help output.
23883 \end_layout
23884
23885 \begin_layout Subsubsection
23886 Code Generation Options
23887 \end_layout
23888
23889 \begin_layout Standard
23890 These options influence the generated assembler code.
23891 \end_layout
23892
23893 \begin_layout Description
23894 -
23895 \begin_inset ERT
23896 status collapsed
23897
23898 \begin_layout Standard
23899
23900
23901 \backslash
23902 /
23903 \end_layout
23904
23905 \end_inset
23906
23907 -pstack-model=[model] Used in conjuction with the command above.
23908  Defines the stack model to be used, valid stack models are:
23909 \end_layout
23910
23911 \begin_deeper
23912 \begin_layout List
23913 \labelwidthstring 00.00.0000
23914
23915 \emph on
23916 small
23917 \emph default
23918  Selects small stack model.
23919  8 bit stack and frame pointers.
23920  Supports 256 bytes stack size.
23921 \end_layout
23922
23923 \begin_layout List
23924 \labelwidthstring 00.00.0000
23925
23926 \emph on
23927 large
23928 \emph default
23929  Selects large stack model.
23930  16 bit stack and frame pointers.
23931  Supports 65536 bytes stack size.
23932 \end_layout
23933
23934 \end_deeper
23935 \begin_layout Description
23936 -
23937 \begin_inset ERT
23938 status collapsed
23939
23940 \begin_layout Standard
23941
23942
23943 \backslash
23944 /
23945 \end_layout
23946
23947 \end_inset
23948
23949 -pno-banksel Do not generate BANKSEL assembler directives.
23950 \end_layout
23951
23952 \begin_layout Description
23953 -
23954 \begin_inset ERT
23955 status collapsed
23956
23957 \begin_layout Standard
23958
23959
23960 \backslash
23961 /
23962 \end_layout
23963
23964 \end_inset
23965
23966 -extended Enable extended instruction set/literal offset addressing mode.
23967  Use with care!
23968 \end_layout
23969
23970 \begin_layout Subsubsection
23971 Optimization Options
23972 \end_layout
23973
23974 \begin_layout Description
23975 -
23976 \begin_inset ERT
23977 status collapsed
23978
23979 \begin_layout Standard
23980
23981
23982 \backslash
23983 /
23984 \end_layout
23985
23986 \end_inset
23987
23988 -obanksel=n Set optimization level for inserting BANKSELs.
23989 \newline
23990
23991 \end_layout
23992
23993 \begin_deeper
23994 \begin_layout List
23995 \labelwidthstring 00.00.0000
23996 0 no optimization
23997 \end_layout
23998
23999 \begin_layout List
24000 \labelwidthstring 00.00.0000
24001 1 checks previous used register and if it is the same then does not emit
24002  BANKSEL, accounts only for labels.
24003 \end_layout
24004
24005 \begin_layout List
24006 \labelwidthstring 00.00.0000
24007 2 tries to check the location of (even different) symbols and removes BANKSELs
24008  if they are in the same bank.
24009  
24010 \newline
24011
24012 \emph on
24013 Important: There might be problems if the linker script has data sections
24014  across bank borders!
24015 \end_layout
24016
24017 \end_deeper
24018 \begin_layout Description
24019 -
24020 \begin_inset ERT
24021 status collapsed
24022
24023 \begin_layout Standard
24024
24025
24026 \backslash
24027 /
24028 \end_layout
24029
24030 \end_inset
24031
24032 -denable-peeps Force the usage of peepholes.
24033  Use with care.
24034 \end_layout
24035
24036 \begin_layout Description
24037 -
24038 \begin_inset ERT
24039 status collapsed
24040
24041 \begin_layout Standard
24042
24043
24044 \backslash
24045 /
24046 \end_layout
24047
24048 \end_inset
24049
24050 -optimize-goto Try to use (conditional) BRA instead of GOTO.
24051 \end_layout
24052
24053 \begin_layout Description
24054 -
24055 \begin_inset ERT
24056 status collapsed
24057
24058 \begin_layout Standard
24059
24060
24061 \backslash
24062 /
24063 \end_layout
24064
24065 \end_inset
24066
24067 -optimize-cmp Try to optimize some compares.
24068 \end_layout
24069
24070 \begin_layout Description
24071 -
24072 \begin_inset ERT
24073 status collapsed
24074
24075 \begin_layout Standard
24076
24077
24078 \backslash
24079 /
24080 \end_layout
24081
24082 \end_inset
24083
24084 -optimize-df Analyze the dataflow of the generated code and improve it.
24085 \end_layout
24086
24087 \begin_layout Subsubsection
24088 Assembling Options
24089 \end_layout
24090
24091 \begin_layout Description
24092 -
24093 \begin_inset ERT
24094 status collapsed
24095
24096 \begin_layout Standard
24097
24098
24099 \backslash
24100 /
24101 \end_layout
24102
24103 \end_inset
24104
24105 -asm= Sets the full path and name of an external assembler to call.
24106 \end_layout
24107
24108 \begin_layout Description
24109 -
24110 \begin_inset ERT
24111 status collapsed
24112
24113 \begin_layout Standard
24114
24115
24116 \backslash
24117 /
24118 \end_layout
24119
24120 \end_inset
24121
24122 -mplab-comp MPLAB
24123 \begin_inset LatexCommand \index{PIC16!MPLAB}
24124
24125 \end_inset
24126
24127  compatibility option.
24128  Currently only suppresses special gpasm directives.
24129 \end_layout
24130
24131 \begin_layout Subsubsection
24132 Linking Options
24133 \end_layout
24134
24135 \begin_layout Description
24136 -
24137 \begin_inset ERT
24138 status collapsed
24139
24140 \begin_layout Standard
24141
24142
24143 \backslash
24144 /
24145 \end_layout
24146
24147 \end_inset
24148
24149 -link= Sets the full path and name of an external linker to call.
24150 \end_layout
24151
24152 \begin_layout Description
24153 -
24154 \begin_inset ERT
24155 status collapsed
24156
24157 \begin_layout Standard
24158
24159
24160 \backslash
24161 /
24162 \end_layout
24163
24164 \end_inset
24165
24166 -preplace-udata-with=[kword] Replaces the default udata keyword for allocating
24167  unitialized data variables with [kword].
24168  Valid keywords are: "udata_acs", "udata_shr", "udata_ovr".
24169 \end_layout
24170
24171 \begin_layout Description
24172 -
24173 \begin_inset ERT
24174 status collapsed
24175
24176 \begin_layout Standard
24177
24178
24179 \backslash
24180 /
24181 \end_layout
24182
24183 \end_inset
24184
24185 -ivt-loc=n Place the interrupt vector table at address 
24186 \emph on
24187 n
24188 \emph default
24189 .
24190  Useful for bootloaders.
24191 \end_layout
24192
24193 \begin_layout Description
24194 -
24195 \begin_inset ERT
24196 status collapsed
24197
24198 \begin_layout Standard
24199
24200
24201 \backslash
24202 /
24203 \end_layout
24204
24205 \end_inset
24206
24207 -nodefaultlibs Do not link default libraries when linking.
24208 \end_layout
24209
24210 \begin_layout Description
24211 -
24212 \begin_inset ERT
24213 status collapsed
24214
24215 \begin_layout Standard
24216
24217
24218 \backslash
24219 /
24220 \end_layout
24221
24222 \end_inset
24223
24224 -use-crt= Use a custom run-time module instead of the defaults.
24225 \end_layout
24226
24227 \begin_layout Description
24228 -
24229 \begin_inset ERT
24230 status collapsed
24231
24232 \begin_layout Standard
24233
24234
24235 \backslash
24236 /
24237 \end_layout
24238
24239 \end_inset
24240
24241 -no-crt Don't link the default run-time modules
24242 \end_layout
24243
24244 \begin_layout Subsubsection
24245 Debugging Options
24246 \end_layout
24247
24248 \begin_layout Standard
24249 Debugging options enable extra debugging information in the output files.
24250 \end_layout
24251
24252 \begin_layout Description
24253 -
24254 \begin_inset ERT
24255 status collapsed
24256
24257 \begin_layout Standard
24258
24259
24260 \backslash
24261 /
24262 \end_layout
24263
24264 \end_inset
24265
24266 -debug-xtra Similar to -
24267 \begin_inset ERT
24268 status collapsed
24269
24270 \begin_layout Standard
24271
24272
24273 \backslash
24274 /
24275 \end_layout
24276
24277 \end_inset
24278
24279 -debug
24280 \begin_inset LatexCommand \index{-\\/-debug}
24281
24282 \end_inset
24283
24284 , but dumps more information.
24285 \end_layout
24286
24287 \begin_layout Description
24288 -
24289 \begin_inset ERT
24290 status collapsed
24291
24292 \begin_layout Standard
24293
24294
24295 \backslash
24296 /
24297 \end_layout
24298
24299 \end_inset
24300
24301 -debug-ralloc Force register allocator to dump <source>.d file with debugging
24302  information.
24303  <source> is the name of the file being compiled.
24304 \end_layout
24305
24306 \begin_layout Description
24307 -
24308 \begin_inset ERT
24309 status collapsed
24310
24311 \begin_layout Standard
24312
24313
24314 \backslash
24315 /
24316 \end_layout
24317
24318 \end_inset
24319
24320 -pcode-verbose Enable pcode debugging information in translation.
24321 \end_layout
24322
24323 \begin_layout Description
24324 -
24325 \begin_inset ERT
24326 status collapsed
24327
24328 \begin_layout Standard
24329
24330
24331 \backslash
24332 /
24333 \end_layout
24334
24335 \end_inset
24336
24337 -calltree Dump call tree in .calltree file.
24338 \end_layout
24339
24340 \begin_layout Description
24341 -
24342 \begin_inset ERT
24343 status collapsed
24344
24345 \begin_layout Standard
24346
24347
24348 \backslash
24349 /
24350 \end_layout
24351
24352 \end_inset
24353
24354 -gstack Trace push/pops for stack pointer overflow.
24355 \end_layout
24356
24357 \begin_layout Subsection
24358 Enviroment Variables
24359 \end_layout
24360
24361 \begin_layout Standard
24362 There is a number of enviromental variables that can be used when running
24363  SDCC to enable certain optimizations or force a specific program behaviour.
24364  these variables are primarily for debugging purposes so they can be enabled/dis
24365 abled at will.
24366 \end_layout
24367
24368 \begin_layout Standard
24369 Currently there is only two such variables available:
24370 \end_layout
24371
24372 \begin_layout Description
24373 OPTIMIZE_BITFIELD_POINTER_GET When this variable exists, reading of structure
24374  bitfields is optimized by directly loading FSR0 with the address of the
24375  bitfield structure.
24376  Normally SDCC will cast the bitfield structure to a bitfield pointer and
24377  then load FSR0.
24378  This step saves data ram and code space for functions that make heavy use
24379  of bitfields.
24380  (i.e., 80 bytes of code space are saved when compiling malloc.c with this
24381  option).
24382  
24383 \end_layout
24384
24385 \begin_layout Description
24386 NO_REG_OPT Do not perform pCode registers optimization.
24387  This should be used for debugging purposes.
24388  If bugs in the pcode optimizer are found, users can benefit from temporarily
24389  disabling the optimizer until the bug is fixed.
24390 \end_layout
24391
24392 \begin_layout Subsection
24393 Preprocessor Macros
24394 \end_layout
24395
24396 \begin_layout Standard
24397 PIC16
24398 \begin_inset LatexCommand \index{PIC16}
24399
24400 \end_inset
24401
24402  port defines the following preprocessor macros while translating a source.
24403 \end_layout
24404
24405 \begin_layout Standard
24406 \align center
24407 \begin_inset Tabular
24408 <lyxtabular version="3" rows="6" columns="2">
24409 <features>
24410 <column alignment="center" valignment="top" leftline="true" width="0">
24411 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
24412 <row topline="true" bottomline="true">
24413 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24414 \begin_inset Text
24415
24416 \begin_layout Standard
24417 Macro
24418 \end_layout
24419
24420 \end_inset
24421 </cell>
24422 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24423 \begin_inset Text
24424
24425 \begin_layout Standard
24426 Description
24427 \end_layout
24428
24429 \end_inset
24430 </cell>
24431 </row>
24432 <row topline="true">
24433 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24434 \begin_inset Text
24435
24436 \begin_layout Standard
24437 SDCC_pic16
24438 \end_layout
24439
24440 \end_inset
24441 </cell>
24442 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24443 \begin_inset Text
24444
24445 \begin_layout Standard
24446 Port identification
24447 \end_layout
24448
24449 \end_inset
24450 </cell>
24451 </row>
24452 <row topline="true">
24453 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24454 \begin_inset Text
24455
24456 \begin_layout Standard
24457 _
24458 \begin_inset ERT
24459 status collapsed
24460
24461 \begin_layout Standard
24462
24463
24464 \backslash
24465 /
24466 \end_layout
24467
24468 \end_inset
24469
24470 _pic16
24471 \end_layout
24472
24473 \end_inset
24474 </cell>
24475 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24476 \begin_inset Text
24477
24478 \begin_layout Standard
24479 Port identification (same as above)
24480 \end_layout
24481
24482 \end_inset
24483 </cell>
24484 </row>
24485 <row topline="true">
24486 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24487 \begin_inset Text
24488
24489 \begin_layout Standard
24490 pic18fxxxx
24491 \end_layout
24492
24493 \end_inset
24494 </cell>
24495 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24496 \begin_inset Text
24497
24498 \begin_layout Standard
24499 MCU Identification.
24500  
24501 \emph on
24502 xxxx
24503 \emph default
24504  is the microcontrol identification number, i.e.
24505  452, 6620, etc
24506 \end_layout
24507
24508 \end_inset
24509 </cell>
24510 </row>
24511 <row topline="true">
24512 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24513 \begin_inset Text
24514
24515 \begin_layout Standard
24516 _
24517 \begin_inset ERT
24518 status collapsed
24519
24520 \begin_layout Standard
24521
24522
24523 \backslash
24524 /
24525 \end_layout
24526
24527 \end_inset
24528
24529 _18Fxxxx
24530 \end_layout
24531
24532 \end_inset
24533 </cell>
24534 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24535 \begin_inset Text
24536
24537 \begin_layout Standard
24538 MCU Identification (same as above)
24539 \end_layout
24540
24541 \end_inset
24542 </cell>
24543 </row>
24544 <row topline="true" bottomline="true">
24545 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24546 \begin_inset Text
24547
24548 \begin_layout Standard
24549 STACK_MODEL_nnn
24550 \end_layout
24551
24552 \end_inset
24553 </cell>
24554 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24555 \begin_inset Text
24556
24557 \begin_layout Standard
24558 nnn = SMALL or LARGE respectively according to the stack model used
24559 \end_layout
24560
24561 \end_inset
24562 </cell>
24563 </row>
24564 </lyxtabular>
24565
24566 \end_inset
24567
24568
24569 \end_layout
24570
24571 \begin_layout Standard
24572 In addition the following macros are defined when calling assembler:
24573 \end_layout
24574
24575 \begin_layout Standard
24576 \align center
24577 \begin_inset Tabular
24578 <lyxtabular version="3" rows="4" columns="2">
24579 <features>
24580 <column alignment="center" valignment="top" leftline="true" width="0">
24581 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
24582 <row topline="true" bottomline="true">
24583 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24584 \begin_inset Text
24585
24586 \begin_layout Standard
24587 Macro
24588 \end_layout
24589
24590 \end_inset
24591 </cell>
24592 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24593 \begin_inset Text
24594
24595 \begin_layout Standard
24596 Description
24597 \end_layout
24598
24599 \end_inset
24600 </cell>
24601 </row>
24602 <row topline="true">
24603 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24604 \begin_inset Text
24605
24606 \begin_layout Standard
24607 __18Fxxxx
24608 \end_layout
24609
24610 \end_inset
24611 </cell>
24612 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24613 \begin_inset Text
24614
24615 \begin_layout Standard
24616 MCU Identification.
24617  
24618 \emph on
24619 xxxx
24620 \emph default
24621  is the microcontrol identification number, i.e.
24622  452, 6620, etc
24623 \end_layout
24624
24625 \end_inset
24626 </cell>
24627 </row>
24628 <row topline="true">
24629 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24630 \begin_inset Text
24631
24632 \begin_layout Standard
24633 SDCC_MODEL_nnn
24634 \end_layout
24635
24636 \end_inset
24637 </cell>
24638 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24639 \begin_inset Text
24640
24641 \begin_layout Standard
24642 nnn = SMALL or LARGE respectively according to the memory model used for
24643  SDCC
24644 \end_layout
24645
24646 \end_inset
24647 </cell>
24648 </row>
24649 <row topline="true" bottomline="true">
24650 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24651 \begin_inset Text
24652
24653 \begin_layout Standard
24654 STACK_MODEL_nnn
24655 \end_layout
24656
24657 \end_inset
24658 </cell>
24659 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24660 \begin_inset Text
24661
24662 \begin_layout Standard
24663 nnn = SMALL or LARGE respectively according to the stack model used
24664 \end_layout
24665
24666 \end_inset
24667 </cell>
24668 </row>
24669 </lyxtabular>
24670
24671 \end_inset
24672
24673
24674 \end_layout
24675
24676 \begin_layout Subsection
24677 Directories
24678 \end_layout
24679
24680 \begin_layout Standard
24681 PIC16
24682 \begin_inset LatexCommand \index{PIC16}
24683
24684 \end_inset
24685
24686  port uses the following directories for searching header files and libraries.
24687 \end_layout
24688
24689 \begin_layout Standard
24690 \align center
24691 \begin_inset Tabular
24692 <lyxtabular version="3" rows="3" columns="4">
24693 <features>
24694 <column alignment="center" valignment="top" leftline="true" width="0">
24695 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
24696 <column alignment="center" valignment="top" width="0">
24697 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
24698 <row topline="true" bottomline="true">
24699 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24700 \begin_inset Text
24701
24702 \begin_layout Standard
24703 Directory
24704 \end_layout
24705
24706 \end_inset
24707 </cell>
24708 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24709 \begin_inset Text
24710
24711 \begin_layout Standard
24712 Description
24713 \end_layout
24714
24715 \end_inset
24716 </cell>
24717 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24718 \begin_inset Text
24719
24720 \begin_layout Standard
24721 Target
24722 \end_layout
24723
24724 \end_inset
24725 </cell>
24726 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24727 \begin_inset Text
24728
24729 \begin_layout Standard
24730 Command prefix
24731 \end_layout
24732
24733 \end_inset
24734 </cell>
24735 </row>
24736 <row topline="true">
24737 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24738 \begin_inset Text
24739
24740 \begin_layout Standard
24741 PREFIX/sdcc/include/pic16
24742 \end_layout
24743
24744 \end_inset
24745 </cell>
24746 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24747 \begin_inset Text
24748
24749 \begin_layout Standard
24750 PIC16 specific headers
24751 \end_layout
24752
24753 \end_inset
24754 </cell>
24755 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24756 \begin_inset Text
24757
24758 \begin_layout Standard
24759 Compiler
24760 \end_layout
24761
24762 \end_inset
24763 </cell>
24764 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24765 \begin_inset Text
24766
24767 \begin_layout Standard
24768 -I
24769 \end_layout
24770
24771 \end_inset
24772 </cell>
24773 </row>
24774 <row topline="true" bottomline="true">
24775 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24776 \begin_inset Text
24777
24778 \begin_layout Standard
24779 PREFIX/sdcc/lib/pic16
24780 \end_layout
24781
24782 \end_inset
24783 </cell>
24784 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24785 \begin_inset Text
24786
24787 \begin_layout Standard
24788 PIC16 specific libraries
24789 \end_layout
24790
24791 \end_inset
24792 </cell>
24793 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24794 \begin_inset Text
24795
24796 \begin_layout Standard
24797 Linker
24798 \end_layout
24799
24800 \end_inset
24801 </cell>
24802 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24803 \begin_inset Text
24804
24805 \begin_layout Standard
24806 -L
24807 \end_layout
24808
24809 \end_inset
24810 </cell>
24811 </row>
24812 </lyxtabular>
24813
24814 \end_inset
24815
24816
24817 \end_layout
24818
24819 \begin_layout Subsection
24820 Pragmas
24821 \begin_inset LatexCommand \label{sub:PIC16_Pragmas}
24822
24823 \end_inset
24824
24825
24826 \end_layout
24827
24828 \begin_layout Standard
24829 The PIC16
24830 \begin_inset LatexCommand \index{PIC16}
24831
24832 \end_inset
24833
24834  port currently supports the following pragmas:
24835 \end_layout
24836
24837 \begin_layout Description
24838 stack
24839 \begin_inset LatexCommand \index{PIC16!Pragmas!\\#pragma stack}
24840
24841 \end_inset
24842
24843  This forces the code generator to initialize the stack & frame pointers
24844  at a specific address.
24845  This is an ad hoc solution for cases where no STACK directive is available
24846  in the linker script or gplink is not instructed to create a stack section.
24847 \newline
24848 The
24849  stack pragma should be used only once in a project.
24850  Multiple pragmas may result in indeterminate behaviour of the program.
24851 \begin_inset Foot
24852 status open
24853
24854 \begin_layout Standard
24855 The old format (ie.
24856  #pragma stack 0x5ff) is deprecated and will cause the stack pointer to
24857  cross page boundaries (or even exceed the available data RAM) and crash
24858  the program.
24859  Make sure that stack does not cross page boundaries when using the SMALL
24860  stack model.
24861 \end_layout
24862
24863 \end_inset
24864
24865
24866 \newline
24867 The format is as follows:
24868 \newline
24869
24870 \end_layout
24871
24872 \begin_layout LyX-Code
24873 #pragma stack bottom_address [stack_size]
24874 \newline
24875
24876 \end_layout
24877
24878 \begin_layout Standard
24879
24880 \emph on
24881 bottom_address
24882 \emph default
24883  is the lower bound of the stack section.
24884  The stack pointer initially will point at address (bottom_address+stack_size-1).
24885 \end_layout
24886
24887 \begin_layout LyX-Code
24888 Example:
24889 \end_layout
24890
24891 \begin_layout LyX-Code
24892
24893 \end_layout
24894
24895 \begin_layout LyX-Code
24896 /* initializes stack of 100 bytes at RAM address 0x200 */
24897 \end_layout
24898
24899 \begin_layout LyX-Code
24900 #pragma stack 0x200 100
24901 \end_layout
24902
24903 \begin_layout Standard
24904 If the stack_size field is omitted then a stack is created with the default
24905  size of 64.
24906  This size might be enough for most programs, but its not enough for operations
24907  with deep function nesting or excessive stack usage.
24908 \end_layout
24909
24910 \begin_layout Description
24911 code
24912 \begin_inset LatexCommand \index{PIC16!Pragmas!\\#pragma code}
24913
24914 \end_inset
24915
24916  Force a function to a static FLASH address.
24917 \end_layout
24918
24919 \begin_layout LyX-Code
24920 Example:
24921 \end_layout
24922
24923 \begin_layout LyX-Code
24924
24925 \end_layout
24926
24927 \begin_layout LyX-Code
24928 /* place function test_func at 0x4000 */
24929 \end_layout
24930
24931 \begin_layout LyX-Code
24932 #pragma code test_func 0x4000
24933 \end_layout
24934
24935 \begin_layout LyX-Code
24936
24937 \end_layout
24938
24939 \begin_layout Description
24940 library instructs the linker to use a library module.
24941 \newline
24942 Usage:
24943 \end_layout
24944
24945 \begin_layout LyX-Code
24946 #pragma library module_name
24947 \end_layout
24948
24949 \begin_layout Standard
24950
24951 \emph on
24952 module_name
24953 \emph default
24954  can be any library or object file (including its path).
24955  Note that there are four reserved keywords which have special meaning.
24956  These are:
24957 \end_layout
24958
24959 \begin_layout Standard
24960 \align center
24961 \begin_inset Tabular
24962 <lyxtabular version="3" rows="6" columns="3">
24963 <features>
24964 <column alignment="center" valignment="top" leftline="true" width="0">
24965 <column alignment="block" valignment="top" leftline="true" width="20page%">
24966 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0">
24967 <row topline="true" bottomline="true">
24968 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24969 \begin_inset Text
24970
24971 \begin_layout Standard
24972 Keyword
24973 \end_layout
24974
24975 \end_inset
24976 </cell>
24977 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24978 \begin_inset Text
24979
24980 \begin_layout Standard
24981 Description
24982 \end_layout
24983
24984 \end_inset
24985 </cell>
24986 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24987 \begin_inset Text
24988
24989 \begin_layout Standard
24990 Module to link
24991 \end_layout
24992
24993 \end_inset
24994 </cell>
24995 </row>
24996 <row topline="true">
24997 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24998 \begin_inset Text
24999
25000 \begin_layout Standard
25001
25002 \series bold
25003 ignore
25004 \end_layout
25005
25006 \end_inset
25007 </cell>
25008 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25009 \begin_inset Text
25010
25011 \begin_layout Standard
25012 ignore all library pragmas
25013 \end_layout
25014
25015 \end_inset
25016 </cell>
25017 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25018 \begin_inset Text
25019
25020 \begin_layout Standard
25021
25022 \emph on
25023 (none)
25024 \end_layout
25025
25026 \end_inset
25027 </cell>
25028 </row>
25029 <row topline="true">
25030 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25031 \begin_inset Text
25032
25033 \begin_layout Standard
25034
25035 \series bold
25036 c
25037 \end_layout
25038
25039 \end_inset
25040 </cell>
25041 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25042 \begin_inset Text
25043
25044 \begin_layout Standard
25045 link the C library
25046 \end_layout
25047
25048 \end_inset
25049 </cell>
25050 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25051 \begin_inset Text
25052
25053 \begin_layout Standard
25054
25055 \emph on
25056 libc18f
25057 \emph default
25058 .lib
25059 \end_layout
25060
25061 \end_inset
25062 </cell>
25063 </row>
25064 <row topline="true">
25065 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25066 \begin_inset Text
25067
25068 \begin_layout Standard
25069
25070 \series bold
25071 math
25072 \end_layout
25073
25074 \end_inset
25075 </cell>
25076 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25077 \begin_inset Text
25078
25079 \begin_layout Standard
25080 link the Math libarary
25081 \end_layout
25082
25083 \end_inset
25084 </cell>
25085 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25086 \begin_inset Text
25087
25088 \begin_layout Standard
25089
25090 \emph on
25091 libm18f
25092 \emph default
25093 .lib
25094 \end_layout
25095
25096 \end_inset
25097 </cell>
25098 </row>
25099 <row topline="true">
25100 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25101 \begin_inset Text
25102
25103 \begin_layout Standard
25104
25105 \series bold
25106 io
25107 \end_layout
25108
25109 \end_inset
25110 </cell>
25111 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25112 \begin_inset Text
25113
25114 \begin_layout Standard
25115 link the I/O library
25116 \end_layout
25117
25118 \end_inset
25119 </cell>
25120 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25121 \begin_inset Text
25122
25123 \begin_layout Standard
25124
25125 \emph on
25126 libio18f*
25127 \emph default
25128 .lib
25129 \end_layout
25130
25131 \end_inset
25132 </cell>
25133 </row>
25134 <row topline="true" bottomline="true">
25135 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25136 \begin_inset Text
25137
25138 \begin_layout Standard
25139
25140 \series bold
25141 debug
25142 \end_layout
25143
25144 \end_inset
25145 </cell>
25146 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25147 \begin_inset Text
25148
25149 \begin_layout Standard
25150 link the debug library
25151 \end_layout
25152
25153 \end_inset
25154 </cell>
25155 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25156 \begin_inset Text
25157
25158 \begin_layout Standard
25159
25160 \emph on
25161 libdebug
25162 \emph default
25163 .lib
25164 \end_layout
25165
25166 \end_inset
25167 </cell>
25168 </row>
25169 </lyxtabular>
25170
25171 \end_inset
25172
25173
25174 \newline
25175 * is the device number, i.e.
25176  452 for PIC18F452 MCU.
25177 \end_layout
25178
25179 \begin_layout Standard
25180 This feature allows for linking with specific libraries withoug having to
25181  explicit name them in the command line.
25182  Note that the 
25183 \noun on
25184 ignore
25185 \noun default
25186  keyword will reject all modules specified by the library pragma.
25187 \end_layout
25188
25189 \begin_layout Description
25190 udata The pragma udata instructs the compiler to emit code so that linker
25191  will place a variable at a specific memory bank.
25192 \end_layout
25193
25194 \begin_layout LyX-Code
25195 Example:
25196 \end_layout
25197
25198 \begin_layout LyX-Code
25199
25200 \end_layout
25201
25202 \begin_layout LyX-Code
25203 /* places variable foo at bank2 */
25204 \end_layout
25205
25206 \begin_layout LyX-Code
25207 #pragma udata bank2 foo
25208 \end_layout
25209
25210 \begin_layout LyX-Code
25211 char foo;
25212 \end_layout
25213
25214 \begin_layout Standard
25215 In order for this pragma to work extra SECTION directives should be added
25216  in the .lkr script.
25217  In the following example a sample .lkr file is shown:
25218 \end_layout
25219
25220 \begin_layout LyX-Code
25221
25222 \end_layout
25223
25224 \begin_layout LyX-Code
25225 // Sample linker script for the PIC18F452 processor
25226 \end_layout
25227
25228 \begin_layout LyX-Code
25229 LIBPATH .
25230 \end_layout
25231
25232 \begin_layout LyX-Code
25233 CODEPAGE   NAME=vectors    START=0x0            END=0x29           PROTECTED
25234 \end_layout
25235
25236 \begin_layout LyX-Code
25237 CODEPAGE   NAME=page       START=0x2A           END=0x7FFF
25238 \end_layout
25239
25240 \begin_layout LyX-Code
25241 CODEPAGE   NAME=idlocs     START=0x200000       END=0x200007       PROTECTED
25242 \end_layout
25243
25244 \begin_layout LyX-Code
25245 CODEPAGE   NAME=config     START=0x300000       END=0x30000D       PROTECTED
25246 \end_layout
25247
25248 \begin_layout LyX-Code
25249 CODEPAGE   NAME=devid      START=0x3FFFFE       END=0x3FFFFF       PROTECTED
25250 \end_layout
25251
25252 \begin_layout LyX-Code
25253 CODEPAGE   NAME=eedata     START=0xF00000       END=0xF000FF       PROTECTED
25254 \end_layout
25255
25256 \begin_layout LyX-Code
25257 ACCESSBANK NAME=accessram  START=0x0            END=0x7F
25258 \end_layout
25259
25260 \begin_layout LyX-Code
25261
25262 \end_layout
25263
25264 \begin_layout LyX-Code
25265 DATABANK   NAME=gpr0       START=0x80           END=0xFF
25266 \end_layout
25267
25268 \begin_layout LyX-Code
25269 DATABANK   NAME=gpr1       START=0x100          END=0x1FF
25270 \end_layout
25271
25272 \begin_layout LyX-Code
25273 DATABANK   NAME=gpr2       START=0x200          END=0x2FF
25274 \end_layout
25275
25276 \begin_layout LyX-Code
25277 DATABANK   NAME=gpr3       START=0x300          END=0x3FF
25278 \end_layout
25279
25280 \begin_layout LyX-Code
25281 DATABANK   NAME=gpr4       START=0x400          END=0x4FF
25282 \end_layout
25283
25284 \begin_layout LyX-Code
25285 DATABANK   NAME=gpr5       START=0x500          END=0x5FF
25286 \end_layout
25287
25288 \begin_layout LyX-Code
25289 ACCESSBANK NAME=accesssfr  START=0xF80          END=0xFFF          PROTECTED
25290 \end_layout
25291
25292 \begin_layout LyX-Code
25293
25294 \end_layout
25295
25296 \begin_layout LyX-Code
25297 SECTION    NAME=CONFIG     ROM=config
25298 \end_layout
25299
25300 \begin_layout LyX-Code
25301
25302 \end_layout
25303
25304 \begin_layout LyX-Code
25305 SECTION    NAME=bank0      RAM=gpr0       # these SECTION directives
25306 \end_layout
25307
25308 \begin_layout LyX-Code
25309 SECTION    NAME=bank1      RAM=gpr1       # should be added to link
25310 \end_layout
25311
25312 \begin_layout LyX-Code
25313 SECTION    NAME=bank2      RAM=gpr2       # section name 'bank?' with
25314 \end_layout
25315
25316 \begin_layout LyX-Code
25317 SECTION    NAME=bank3      RAM=gpr3       # a specific DATABANK name
25318 \end_layout
25319
25320 \begin_layout LyX-Code
25321 SECTION    NAME=bank4      RAM=gpr4
25322 \end_layout
25323
25324 \begin_layout LyX-Code
25325 SECTION    NAME=bank5      RAM=gpr5
25326 \end_layout
25327
25328 \begin_layout Standard
25329 The linker will recognise the section name set in the pragma statement and
25330  will position the variable at the memory bank set with the RAM field at
25331  the SECTION line in the linker script file.
25332 \end_layout
25333
25334 \begin_layout Subsection
25335 Header Files
25336 \begin_inset LatexCommand \label{sub:PIC16_Header-Files}
25337
25338 \end_inset
25339
25340
25341 \end_layout
25342
25343 \begin_layout Standard
25344 There is one main header file
25345 \begin_inset LatexCommand \index{PIC16!Header files}
25346
25347 \end_inset
25348
25349  that can be included to the source files using the pic16
25350 \begin_inset LatexCommand \index{PIC16}
25351
25352 \end_inset
25353
25354  port.
25355  That file is the 
25356 \series bold
25357 pic18fregs.h
25358 \series default
25359 .
25360  This header file contains the definitions for the processor special registers,
25361  so it is necessary if the source accesses them.
25362  It can be included by adding the following line in the beginning of the
25363  file:
25364 \end_layout
25365
25366 \begin_layout LyX-Code
25367 #include <pic18fregs.h>
25368 \end_layout
25369
25370 \begin_layout Standard
25371 The specific microcontroller is selected within the pic18fregs.h automatically,
25372  so the same source can be used with a variety of devices.
25373 \end_layout
25374
25375 \begin_layout Subsection
25376 Libraries
25377 \end_layout
25378
25379 \begin_layout Standard
25380 The libraries
25381 \begin_inset LatexCommand \index{PIC16!Libraries}
25382
25383 \end_inset
25384
25385  that PIC16
25386 \begin_inset LatexCommand \index{PIC16}
25387
25388 \end_inset
25389
25390  port depends on are the microcontroller device libraries which contain
25391  the symbol definitions for the microcontroller special function registers.
25392  These libraries have the format pic18fxxxx.lib, where 
25393 \emph on
25394 xxxx
25395 \emph default
25396  is the microcontroller identification number.
25397  The specific library is selected automatically by the compiler at link
25398  stage according to the selected device.
25399 \end_layout
25400
25401 \begin_layout Standard
25402 Libraries are created with gplib which is part of the gputils package 
25403 \begin_inset LatexCommand \url{http://sourceforge.net/projects/gputils}
25404
25405 \end_inset
25406
25407 .
25408 \end_layout
25409
25410 \begin_layout Subsubsection*
25411 Building the libraries
25412 \end_layout
25413
25414 \begin_layout Standard
25415 Before using SDCC/pic16 there are some libraries that need to be compiled.
25416  This process is not done automatically by SDCC since not all users use
25417  SDCC for pic16 projects.
25418  So each user should compile the libraries separately.
25419 \end_layout
25420
25421 \begin_layout Standard
25422 The steps to compile the pic16 libraries under Linux and Mac OS X are:
25423 \end_layout
25424
25425 \begin_layout LyX-Code
25426 cd device/lib/pic16
25427 \end_layout
25428
25429 \begin_layout LyX-Code
25430 ./configure
25431 \end_layout
25432
25433 \begin_layout LyX-Code
25434 make
25435 \end_layout
25436
25437 \begin_layout LyX-Code
25438 cd ..
25439 \end_layout
25440
25441 \begin_layout LyX-Code
25442 make model-pic16
25443 \end_layout
25444
25445 \begin_layout LyX-Code
25446 su -c 'make install'     # install the libraries, you need the root password
25447 \end_layout
25448
25449 \begin_layout Standard
25450 If you need to install the headers too, do:
25451 \end_layout
25452
25453 \begin_layout LyX-Code
25454 cd device/include
25455 \end_layout
25456
25457 \begin_layout LyX-Code
25458 su -c 'make install'     # install the headers, you need the root password
25459 \end_layout
25460
25461 \begin_layout Standard
25462 There exist a special target to build the I/O libraries.
25463  This target is not automatically build because it will build the I/O library
25464  for 
25465 \emph on
25466 every
25467 \emph default
25468  supported device.
25469  This way building will take quite a lot of time.
25470  Users are advised to edit the 
25471 \series bold
25472 device/lib/pic16/pics.build
25473 \series default
25474  file and then execute:
25475 \end_layout
25476
25477 \begin_layout LyX-Code
25478 make lib-io
25479 \end_layout
25480
25481 \begin_layout Subsection
25482 Adding New Devices to the Port
25483 \end_layout
25484
25485 \begin_layout Standard
25486 Adding support for a new 16
25487 \begin_inset ERT
25488 status open
25489
25490 \begin_layout Standard
25491
25492
25493 \backslash
25494 ,
25495 \end_layout
25496
25497 \end_inset
25498
25499 bit PIC MCU requires the following steps:
25500 \end_layout
25501
25502 \begin_layout Enumerate
25503 Create picDEVICE.c and picDEVICE.h from pDEVICE.inc using
25504 \newline
25505
25506 \family typewriter
25507 perl /path/to/sdcc/support/scripts/inc2h-pic16.pl /path/to/gputils/header/pDEVICE.
25508 inc
25509 \end_layout
25510
25511 \begin_layout Enumerate
25512
25513 \family typewriter
25514 mv picDEVICE.h /path/to/sdcc/device/include/pic16
25515 \end_layout
25516
25517 \begin_layout Enumerate
25518
25519 \family typewriter
25520 mv picDEVICE.c /path/to/sdcc/device/lib/pic16/libdev
25521 \end_layout
25522
25523 \begin_layout Enumerate
25524 Add DEVICE to 
25525 \family typewriter
25526 /path/to/sdcc/device/lib/pics.all
25527 \family default
25528  (and 
25529 \family typewriter
25530 .build
25531 \family default
25532 ).
25533 \newline
25534 Note: No 18f prefix here!
25535 \end_layout
25536
25537 \begin_layout Enumerate
25538 Adjust 
25539 \family typewriter
25540 /path/to/sdcc/device/lib/pic16/libio/*.ignore
25541 \family default
25542
25543 \newline
25544 Add your DEVICE if it does not compile in 
25545 \family typewriter
25546 adc
25547 \family default
25548
25549 \family typewriter
25550 i2c
25551 \family default
25552 , or 
25553 \family typewriter
25554 usart
25555 \family default
25556 .
25557 \end_layout
25558
25559 \begin_layout Enumerate
25560 Edit 
25561 \family typewriter
25562 /path/to/sdcc/device/include/pic16/pic18fregs.h
25563 \family default
25564 .
25565  The file format is self-explanatory, just add
25566 \newline
25567
25568 \family typewriter
25569 #elif defined(picDEVICE)
25570 \newline
25571 # include <picDEVICE.h>
25572 \family default
25573
25574 \newline
25575 at the right place (keep it sorted).
25576 \end_layout
25577
25578 \begin_layout Enumerate
25579 Edit 
25580 \family typewriter
25581 /path/to/sdcc/src/pic16/devices.inc
25582 \family default
25583 .
25584  Copy and modify an existing entry and insert it at the correct place (keep
25585  the file sorted).
25586  The file is hardly documented, look at the entries for the 18f2221...
25587 \end_layout
25588
25589 \begin_layout Enumerate
25590 Recompile SDCC, including the pic16 libraries.
25591 \end_layout
25592
25593 \begin_layout Subsection
25594 Memory Models
25595 \end_layout
25596
25597 \begin_layout Standard
25598 The following memory models are supported by the PIC16 port:
25599 \end_layout
25600
25601 \begin_layout Itemize
25602 small model
25603 \end_layout
25604
25605 \begin_layout Itemize
25606 large model
25607 \end_layout
25608
25609 \begin_layout Standard
25610 Memory model affects the default size of pointers within the source.
25611  The sizes are shown in the next table:
25612 \end_layout
25613
25614 \begin_layout Standard
25615 \align center
25616 \begin_inset Tabular
25617 <lyxtabular version="3" rows="3" columns="3">
25618 <features>
25619 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
25620 <column alignment="center" valignment="top" leftline="true" width="0">
25621 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
25622 <row topline="true" bottomline="true">
25623 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25624 \begin_inset Text
25625
25626 \begin_layout Standard
25627 Pointer sizes according to memory model
25628 \end_layout
25629
25630 \end_inset
25631 </cell>
25632 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25633 \begin_inset Text
25634
25635 \begin_layout Standard
25636 small model
25637 \end_layout
25638
25639 \end_inset
25640 </cell>
25641 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25642 \begin_inset Text
25643
25644 \begin_layout Standard
25645 large model
25646 \end_layout
25647
25648 \end_inset
25649 </cell>
25650 </row>
25651 <row topline="true" bottomline="true">
25652 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25653 \begin_inset Text
25654
25655 \begin_layout Standard
25656 code pointers
25657 \end_layout
25658
25659 \end_inset
25660 </cell>
25661 <cell multicolumn="1" alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25662 \begin_inset Text
25663
25664 \begin_layout Standard
25665 16-bits
25666 \end_layout
25667
25668 \end_inset
25669 </cell>
25670 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25671 \begin_inset Text
25672
25673 \begin_layout Standard
25674 24-bits
25675 \end_layout
25676
25677 \end_inset
25678 </cell>
25679 </row>
25680 <row topline="true" bottomline="true">
25681 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25682 \begin_inset Text
25683
25684 \begin_layout Standard
25685 data pointers
25686 \end_layout
25687
25688 \end_inset
25689 </cell>
25690 <cell multicolumn="1" alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
25691 \begin_inset Text
25692
25693 \begin_layout Standard
25694 16-bits
25695 \end_layout
25696
25697 \end_inset
25698 </cell>
25699 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
25700 \begin_inset Text
25701
25702 \begin_layout Standard
25703 16-bits
25704 \end_layout
25705
25706 \end_inset
25707 </cell>
25708 </row>
25709 </lyxtabular>
25710
25711 \end_inset
25712
25713
25714 \end_layout
25715
25716 \begin_layout Standard
25717 It is advisable that all sources within a project are compiled with the
25718  same memory model.
25719  If one wants to override the default memory model, this can be done by
25720  declaring a pointer as 
25721 \series bold
25722 far
25723 \series default
25724  or 
25725 \series bold
25726 near
25727 \series default
25728 .
25729  Far selects large memory model's pointers, while near selects small memory
25730  model's pointers.
25731 \end_layout
25732
25733 \begin_layout Standard
25734 The standard device libraries (see 
25735 \begin_inset LatexCommand \ref{sub:PIC16_Header-Files}
25736
25737 \end_inset
25738
25739 ) contain no reference to pointers, so they can be used with both memory
25740  models.
25741 \end_layout
25742
25743 \begin_layout Subsection
25744 Stack
25745 \end_layout
25746
25747 \begin_layout Standard
25748 The stack
25749 \begin_inset LatexCommand \index{PIC16!stack}
25750
25751 \end_inset
25752
25753  implementation for the PIC16 port uses two indirect registers, FSR1 and
25754  FSR2.
25755 \end_layout
25756
25757 \begin_layout Description
25758 FSR1 is assigned as stack pointer
25759 \end_layout
25760
25761 \begin_layout Description
25762 FSR2 is assigned as frame pointer
25763 \end_layout
25764
25765 \begin_layout Standard
25766 The following stack models are supported by the PIC16 port
25767 \end_layout
25768
25769 \begin_layout Itemize
25770
25771 \noun on
25772 small
25773 \noun default
25774  model
25775 \end_layout
25776
25777 \begin_layout Itemize
25778
25779 \noun on
25780 large
25781 \noun default
25782  model
25783 \end_layout
25784
25785 \begin_layout Standard
25786
25787 \noun on
25788 Small
25789 \noun default
25790  model means that only the FSRxL byte is used to access stack and frame,
25791  while 
25792 \emph on
25793 \noun on
25794 large
25795 \emph default
25796 \noun default
25797  uses both FSRxL and FSRxH registers.
25798  The following table shows the stack/frame pointers sizes according to stack
25799  model and the maximum space they can address:
25800 \end_layout
25801
25802 \begin_layout Standard
25803 \align center
25804 \begin_inset Tabular
25805 <lyxtabular version="3" rows="3" columns="3">
25806 <features>
25807 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
25808 <column alignment="center" valignment="top" leftline="true" width="0">
25809 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
25810 <row topline="true" bottomline="true">
25811 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25812 \begin_inset Text
25813
25814 \begin_layout Standard
25815 Stack & Frame pointer sizes according to stack model
25816 \end_layout
25817
25818 \end_inset
25819 </cell>
25820 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25821 \begin_inset Text
25822
25823 \begin_layout Standard
25824 small
25825 \end_layout
25826
25827 \end_inset
25828 </cell>
25829 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25830 \begin_inset Text
25831
25832 \begin_layout Standard
25833 large
25834 \end_layout
25835
25836 \end_inset
25837 </cell>
25838 </row>
25839 <row topline="true">
25840 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25841 \begin_inset Text
25842
25843 \begin_layout Standard
25844 Stack pointer FSR1
25845 \end_layout
25846
25847 \end_inset
25848 </cell>
25849 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25850 \begin_inset Text
25851
25852 \begin_layout Standard
25853 8-bits
25854 \end_layout
25855
25856 \end_inset
25857 </cell>
25858 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25859 \begin_inset Text
25860
25861 \begin_layout Standard
25862 16-bits
25863 \end_layout
25864
25865 \end_inset
25866 </cell>
25867 </row>
25868 <row topline="true" bottomline="true">
25869 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25870 \begin_inset Text
25871
25872 \begin_layout Standard
25873 Frame pointer FSR2
25874 \end_layout
25875
25876 \end_inset
25877 </cell>
25878 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25879 \begin_inset Text
25880
25881 \begin_layout Standard
25882 8-bits
25883 \end_layout
25884
25885 \end_inset
25886 </cell>
25887 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
25888 \begin_inset Text
25889
25890 \begin_layout Standard
25891 16-bits
25892 \end_layout
25893
25894 \end_inset
25895 </cell>
25896 </row>
25897 </lyxtabular>
25898
25899 \end_inset
25900
25901
25902 \end_layout
25903
25904 \begin_layout Standard
25905
25906 \noun on
25907 Large 
25908 \noun default
25909 stack model is currently not working properly throughout the code generator.
25910  So its use is not advised.
25911  Also there are some other points that need special care:
25912 \newline
25913
25914 \end_layout
25915
25916 \begin_layout Enumerate
25917 Do not create stack sections with size more than one physical bank (that
25918  is 256 bytes)
25919 \end_layout
25920
25921 \begin_layout Enumerate
25922 Stack sections should no cross physical bank limits (i.e.
25923  #pragma stack 0x50 0x100)
25924 \end_layout
25925
25926 \begin_layout Standard
25927 These limitations are caused by the fact that only FSRxL is modified when
25928  using SMALL stack model, so no more than 256 bytes of stack can be used.
25929  This problem will disappear after LARGE model is fully implemented.
25930 \end_layout
25931
25932 \begin_layout Subsection
25933 Functions
25934 \end_layout
25935
25936 \begin_layout Standard
25937 In addition to the standard SDCC function keywords, PIC16
25938 \begin_inset LatexCommand \index{PIC16}
25939
25940 \end_inset
25941
25942  port makes available two more:
25943 \end_layout
25944
25945 \begin_layout Description
25946 wparam
25947 \begin_inset LatexCommand \index{PIC16!wparam}
25948
25949 \end_inset
25950
25951  Use the WREG to pass one byte of the first function argument.
25952  This improves speed but you may not use this for functions with arguments
25953  that are called via function pointers, otherwise the first byte of the
25954  first parameter will get lost.
25955  Usage:
25956 \end_layout
25957
25958 \begin_layout LyX-Code
25959 void func_wparam(int a) wparam
25960 \end_layout
25961
25962 \begin_layout LyX-Code
25963 {
25964 \end_layout
25965
25966 \begin_layout LyX-Code
25967     /* WREG hold the lower part of a */
25968 \end_layout
25969
25970 \begin_layout LyX-Code
25971     /* the high part of a is stored in FSR2+2 (or +3 for large stack model)
25972  */
25973 \end_layout
25974
25975 \begin_layout LyX-Code
25976 ...
25977 \end_layout
25978
25979 \begin_layout LyX-Code
25980 }
25981 \end_layout
25982
25983 \begin_layout Description
25984 shadowregs
25985 \begin_inset LatexCommand \index{PIC16!shadowregs}
25986
25987 \end_inset
25988
25989  When entering/exiting an ISR, it is possible to take advantage of the PIC18F
25990  hardware shadow registers which hold the values of WREG, STATUS and BSR
25991  registers.
25992  This can be done by adding the keyword 
25993 \emph on
25994 shadowregs
25995 \emph default
25996  before the 
25997 \emph on
25998 interrupt
25999 \emph default
26000  keyword in the function's header.
26001 \end_layout
26002
26003 \begin_layout LyX-Code
26004 void isr_shadow(void) shadowregs interrupt 1
26005 \end_layout
26006
26007 \begin_layout LyX-Code
26008 {
26009 \end_layout
26010
26011 \begin_layout LyX-Code
26012 ...
26013 \end_layout
26014
26015 \begin_layout LyX-Code
26016 }
26017 \end_layout
26018
26019 \begin_layout Standard
26020
26021 \emph on
26022 shadowregs
26023 \emph default
26024  instructs the code generator not to store/restore WREG, STATUS, BSR when
26025  entering/exiting the ISR.
26026 \end_layout
26027
26028 \begin_layout Subsection
26029 Function return values
26030 \end_layout
26031
26032 \begin_layout Standard
26033 Return values from functions are placed to the appropriate registers following
26034  a modified Microchip policy optimized for SDCC.
26035  The following table shows these registers:
26036 \end_layout
26037
26038 \begin_layout Standard
26039 \align center
26040 \begin_inset Tabular
26041 <lyxtabular version="3" rows="6" columns="2">
26042 <features>
26043 <column alignment="center" valignment="top" leftline="true" width="0">
26044 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26045 <row topline="true" bottomline="true">
26046 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26047 \begin_inset Text
26048
26049 \begin_layout Standard
26050 size
26051 \end_layout
26052
26053 \end_inset
26054 </cell>
26055 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26056 \begin_inset Text
26057
26058 \begin_layout Standard
26059 destination register
26060 \end_layout
26061
26062 \end_inset
26063 </cell>
26064 </row>
26065 <row topline="true">
26066 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26067 \begin_inset Text
26068
26069 \begin_layout Standard
26070 8 bits
26071 \end_layout
26072
26073 \end_inset
26074 </cell>
26075 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26076 \begin_inset Text
26077
26078 \begin_layout Standard
26079 WREG
26080 \end_layout
26081
26082 \end_inset
26083 </cell>
26084 </row>
26085 <row topline="true">
26086 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26087 \begin_inset Text
26088
26089 \begin_layout Standard
26090 16 bits
26091 \end_layout
26092
26093 \end_inset
26094 </cell>
26095 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26096 \begin_inset Text
26097
26098 \begin_layout Standard
26099 PRODL:WREG
26100 \end_layout
26101
26102 \end_inset
26103 </cell>
26104 </row>
26105 <row topline="true">
26106 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26107 \begin_inset Text
26108
26109 \begin_layout Standard
26110 24 bits
26111 \end_layout
26112
26113 \end_inset
26114 </cell>
26115 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26116 \begin_inset Text
26117
26118 \begin_layout Standard
26119 PRODH:PRODL:WREG
26120 \end_layout
26121
26122 \end_inset
26123 </cell>
26124 </row>
26125 <row topline="true">
26126 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26127 \begin_inset Text
26128
26129 \begin_layout Standard
26130 32 bits
26131 \end_layout
26132
26133 \end_inset
26134 </cell>
26135 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26136 \begin_inset Text
26137
26138 \begin_layout Standard
26139 FSR0L:PRODH:PRODL:WREG
26140 \end_layout
26141
26142 \end_inset
26143 </cell>
26144 </row>
26145 <row topline="true" bottomline="true">
26146 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26147 \begin_inset Text
26148
26149 \begin_layout Standard
26150 >32 bits
26151 \end_layout
26152
26153 \end_inset
26154 </cell>
26155 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26156 \begin_inset Text
26157
26158 \begin_layout Standard
26159 on stack, FSR0 points to the beginning
26160 \end_layout
26161
26162 \end_inset
26163 </cell>
26164 </row>
26165 </lyxtabular>
26166
26167 \end_inset
26168
26169
26170 \end_layout
26171
26172 \begin_layout Subsection
26173 Interrupts
26174 \end_layout
26175
26176 \begin_layout Standard
26177 An interrupt
26178 \begin_inset LatexCommand \index{PIC16!interrupt}
26179
26180 \end_inset
26181
26182  service routine (ISR) is declared using the 
26183 \emph on
26184 interrupt
26185 \emph default
26186  keyword.
26187 \end_layout
26188
26189 \begin_layout LyX-Code
26190 void isr(void) interrupt 
26191 \emph on
26192 n
26193 \end_layout
26194
26195 \begin_layout LyX-Code
26196 {
26197 \end_layout
26198
26199 \begin_layout LyX-Code
26200 ...
26201 \end_layout
26202
26203 \begin_layout LyX-Code
26204 }
26205 \end_layout
26206
26207 \begin_layout Standard
26208
26209 \emph on
26210 n
26211 \emph default
26212  is the interrupt number, which for PIC18F devices can be:
26213 \end_layout
26214
26215 \begin_layout Standard
26216 \align center
26217 \begin_inset Tabular
26218 <lyxtabular version="3" rows="4" columns="3">
26219 <features>
26220 <column alignment="center" valignment="top" leftline="true" width="0">
26221 <column alignment="center" valignment="top" leftline="true" width="0">
26222 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26223 <row topline="true" bottomline="true">
26224 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26225 \begin_inset Text
26226
26227 \begin_layout Standard
26228
26229 \emph on
26230 n
26231 \end_layout
26232
26233 \end_inset
26234 </cell>
26235 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26236 \begin_inset Text
26237
26238 \begin_layout Standard
26239 Interrupt Vector
26240 \end_layout
26241
26242 \end_inset
26243 </cell>
26244 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26245 \begin_inset Text
26246
26247 \begin_layout Standard
26248 Interrupt Vector Address
26249 \end_layout
26250
26251 \end_inset
26252 </cell>
26253 </row>
26254 <row topline="true">
26255 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26256 \begin_inset Text
26257
26258 \begin_layout Standard
26259 0
26260 \end_layout
26261
26262 \end_inset
26263 </cell>
26264 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26265 \begin_inset Text
26266
26267 \begin_layout Standard
26268 RESET vector
26269 \end_layout
26270
26271 \end_inset
26272 </cell>
26273 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26274 \begin_inset Text
26275
26276 \begin_layout Standard
26277 0x000000
26278 \end_layout
26279
26280 \end_inset
26281 </cell>
26282 </row>
26283 <row topline="true">
26284 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26285 \begin_inset Text
26286
26287 \begin_layout Standard
26288
26289 \family roman
26290 \series medium
26291 \shape up
26292 \size normal
26293 \emph off
26294 \bar no
26295 \noun off
26296 \color none
26297 1
26298 \end_layout
26299
26300 \end_inset
26301 </cell>
26302 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26303 \begin_inset Text
26304
26305 \begin_layout Standard
26306
26307 \family roman
26308 \series medium
26309 \shape up
26310 \size normal
26311 \emph off
26312 \bar no
26313 \noun off
26314 \color none
26315 HIGH priority interrupts
26316 \end_layout
26317
26318 \end_inset
26319 </cell>
26320 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26321 \begin_inset Text
26322
26323 \begin_layout Standard
26324 0x000008
26325 \end_layout
26326
26327 \end_inset
26328 </cell>
26329 </row>
26330 <row topline="true" bottomline="true">
26331 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26332 \begin_inset Text
26333
26334 \begin_layout Standard
26335 2
26336 \end_layout
26337
26338 \end_inset
26339 </cell>
26340 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26341 \begin_inset Text
26342
26343 \begin_layout Standard
26344 LOW priority interrupts
26345 \end_layout
26346
26347 \end_inset
26348 </cell>
26349 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26350 \begin_inset Text
26351
26352 \begin_layout Standard
26353 0x000018
26354 \end_layout
26355
26356 \end_inset
26357 </cell>
26358 </row>
26359 </lyxtabular>
26360
26361 \end_inset
26362
26363
26364 \end_layout
26365
26366 \begin_layout Standard
26367 When generating assembly code for ISR the code generator places a 
26368 \noun on
26369 goto 
26370 \noun default
26371 instruction at the 
26372 \emph on
26373 Interrupt Vector Address
26374 \emph default
26375  which points at the genetated ISR.
26376  This single GOTO instruction is part of an automatically generated 
26377 \emph on
26378 interrupt entry point
26379 \emph default
26380  function.
26381  The actuall ISR code is placed as normally would in the code space.
26382  Upon interrupt request, the GOTO instruction is executed which jumps to
26383  the ISR code.
26384  When declaring interrupt functions as _naked this GOTO instruction is 
26385 \series bold
26386 not
26387 \series default
26388  generated.
26389  The whole interrupt functions is therefore placed at the Interrupt Vector
26390  Address of the specific interrupt.
26391  This is not a problem for the LOW priority interrupts, but it is a problem
26392  for the RESET and the HIGH priority interrupts because code may be written
26393  at the next interrupt's vector address and cause undeterminate program
26394  behaviour if that interrupt is raised.
26395 \begin_inset Foot
26396 status open
26397
26398 \begin_layout Standard
26399 This is not a problem when
26400 \end_layout
26401
26402 \begin_layout Enumerate
26403 this is a HIGH interrupt ISR and LOW interrupts are 
26404 \emph on
26405 disabled
26406 \emph default
26407  or not used.
26408 \end_layout
26409
26410 \begin_layout Enumerate
26411 when the ISR is small enough not to reach the next interrupt's vector address.
26412 \end_layout
26413
26414 \end_inset
26415
26416
26417 \end_layout
26418
26419 \begin_layout Standard
26420
26421 \emph on
26422 n
26423 \emph default
26424  may be omitted.
26425  This way a function is generated similar to an ISR, but it is not assigned
26426  to any interrupt.
26427 \end_layout
26428
26429 \begin_layout Standard
26430 When entering an interrupt, currently the PIC16
26431 \begin_inset LatexCommand \index{PIC16}
26432
26433 \end_inset
26434
26435  port automatically saves the following registers:
26436 \end_layout
26437
26438 \begin_layout Itemize
26439 WREG
26440 \end_layout
26441
26442 \begin_layout Itemize
26443 STATUS
26444 \end_layout
26445
26446 \begin_layout Itemize
26447 BSR
26448 \end_layout
26449
26450 \begin_layout Itemize
26451 PROD (PRODL and PRODH)
26452 \end_layout
26453
26454 \begin_layout Itemize
26455 FSR0 (FSR0L and FSR0H)
26456 \end_layout
26457
26458 \begin_layout Standard
26459 These registers are restored upon return from the interrupt routine.
26460 \begin_inset Foot
26461 status open
26462
26463 \begin_layout Standard
26464 NOTE that when the _naked attribute is specified for an interrupt routine,
26465  then NO registers are stored or restored.
26466 \end_layout
26467
26468 \end_inset
26469
26470
26471 \end_layout
26472
26473 \begin_layout Subsection
26474 Generic Pointers
26475 \end_layout
26476
26477 \begin_layout Standard
26478 Generic pointers are implemented in PIC16 port as 3-byte (24-bit) types.
26479  There are 3 types of generic pointers currently implemented data, code
26480  and eeprom pointers.
26481  They are differentiated by the value of the 7th and 6th bits of the upper
26482  byte:
26483 \end_layout
26484
26485 \begin_layout Standard
26486 \align center
26487 \begin_inset Tabular
26488 <lyxtabular version="3" rows="5" columns="5">
26489 <features>
26490 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26491 <column alignment="center" valignment="top" width="0">
26492 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26493 <column alignment="center" valignment="top" width="0">
26494 <column alignment="left" valignment="top" rightline="true" width="0">
26495 <row topline="true" bottomline="true">
26496 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26497 \begin_inset Text
26498
26499 \begin_layout Standard
26500 pointer type
26501 \end_layout
26502
26503 \end_inset
26504 </cell>
26505 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26506 \begin_inset Text
26507
26508 \begin_layout Standard
26509 7th bit
26510 \end_layout
26511
26512 \end_inset
26513 </cell>
26514 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26515 \begin_inset Text
26516
26517 \begin_layout Standard
26518 6th bit
26519 \end_layout
26520
26521 \end_inset
26522 </cell>
26523 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26524 \begin_inset Text
26525
26526 \begin_layout Standard
26527 rest of the pointer
26528 \end_layout
26529
26530 \end_inset
26531 </cell>
26532 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26533 \begin_inset Text
26534
26535 \begin_layout Standard
26536 description
26537 \end_layout
26538
26539 \end_inset
26540 </cell>
26541 </row>
26542 <row topline="true" bottomline="true">
26543 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26544 \begin_inset Text
26545
26546 \begin_layout Standard
26547 data 
26548 \end_layout
26549
26550 \end_inset
26551 </cell>
26552 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26553 \begin_inset Text
26554
26555 \begin_layout Standard
26556 1
26557 \end_layout
26558
26559 \end_inset
26560 </cell>
26561 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26562 \begin_inset Text
26563
26564 \begin_layout Standard
26565 0
26566 \end_layout
26567
26568 \end_inset
26569 </cell>
26570 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26571 \begin_inset Text
26572
26573 \begin_layout Standard
26574
26575 \family typewriter
26576 \shape slanted
26577 \emph on
26578 uuuuuu uuuuxxxx xxxxxxxx
26579 \end_layout
26580
26581 \end_inset
26582 </cell>
26583 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26584 \begin_inset Text
26585
26586 \begin_layout Standard
26587 a 12-bit data pointer in data RAM memory
26588 \end_layout
26589
26590 \end_inset
26591 </cell>
26592 </row>
26593 <row bottomline="true">
26594 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26595 \begin_inset Text
26596
26597 \begin_layout Standard
26598 code
26599 \end_layout
26600
26601 \end_inset
26602 </cell>
26603 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26604 \begin_inset Text
26605
26606 \begin_layout Standard
26607 0
26608 \end_layout
26609
26610 \end_inset
26611 </cell>
26612 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26613 \begin_inset Text
26614
26615 \begin_layout Standard
26616 0
26617 \end_layout
26618
26619 \end_inset
26620 </cell>
26621 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26622 \begin_inset Text
26623
26624 \begin_layout Standard
26625
26626 \family typewriter
26627 \shape slanted
26628 \emph on
26629 uxxxxx xxxxxxxx xxxxxxxx
26630 \end_layout
26631
26632 \end_inset
26633 </cell>
26634 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26635 \begin_inset Text
26636
26637 \begin_layout Standard
26638 a 21-bit code pointer in FLASH memory
26639 \end_layout
26640
26641 \end_inset
26642 </cell>
26643 </row>
26644 <row bottomline="true">
26645 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26646 \begin_inset Text
26647
26648 \begin_layout Standard
26649 eeprom
26650 \end_layout
26651
26652 \end_inset
26653 </cell>
26654 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26655 \begin_inset Text
26656
26657 \begin_layout Standard
26658 0
26659 \end_layout
26660
26661 \end_inset
26662 </cell>
26663 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26664 \begin_inset Text
26665
26666 \begin_layout Standard
26667 1
26668 \end_layout
26669
26670 \end_inset
26671 </cell>
26672 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26673 \begin_inset Text
26674
26675 \begin_layout Standard
26676
26677 \family typewriter
26678 \shape slanted
26679 \emph on
26680 uuuuuu uuuuuuxx xxxxxxxx
26681 \end_layout
26682
26683 \end_inset
26684 </cell>
26685 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26686 \begin_inset Text
26687
26688 \begin_layout Standard
26689 a 10-bit eeprom pointer in EEPROM memory
26690 \end_layout
26691
26692 \end_inset
26693 </cell>
26694 </row>
26695 <row bottomline="true">
26696 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26697 \begin_inset Text
26698
26699 \begin_layout Standard
26700 (unimplemented)
26701 \end_layout
26702
26703 \end_inset
26704 </cell>
26705 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26706 \begin_inset Text
26707
26708 \begin_layout Standard
26709 1
26710 \end_layout
26711
26712 \end_inset
26713 </cell>
26714 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26715 \begin_inset Text
26716
26717 \begin_layout Standard
26718 1
26719 \end_layout
26720
26721 \end_inset
26722 </cell>
26723 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26724 \begin_inset Text
26725
26726 \begin_layout Standard
26727
26728 \family typewriter
26729 \shape slanted
26730 \emph on
26731 xxxxxx xxxxxxxx xxxxxxxx
26732 \end_layout
26733
26734 \end_inset
26735 </cell>
26736 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26737 \begin_inset Text
26738
26739 \begin_layout Standard
26740 unimplemented pointer type
26741 \end_layout
26742
26743 \end_inset
26744 </cell>
26745 </row>
26746 </lyxtabular>
26747
26748 \end_inset
26749
26750
26751 \end_layout
26752
26753 \begin_layout Standard
26754 Generic pointer are read and written with a set of library functions which
26755  read/write 1, 2, 3, 4 bytes.
26756 \end_layout
26757
26758 \begin_layout Subsection
26759 PIC16 C Libraries
26760 \end_layout
26761
26762 \begin_layout Subsubsection
26763 Standard I/O Streams
26764 \end_layout
26765
26766 \begin_layout Standard
26767 In the 
26768 \emph on
26769 stdio.h
26770 \emph default
26771  the type FILE is defined as:
26772 \end_layout
26773
26774 \begin_layout LyX-Code
26775 typedef char * FILE;
26776 \end_layout
26777
26778 \begin_layout Standard
26779 This type is the stream type implemented I/O in the PIC18F devices.
26780  Also the standard input and output streams are declared in stdio.h:
26781 \end_layout
26782
26783 \begin_layout LyX-Code
26784 extern FILE * stdin;
26785 \end_layout
26786
26787 \begin_layout LyX-Code
26788 extern FILE * stdout;
26789 \end_layout
26790
26791 \begin_layout Standard
26792 The FILE type is actually a generic pointer which defines one more type
26793  of generic pointers, the 
26794 \emph on
26795 stream
26796 \emph default
26797  pointer.
26798  This new type has the format:
26799 \end_layout
26800
26801 \begin_layout Standard
26802 \align center
26803 \begin_inset Tabular
26804 <lyxtabular version="3" rows="2" columns="7">
26805 <features>
26806 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26807 <column alignment="center" valignment="top" width="0">
26808 <column alignment="center" valignment="top" leftline="true" width="0">
26809 <column alignment="center" valignment="top" leftline="true" width="0">
26810 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26811 <column alignment="center" valignment="top" width="0">
26812 <column alignment="left" valignment="top" rightline="true" width="0">
26813 <row topline="true" bottomline="true">
26814 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26815 \begin_inset Text
26816
26817 \begin_layout Standard
26818 pointer type
26819 \end_layout
26820
26821 \end_inset
26822 </cell>
26823 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26824 \begin_inset Text
26825
26826 \begin_layout Standard
26827 <7:6>
26828 \end_layout
26829
26830 \end_inset
26831 </cell>
26832 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26833 \begin_inset Text
26834
26835 \begin_layout Standard
26836 <5>
26837 \end_layout
26838
26839 \end_inset
26840 </cell>
26841 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26842 \begin_inset Text
26843
26844 \begin_layout Standard
26845 <4>
26846 \end_layout
26847
26848 \end_inset
26849 </cell>
26850 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26851 \begin_inset Text
26852
26853 \begin_layout Standard
26854 <3:0>
26855 \end_layout
26856
26857 \end_inset
26858 </cell>
26859 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26860 \begin_inset Text
26861
26862 \begin_layout Standard
26863 rest of the pointer
26864 \end_layout
26865
26866 \end_inset
26867 </cell>
26868 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26869 \begin_inset Text
26870
26871 \begin_layout Standard
26872 descrption
26873 \end_layout
26874
26875 \end_inset
26876 </cell>
26877 </row>
26878 <row topline="true" bottomline="true">
26879 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26880 \begin_inset Text
26881
26882 \begin_layout Standard
26883 stream
26884 \end_layout
26885
26886 \end_inset
26887 </cell>
26888 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26889 \begin_inset Text
26890
26891 \begin_layout Standard
26892 00
26893 \end_layout
26894
26895 \end_inset
26896 </cell>
26897 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26898 \begin_inset Text
26899
26900 \begin_layout Standard
26901 1
26902 \end_layout
26903
26904 \end_inset
26905 </cell>
26906 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26907 \begin_inset Text
26908
26909 \begin_layout Standard
26910 0
26911 \end_layout
26912
26913 \end_inset
26914 </cell>
26915 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26916 \begin_inset Text
26917
26918 \begin_layout Standard
26919 nnnn
26920 \end_layout
26921
26922 \end_inset
26923 </cell>
26924 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26925 \begin_inset Text
26926
26927 \begin_layout Standard
26928
26929 \family typewriter
26930 \shape slanted
26931 \emph on
26932 uuuuuuuu uuuuuuuu
26933 \end_layout
26934
26935 \end_inset
26936 </cell>
26937 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26938 \begin_inset Text
26939
26940 \begin_layout Standard
26941 upper byte high nubble is 0x2n, the rest are zeroes
26942 \end_layout
26943
26944 \end_inset
26945 </cell>
26946 </row>
26947 </lyxtabular>
26948
26949 \end_inset
26950
26951
26952 \end_layout
26953
26954 \begin_layout Standard
26955 Currently implemented there are 3 types of streams defined:
26956 \end_layout
26957
26958 \begin_layout Standard
26959 \align center
26960 \begin_inset Tabular
26961 <lyxtabular version="3" rows="4" columns="4">
26962 <features>
26963 <column alignment="center" valignment="top" leftline="true" width="0">
26964 <column alignment="center" valignment="top" leftline="true" width="0">
26965 <column alignment="center" valignment="top" leftline="true" width="0">
26966 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26967 <row topline="true" bottomline="true">
26968 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26969 \begin_inset Text
26970
26971 \begin_layout Standard
26972 stream type
26973 \end_layout
26974
26975 \end_inset
26976 </cell>
26977 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26978 \begin_inset Text
26979
26980 \begin_layout Standard
26981 value
26982 \end_layout
26983
26984 \end_inset
26985 </cell>
26986 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26987 \begin_inset Text
26988
26989 \begin_layout Standard
26990 module
26991 \end_layout
26992
26993 \end_inset
26994 </cell>
26995 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26996 \begin_inset Text
26997
26998 \begin_layout Standard
26999 description
27000 \end_layout
27001
27002 \end_inset
27003 </cell>
27004 </row>
27005 <row topline="true">
27006 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27007 \begin_inset Text
27008
27009 \begin_layout Standard
27010 STREAM_USART
27011 \end_layout
27012
27013 \end_inset
27014 </cell>
27015 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27016 \begin_inset Text
27017
27018 \begin_layout Standard
27019
27020 \family typewriter
27021 0x200000UL
27022 \end_layout
27023
27024 \end_inset
27025 </cell>
27026 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27027 \begin_inset Text
27028
27029 \begin_layout Standard
27030 USART
27031 \end_layout
27032
27033 \end_inset
27034 </cell>
27035 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27036 \begin_inset Text
27037
27038 \begin_layout Standard
27039 Writes/Reads characters via the USART peripheral
27040 \end_layout
27041
27042 \end_inset
27043 </cell>
27044 </row>
27045 <row topline="true">
27046 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27047 \begin_inset Text
27048
27049 \begin_layout Standard
27050 STREAM_MSSP
27051 \end_layout
27052
27053 \end_inset
27054 </cell>
27055 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27056 \begin_inset Text
27057
27058 \begin_layout Standard
27059
27060 \family typewriter
27061 0x210000UL
27062 \end_layout
27063
27064 \end_inset
27065 </cell>
27066 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27067 \begin_inset Text
27068
27069 \begin_layout Standard
27070 MSSP
27071 \end_layout
27072
27073 \end_inset
27074 </cell>
27075 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27076 \begin_inset Text
27077
27078 \begin_layout Standard
27079 Writes/Reads characters via the MSSP peripheral
27080 \end_layout
27081
27082 \end_inset
27083 </cell>
27084 </row>
27085 <row topline="true" bottomline="true">
27086 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27087 \begin_inset Text
27088
27089 \begin_layout Standard
27090 STREAM_USER
27091 \end_layout
27092
27093 \end_inset
27094 </cell>
27095 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27096 \begin_inset Text
27097
27098 \begin_layout Standard
27099
27100 \family typewriter
27101 0x2f0000UL
27102 \end_layout
27103
27104 \end_inset
27105 </cell>
27106 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27107 \begin_inset Text
27108
27109 \begin_layout Standard
27110 (none)
27111 \end_layout
27112
27113 \end_inset
27114 </cell>
27115 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27116 \begin_inset Text
27117
27118 \begin_layout Standard
27119 Writes/Reads characters via used defined functions
27120 \end_layout
27121
27122 \end_inset
27123 </cell>
27124 </row>
27125 </lyxtabular>
27126
27127 \end_inset
27128
27129
27130 \end_layout
27131
27132 \begin_layout Standard
27133 The stream identifiers are declared as macros in the stdio.h header.
27134 \end_layout
27135
27136 \begin_layout Standard
27137 In the libc library there exist the functions that are used to write to
27138  each of the above streams.
27139  These are
27140 \end_layout
27141
27142 \begin_layout Description
27143 _
27144 \begin_inset ERT
27145 status collapsed
27146
27147 \begin_layout Standard
27148
27149
27150 \backslash
27151 /
27152 \end_layout
27153
27154 \end_inset
27155
27156 _stream_usart_putchar writes a character at the USART stream
27157 \end_layout
27158
27159 \begin_layout Description
27160 _
27161 \begin_inset ERT
27162 status collapsed
27163
27164 \begin_layout Standard
27165
27166
27167 \backslash
27168 /
27169 \end_layout
27170
27171 \end_inset
27172
27173 _stream_mssp_putchar writes a character at the MSSP stream
27174 \end_layout
27175
27176 \begin_layout Description
27177 putchar dummy function.
27178  This writes a character to a user specified manner.
27179 \end_layout
27180
27181 \begin_layout Standard
27182 In order to increase performance 
27183 \emph on
27184 putchar
27185 \emph default
27186  is declared in stdio.h as having its parameter in WREG (it has the wparam
27187  keyword).
27188  In stdio.h exists the macro PUTCHAR(arg) that defines the putchar function
27189  in a user-friendly way.
27190  
27191 \emph on
27192 arg
27193 \emph default
27194  is the name of the variable that holds the character to print.
27195  An example follows:
27196 \end_layout
27197
27198 \begin_layout LyX-Code
27199 #include <pic18fregs.h>
27200 \newline
27201 #include <stdio.h>
27202 \newline
27203
27204 \newline
27205 PUTCHAR( c )
27206 \end_layout
27207
27208 \begin_layout LyX-Code
27209 {
27210 \end_layout
27211
27212 \begin_layout LyX-Code
27213     PORTA = c;    /* dump character c to PORTA */
27214 \end_layout
27215
27216 \begin_layout LyX-Code
27217
27218 \newline
27219
27220 \newline
27221 void main(void)
27222 \end_layout
27223
27224 \begin_layout LyX-Code
27225 {
27226 \end_layout
27227
27228 \begin_layout LyX-Code
27229     stdout = STREAM_USER;    /* this is not necessary, since stdout points
27230 \end_layout
27231
27232 \begin_layout LyX-Code
27233                               * by default to STREAM_USER */
27234 \end_layout
27235
27236 \begin_layout LyX-Code
27237     printf (
27238 \begin_inset Quotes sld
27239 \end_inset
27240
27241 This is a printf test
27242 \backslash
27243 n
27244 \begin_inset Quotes srd
27245 \end_inset
27246
27247 );
27248 \end_layout
27249
27250 \begin_layout LyX-Code
27251 }
27252 \end_layout
27253
27254 \begin_layout LyX-Code
27255
27256 \end_layout
27257
27258 \begin_layout Subsubsection
27259 Printing functions
27260 \end_layout
27261
27262 \begin_layout Standard
27263 PIC16 contains an implementation of the printf-family of functions.
27264  There exist the following functions:
27265 \end_layout
27266
27267 \begin_layout LyX-Code
27268 extern unsigned int sprintf(char *buf, char *fmt, ...);
27269 \end_layout
27270
27271 \begin_layout LyX-Code
27272 extern unsigned int vsprintf(char *buf, char *fmt, va_list ap);
27273 \end_layout
27274
27275 \begin_layout LyX-Code
27276
27277 \end_layout
27278
27279 \begin_layout LyX-Code
27280 extern unsigned int printf(char *fmt, ...);
27281 \end_layout
27282
27283 \begin_layout LyX-Code
27284 extern unsigned int vprintf(char *fmt, va_lista ap);
27285 \end_layout
27286
27287 \begin_layout LyX-Code
27288
27289 \end_layout
27290
27291 \begin_layout LyX-Code
27292 extern unsigned int fprintf(FILE *fp, char *fmt, ...);
27293 \end_layout
27294
27295 \begin_layout LyX-Code
27296 extern unsigned int vfprintf(FILE *fp, char *fmt, va_list ap);
27297 \end_layout
27298
27299 \begin_layout Standard
27300 For sprintf and vsprintf 
27301 \emph on
27302 buf
27303 \emph default
27304  should normally be a data pointer where the resulting string will be placed.
27305  No range checking is done so the user should allocate the necessery buffer.
27306  For fprintf and vfprintf 
27307 \emph on
27308 fp
27309 \emph default
27310  should be a stream pointer (i.e.
27311  stdout, STREAM_MSSP, etc...).
27312 \end_layout
27313
27314 \begin_layout Subsubsection
27315 Signals
27316 \end_layout
27317
27318 \begin_layout Standard
27319 The PIC18F family of microcontrollers supports a number of interrupt sources.
27320  A list of these interrupts is shown in the following table:
27321 \end_layout
27322
27323 \begin_layout Standard
27324 \align center
27325 \begin_inset Tabular
27326 <lyxtabular version="3" rows="11" columns="4">
27327 <features>
27328 <column alignment="left" valignment="top" leftline="true" width="0">
27329 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
27330 <column alignment="left" valignment="top" leftline="true" width="0">
27331 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
27332 <row topline="true" bottomline="true">
27333 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27334 \begin_inset Text
27335
27336 \begin_layout Standard
27337 signal name
27338 \end_layout
27339
27340 \end_inset
27341 </cell>
27342 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27343 \begin_inset Text
27344
27345 \begin_layout Standard
27346 description
27347 \end_layout
27348
27349 \end_inset
27350 </cell>
27351 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27352 \begin_inset Text
27353
27354 \begin_layout Standard
27355 signal name
27356 \end_layout
27357
27358 \end_inset
27359 </cell>
27360 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27361 \begin_inset Text
27362
27363 \begin_layout Standard
27364 descritpion
27365 \end_layout
27366
27367 \end_inset
27368 </cell>
27369 </row>
27370 <row topline="true">
27371 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27372 \begin_inset Text
27373
27374 \begin_layout Standard
27375 SIG_RB
27376 \end_layout
27377
27378 \end_inset
27379 </cell>
27380 <cell multicolumn="1" alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27381 \begin_inset Text
27382
27383 \begin_layout Standard
27384 PORTB change interrupt
27385 \end_layout
27386
27387 \end_inset
27388 </cell>
27389 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27390 \begin_inset Text
27391
27392 \begin_layout Standard
27393 SIG_EE
27394 \end_layout
27395
27396 \end_inset
27397 </cell>
27398 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27399 \begin_inset Text
27400
27401 \begin_layout Standard
27402 EEPROM/FLASH write complete interrupt
27403 \end_layout
27404
27405 \end_inset
27406 </cell>
27407 </row>
27408 <row topline="true">
27409 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27410 \begin_inset Text
27411
27412 \begin_layout Standard
27413 SIG_INT0
27414 \end_layout
27415
27416 \end_inset
27417 </cell>
27418 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27419 \begin_inset Text
27420
27421 \begin_layout Standard
27422 INT0 external interrupt
27423 \end_layout
27424
27425 \end_inset
27426 </cell>
27427 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27428 \begin_inset Text
27429
27430 \begin_layout Standard
27431 SIG_BCOL
27432 \end_layout
27433
27434 \end_inset
27435 </cell>
27436 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27437 \begin_inset Text
27438
27439 \begin_layout Standard
27440 Bus collision interrupt
27441 \end_layout
27442
27443 \end_inset
27444 </cell>
27445 </row>
27446 <row topline="true">
27447 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27448 \begin_inset Text
27449
27450 \begin_layout Standard
27451 SIG_INT1
27452 \end_layout
27453
27454 \end_inset
27455 </cell>
27456 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27457 \begin_inset Text
27458
27459 \begin_layout Standard
27460 INT1 external interrupt
27461 \end_layout
27462
27463 \end_inset
27464 </cell>
27465 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27466 \begin_inset Text
27467
27468 \begin_layout Standard
27469 SIG_LVD
27470 \end_layout
27471
27472 \end_inset
27473 </cell>
27474 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27475 \begin_inset Text
27476
27477 \begin_layout Standard
27478 Low voltage detect interrupt
27479 \end_layout
27480
27481 \end_inset
27482 </cell>
27483 </row>
27484 <row topline="true">
27485 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27486 \begin_inset Text
27487
27488 \begin_layout Standard
27489 SIG_INT2
27490 \end_layout
27491
27492 \end_inset
27493 </cell>
27494 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27495 \begin_inset Text
27496
27497 \begin_layout Standard
27498 INT2 external interrupt
27499 \end_layout
27500
27501 \end_inset
27502 </cell>
27503 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27504 \begin_inset Text
27505
27506 \begin_layout Standard
27507 SIG_PSP
27508 \end_layout
27509
27510 \end_inset
27511 </cell>
27512 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27513 \begin_inset Text
27514
27515 \begin_layout Standard
27516 Parallel slave port interrupt
27517 \end_layout
27518
27519 \end_inset
27520 </cell>
27521 </row>
27522 <row topline="true">
27523 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27524 \begin_inset Text
27525
27526 \begin_layout Standard
27527 SIG_CCP1
27528 \end_layout
27529
27530 \end_inset
27531 </cell>
27532 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27533 \begin_inset Text
27534
27535 \begin_layout Standard
27536 CCP1 module interrupt
27537 \end_layout
27538
27539 \end_inset
27540 </cell>
27541 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27542 \begin_inset Text
27543
27544 \begin_layout Standard
27545 SIG_AD
27546 \end_layout
27547
27548 \end_inset
27549 </cell>
27550 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27551 \begin_inset Text
27552
27553 \begin_layout Standard
27554 AD convertion complete interrupt
27555 \end_layout
27556
27557 \end_inset
27558 </cell>
27559 </row>
27560 <row topline="true">
27561 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27562 \begin_inset Text
27563
27564 \begin_layout Standard
27565 SIG_CCP2
27566 \end_layout
27567
27568 \end_inset
27569 </cell>
27570 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27571 \begin_inset Text
27572
27573 \begin_layout Standard
27574 CCP2 module interrupt
27575 \end_layout
27576
27577 \end_inset
27578 </cell>
27579 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27580 \begin_inset Text
27581
27582 \begin_layout Standard
27583 SIG_RC
27584 \end_layout
27585
27586 \end_inset
27587 </cell>
27588 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27589 \begin_inset Text
27590
27591 \begin_layout Standard
27592 USART receive interrupt
27593 \end_layout
27594
27595 \end_inset
27596 </cell>
27597 </row>
27598 <row topline="true">
27599 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27600 \begin_inset Text
27601
27602 \begin_layout Standard
27603 SIG_TMR0
27604 \end_layout
27605
27606 \end_inset
27607 </cell>
27608 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27609 \begin_inset Text
27610
27611 \begin_layout Standard
27612 TMR0 overflow interrupt
27613 \end_layout
27614
27615 \end_inset
27616 </cell>
27617 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27618 \begin_inset Text
27619
27620 \begin_layout Standard
27621 SIG_TX
27622 \end_layout
27623
27624 \end_inset
27625 </cell>
27626 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27627 \begin_inset Text
27628
27629 \begin_layout Standard
27630 USART transmit interrupt
27631 \end_layout
27632
27633 \end_inset
27634 </cell>
27635 </row>
27636 <row topline="true">
27637 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27638 \begin_inset Text
27639
27640 \begin_layout Standard
27641 SIG_TMR1
27642 \end_layout
27643
27644 \end_inset
27645 </cell>
27646 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27647 \begin_inset Text
27648
27649 \begin_layout Standard
27650 TMR1 overflow interrupt
27651 \end_layout
27652
27653 \end_inset
27654 </cell>
27655 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27656 \begin_inset Text
27657
27658 \begin_layout Standard
27659 SIG_MSSP
27660 \end_layout
27661
27662 \end_inset
27663 </cell>
27664 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27665 \begin_inset Text
27666
27667 \begin_layout Standard
27668 SSP receive/transmit interrupt
27669 \end_layout
27670
27671 \end_inset
27672 </cell>
27673 </row>
27674 <row topline="true">
27675 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27676 \begin_inset Text
27677
27678 \begin_layout Standard
27679 SIG_TMR2
27680 \end_layout
27681
27682 \end_inset
27683 </cell>
27684 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27685 \begin_inset Text
27686
27687 \begin_layout Standard
27688 TMR2 matches PR2 interrupt
27689 \end_layout
27690
27691 \end_inset
27692 </cell>
27693 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27694 \begin_inset Text
27695
27696 \begin_layout Standard
27697
27698 \end_layout
27699
27700 \end_inset
27701 </cell>
27702 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27703 \begin_inset Text
27704
27705 \begin_layout Standard
27706
27707 \end_layout
27708
27709 \end_inset
27710 </cell>
27711 </row>
27712 <row topline="true" bottomline="true">
27713 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27714 \begin_inset Text
27715
27716 \begin_layout Standard
27717 SIG_TMR3
27718 \end_layout
27719
27720 \end_inset
27721 </cell>
27722 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27723 \begin_inset Text
27724
27725 \begin_layout Standard
27726 TMR3 overflow interrupt
27727 \end_layout
27728
27729 \end_inset
27730 </cell>
27731 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27732 \begin_inset Text
27733
27734 \begin_layout Standard
27735
27736 \end_layout
27737
27738 \end_inset
27739 </cell>
27740 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27741 \begin_inset Text
27742
27743 \begin_layout Standard
27744
27745 \end_layout
27746
27747 \end_inset
27748 </cell>
27749 </row>
27750 </lyxtabular>
27751
27752 \end_inset
27753
27754
27755 \end_layout
27756
27757 \begin_layout Standard
27758 The prototypes for these names are defined in the header file 
27759 \emph on
27760 signal.h
27761 \emph default
27762  .
27763 \end_layout
27764
27765 \begin_layout Standard
27766 In order to simplify signal handling, a number of macros is provided:
27767 \end_layout
27768
27769 \begin_layout List
27770 \labelwidthstring 00.00.0000
27771 DEF_INTHIGH(name) begin the definition of the interrupt dispatch table for
27772  high priority interrupts.
27773  
27774 \emph on
27775 name
27776 \emph default
27777  is the function name to use.
27778 \end_layout
27779
27780 \begin_layout List
27781 \labelwidthstring 00.00.0000
27782 DEF_INTLOW(name) begin the definition of the interrupt dispatch table fo
27783  low priority interrupt.
27784  
27785 \emph on
27786 name
27787 \emph default
27788  is the function name to use.
27789 \end_layout
27790
27791 \begin_layout List
27792 \labelwidthstring 00.00.0000
27793 DEF_HANDLER(sig,handler) define a handler for signal 
27794 \emph on
27795 sig.
27796 \end_layout
27797
27798 \begin_layout List
27799 \labelwidthstring 00.00.0000
27800 END_DEF end the declaration of the dispatch table.
27801 \end_layout
27802
27803 \begin_layout Standard
27804 Additionally there are two more macros to simplify the declaration of the
27805  signal handler:
27806 \end_layout
27807
27808 \begin_layout List
27809 \labelwidthstring 00.00.0000
27810
27811 \series medium
27812 SIGHANDLER(handler)
27813 \series default
27814  this declares the function prototype for the 
27815 \emph on
27816 handler
27817 \emph default
27818  function.
27819 \end_layout
27820
27821 \begin_layout List
27822 \labelwidthstring 00.00.0000
27823 SIGHANDLERNAKED(handler) same as SIGHANDLER() but declares a naked function.
27824 \end_layout
27825
27826 \begin_layout Standard
27827 An example of using the macros above is shown below:
27828 \end_layout
27829
27830 \begin_layout LyX-Code
27831 #include <pic18fregs.h>
27832 \end_layout
27833
27834 \begin_layout LyX-Code
27835 #include <signal.h>
27836 \newline
27837
27838 \newline
27839 DEF_INTHIGH(high_int)
27840 \end_layout
27841
27842 \begin_layout LyX-Code
27843 DEF_HANDLER(SIG_TMR0, _tmr0_handler)
27844 \end_layout
27845
27846 \begin_layout LyX-Code
27847 DEF_HANDLER(SIG_BCOL, _bcol_handler)
27848 \end_layout
27849
27850 \begin_layout LyX-Code
27851 END_DEF
27852 \newline
27853
27854 \newline
27855 SIGHANDLER(_tmr0_handler)
27856 \end_layout
27857
27858 \begin_layout LyX-Code
27859 {
27860 \end_layout
27861
27862 \begin_layout LyX-Code
27863   /* action to be taken when timer 0 overflows */
27864 \end_layout
27865
27866 \begin_layout LyX-Code
27867 }
27868 \newline
27869
27870 \newline
27871 SIGHANDLERNAKED(_bcol_handler)
27872 \end_layout
27873
27874 \begin_layout LyX-Code
27875 {
27876 \end_layout
27877
27878 \begin_layout LyX-Code
27879   _asm
27880 \end_layout
27881
27882 \begin_layout LyX-Code
27883     /* action to be taken when bus collision occurs */
27884 \end_layout
27885
27886 \begin_layout LyX-Code
27887     retfie
27888 \end_layout
27889
27890 \begin_layout LyX-Code
27891  _endasm;
27892 \end_layout
27893
27894 \begin_layout LyX-Code
27895 }
27896 \end_layout
27897
27898 \begin_layout Standard
27899
27900 \series bold
27901 NOTES:
27902 \series default
27903  Special care should be taken when using the above scheme:
27904 \end_layout
27905
27906 \begin_layout Itemize
27907 do not place a colon (;) at the end of the DEF_* and END_DEF macros.
27908 \end_layout
27909
27910 \begin_layout Itemize
27911 when declaring SIGHANDLERNAKED handler never forget to use 
27912 \emph on
27913 retfie
27914 \emph default
27915  for proper returning.
27916 \end_layout
27917
27918 \begin_layout Subsection
27919 PIC16 Port -- Tips
27920 \end_layout
27921
27922 \begin_layout Standard
27923 Here you can find some general tips for compiling programs with SDCC/pic16.
27924 \end_layout
27925
27926 \begin_layout Subsubsection
27927 Stack size
27928 \end_layout
27929
27930 \begin_layout Standard
27931 The default stack
27932 \begin_inset LatexCommand \index{PIC16!stack}
27933
27934 \end_inset
27935
27936  size (that is 64 bytes) probably is enough for many programs.
27937  One must take care that when there are many levels of function nesting,
27938  or there is excessive usage of stack, its size should be extended.
27939  An example of such a case is the printf/sprintf family of functions.
27940  If you encounter problems like not being able to print integers, then you
27941  need to set the stack size around the maximum (256 for small stack model).
27942  The following diagram shows what happens when calling printf to print an
27943  integer:
27944 \end_layout
27945
27946 \begin_layout LyX-Code
27947 printf () --> ltoa () --> ultoa () --> divschar ()
27948 \end_layout
27949
27950 \begin_layout Standard
27951 It is should be understood that stack is easily consumed when calling complicate
27952 d functions.
27953  Using command line arguments like -
27954 \begin_inset ERT
27955 status collapsed
27956
27957 \begin_layout Standard
27958
27959
27960 \backslash
27961 /
27962 \end_layout
27963
27964 \end_inset
27965
27966 -fommit-frame-pointer might reduce stack usage by not creating unnecessery
27967  stack frames.
27968  Other ways to reduce stack usage may exist.
27969 \end_layout
27970
27971 \begin_layout Subsection
27972 Known Bugs
27973 \end_layout
27974
27975 \begin_layout Standard
27976 The PIC16 Port currently does not pass SDCC's regression test
27977 \begin_inset LatexCommand \index{Regression test (PIC16)}
27978
27979 \end_inset
27980
27981  suite (see section 
27982 \begin_inset LatexCommand \ref{sec:Quality-control}
27983
27984 \end_inset
27985
27986 ) and thus the snapshot build regression tests for the PIC16 target are
27987  currently disabled for all hosts
27988 \emph on
27989 .
27990 \end_layout
27991
27992 \begin_layout Chapter
27993 Debugging
27994 \end_layout
27995
27996 \begin_layout Standard
27997 There are several approaches to debugging your code.
27998  This chapter is meant to show your options and to give detail on some of
27999  them:
28000 \newline
28001
28002 \newline
28003 When writing your code:
28004 \end_layout
28005
28006 \begin_layout Itemize
28007 write your code with debugging in mind (avoid duplicating code, put conceptually
28008  similar variables into structs, use structured code, have strategic points
28009  within your code where all variables are consistent, ...)
28010 \end_layout
28011
28012 \begin_layout Itemize
28013 run a syntax-checking tool like splint
28014 \begin_inset LatexCommand \index{splint (syntax checking tool)}
28015
28016 \end_inset
28017
28018
28019 \begin_inset LatexCommand \index{lint (syntax checking tool)}
28020
28021 \end_inset
28022
28023  (see -
28024 \begin_inset ERT
28025 status collapsed
28026
28027 \begin_layout Standard
28028
28029
28030 \backslash
28031 /
28032 \end_layout
28033
28034 \end_inset
28035
28036 -more-pedantic 
28037 \begin_inset LatexCommand \ref{lyx:more-pedantic-SPLINT}
28038
28039 \end_inset
28040
28041 ) over the code.
28042 \end_layout
28043
28044 \begin_layout Itemize
28045 for the high level code use a C-compiler (like f.e.
28046  GCC) to compile run and debug the code on your host.
28047  See (see -
28048 \begin_inset ERT
28049 status collapsed
28050
28051 \begin_layout Standard
28052
28053
28054 \backslash
28055 /
28056 \end_layout
28057
28058 \end_inset
28059
28060 -more-pedantic 
28061 \begin_inset LatexCommand \ref{lyx:more-pedantic-SPLINT}
28062
28063 \end_inset
28064
28065 ) on how to handle syntax extensions like __xdata, __at(), ...
28066  
28067 \end_layout
28068
28069 \begin_layout Itemize
28070 use another C-compiler to compile code for your target.
28071  Always an option but not recommended:) And not very likely to help you.
28072  If you seriously consider walking this path you should at least occasionally
28073  check portability of your code.
28074  Most commercial compiler vendors will offer an evaluation version so you
28075  can test compile your code or snippets of your code.
28076 \end_layout
28077
28078 \begin_layout Standard
28079 Debugging on a simulator:
28080 \end_layout
28081
28082 \begin_layout Itemize
28083 there is a separate section about SDCDB (section 
28084 \begin_inset LatexCommand \ref{cha:Debugging-with-SDCDB}
28085
28086 \end_inset
28087
28088 ) below.
28089 \end_layout
28090
28091 \begin_layout Itemize
28092 or (8051 specific) use a freeware/commercial simulator which interfaces
28093  to the AOMF
28094 \begin_inset LatexCommand \index{AOMF, AOMF51}
28095
28096 \end_inset
28097
28098  file (see 
28099 \begin_inset LatexCommand \ref{OMF file}
28100
28101 \end_inset
28102
28103 ) optionally generated by SDCC.
28104 \end_layout
28105
28106 \begin_layout Standard
28107 Debugging On-target: 
28108 \end_layout
28109
28110 \begin_layout Itemize
28111 use a MCU port pin to serially output debug data to the RS232 port of your
28112  host.
28113  You'll probably want some level shifting device typically involving a MAX232
28114  or similar IC.
28115  If the hardware serial port of the MCU is not available search for 'Software
28116  UART' in your favourite search machine.
28117 \end_layout
28118
28119 \begin_layout Itemize
28120 use an on-target monitor.
28121  In this context a monitor is a small program which usually accepts commands
28122  via a serial line and allows to set program counter, to single step through
28123  a program and read/write memory locations.
28124  For the 8051 good examples of monitors are paulmon and cmon51 (see section
28125  
28126 \begin_inset LatexCommand \ref{sec:Related-open-source-tools}
28127
28128 \end_inset
28129
28130 ).
28131 \end_layout
28132
28133 \begin_layout Itemize
28134 toggle MCU port pins at strategic points within your code and use an oscilloscop
28135 e.
28136  A 
28137 \emph on
28138 digital oscilloscope
28139 \emph default
28140
28141 \begin_inset LatexCommand \index{Oscilloscope}
28142
28143 \end_inset
28144
28145  with deep trace memory is really helpful especially if you have to debug
28146  a realtime application.
28147  If you need to monitor more pins than your oscilloscope provides you can
28148  sometimes get away with a small R-2R network.
28149  On a single channel oscilloscope you could f.e.
28150  monitor 2 push-pull driven pins by connecting one via a 10\InsetSpace ~
28151 k
28152 \begin_inset Formula $\Omega$
28153 \end_inset
28154
28155  resistor and the other one by a 5\InsetSpace ~
28156 k
28157 \begin_inset Formula $\Omega$
28158 \end_inset
28159
28160  resistor to the oscilloscope probe (check output drive capability of the
28161  pins you want to monitor).
28162  If you need to monitor many more pins a 
28163 \emph on
28164 logic analyzer
28165 \emph default
28166  will be handy.
28167 \end_layout
28168
28169 \begin_layout Itemize
28170 use an ICE (
28171 \emph on
28172 i
28173 \emph default
28174
28175 \emph on
28176 c
28177 \emph default
28178 ircuit 
28179 \emph on
28180 e
28181 \emph default
28182 mulator
28183 \begin_inset LatexCommand \index{ICE (in circuit emulator)}
28184
28185 \end_inset
28186
28187 ).
28188  Usually very expensive.
28189  And very nice to have too.
28190  And usually locks you (for years...) to the devices the ICE can emulate.
28191  
28192 \end_layout
28193
28194 \begin_layout Itemize
28195 use a remote debugger.
28196  In most 8-bit systems the symbol information is not available on the target,
28197  and a complete debugger is too bulky for the target system.
28198  Therefore usually a debugger on the host system connects to an on-target
28199  debugging stub which accepts only primitive commands.
28200  
28201 \newline
28202 Terms to enter into your favourite search engine could be 'remote debugging',
28203  'gdb stub' or 'inferior debugger'.
28204  (is there one?)
28205 \end_layout
28206
28207 \begin_layout Itemize
28208 use an on target hardware debugger.
28209  Some of the more modern MCUs include hardware support for setting break
28210  points and monitoring/changing variables by using dedicated hardware pins.
28211  This facility doesn't require additional code to run on the target and
28212  
28213 \emph on
28214 usually
28215 \emph default
28216  doesn't affect runtime behaviour until a breakpoint is hit.
28217  For the mcs51 most hardware debuggers use the AOMF
28218 \begin_inset LatexCommand \index{AOMF, AOMF51}
28219
28220 \end_inset
28221
28222  file (see 
28223 \begin_inset LatexCommand \ref{OMF file}
28224
28225 \end_inset
28226
28227 ) as input file.
28228  
28229 \end_layout
28230
28231 \begin_layout Standard
28232 Last not least:
28233 \end_layout
28234
28235 \begin_layout Itemize
28236 if you are not familiar with any of the following terms you're likely to
28237  run into problems rather sooner than later: 
28238 \emph on
28239 volatile
28240 \emph default
28241
28242 \emph on
28243 atomic
28244 \emph default
28245
28246 \emph on
28247 memory map
28248 \emph default
28249
28250 \emph on
28251 overlay
28252 \emph default
28253 .
28254  As an embedded programmer you 
28255 \emph on
28256 have
28257 \emph default
28258  to know them so why not look them up 
28259 \emph on
28260 before
28261 \emph default
28262  you have problems?)
28263 \end_layout
28264
28265 \begin_layout Itemize
28266 tell someone else about your problem (actually this is a surprisingly effective
28267  means to hunt down the bug even if the listener is not familiar with your
28268  environment).
28269  As 'failure to communicate' is probably one of the job-induced deformations
28270  of an embedded programmer this is highly encouraged.
28271 \end_layout
28272
28273 \begin_layout Section
28274 Debugging with SDCDB
28275 \begin_inset LatexCommand \label{cha:Debugging-with-SDCDB}
28276
28277 \end_inset
28278
28279
28280 \begin_inset LatexCommand \index{SDCDB (debugger)}
28281
28282 \end_inset
28283
28284  
28285 \end_layout
28286
28287 \begin_layout Standard
28288 SDCC is distributed with a source level debugger
28289 \begin_inset LatexCommand \index{Debugger}
28290
28291 \end_inset
28292
28293 .
28294  The debugger uses a command line interface, the command repertoire of the
28295  debugger has been kept as close to gdb
28296 \begin_inset LatexCommand \index{gdb}
28297
28298 \end_inset
28299
28300  (the GNU debugger) as possible.
28301  The configuration and build process is part of the standard compiler installati
28302 on, which also builds and installs the debugger in the target directory
28303  specified during configuration.
28304  The debugger allows you debug BOTH at the C source and at the ASM source
28305  level.
28306 \end_layout
28307
28308 \begin_layout Subsection
28309 Compiling for Debugging
28310 \end_layout
28311
28312 \begin_layout Standard
28313 The -
28314 \begin_inset ERT
28315 status collapsed
28316
28317 \begin_layout Standard
28318
28319
28320 \backslash
28321 /
28322 \end_layout
28323
28324 \end_inset
28325
28326 -debug
28327 \begin_inset LatexCommand \index{-\\/-debug}
28328
28329 \end_inset
28330
28331  option must be specified for all files for which debug information is to
28332  be generated.
28333  The compiler generates a .adb file for each of these files.
28334  The linker creates the .cdb
28335 \begin_inset LatexCommand \index{<file>.cdb}
28336
28337 \end_inset
28338
28339  file from the .adb
28340 \begin_inset LatexCommand \index{<file>.adb}
28341
28342 \end_inset
28343
28344  files and the address information.
28345  This .cdb is used by the debugger.
28346 \end_layout
28347
28348 \begin_layout Subsection
28349 How the Debugger Works
28350 \end_layout
28351
28352 \begin_layout Standard
28353 When the -
28354 \begin_inset ERT
28355 status collapsed
28356
28357 \begin_layout Standard
28358
28359
28360 \backslash
28361 /
28362 \end_layout
28363
28364 \end_inset
28365
28366 -debug option is specified the compiler generates extra symbol information
28367  some of which are put into the assembler source and some are put into the
28368  .adb file.
28369  Then the linker creates the .cdb file from the individual .adb files with
28370  the address information for the symbols.
28371  The debugger reads the symbolic information generated by the compiler &
28372  the address information generated by the linker.
28373  It uses the SIMULATOR (Daniel's S51) to execute the program, the program
28374  execution is controlled by the debugger.
28375  When a command is issued for the debugger, it translates it into appropriate
28376  commands for the simulator.
28377  (Currently SDCDM only connects to the simulator but 
28378 \emph on
28379 newcdb
28380 \emph default
28381  at 
28382 \begin_inset LatexCommand \url{http://ec2drv.sf.net/}
28383
28384 \end_inset
28385
28386  is an effort to connect directly to the hardware.) 
28387 \end_layout
28388
28389 \begin_layout Subsection
28390 Starting the Debugger SDCDB
28391 \end_layout
28392
28393 \begin_layout Standard
28394 The debugger can be started using the following command line.
28395  (Assume the file you are debugging has the file name foo).
28396 \newline
28397
28398 \newline
28399
28400 \family sans
28401 \series bold
28402 sdcdb foo
28403 \newline
28404
28405 \family default
28406 \series default
28407
28408 \newline
28409 The debugger will look for the following files.
28410 \end_layout
28411
28412 \begin_layout Itemize
28413 foo.c - the source file.
28414 \end_layout
28415
28416 \begin_layout Itemize
28417 foo.cdb - the debugger symbol information file.
28418 \end_layout
28419
28420 \begin_layout Itemize
28421 foo.ihx - the Intel hex format
28422 \begin_inset LatexCommand \index{Intel hex format}
28423
28424 \end_inset
28425
28426  object file.
28427 \end_layout
28428
28429 \begin_layout Subsection
28430 SDCDB Command Line Options
28431 \end_layout
28432
28433 \begin_layout Itemize
28434 -
28435 \begin_inset ERT
28436 status collapsed
28437
28438 \begin_layout Standard
28439
28440
28441 \backslash
28442 /
28443 \end_layout
28444
28445 \end_inset
28446
28447 -directory=<source file directory> this option can used to specify the directory
28448  search list.
28449  The debugger will look into the directory list specified for source, cdb
28450  & ihx files.
28451  The items in the directory list must be separated by ':', e.g.
28452  if the source files can be in the directories /home/src1 and /home/src2,
28453  the -
28454 \begin_inset ERT
28455 status collapsed
28456
28457 \begin_layout Standard
28458
28459
28460 \backslash
28461 /
28462 \end_layout
28463
28464 \end_inset
28465
28466 -directory option should be -
28467 \begin_inset ERT
28468 status collapsed
28469
28470 \begin_layout Standard
28471
28472
28473 \backslash
28474 /
28475 \end_layout
28476
28477 \end_inset
28478
28479 -directory=/home/src1:/home/src2.
28480  Note there can be no spaces in the option.
28481  
28482 \end_layout
28483
28484 \begin_layout Itemize
28485 -cd <directory> - change to the <directory>.
28486 \end_layout
28487
28488 \begin_layout Itemize
28489 -fullname - used by GUI front ends.
28490 \end_layout
28491
28492 \begin_layout Itemize
28493 -cpu <cpu-type> - this argument is passed to the simulator please see the
28494  simulator docs for details.
28495 \end_layout
28496
28497 \begin_layout Itemize
28498 -X <Clock frequency > this options is passed to the simulator please see
28499  the simulator docs for details.
28500 \end_layout
28501
28502 \begin_layout Itemize
28503 -s <serial port file> passed to simulator see the simulator docs for details.
28504 \end_layout
28505
28506 \begin_layout Itemize
28507 -S <serial in,out> passed to simulator see the simulator docs for details.
28508 \end_layout
28509
28510 \begin_layout Itemize
28511 -k <port number> passed to simulator see the simulator docs for details.
28512 \end_layout
28513
28514 \begin_layout Subsection
28515 SDCDB Debugger Commands
28516 \end_layout
28517
28518 \begin_layout Standard
28519 As mentioned earlier the command interface for the debugger has been deliberatel
28520 y kept as close the GNU debugger gdb, as possible.
28521  This will help the integration with existing graphical user interfaces
28522  (like ddd, xxgdb or xemacs) existing for the GNU debugger.
28523  If you use a graphical user interface for the debugger you can skip this
28524  section.
28525 \end_layout
28526
28527 \begin_layout Subsubsection*
28528 break [line | file:line | function | file:function]
28529 \end_layout
28530
28531 \begin_layout Standard
28532 Set breakpoint at specified line or function:
28533 \newline
28534
28535 \newline
28536
28537 \family sans
28538 \series bold
28539 sdcdb>break 100 
28540 \newline
28541 sdcdb>break foo.c:100
28542 \newline
28543 sdcdb>break funcfoo
28544 \newline
28545 sdcdb>break foo.c:funcfoo
28546 \end_layout
28547
28548 \begin_layout Subsubsection*
28549 clear [line | file:line | function | file:function ]
28550 \end_layout
28551
28552 \begin_layout Standard
28553 Clear breakpoint at specified line or function:
28554 \newline
28555
28556 \newline
28557
28558 \family sans
28559 \series bold
28560 sdcdb>clear 100
28561 \newline
28562 sdcdb>clear foo.c:100
28563 \newline
28564 sdcdb>clear funcfoo
28565 \newline
28566 sdcdb>clear foo.c:funcfoo
28567 \end_layout
28568
28569 \begin_layout Subsubsection*
28570 continue
28571 \end_layout
28572
28573 \begin_layout Standard
28574 Continue program being debugged, after breakpoint.
28575 \end_layout
28576
28577 \begin_layout Subsubsection*
28578 finish
28579 \end_layout
28580
28581 \begin_layout Standard
28582 Execute till the end of the current function.
28583 \end_layout
28584
28585 \begin_layout Subsubsection*
28586 delete [n]
28587 \end_layout
28588
28589 \begin_layout Standard
28590 Delete breakpoint number 'n'.
28591  If used without any option clear ALL user defined break points.
28592 \end_layout
28593
28594 \begin_layout Subsubsection*
28595 info [break | stack | frame | registers ]
28596 \end_layout
28597
28598 \begin_layout Itemize
28599 info break - list all breakpoints
28600 \end_layout
28601
28602 \begin_layout Itemize
28603 info stack - show the function call stack.
28604 \end_layout
28605
28606 \begin_layout Itemize
28607 info frame - show information about the current execution frame.
28608 \end_layout
28609
28610 \begin_layout Itemize
28611 info registers - show content of all registers.
28612 \end_layout
28613
28614 \begin_layout Subsubsection*
28615 step
28616 \end_layout
28617
28618 \begin_layout Standard
28619 Step program until it reaches a different source line.
28620  Note: pressing <return> repeats the last command.
28621 \end_layout
28622
28623 \begin_layout Subsubsection*
28624 next
28625 \end_layout
28626
28627 \begin_layout Standard
28628 Step program, proceeding through subroutine calls.
28629 \end_layout
28630
28631 \begin_layout Subsubsection*
28632 run
28633 \end_layout
28634
28635 \begin_layout Standard
28636 Start debugged program.
28637 \end_layout
28638
28639 \begin_layout Subsubsection*
28640 ptype variable 
28641 \end_layout
28642
28643 \begin_layout Standard
28644 Print type information of the variable.
28645 \end_layout
28646
28647 \begin_layout Subsubsection*
28648 print variable
28649 \end_layout
28650
28651 \begin_layout Standard
28652 print value of variable.
28653 \end_layout
28654
28655 \begin_layout Subsubsection*
28656 file filename
28657 \end_layout
28658
28659 \begin_layout Standard
28660 load the given file name.
28661  Note this is an alternate method of loading file for debugging.
28662 \end_layout
28663
28664 \begin_layout Subsubsection*
28665 frame
28666 \end_layout
28667
28668 \begin_layout Standard
28669 print information about current frame.
28670 \end_layout
28671
28672 \begin_layout Subsubsection*
28673 set srcmode
28674 \end_layout
28675
28676 \begin_layout Standard
28677 Toggle between C source & assembly source.
28678 \end_layout
28679
28680 \begin_layout Subsubsection*
28681 ! simulator command
28682 \end_layout
28683
28684 \begin_layout Standard
28685 Send the string following '!' to the simulator, the simulator response is
28686  displayed.
28687  Note the debugger does not interpret the command being sent to the simulator,
28688  so if a command like 'go' is sent the debugger can loose its execution
28689  context and may display incorrect values.
28690 \end_layout
28691
28692 \begin_layout Subsubsection*
28693 quit
28694 \end_layout
28695
28696 \begin_layout Standard
28697 "Watch me now.
28698  Iam going Down.
28699  My name is Bobby Brown"
28700 \end_layout
28701
28702 \begin_layout Subsection
28703 Interfacing SDCDB with DDD
28704 \end_layout
28705
28706 \begin_layout Standard
28707 \begin_inset Note Note
28708 status collapsed
28709
28710 \begin_layout Standard
28711 The screenshot was converted from png to eps with: 
28712 \begin_inset Quotes sld
28713 \end_inset
28714
28715 bmeps -c -e8f -p3 ddd_example.png >ddd_example.eps
28716 \begin_inset Quotes srd
28717 \end_inset
28718
28719  which produces a pretty compact eps file which is free from compression
28720  artifacts.
28721 \end_layout
28722
28723 \begin_layout Standard
28724 The screenshot was included in sdccman.lyx cvs version 1.120 but later removed
28725  as this broke the build system on Sourceforge (pdf-file was broken.
28726  pdflatex does not accept eps files).
28727 \end_layout
28728
28729 \end_inset
28730
28731
28732 \end_layout
28733
28734 \begin_layout Standard
28735 The 
28736 \emph on
28737 p
28738 \emph default
28739 ortable 
28740 \emph on
28741 n
28742 \emph default
28743 etwork 
28744 \emph on
28745 g
28746 \emph default
28747 raphics File 
28748 \size footnotesize
28749
28750 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/doc/figures/ddd_example.png}
28751
28752 \end_inset
28753
28754
28755 \size default
28756  shows a screenshot of a debugging session with DDD
28757 \begin_inset LatexCommand \index{DDD (debugger)}
28758
28759 \end_inset
28760
28761  (Unix only) on a simulated 8032.
28762  The debugging session might not run as smoothly as the screenshot suggests.
28763  The debugger allows setting of breakpoints, displaying and changing variables,
28764  single stepping through C and assembler code.
28765  
28766 \newline
28767 The source was compiled with 
28768 \family sans
28769 \series bold
28770
28771 \newline
28772
28773 \newline
28774 sdcc -
28775 \family default
28776 \series default
28777
28778 \begin_inset ERT
28779 status collapsed
28780
28781 \begin_layout Standard
28782
28783
28784 \backslash
28785 /
28786 \end_layout
28787
28788 \end_inset
28789
28790
28791 \family sans
28792 \series bold
28793 -debug ddd_example.c
28794 \family default
28795 \series default
28796  
28797 \family sans
28798 \series bold
28799
28800 \newline
28801
28802 \family default
28803 \series default
28804
28805 \newline
28806 and DDD was invoked with 
28807 \family sans
28808 \series bold
28809
28810 \newline
28811
28812 \newline
28813 ddd -debugger "sdcdb -cpu 8032 ddd_example"
28814 \end_layout
28815
28816 \begin_layout Standard
28817 \begin_inset Note Note
28818 status open
28819
28820 \begin_layout Standard
28821 Check that the double quotes or an apostroph within the command line survive
28822  the LyX tool chain.
28823  Previously the apostrophs got slanted in the PDF output so a cut and paste
28824  did not work.
28825 \end_layout
28826
28827 \end_inset
28828
28829
28830 \end_layout
28831
28832 \begin_layout Subsection
28833 Interfacing SDCDB with XEmacs
28834 \begin_inset LatexCommand \index{XEmacs}
28835
28836 \end_inset
28837
28838
28839 \begin_inset LatexCommand \index{Emacs}
28840
28841 \end_inset
28842
28843
28844 \end_layout
28845
28846 \begin_layout Standard
28847 Two files (in emacs lisp) are provided for the interfacing with XEmacs,
28848  sdcdb.el and sdcdbsrc.el.
28849  These two files can be found in the $(prefix)/bin directory after the installat
28850 ion is complete.
28851  These files need to be loaded into XEmacs for the interface to work.
28852  This can be done at XEmacs startup time by inserting the following into
28853  your '.xemacs' file (which can be found in your HOME directory): 
28854 \newline
28855
28856 \newline
28857
28858 \family typewriter
28859 (load-file sdcdbsrc.el)
28860 \family default
28861  
28862 \newline
28863
28864 \newline
28865 .xemacs is a lisp file so the () around the command is REQUIRED.
28866  The files can also be loaded dynamically while XEmacs is running, set the
28867  environment variable 'EMACSLOADPATH' to the installation bin directory
28868  (<installdir>/bin), then enter the following command ESC-x load-file sdcdbsrc.
28869  To start the interface enter the following command: 
28870 \newline
28871
28872 \newline
28873
28874 \family sans
28875 \series bold
28876 ESC-x sdcdbsrc
28877 \family default
28878 \series default
28879
28880 \newline
28881
28882 \newline
28883 You will prompted to enter the file name to be debugged.
28884  
28885 \newline
28886
28887 \newline
28888 The command line options that are passed to the simulator directly are
28889  bound to default values in the file sdcdbsrc.el.
28890  The variables are listed below, these values maybe changed as required.
28891 \end_layout
28892
28893 \begin_layout Itemize
28894 sdcdbsrc-cpu-type '51
28895 \end_layout
28896
28897 \begin_layout Itemize
28898 sdcdbsrc-frequency '11059200
28899 \end_layout
28900
28901 \begin_layout Itemize
28902 sdcdbsrc-serial nil
28903 \end_layout
28904
28905 \begin_layout Standard
28906 The following is a list of key mapping for the debugger interface.
28907 \end_layout
28908
28909 \begin_layout Standard
28910 \InsetSpace ~
28911
28912 \family typewriter
28913
28914 \newline
28915 ;;\InsetSpace ~
28916 Current Listing :: 
28917 \newline
28918 ;;key\InsetSpace ~
28919 \InsetSpace ~
28920 \InsetSpace ~
28921 \InsetSpace ~
28922 \InsetSpace ~
28923 \InsetSpace ~
28924 \InsetSpace ~
28925 \InsetSpace ~
28926 \InsetSpace ~
28927 \InsetSpace ~
28928 \InsetSpace ~
28929 \InsetSpace ~
28930 \InsetSpace ~
28931 \InsetSpace ~
28932 binding\InsetSpace ~
28933 \InsetSpace ~
28934 \InsetSpace ~
28935 \InsetSpace ~
28936 \InsetSpace ~
28937 \InsetSpace ~
28938 \InsetSpace ~
28939 \InsetSpace ~
28940 \InsetSpace ~
28941 \InsetSpace ~
28942 \InsetSpace ~
28943 \InsetSpace ~
28944 \InsetSpace ~
28945 \InsetSpace ~
28946 \InsetSpace ~
28947 \InsetSpace ~
28948 \InsetSpace ~
28949 \InsetSpace ~
28950 \InsetSpace ~
28951 \InsetSpace ~
28952 \InsetSpace ~
28953 \InsetSpace ~
28954 Comment 
28955 \newline
28956 ;;---\InsetSpace ~
28957 \InsetSpace ~
28958 \InsetSpace ~
28959 \InsetSpace ~
28960 \InsetSpace ~
28961 \InsetSpace ~
28962 \InsetSpace ~
28963 \InsetSpace ~
28964 \InsetSpace ~
28965 \InsetSpace ~
28966 \InsetSpace ~
28967 \InsetSpace ~
28968 \InsetSpace ~
28969 \InsetSpace ~
28970 -------\InsetSpace ~
28971 \InsetSpace ~
28972 \InsetSpace ~
28973 \InsetSpace ~
28974 \InsetSpace ~
28975 \InsetSpace ~
28976 \InsetSpace ~
28977 \InsetSpace ~
28978 \InsetSpace ~
28979 \InsetSpace ~
28980 \InsetSpace ~
28981 \InsetSpace ~
28982 \InsetSpace ~
28983 \InsetSpace ~
28984 \InsetSpace ~
28985 \InsetSpace ~
28986 \InsetSpace ~
28987 \InsetSpace ~
28988 \InsetSpace ~
28989 \InsetSpace ~
28990 \InsetSpace ~
28991 \InsetSpace ~
28992 -------
28993 \newline
28994 ;; 
28995 \newline
28996 ;;\InsetSpace ~
28997 n\InsetSpace ~
28998 \InsetSpace ~
28999 \InsetSpace ~
29000 \InsetSpace ~
29001 \InsetSpace ~
29002 \InsetSpace ~
29003 \InsetSpace ~
29004 \InsetSpace ~
29005 \InsetSpace ~
29006 \InsetSpace ~
29007 \InsetSpace ~
29008 \InsetSpace ~
29009 \InsetSpace ~
29010 \InsetSpace ~
29011 \InsetSpace ~
29012 sdcdb-next-fro
29013 m-src\InsetSpace ~
29014 \InsetSpace ~
29015 \InsetSpace ~
29016 \InsetSpace ~
29017 \InsetSpace ~
29018 \InsetSpace ~
29019 \InsetSpace ~
29020 \InsetSpace ~
29021 \InsetSpace ~
29022 \InsetSpace ~
29023 SDCDB next command 
29024 \newline
29025 ;;\InsetSpace ~
29026 b\InsetSpace ~
29027 \InsetSpace ~
29028 \InsetSpace ~
29029 \InsetSpace ~
29030 \InsetSpace ~
29031 \InsetSpace ~
29032 \InsetSpace ~
29033 \InsetSpace ~
29034 \InsetSpace ~
29035 \InsetSpace ~
29036 \InsetSpace ~
29037 \InsetSpace ~
29038 \InsetSpace ~
29039 \InsetSpace ~
29040 \InsetSpace ~
29041 sdcdb-back-from-src\InsetSpace ~
29042 \InsetSpace ~
29043 \InsetSpace ~
29044 \InsetSpace ~
29045 \InsetSpace ~
29046 \InsetSpace ~
29047 \InsetSpace ~
29048 \InsetSpace ~
29049 \InsetSpace ~
29050 \InsetSpace ~
29051 SDCDB back command 
29052 \newline
29053 ;;\InsetSpace ~
29054 c\InsetSpace ~
29055 \InsetSpace ~
29056 \InsetSpace ~
29057 \InsetSpace ~
29058 \InsetSpace ~
29059 \InsetSpace ~
29060 \InsetSpace ~
29061 \InsetSpace ~
29062 \InsetSpace ~
29063 \InsetSpace ~
29064 \InsetSpace ~
29065 \InsetSpace ~
29066 \InsetSpace ~
29067 \InsetSpace ~
29068 \InsetSpace ~
29069 sdcdb-cont-f
29070 rom-src\InsetSpace ~
29071 \InsetSpace ~
29072 \InsetSpace ~
29073 \InsetSpace ~
29074 \InsetSpace ~
29075 \InsetSpace ~
29076 \InsetSpace ~
29077 \InsetSpace ~
29078 \InsetSpace ~
29079 \InsetSpace ~
29080 SDCDB continue command
29081 \newline
29082 ;;\InsetSpace ~
29083 s\InsetSpace ~
29084 \InsetSpace ~
29085 \InsetSpace ~
29086 \InsetSpace ~
29087 \InsetSpace ~
29088 \InsetSpace ~
29089 \InsetSpace ~
29090 \InsetSpace ~
29091 \InsetSpace ~
29092 \InsetSpace ~
29093 \InsetSpace ~
29094 \InsetSpace ~
29095 \InsetSpace ~
29096 \InsetSpace ~
29097 \InsetSpace ~
29098 sdcdb-step-from-src\InsetSpace ~
29099 \InsetSpace ~
29100 \InsetSpace ~
29101 \InsetSpace ~
29102 \InsetSpace ~
29103 \InsetSpace ~
29104 \InsetSpace ~
29105 \InsetSpace ~
29106 \InsetSpace ~
29107 \InsetSpace ~
29108 SDCDB step command 
29109 \newline
29110 ;;\InsetSpace ~
29111 ?\InsetSpace ~
29112 \InsetSpace ~
29113 \InsetSpace ~
29114 \InsetSpace ~
29115 \InsetSpace ~
29116 \InsetSpace ~
29117 \InsetSpace ~
29118 \InsetSpace ~
29119 \InsetSpace ~
29120 \InsetSpace ~
29121 \InsetSpace ~
29122 \InsetSpace ~
29123 \InsetSpace ~
29124 \InsetSpace ~
29125 \InsetSpace ~
29126 sdcdb-w
29127 hatis-c-sexp\InsetSpace ~
29128 \InsetSpace ~
29129 \InsetSpace ~
29130 \InsetSpace ~
29131 \InsetSpace ~
29132 \InsetSpace ~
29133 \InsetSpace ~
29134 \InsetSpace ~
29135 \InsetSpace ~
29136 \InsetSpace ~
29137 SDCDB ptypecommand for data at 
29138 \newline
29139 ;;\InsetSpace ~
29140 \InsetSpace ~
29141 \InsetSpace ~
29142 \InsetSpace ~
29143 \InsetSpace ~
29144 \InsetSpace ~
29145 \InsetSpace ~
29146 \InsetSpace ~
29147 \InsetSpace ~
29148 \InsetSpace ~
29149 \InsetSpace ~
29150 \InsetSpace ~
29151 \InsetSpace ~
29152 \InsetSpace ~
29153 \InsetSpace ~
29154 \InsetSpace ~
29155 \InsetSpace ~
29156 \InsetSpace ~
29157 \InsetSpace ~
29158 \InsetSpace ~
29159 \InsetSpace ~
29160 \InsetSpace ~
29161 \InsetSpace ~
29162 \InsetSpace ~
29163 \InsetSpace ~
29164 \InsetSpace ~
29165 \InsetSpace ~
29166 \InsetSpace ~
29167 \InsetSpace ~
29168 \InsetSpace ~
29169 \InsetSpace ~
29170 \InsetSpace ~
29171 \InsetSpace ~
29172 \InsetSpace ~
29173 \InsetSpace ~
29174 \InsetSpace ~
29175 \InsetSpace ~
29176 \InsetSpace ~
29177 \InsetSpace ~
29178 \InsetSpace ~
29179 \InsetSpace ~
29180 \InsetSpace ~
29181 \InsetSpace ~
29182 \InsetSpace ~
29183 \InsetSpace ~
29184 \InsetSpace ~
29185 \InsetSpace ~
29186 buffer point 
29187 \newline
29188 ;;\InsetSpace ~
29189 x\InsetSpace ~
29190 \InsetSpace ~
29191 \InsetSpace ~
29192 \InsetSpace ~
29193 \InsetSpace ~
29194 \InsetSpace ~
29195 \InsetSpace ~
29196 \InsetSpace ~
29197 \InsetSpace ~
29198 \InsetSpace ~
29199 \InsetSpace ~
29200 \InsetSpace ~
29201 \InsetSpace ~
29202 \InsetSpace ~
29203 \InsetSpace ~
29204 sdcdbsrc-delete\InsetSpace ~
29205 \InsetSpace ~
29206 \InsetSpace ~
29207 \InsetSpace ~
29208 \InsetSpace ~
29209 \InsetSpace ~
29210 \InsetSpace ~
29211 \InsetSpace ~
29212 \InsetSpace ~
29213 \InsetSpace ~
29214 \InsetSpace ~
29215 \InsetSpace ~
29216 \InsetSpace ~
29217 \InsetSpace ~
29218 SDCD
29219 B Delete all breakpoints if no arg 
29220 \newline
29221 ;;\InsetSpace ~
29222 \InsetSpace ~
29223 \InsetSpace ~
29224 \InsetSpace ~
29225 \InsetSpace ~
29226 \InsetSpace ~
29227 \InsetSpace ~
29228 \InsetSpace ~
29229 \InsetSpace ~
29230 \InsetSpace ~
29231 \InsetSpace ~
29232 \InsetSpace ~
29233 \InsetSpace ~
29234 \InsetSpace ~
29235 \InsetSpace ~
29236 \InsetSpace ~
29237 \InsetSpace ~
29238 \InsetSpace ~
29239 \InsetSpace ~
29240 \InsetSpace ~
29241 \InsetSpace ~
29242 \InsetSpace ~
29243 \InsetSpace ~
29244 \InsetSpace ~
29245 \InsetSpace ~
29246 \InsetSpace ~
29247 \InsetSpace ~
29248 \InsetSpace ~
29249 \InsetSpace ~
29250 \InsetSpace ~
29251 \InsetSpace ~
29252 \InsetSpace ~
29253 \InsetSpace ~
29254 \InsetSpace ~
29255 \InsetSpace ~
29256 \InsetSpace ~
29257 \InsetSpace ~
29258 \InsetSpace ~
29259 \InsetSpace ~
29260 \InsetSpace ~
29261 \InsetSpace ~
29262 \InsetSpace ~
29263 \InsetSpace ~
29264 \InsetSpace ~
29265 \InsetSpace ~
29266 \InsetSpace ~
29267 \InsetSpace ~
29268 given or delete arg (C-u arg x) 
29269 \newline
29270 ;;\InsetSpace ~
29271 m\InsetSpace ~
29272 \InsetSpace ~
29273 \InsetSpace ~
29274 \InsetSpace ~
29275 \InsetSpace ~
29276 \InsetSpace ~
29277 \InsetSpace ~
29278 \InsetSpace ~
29279 \InsetSpace ~
29280 \InsetSpace ~
29281 \InsetSpace ~
29282 \InsetSpace ~
29283 \InsetSpace ~
29284 \InsetSpace ~
29285 \InsetSpace ~
29286 sdcdbsrc
29287 -frame\InsetSpace ~
29288 \InsetSpace ~
29289 \InsetSpace ~
29290 \InsetSpace ~
29291 \InsetSpace ~
29292 \InsetSpace ~
29293 \InsetSpace ~
29294 \InsetSpace ~
29295 \InsetSpace ~
29296 \InsetSpace ~
29297 \InsetSpace ~
29298 \InsetSpace ~
29299 \InsetSpace ~
29300 \InsetSpace ~
29301 \InsetSpace ~
29302 SDCDB Display current frame if no arg, 
29303 \newline
29304 ;;\InsetSpace ~
29305 \InsetSpace ~
29306 \InsetSpace ~
29307 \InsetSpace ~
29308 \InsetSpace ~
29309 \InsetSpace ~
29310 \InsetSpace ~
29311 \InsetSpace ~
29312 \InsetSpace ~
29313 \InsetSpace ~
29314 \InsetSpace ~
29315 \InsetSpace ~
29316 \InsetSpace ~
29317 \InsetSpace ~
29318 \InsetSpace ~
29319 \InsetSpace ~
29320 \InsetSpace ~
29321 \InsetSpace ~
29322 \InsetSpace ~
29323 \InsetSpace ~
29324 \InsetSpace ~
29325 \InsetSpace ~
29326 \InsetSpace ~
29327 \InsetSpace ~
29328 \InsetSpace ~
29329 \InsetSpace ~
29330 \InsetSpace ~
29331 \InsetSpace ~
29332 \InsetSpace ~
29333 \InsetSpace ~
29334 \InsetSpace ~
29335 \InsetSpace ~
29336 \InsetSpace ~
29337 \InsetSpace ~
29338 \InsetSpace ~
29339 \InsetSpace ~
29340 \InsetSpace ~
29341 \InsetSpace ~
29342 \InsetSpace ~
29343 \InsetSpace ~
29344 \InsetSpace ~
29345 \InsetSpace ~
29346 \InsetSpace ~
29347 \InsetSpace ~
29348 \InsetSpace ~
29349 \InsetSpace ~
29350 \InsetSpace ~
29351 given or display frame arg
29352  
29353 \newline
29354 ;;\InsetSpace ~
29355 \InsetSpace ~
29356 \InsetSpace ~
29357 \InsetSpace ~
29358 \InsetSpace ~
29359 \InsetSpace ~
29360 \InsetSpace ~
29361 \InsetSpace ~
29362 \InsetSpace ~
29363 \InsetSpace ~
29364 \InsetSpace ~
29365 \InsetSpace ~
29366 \InsetSpace ~
29367 \InsetSpace ~
29368 \InsetSpace ~
29369 \InsetSpace ~
29370 \InsetSpace ~
29371 \InsetSpace ~
29372 \InsetSpace ~
29373 \InsetSpace ~
29374 \InsetSpace ~
29375 \InsetSpace ~
29376 \InsetSpace ~
29377 \InsetSpace ~
29378 \InsetSpace ~
29379 \InsetSpace ~
29380 \InsetSpace ~
29381 \InsetSpace ~
29382 \InsetSpace ~
29383 \InsetSpace ~
29384 \InsetSpace ~
29385 \InsetSpace ~
29386 \InsetSpace ~
29387 \InsetSpace ~
29388 \InsetSpace ~
29389 \InsetSpace ~
29390 \InsetSpace ~
29391 \InsetSpace ~
29392 \InsetSpace ~
29393 \InsetSpace ~
29394 \InsetSpace ~
29395 \InsetSpace ~
29396 \InsetSpace ~
29397 \InsetSpace ~
29398 \InsetSpace ~
29399 \InsetSpace ~
29400 \InsetSpace ~
29401 buffer point 
29402 \newline
29403 ;;\InsetSpace ~
29404 !\InsetSpace ~
29405 \InsetSpace ~
29406 \InsetSpace ~
29407 \InsetSpace ~
29408 \InsetSpace ~
29409 \InsetSpace ~
29410 \InsetSpace ~
29411 \InsetSpace ~
29412 \InsetSpace ~
29413 \InsetSpace ~
29414 \InsetSpace ~
29415 \InsetSpace ~
29416 \InsetSpace ~
29417 \InsetSpace ~
29418 \InsetSpace ~
29419 sdcdbsrc-goto-sdcdb\InsetSpace ~
29420 \InsetSpace ~
29421 \InsetSpace ~
29422 \InsetSpace ~
29423 \InsetSpace ~
29424 \InsetSpace ~
29425 \InsetSpace ~
29426 \InsetSpace ~
29427 \InsetSpace ~
29428 \InsetSpace ~
29429 Goto the SDCDB output buffer 
29430 \newline
29431 ;;\InsetSpace ~
29432 p\InsetSpace ~
29433 \InsetSpace ~
29434 \InsetSpace ~
29435 \InsetSpace ~
29436 \InsetSpace ~
29437 \InsetSpace ~
29438 \InsetSpace ~
29439 \InsetSpace ~
29440 \InsetSpace ~
29441 \InsetSpace ~
29442 \InsetSpace ~
29443 \InsetSpace ~
29444 \InsetSpace ~
29445 \InsetSpace ~
29446 \InsetSpace ~
29447 sdcdb-prin
29448 t-c-sexp\InsetSpace ~
29449 \InsetSpace ~
29450 \InsetSpace ~
29451 \InsetSpace ~
29452 \InsetSpace ~
29453 \InsetSpace ~
29454 \InsetSpace ~
29455 \InsetSpace ~
29456 \InsetSpace ~
29457 \InsetSpace ~
29458 \InsetSpace ~
29459 SDCDB print command for data at 
29460 \newline
29461 ;;\InsetSpace ~
29462 \InsetSpace ~
29463 \InsetSpace ~
29464 \InsetSpace ~
29465 \InsetSpace ~
29466 \InsetSpace ~
29467 \InsetSpace ~
29468 \InsetSpace ~
29469 \InsetSpace ~
29470 \InsetSpace ~
29471 \InsetSpace ~
29472 \InsetSpace ~
29473 \InsetSpace ~
29474 \InsetSpace ~
29475 \InsetSpace ~
29476 \InsetSpace ~
29477 \InsetSpace ~
29478 \InsetSpace ~
29479 \InsetSpace ~
29480 \InsetSpace ~
29481 \InsetSpace ~
29482 \InsetSpace ~
29483 \InsetSpace ~
29484 \InsetSpace ~
29485 \InsetSpace ~
29486 \InsetSpace ~
29487 \InsetSpace ~
29488 \InsetSpace ~
29489 \InsetSpace ~
29490 \InsetSpace ~
29491 \InsetSpace ~
29492 \InsetSpace ~
29493 \InsetSpace ~
29494 \InsetSpace ~
29495 \InsetSpace ~
29496 \InsetSpace ~
29497 \InsetSpace ~
29498 \InsetSpace ~
29499 \InsetSpace ~
29500 \InsetSpace ~
29501 \InsetSpace ~
29502 \InsetSpace ~
29503 \InsetSpace ~
29504 \InsetSpace ~
29505 \InsetSpace ~
29506 \InsetSpace ~
29507 \InsetSpace ~
29508 buffer point 
29509 \newline
29510 ;;\InsetSpace ~
29511 g\InsetSpace ~
29512 \InsetSpace ~
29513 \InsetSpace ~
29514 \InsetSpace ~
29515 \InsetSpace ~
29516 \InsetSpace ~
29517 \InsetSpace ~
29518 \InsetSpace ~
29519 \InsetSpace ~
29520 \InsetSpace ~
29521 \InsetSpace ~
29522 \InsetSpace ~
29523 \InsetSpace ~
29524 \InsetSpace ~
29525 \InsetSpace ~
29526 sdcdbsrc-goto-sdcdb\InsetSpace ~
29527 \InsetSpace ~
29528 \InsetSpace ~
29529 \InsetSpace ~
29530 \InsetSpace ~
29531 \InsetSpace ~
29532 \InsetSpace ~
29533 \InsetSpace ~
29534 \InsetSpace ~
29535 \InsetSpace ~
29536 Got
29537 o the SDCDB output buffer 
29538 \newline
29539 ;;\InsetSpace ~
29540 t\InsetSpace ~
29541 \InsetSpace ~
29542 \InsetSpace ~
29543 \InsetSpace ~
29544 \InsetSpace ~
29545 \InsetSpace ~
29546 \InsetSpace ~
29547 \InsetSpace ~
29548 \InsetSpace ~
29549 \InsetSpace ~
29550 \InsetSpace ~
29551 \InsetSpace ~
29552 \InsetSpace ~
29553 \InsetSpace ~
29554 \InsetSpace ~
29555 sdcdbsrc-mode\InsetSpace ~
29556 \InsetSpace ~
29557 \InsetSpace ~
29558 \InsetSpace ~
29559 \InsetSpace ~
29560 \InsetSpace ~
29561 \InsetSpace ~
29562 \InsetSpace ~
29563 \InsetSpace ~
29564 \InsetSpace ~
29565 \InsetSpace ~
29566 \InsetSpace ~
29567 \InsetSpace ~
29568 \InsetSpace ~
29569 \InsetSpace ~
29570 \InsetSpace ~
29571 Toggles Sdcdbsrc mode (turns it
29572  off) 
29573 \newline
29574 ;; 
29575 \newline
29576 ;;\InsetSpace ~
29577 C-c\InsetSpace ~
29578 C-f\InsetSpace ~
29579 \InsetSpace ~
29580 \InsetSpace ~
29581 \InsetSpace ~
29582 \InsetSpace ~
29583 \InsetSpace ~
29584 \InsetSpace ~
29585 \InsetSpace ~
29586 \InsetSpace ~
29587 sdcdb-finish-from-src\InsetSpace ~
29588 \InsetSpace ~
29589 \InsetSpace ~
29590 \InsetSpace ~
29591 \InsetSpace ~
29592 \InsetSpace ~
29593 \InsetSpace ~
29594 \InsetSpace ~
29595 SDCDB finish command 
29596 \newline
29597 ;; 
29598 \newline
29599 ;;\InsetSpace ~
29600 C-x\InsetSpace ~
29601 SPC\InsetSpace ~
29602 \InsetSpace ~
29603 \InsetSpace ~
29604 \InsetSpace ~
29605 \InsetSpace ~
29606 \InsetSpace ~
29607 \InsetSpace ~
29608 \InsetSpace ~
29609 \InsetSpace ~
29610 sdcdb-brea
29611 k\InsetSpace ~
29612 \InsetSpace ~
29613 \InsetSpace ~
29614 \InsetSpace ~
29615 \InsetSpace ~
29616 \InsetSpace ~
29617 \InsetSpace ~
29618 \InsetSpace ~
29619 \InsetSpace ~
29620 \InsetSpace ~
29621 \InsetSpace ~
29622 \InsetSpace ~
29623 \InsetSpace ~
29624 \InsetSpace ~
29625 \InsetSpace ~
29626 \InsetSpace ~
29627 \InsetSpace ~
29628 \InsetSpace ~
29629 Set break for line with point 
29630 \newline
29631 ;;\InsetSpace ~
29632 ESC\InsetSpace ~
29633 t\InsetSpace ~
29634 \InsetSpace ~
29635 \InsetSpace ~
29636 \InsetSpace ~
29637 \InsetSpace ~
29638 \InsetSpace ~
29639 \InsetSpace ~
29640 \InsetSpace ~
29641 \InsetSpace ~
29642 \InsetSpace ~
29643 \InsetSpace ~
29644 sdcdbsrc-mode\InsetSpace ~
29645 \InsetSpace ~
29646 \InsetSpace ~
29647 \InsetSpace ~
29648 \InsetSpace ~
29649 \InsetSpace ~
29650 \InsetSpace ~
29651 \InsetSpace ~
29652 \InsetSpace ~
29653 \InsetSpace ~
29654 \InsetSpace ~
29655 \InsetSpace ~
29656 \InsetSpace ~
29657 \InsetSpace ~
29658 \InsetSpace ~
29659 \InsetSpace ~
29660 Toggle Sdcdbsrc mode 
29661 \newline
29662 ;;\InsetSpace ~
29663 ESC\InsetSpace ~
29664 m\InsetSpace ~
29665 \InsetSpace ~
29666 \InsetSpace ~
29667 \InsetSpace ~
29668 \InsetSpace ~
29669 \InsetSpace ~
29670 \InsetSpace ~
29671 \InsetSpace ~
29672 \InsetSpace ~
29673 \InsetSpace ~
29674 \InsetSpace ~
29675 sdc
29676 dbsrc-srcmode\InsetSpace ~
29677 \InsetSpace ~
29678 \InsetSpace ~
29679 \InsetSpace ~
29680 \InsetSpace ~
29681 \InsetSpace ~
29682 \InsetSpace ~
29683 \InsetSpace ~
29684 \InsetSpace ~
29685 \InsetSpace ~
29686 \InsetSpace ~
29687 \InsetSpace ~
29688 \InsetSpace ~
29689 Toggle list mode 
29690 \newline
29691 ;; 
29692 \newline
29693
29694 \family default
29695
29696 \newpage
29697
29698 \end_layout
29699
29700 \begin_layout Chapter
29701 TIPS
29702 \end_layout
29703
29704 \begin_layout Standard
29705 Here are a few guidelines that will help the compiler generate more efficient
29706  code, some of the tips are specific to this compiler others are generally
29707  good programming practice.
29708 \end_layout
29709
29710 \begin_layout Itemize
29711 Use the smallest data type to represent your data-value.
29712  If it is known in advance that the value is going to be less than 256 then
29713  use an 'unsigned char' instead of a 'short' or 'int'.
29714  Please note, that ANSI C requires both signed and unsigned chars to be
29715  promoted to 'signed int'
29716 \begin_inset LatexCommand \index{promotion to signed int}
29717
29718 \end_inset
29719
29720
29721 \begin_inset Marginal
29722 status collapsed
29723
29724 \begin_layout Standard
29725
29726 \series bold
29727 \InsetSpace ~
29728 !
29729 \end_layout
29730
29731 \end_inset
29732
29733  before doing any operation.
29734  This promotion
29735 \begin_inset LatexCommand \index{type promotion}
29736
29737 \end_inset
29738
29739
29740 \begin_inset LatexCommand \label{type promotion}
29741
29742 \end_inset
29743
29744  can be omitted, if the result is the same.
29745  The effect of the promotion rules together with the sign-extension is often
29746  surprising:
29747 \end_layout
29748
29749 \begin_deeper
29750 \begin_layout Verse
29751
29752 \family typewriter
29753 unsigned char uc = 0xfe;
29754 \newline
29755 if (uc * uc < 0) /* this is true! */
29756 \newline
29757 {
29758 \newline
29759 \InsetSpace ~
29760 \InsetSpace ~
29761 \InsetSpace ~
29762 \InsetSpace ~
29763 ....
29764 \newline
29765 }
29766 \end_layout
29767
29768 \begin_layout Standard
29769
29770 \family typewriter
29771 uc * uc
29772 \family default
29773  is evaluated as 
29774 \family typewriter
29775 (int) uc * (int) uc = (int) 0xfe * (int) 0xfe = (int) 0xfc04 = -1024
29776 \family default
29777 .
29778  
29779 \newline
29780 Another one:
29781 \end_layout
29782
29783 \begin_layout Verse
29784
29785 \family typewriter
29786 (unsigned char) -12 / (signed char) -3 = ...
29787 \end_layout
29788
29789 \begin_layout Standard
29790 No, the result is not 4:
29791 \end_layout
29792
29793 \begin_layout Verse
29794
29795 \family typewriter
29796 (int) (unsigned char) -12 / (int) (signed char) -3 =
29797 \newline
29798 (int) (unsigned char)
29799  0xf4 / (int) (signed char) 0xfd =
29800 \newline
29801 (int) 0x00f4 / (int) 0xfffd =
29802 \newline
29803 (int) 0x00f4
29804  / (int) 0xfffd =
29805 \newline
29806 (int) 244 / (int) -3 =
29807 \newline
29808 (int) -81 = (int) 0xffaf;
29809 \end_layout
29810
29811 \begin_layout Standard
29812 Don't complain, that gcc gives you a different result.
29813  gcc uses 32 bit ints, while SDCC uses 16 bit ints.
29814  Therefore the results are different.
29815 \newline
29816 From 
29817 \begin_inset Quotes sld
29818 \end_inset
29819
29820 comp.lang.c FAQ
29821 \begin_inset Quotes srd
29822 \end_inset
29823
29824 :
29825 \end_layout
29826
29827 \begin_layout Quote
29828
29829 \emph on
29830 If well-defined overflow characteristics are important and negative values
29831  are not, or if you want to steer clear of sign-extension problems when
29832  manipulating bits or bytes, use one of the corresponding unsigned types.
29833  (Beware when mixing signed and unsigned values in expressions, though.)
29834 \newline
29835 Although
29836  character types (especially unsigned char) can be used as "tiny" integers,
29837  doing so is sometimes more trouble than it's worth, due to unpredictable
29838  sign extension and increased code size.
29839 \end_layout
29840
29841 \end_deeper
29842 \begin_layout Itemize
29843 Use unsigned when it is known in advance that the value is not going to
29844  be negative.
29845  This helps especially if you are doing division or multiplication, bit-shifting
29846  or are using an array index.
29847 \end_layout
29848
29849 \begin_layout Itemize
29850 NEVER jump into a LOOP.
29851 \end_layout
29852
29853 \begin_layout Itemize
29854 Declare the variables to be local
29855 \begin_inset LatexCommand \index{local variables}
29856
29857 \end_inset
29858
29859  whenever possible, especially loop control variables (induction).
29860 \end_layout
29861
29862 \begin_layout Itemize
29863 Have a look at the assembly listing to get a 
29864 \begin_inset Quotes sld
29865 \end_inset
29866
29867 feeling
29868 \begin_inset Quotes srd
29869 \end_inset
29870
29871  for the code generation.
29872 \end_layout
29873
29874 \begin_layout Section
29875 Porting code from or to other compilers
29876 \begin_inset LatexCommand \label{sec:Porting-code-to-other-compilers}
29877
29878 \end_inset
29879
29880
29881 \end_layout
29882
29883 \begin_layout Itemize
29884 check whether endianness of the compilers differs and adapt where needed.
29885 \end_layout
29886
29887 \begin_layout Itemize
29888 check the device specific header files
29889 \begin_inset LatexCommand \index{Header files}
29890
29891 \end_inset
29892
29893
29894 \begin_inset LatexCommand \index{Include files}
29895
29896 \end_inset
29897
29898  for compiler specific syntax.
29899  Eventually include the file <compiler.h
29900 \begin_inset LatexCommand \index{compiler.h (include file)}
29901
29902 \end_inset
29903
29904
29905 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/device/include/mcs51/compiler.h?view=markup}
29906
29907 \end_inset
29908
29909  to allow using common header files.
29910  (see f.e.
29911  cc2510fx.h 
29912 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/device/include/mcs51/cc2510fx.h?view=markup}
29913
29914 \end_inset
29915
29916 ).
29917 \end_layout
29918
29919 \begin_layout Itemize
29920 check whether the startup code contains the correct initialization (watchdog,
29921  peripherals).
29922 \end_layout
29923
29924 \begin_layout Itemize
29925 check whether the sizes of short, int, long match.
29926 \end_layout
29927
29928 \begin_layout Itemize
29929 check if some 16 or 32 bit hardware registers require a specific addressing
29930  order (least significant or most significant byte first) and adapt if needed
29931  (
29932 \emph on
29933 first
29934 \emph default
29935  and 
29936 \emph on
29937 last
29938 \emph default
29939  relate to time and not to lower/upper memory location here, so this is
29940  
29941 \emph on
29942 not
29943 \emph default
29944  the same as endianness).
29945 \end_layout
29946
29947 \begin_layout Itemize
29948 check whether the keyword 
29949 \emph on
29950 volatile
29951 \emph default
29952  is used where needed.
29953  The compilers might differ in their optimization characteristics (as different
29954  versions of the same compiler might also use more clever optimizations
29955  this is good idea anyway).
29956  See section 
29957 \begin_inset LatexCommand \ref{sub:Common-interrupt-pitfall-volatile}
29958
29959 \end_inset
29960
29961 .
29962 \end_layout
29963
29964 \begin_layout Itemize
29965 check that the compilers are not told to supress warnings.
29966 \end_layout
29967
29968 \begin_layout Itemize
29969 check and convert compiler specific extensions (interrupts, memory areas,
29970  pragmas etc.).
29971 \end_layout
29972
29973 \begin_layout Itemize
29974 check for differences in type promotion.
29975  Especially check for math operations on 
29976 \family typewriter
29977 char
29978 \family default
29979  or 
29980 \family typewriter
29981 unsigned char
29982 \family default
29983  variables.
29984  For the sake of C99 compatibility SDCC will probably promote these to 
29985 \family typewriter
29986 int
29987 \family default
29988  more often than other compilers.
29989  Eventually insert explicit casts to 
29990 \family typewriter
29991 (char)
29992 \family default
29993  or 
29994 \family typewriter
29995 (unsigned char)
29996 \family default
29997 .
29998  Also check that the ~\InsetSpace ~
29999 operator
30000 \begin_inset LatexCommand \index{\\~\\/ Operator}
30001
30002 \end_inset
30003
30004  is not used on 
30005 \family typewriter
30006 bit
30007 \begin_inset LatexCommand \index{bit}
30008
30009 \end_inset
30010
30011
30012 \family default
30013  variables, use the !\InsetSpace ~
30014 operator instead.
30015  See sections 
30016 \begin_inset LatexCommand \ref{type promotion}
30017
30018 \end_inset
30019
30020  and 
30021 \begin_inset LatexCommand \ref{sec:Compatibility-with-previous}
30022
30023 \end_inset
30024
30025 .
30026 \end_layout
30027
30028 \begin_layout Itemize
30029 check the assembly code generated for interrupt routines (f.e.
30030  for calls to possibly non-reentrant library functions).
30031 \end_layout
30032
30033 \begin_layout Itemize
30034 check whether timing loops result in proper timing (or preferably consider
30035  a rewrite of the code with timer based delays instead).
30036 \end_layout
30037
30038 \begin_layout Itemize
30039 check for differences in printf parameters (some compilers push (va_arg
30040 \begin_inset LatexCommand \index{vararg, va\\_arg}
30041
30042 \end_inset
30043
30044 ) char variables as 
30045 \family typewriter
30046 int
30047 \family default
30048  others push them as 
30049 \family typewriter
30050 char
30051 \family default
30052 .
30053  See section 
30054 \begin_inset LatexCommand \ref{sec:Compatibility-with-previous}
30055
30056 \end_inset
30057
30058 ).
30059 \end_layout
30060
30061 \begin_layout Itemize
30062 check the resulting memory map
30063 \begin_inset LatexCommand \index{Memory map}
30064
30065 \end_inset
30066
30067 .
30068  Usage of different memory spaces: code, stack, data (for mcs51/ds390 additional
30069 ly idata, pdata, xdata).
30070  Eventually check if unexpected library functions are included.
30071 \end_layout
30072
30073 \begin_layout Section
30074 Tools
30075 \begin_inset LatexCommand \index{Tools}
30076
30077 \end_inset
30078
30079  included in the distribution
30080 \end_layout
30081
30082 \begin_layout Standard
30083 \align left
30084 \begin_inset Tabular
30085 <lyxtabular version="3" rows="12" columns="3">
30086 <features>
30087 <column alignment="left" valignment="top" leftline="true" width="0pt">
30088 <column alignment="left" valignment="top" leftline="true" width="0pt">
30089 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0pt">
30090 <row topline="true" bottomline="true">
30091 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30092 \begin_inset Text
30093
30094 \begin_layout Standard
30095
30096 \series bold
30097 Name
30098 \end_layout
30099
30100 \end_inset
30101 </cell>
30102 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30103 \begin_inset Text
30104
30105 \begin_layout Standard
30106
30107 \series bold
30108 Purpose
30109 \end_layout
30110
30111 \end_inset
30112 </cell>
30113 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30114 \begin_inset Text
30115
30116 \begin_layout Standard
30117
30118 \series bold
30119 Directory
30120 \end_layout
30121
30122 \end_inset
30123 </cell>
30124 </row>
30125 <row topline="true">
30126 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30127 \begin_inset Text
30128
30129 \begin_layout Standard
30130 uCsim
30131 \begin_inset LatexCommand \index{uCsim}
30132
30133 \end_inset
30134
30135
30136 \end_layout
30137
30138 \end_inset
30139 </cell>
30140 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30141 \begin_inset Text
30142
30143 \begin_layout Standard
30144 Simulator for various architectures
30145 \end_layout
30146
30147 \end_inset
30148 </cell>
30149 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30150 \begin_inset Text
30151
30152 \begin_layout Standard
30153 sdcc/sim/ucsim
30154 \end_layout
30155
30156 \end_inset
30157 </cell>
30158 </row>
30159 <row topline="true">
30160 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30161 \begin_inset Text
30162
30163 \begin_layout Standard
30164 keil2sdcc.pl
30165 \end_layout
30166
30167 \end_inset
30168 </cell>
30169 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30170 \begin_inset Text
30171
30172 \begin_layout Standard
30173 header file
30174 \begin_inset LatexCommand \index{Header files}
30175
30176 \end_inset
30177
30178
30179 \begin_inset LatexCommand \index{Include files}
30180
30181 \end_inset
30182
30183  conversion
30184 \end_layout
30185
30186 \end_inset
30187 </cell>
30188 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30189 \begin_inset Text
30190
30191 \begin_layout Standard
30192 sdcc/support/scripts
30193 \end_layout
30194
30195 \end_inset
30196 </cell>
30197 </row>
30198 <row topline="true">
30199 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30200 \begin_inset Text
30201
30202 \begin_layout Standard
30203 mh2h.c
30204 \end_layout
30205
30206 \end_inset
30207 </cell>
30208 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30209 \begin_inset Text
30210
30211 \begin_layout Standard
30212 header file conversion
30213 \end_layout
30214
30215 \end_inset
30216 </cell>
30217 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30218 \begin_inset Text
30219
30220 \begin_layout Standard
30221 sdcc/support/scripts
30222 \end_layout
30223
30224 \end_inset
30225 </cell>
30226 </row>
30227 <row topline="true">
30228 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30229 \begin_inset Text
30230
30231 \begin_layout Standard
30232 as-gbz80
30233 \end_layout
30234
30235 \end_inset
30236 </cell>
30237 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30238 \begin_inset Text
30239
30240 \begin_layout Standard
30241 Assembler
30242 \end_layout
30243
30244 \end_inset
30245 </cell>
30246 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30247 \begin_inset Text
30248
30249 \begin_layout Standard
30250
30251 \family roman
30252 \series medium
30253 \shape up
30254 \size normal
30255 \emph off
30256 \bar no
30257 \noun off
30258 \color none
30259 sdcc/bin
30260 \end_layout
30261
30262 \end_inset
30263 </cell>
30264 </row>
30265 <row topline="true">
30266 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30267 \begin_inset Text
30268
30269 \begin_layout Standard
30270 as-z80
30271 \end_layout
30272
30273 \end_inset
30274 </cell>
30275 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30276 \begin_inset Text
30277
30278 \begin_layout Standard
30279 Assembler
30280 \end_layout
30281
30282 \end_inset
30283 </cell>
30284 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30285 \begin_inset Text
30286
30287 \begin_layout Standard
30288
30289 \family roman
30290 \series medium
30291 \shape up
30292 \size normal
30293 \emph off
30294 \bar no
30295 \noun off
30296 \color none
30297 sdcc/bin
30298 \end_layout
30299
30300 \end_inset
30301 </cell>
30302 </row>
30303 <row topline="true">
30304 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30305 \begin_inset Text
30306
30307 \begin_layout Standard
30308 asx8051
30309 \end_layout
30310
30311 \end_inset
30312 </cell>
30313 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30314 \begin_inset Text
30315
30316 \begin_layout Standard
30317 Assembler
30318 \end_layout
30319
30320 \end_inset
30321 </cell>
30322 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30323 \begin_inset Text
30324
30325 \begin_layout Standard
30326
30327 \family roman
30328 \series medium
30329 \shape up
30330 \size normal
30331 \emph off
30332 \bar no
30333 \noun off
30334 \color none
30335 sdcc/bin
30336 \end_layout
30337
30338 \end_inset
30339 </cell>
30340 </row>
30341 <row topline="true">
30342 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30343 \begin_inset Text
30344
30345 \begin_layout Standard
30346 SDCDB
30347 \end_layout
30348
30349 \end_inset
30350 </cell>
30351 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30352 \begin_inset Text
30353
30354 \begin_layout Standard
30355 Simulator
30356 \end_layout
30357
30358 \end_inset
30359 </cell>
30360 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30361 \begin_inset Text
30362
30363 \begin_layout Standard
30364
30365 \family roman
30366 \series medium
30367 \shape up
30368 \size normal
30369 \emph off
30370 \bar no
30371 \noun off
30372 \color none
30373 sdcc/bin
30374 \end_layout
30375
30376 \end_inset
30377 </cell>
30378 </row>
30379 <row topline="true">
30380 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30381 \begin_inset Text
30382
30383 \begin_layout Standard
30384 aslink
30385 \end_layout
30386
30387 \end_inset
30388 </cell>
30389 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30390 \begin_inset Text
30391
30392 \begin_layout Standard
30393 Linker
30394 \end_layout
30395
30396 \end_inset
30397 </cell>
30398 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30399 \begin_inset Text
30400
30401 \begin_layout Standard
30402
30403 \family roman
30404 \series medium
30405 \shape up
30406 \size normal
30407 \emph off
30408 \bar no
30409 \noun off
30410 \color none
30411 sdcc/bin
30412 \end_layout
30413
30414 \end_inset
30415 </cell>
30416 </row>
30417 <row topline="true">
30418 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30419 \begin_inset Text
30420
30421 \begin_layout Standard
30422 link-z80
30423 \end_layout
30424
30425 \end_inset
30426 </cell>
30427 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30428 \begin_inset Text
30429
30430 \begin_layout Standard
30431 Linker
30432 \end_layout
30433
30434 \end_inset
30435 </cell>
30436 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30437 \begin_inset Text
30438
30439 \begin_layout Standard
30440
30441 \family roman
30442 \series medium
30443 \shape up
30444 \size normal
30445 \emph off
30446 \bar no
30447 \noun off
30448 \color none
30449 sdcc/bin
30450 \end_layout
30451
30452 \end_inset
30453 </cell>
30454 </row>
30455 <row topline="true">
30456 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30457 \begin_inset Text
30458
30459 \begin_layout Standard
30460 link-gbz80
30461 \end_layout
30462
30463 \end_inset
30464 </cell>
30465 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30466 \begin_inset Text
30467
30468 \begin_layout Standard
30469 Linker
30470 \end_layout
30471
30472 \end_inset
30473 </cell>
30474 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30475 \begin_inset Text
30476
30477 \begin_layout Standard
30478
30479 \family roman
30480 \series medium
30481 \shape up
30482 \size normal
30483 \emph off
30484 \bar no
30485 \noun off
30486 \color none
30487 sdcc/bin
30488 \end_layout
30489
30490 \end_inset
30491 </cell>
30492 </row>
30493 <row topline="true" bottomline="true">
30494 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30495 \begin_inset Text
30496
30497 \begin_layout Standard
30498 packihx
30499 \end_layout
30500
30501 \end_inset
30502 </cell>
30503 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30504 \begin_inset Text
30505
30506 \begin_layout Standard
30507 Intel Hex packer 
30508 \begin_inset LatexCommand \index{packihx (tool)}
30509
30510 \end_inset
30511
30512
30513 \end_layout
30514
30515 \end_inset
30516 </cell>
30517 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30518 \begin_inset Text
30519
30520 \begin_layout Standard
30521
30522 \family roman
30523 \series medium
30524 \shape up
30525 \size normal
30526 \emph off
30527 \bar no
30528 \noun off
30529 \color none
30530 sdcc/bin
30531 \end_layout
30532
30533 \end_inset
30534 </cell>
30535 </row>
30536 </lyxtabular>
30537
30538 \end_inset
30539
30540
30541 \newline
30542
30543 \end_layout
30544
30545 \begin_layout Section
30546 Documentation
30547 \begin_inset LatexCommand \index{Documentation}
30548
30549 \end_inset
30550
30551  included in the distribution
30552 \end_layout
30553
30554 \begin_layout Standard
30555 \align left
30556 \begin_inset Tabular
30557 <lyxtabular version="3" rows="10" columns="2">
30558 <features>
30559 <column alignment="block" valignment="top" leftline="true" width="40col%">
30560 <column alignment="block" valignment="top" leftline="true" rightline="true" width="60col%">
30561 <row topline="true" bottomline="true" endhead="true">
30562 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30563 \begin_inset Text
30564
30565 \begin_layout Standard
30566
30567 \series bold
30568 Subject / Title
30569 \end_layout
30570
30571 \end_inset
30572 </cell>
30573 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30574 \begin_inset Text
30575
30576 \begin_layout Standard
30577
30578 \series bold
30579 Filename / Where to get
30580 \end_layout
30581
30582 \end_inset
30583 </cell>
30584 </row>
30585 <row topline="true">
30586 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30587 \begin_inset Text
30588
30589 \begin_layout Standard
30590 SDCC Compiler User Guide
30591 \end_layout
30592
30593 \end_inset
30594 </cell>
30595 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30596 \begin_inset Text
30597
30598 \begin_layout Standard
30599 You're reading it right now 
30600 \emph on
30601 \InsetSpace ~
30602 \InsetSpace ~
30603 \InsetSpace ~
30604
30605 \hfill
30606 online at:
30607 \emph default
30608
30609 \newline
30610
30611 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/doc/sdccman.pdf}
30612
30613 \end_inset
30614
30615
30616 \end_layout
30617
30618 \end_inset
30619 </cell>
30620 </row>
30621 <row topline="true">
30622 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30623 \begin_inset Text
30624
30625 \begin_layout Standard
30626 Changelog of SDCC
30627 \end_layout
30628
30629 \end_inset
30630 </cell>
30631 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30632 \begin_inset Text
30633
30634 \begin_layout Standard
30635 sdcc/Changelog 
30636 \emph on
30637 \InsetSpace ~
30638 \InsetSpace ~
30639 \InsetSpace ~
30640
30641 \hfill
30642 online at:
30643 \emph default
30644
30645 \newline
30646
30647 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/ChangeLog}
30648
30649 \end_inset
30650
30651
30652 \end_layout
30653
30654 \end_inset
30655 </cell>
30656 </row>
30657 <row topline="true">
30658 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30659 \begin_inset Text
30660
30661 \begin_layout Standard
30662 ASXXXX
30663 \begin_inset LatexCommand \index{asXXXX (as-gbz80, as-hc08, asx8051, as-z80)}
30664
30665 \end_inset
30666
30667
30668 \begin_inset LatexCommand \index{Assembler documentation}
30669
30670 \end_inset
30671
30672  Assemblers and
30673 \newline
30674 ASLINK
30675 \begin_inset LatexCommand \index{aslink}
30676
30677 \end_inset
30678
30679
30680 \begin_inset LatexCommand \index{Linker documentation}
30681
30682 \end_inset
30683
30684  Relocating Linker
30685 \end_layout
30686
30687 \end_inset
30688 </cell>
30689 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30690 \begin_inset Text
30691
30692 \begin_layout Standard
30693 sdcc/as/doc/asxhtm.html 
30694 \emph on
30695 \InsetSpace ~
30696 \InsetSpace ~
30697 \InsetSpace ~
30698
30699 \hfill
30700 online at:
30701 \emph default
30702
30703 \newline
30704
30705 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/as/doc/asxhtm.html}
30706
30707 \end_inset
30708
30709
30710 \end_layout
30711
30712 \end_inset
30713 </cell>
30714 </row>
30715 <row topline="true">
30716 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30717 \begin_inset Text
30718
30719 \begin_layout Standard
30720 SDCC regression test
30721 \begin_inset LatexCommand \index{Regression test}
30722
30723 \end_inset
30724
30725
30726 \end_layout
30727
30728 \end_inset
30729 </cell>
30730 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30731 \begin_inset Text
30732
30733 \begin_layout Standard
30734 sdcc/doc/test_suite_spec.pdf 
30735 \emph on
30736 \InsetSpace ~
30737 \InsetSpace ~
30738 \InsetSpace ~
30739
30740 \hfill
30741 online at:
30742 \emph default
30743
30744 \newline
30745
30746 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/doc/test_suite_spec.pdf}
30747
30748 \end_inset
30749
30750
30751 \end_layout
30752
30753 \end_inset
30754 </cell>
30755 </row>
30756 <row topline="true">
30757 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30758 \begin_inset Text
30759
30760 \begin_layout Standard
30761 Various notes
30762 \end_layout
30763
30764 \end_inset
30765 </cell>
30766 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30767 \begin_inset Text
30768
30769 \begin_layout Standard
30770 sdcc/doc/* 
30771 \emph on
30772 \InsetSpace ~
30773 \InsetSpace ~
30774 \InsetSpace ~
30775
30776 \hfill
30777 online at:
30778 \emph default
30779
30780 \newline
30781
30782 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/doc/}
30783
30784 \end_inset
30785
30786
30787 \end_layout
30788
30789 \end_inset
30790 </cell>
30791 </row>
30792 <row topline="true">
30793 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30794 \begin_inset Text
30795
30796 \begin_layout Standard
30797 Notes on debugging with SDCDB
30798 \begin_inset LatexCommand \index{SDCDB (debugger)}
30799
30800 \end_inset
30801
30802
30803 \end_layout
30804
30805 \end_inset
30806 </cell>
30807 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30808 \begin_inset Text
30809
30810 \begin_layout Standard
30811 sdcc/debugger/README 
30812 \emph on
30813 \InsetSpace ~
30814 \InsetSpace ~
30815 \InsetSpace ~
30816
30817 \hfill
30818 online at
30819 \emph default
30820 :
30821 \newline
30822
30823 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/debugger/README}
30824
30825 \end_inset
30826
30827
30828 \end_layout
30829
30830 \end_inset
30831 </cell>
30832 </row>
30833 <row topline="true">
30834 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30835 \begin_inset Text
30836
30837 \begin_layout Standard
30838 uCsim
30839 \begin_inset LatexCommand \index{uCsim}
30840
30841 \end_inset
30842
30843  Software simulator for microcontrollers
30844 \end_layout
30845
30846 \end_inset
30847 </cell>
30848 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30849 \begin_inset Text
30850
30851 \begin_layout Standard
30852
30853 \family roman
30854 \series medium
30855 \shape up
30856 \size normal
30857 \emph off
30858 \bar no
30859 \noun off
30860 \color none
30861 sdcc/sim/ucsim/doc
30862 \family default
30863 \series default
30864 \shape default
30865 \size default
30866 \emph default
30867 \bar default
30868 \noun default
30869 /index.html 
30870 \emph on
30871 \InsetSpace ~
30872 \InsetSpace ~
30873 \InsetSpace ~
30874
30875 \hfill
30876 online at:
30877 \emph default
30878
30879 \newline
30880
30881 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/sim/ucsim/doc/index.html}
30882
30883 \end_inset
30884
30885
30886 \end_layout
30887
30888 \end_inset
30889 </cell>
30890 </row>
30891 <row topline="true">
30892 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30893 \begin_inset Text
30894
30895 \begin_layout Standard
30896 Temporary notes on the pic16
30897 \begin_inset LatexCommand \index{PIC16}
30898
30899 \end_inset
30900
30901  port
30902 \end_layout
30903
30904 \end_inset
30905 </cell>
30906 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30907 \begin_inset Text
30908
30909 \begin_layout Standard
30910 sdcc/src/pic16/NOTES 
30911 \emph on
30912 \InsetSpace ~
30913 \InsetSpace ~
30914 \InsetSpace ~
30915
30916 \hfill
30917 online at:
30918 \newline
30919
30920 \emph default
30921
30922 \begin_inset LatexCommand \url{http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/src/pic16/NOTES}
30923
30924 \end_inset
30925
30926
30927 \end_layout
30928
30929 \end_inset
30930 </cell>
30931 </row>
30932 <row topline="true" bottomline="true">
30933 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
30934 \begin_inset Text
30935
30936 \begin_layout Standard
30937 SDCC internal documentation (debugging file format)
30938 \end_layout
30939
30940 \end_inset
30941 </cell>
30942 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
30943 \begin_inset Text
30944
30945 \begin_layout Standard
30946 sdcc/doc/
30947 \family roman
30948 \series medium
30949 \shape up
30950 \size normal
30951 \emph off
30952 \bar no
30953 \noun off
30954 \color none
30955 cdbfileformat.pd
30956 \family default
30957 \series default
30958 \shape default
30959 \size default
30960 \emph default
30961 \bar default
30962 \noun default
30963
30964 \emph on
30965 \InsetSpace ~
30966 \InsetSpace ~
30967 \InsetSpace ~
30968
30969 \hfill
30970 online at:
30971 \emph default
30972
30973 \newline
30974
30975 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/doc/cdbfileformat.pdf}
30976
30977 \end_inset
30978
30979
30980 \end_layout
30981
30982 \end_inset
30983 </cell>
30984 </row>
30985 </lyxtabular>
30986
30987 \end_inset
30988
30989
30990 \newline
30991
30992 \end_layout
30993
30994 \begin_layout Section
30995 Related open source tools
30996 \begin_inset LatexCommand \label{sec:Related-open-source-tools}
30997
30998 \end_inset
30999
31000
31001 \begin_inset LatexCommand \index{Related tools}
31002
31003 \end_inset
31004
31005
31006 \end_layout
31007
31008 \begin_layout Standard
31009 \align left
31010 \begin_inset Tabular
31011 <lyxtabular version="3" rows="14" columns="3">
31012 <features>
31013 <column alignment="left" valignment="top" leftline="true" width="0pt">
31014 <column alignment="block" valignment="top" leftline="true" width="30line%">
31015 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0pt">
31016 <row topline="true" bottomline="true">
31017 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31018 \begin_inset Text
31019
31020 \begin_layout Standard
31021
31022 \series bold
31023 Name
31024 \end_layout
31025
31026 \end_inset
31027 </cell>
31028 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31029 \begin_inset Text
31030
31031 \begin_layout Standard
31032
31033 \series bold
31034 Purpose
31035 \end_layout
31036
31037 \end_inset
31038 </cell>
31039 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31040 \begin_inset Text
31041
31042 \begin_layout Standard
31043
31044 \series bold
31045 Where to get
31046 \end_layout
31047
31048 \end_inset
31049 </cell>
31050 </row>
31051 <row topline="true">
31052 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31053 \begin_inset Text
31054
31055 \begin_layout Standard
31056 gpsim
31057 \begin_inset LatexCommand \index{gpsim (pic simulator)}
31058
31059 \end_inset
31060
31061
31062 \end_layout
31063
31064 \end_inset
31065 </cell>
31066 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31067 \begin_inset Text
31068
31069 \begin_layout Standard
31070 PIC simulator
31071 \end_layout
31072
31073 \end_inset
31074 </cell>
31075 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31076 \begin_inset Text
31077
31078 \begin_layout Standard
31079 \begin_inset LatexCommand \url{http://www.dattalo.com/gnupic/gpsim.html}
31080
31081 \end_inset
31082
31083
31084 \end_layout
31085
31086 \end_inset
31087 </cell>
31088 </row>
31089 <row topline="true">
31090 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31091 \begin_inset Text
31092
31093 \begin_layout Standard
31094 gputils
31095 \begin_inset LatexCommand \index{gputils (pic tools)}
31096
31097 \end_inset
31098
31099
31100 \end_layout
31101
31102 \end_inset
31103 </cell>
31104 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31105 \begin_inset Text
31106
31107 \begin_layout Standard
31108 GNU PIC utilities
31109 \end_layout
31110
31111 \end_inset
31112 </cell>
31113 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31114 \begin_inset Text
31115
31116 \begin_layout Standard
31117 \begin_inset LatexCommand \url{http://sourceforge.net/projects/gputils}
31118
31119 \end_inset
31120
31121
31122 \end_layout
31123
31124 \end_inset
31125 </cell>
31126 </row>
31127 <row topline="true">
31128 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31129 \begin_inset Text
31130
31131 \begin_layout Standard
31132 flP5
31133 \end_layout
31134
31135 \end_inset
31136 </cell>
31137 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31138 \begin_inset Text
31139
31140 \begin_layout Standard
31141 PIC programmer
31142 \end_layout
31143
31144 \end_inset
31145 </cell>
31146 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31147 \begin_inset Text
31148
31149 \begin_layout Standard
31150 \begin_inset LatexCommand \url{http://freshmeat.net/projects/flp5/}
31151
31152 \end_inset
31153
31154
31155 \end_layout
31156
31157 \end_inset
31158 </cell>
31159 </row>
31160 <row topline="true">
31161 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31162 \begin_inset Text
31163
31164 \begin_layout Standard
31165 ec2drv/newcdb
31166 \end_layout
31167
31168 \end_inset
31169 </cell>
31170 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31171 \begin_inset Text
31172
31173 \begin_layout Standard
31174 Tools for Silicon Laboratories JTAG debug adapter, partly based on SDCDB
31175  (Unix only)
31176 \end_layout
31177
31178 \end_inset
31179 </cell>
31180 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31181 \begin_inset Text
31182
31183 \begin_layout Standard
31184 \begin_inset LatexCommand \url{http://sourceforge.net/projects/ec2drv}
31185
31186 \end_inset
31187
31188
31189 \end_layout
31190
31191 \end_inset
31192 </cell>
31193 </row>
31194 <row topline="true">
31195 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31196 \begin_inset Text
31197
31198 \begin_layout Standard
31199 indent
31200 \begin_inset LatexCommand \index{indent (source formatting tool)}
31201
31202 \end_inset
31203
31204
31205 \end_layout
31206
31207 \end_inset
31208 </cell>
31209 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31210 \begin_inset Text
31211
31212 \begin_layout Standard
31213 Formats C source - Master of the white spaces
31214 \end_layout
31215
31216 \end_inset
31217 </cell>
31218 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31219 \begin_inset Text
31220
31221 \begin_layout Standard
31222 \begin_inset LatexCommand \url{http://directory.fsf.org/GNU/indent.html}
31223
31224 \end_inset
31225
31226
31227 \end_layout
31228
31229 \end_inset
31230 </cell>
31231 </row>
31232 <row topline="true">
31233 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31234 \begin_inset Text
31235
31236 \begin_layout Standard
31237 srecord
31238 \begin_inset LatexCommand \index{srecord (bin, hex, ... tool)}
31239
31240 \end_inset
31241
31242
31243 \end_layout
31244
31245 \end_inset
31246 </cell>
31247 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31248 \begin_inset Text
31249
31250 \begin_layout Standard
31251 Object file conversion, checksumming, ...
31252 \end_layout
31253
31254 \end_inset
31255 </cell>
31256 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31257 \begin_inset Text
31258
31259 \begin_layout Standard
31260 \begin_inset LatexCommand \url{http://sourceforge.net/projects/srecord}
31261
31262 \end_inset
31263
31264
31265 \end_layout
31266
31267 \end_inset
31268 </cell>
31269 </row>
31270 <row topline="true">
31271 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31272 \begin_inset Text
31273
31274 \begin_layout Standard
31275 objdump
31276 \begin_inset LatexCommand \index{objdump (tool)}
31277
31278 \end_inset
31279
31280
31281 \end_layout
31282
31283 \end_inset
31284 </cell>
31285 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31286 \begin_inset Text
31287
31288 \begin_layout Standard
31289 Object file conversion, ...
31290 \end_layout
31291
31292 \end_inset
31293 </cell>
31294 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31295 \begin_inset Text
31296
31297 \begin_layout Standard
31298 Part of binutils (should be there anyway)
31299 \end_layout
31300
31301 \end_inset
31302 </cell>
31303 </row>
31304 <row topline="true">
31305 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31306 \begin_inset Text
31307
31308 \begin_layout Standard
31309 cmon51
31310 \end_layout
31311
31312 \end_inset
31313 </cell>
31314 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31315 \begin_inset Text
31316
31317 \begin_layout Standard
31318 8051 monitor (hex up-/download, single step, disassemble)
31319 \end_layout
31320
31321 \end_inset
31322 </cell>
31323 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31324 \begin_inset Text
31325
31326 \begin_layout Standard
31327 \begin_inset LatexCommand \url{http://sourceforge.net/projects/cmon51}
31328
31329 \end_inset
31330
31331
31332 \end_layout
31333
31334 \end_inset
31335 </cell>
31336 </row>
31337 <row topline="true">
31338 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31339 \begin_inset Text
31340
31341 \begin_layout Standard
31342 doxygen
31343 \begin_inset LatexCommand \index{doxygen (source documentation tool)}
31344
31345 \end_inset
31346
31347
31348 \end_layout
31349
31350 \end_inset
31351 </cell>
31352 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31353 \begin_inset Text
31354
31355 \begin_layout Standard
31356 Source code documentation system
31357 \end_layout
31358
31359 \end_inset
31360 </cell>
31361 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31362 \begin_inset Text
31363
31364 \begin_layout Standard
31365 \begin_inset LatexCommand \url{http://www.doxygen.org}
31366
31367 \end_inset
31368
31369
31370 \end_layout
31371
31372 \end_inset
31373 </cell>
31374 </row>
31375 <row topline="true">
31376 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31377 \begin_inset Text
31378
31379 \begin_layout Standard
31380 kdevelop
31381 \end_layout
31382
31383 \end_inset
31384 </cell>
31385 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31386 \begin_inset Text
31387
31388 \begin_layout Standard
31389 IDE (has anyone tried integrating SDCC & SDCDB? Unix only)
31390 \end_layout
31391
31392 \end_inset
31393 </cell>
31394 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31395 \begin_inset Text
31396
31397 \begin_layout Standard
31398 \begin_inset LatexCommand \url{http://www.kdevelop.org}
31399
31400 \end_inset
31401
31402
31403 \end_layout
31404
31405 \end_inset
31406 </cell>
31407 </row>
31408 <row topline="true">
31409 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31410 \begin_inset Text
31411
31412 \begin_layout Standard
31413 paulmon
31414 \end_layout
31415
31416 \end_inset
31417 </cell>
31418 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31419 \begin_inset Text
31420
31421 \begin_layout Standard
31422 8051 monitor (hex up-/download, single step, disassemble)
31423 \end_layout
31424
31425 \end_inset
31426 </cell>
31427 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31428 \begin_inset Text
31429
31430 \begin_layout Standard
31431 \begin_inset LatexCommand \url{http://www.pjrc.com/tech/8051/paulmon2.html}
31432
31433 \end_inset
31434
31435
31436 \end_layout
31437
31438 \end_inset
31439 </cell>
31440 </row>
31441 <row topline="true">
31442 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31443 \begin_inset Text
31444
31445 \begin_layout Standard
31446 splint
31447 \begin_inset LatexCommand \index{splint (syntax checking tool)}
31448
31449 \end_inset
31450
31451
31452 \end_layout
31453
31454 \end_inset
31455 </cell>
31456 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31457 \begin_inset Text
31458
31459 \begin_layout Standard
31460 Statically checks c sources (see 
31461 \begin_inset LatexCommand \ref{lyx:more-pedantic-SPLINT}
31462
31463 \end_inset
31464
31465 )
31466 \end_layout
31467
31468 \end_inset
31469 </cell>
31470 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31471 \begin_inset Text
31472
31473 \begin_layout Standard
31474 \begin_inset LatexCommand \url{http://www.splint.org}
31475
31476 \end_inset
31477
31478
31479 \end_layout
31480
31481 \end_inset
31482 </cell>
31483 </row>
31484 <row topline="true" bottomline="true">
31485 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31486 \begin_inset Text
31487
31488 \begin_layout Standard
31489 ddd
31490 \begin_inset LatexCommand \index{DDD (debugger)}
31491
31492 \end_inset
31493
31494
31495 \end_layout
31496
31497 \end_inset
31498 </cell>
31499 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31500 \begin_inset Text
31501
31502 \begin_layout Standard
31503 Debugger, serves nicely as GUI to SDCDB
31504 \begin_inset LatexCommand \index{SDCDB (debugger)}
31505
31506 \end_inset
31507
31508  (Unix only)
31509 \end_layout
31510
31511 \end_inset
31512 </cell>
31513 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31514 \begin_inset Text
31515
31516 \begin_layout Standard
31517 \begin_inset LatexCommand \url{http://www.gnu.org/software/ddd/}
31518
31519 \end_inset
31520
31521
31522 \end_layout
31523
31524 \end_inset
31525 </cell>
31526 </row>
31527 </lyxtabular>
31528
31529 \end_inset
31530
31531
31532 \newline
31533
31534 \end_layout
31535
31536 \begin_layout Section
31537 Related documentation / recommended reading
31538 \end_layout
31539
31540 \begin_layout Standard
31541 \align left
31542 \begin_inset Tabular
31543 <lyxtabular version="3" rows="7" columns="3">
31544 <features>
31545 <column alignment="left" valignment="top" leftline="true" width="0pt">
31546 <column alignment="left" valignment="top" leftline="true" width="0">
31547 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0pt">
31548 <row topline="true" bottomline="true">
31549 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31550 \begin_inset Text
31551
31552 \begin_layout Standard
31553
31554 \series bold
31555 Name
31556 \end_layout
31557
31558 \end_inset
31559 </cell>
31560 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31561 \begin_inset Text
31562
31563 \begin_layout Standard
31564
31565 \series bold
31566 Subject / Title
31567 \end_layout
31568
31569 \end_inset
31570 </cell>
31571 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31572 \begin_inset Text
31573
31574 \begin_layout Standard
31575
31576 \series bold
31577 Where to get
31578 \end_layout
31579
31580 \end_inset
31581 </cell>
31582 </row>
31583 <row topline="true">
31584 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31585 \begin_inset Text
31586
31587 \begin_layout Standard
31588
31589 \family roman
31590 \series medium
31591 \shape up
31592 \size normal
31593 \emph off
31594 \bar no
31595 \noun off
31596 \color none
31597 c-refcard.pdf
31598 \end_layout
31599
31600 \end_inset
31601 </cell>
31602 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31603 \begin_inset Text
31604
31605 \begin_layout Standard
31606 C Reference Card
31607 \begin_inset LatexCommand \index{C Reference card}
31608
31609 \end_inset
31610
31611 , 2 pages
31612 \end_layout
31613
31614 \end_inset
31615 </cell>
31616 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31617 \begin_inset Text
31618
31619 \begin_layout Standard
31620 \begin_inset LatexCommand \url{http://refcards.com/refcards/c/index.html}
31621
31622 \end_inset
31623
31624
31625 \end_layout
31626
31627 \end_inset
31628 </cell>
31629 </row>
31630 <row topline="true">
31631 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31632 \begin_inset Text
31633
31634 \begin_layout Standard
31635 c-faq
31636 \end_layout
31637
31638 \end_inset
31639 </cell>
31640 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31641 \begin_inset Text
31642
31643 \begin_layout Standard
31644 C-FAQ
31645 \begin_inset LatexCommand \index{C FAQ}
31646
31647 \end_inset
31648
31649
31650 \end_layout
31651
31652 \end_inset
31653 </cell>
31654 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31655 \begin_inset Text
31656
31657 \begin_layout Standard
31658 \begin_inset LatexCommand \url{http://www.c-faq.com}
31659
31660 \end_inset
31661
31662
31663 \end_layout
31664
31665 \end_inset
31666 </cell>
31667 </row>
31668 <row topline="true">
31669 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31670 \begin_inset Text
31671
31672 \begin_layout Standard
31673 ISO/IEC 9899:TC2
31674 \end_layout
31675
31676 \end_inset
31677 </cell>
31678 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31679 \begin_inset Text
31680
31681 \begin_layout Standard
31682 \begin_inset Quotes sld
31683 \end_inset
31684
31685 C-Standard
31686 \begin_inset Quotes srd
31687 \end_inset
31688
31689
31690 \end_layout
31691
31692 \end_inset
31693 </cell>
31694 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31695 \begin_inset Text
31696
31697 \begin_layout Standard
31698
31699 \size footnotesize
31700 \begin_inset LatexCommand \url{http://www.open-std.org/jtc1/sc22/wg14/www/standards.html#9899}
31701
31702 \end_inset
31703
31704
31705 \end_layout
31706
31707 \end_inset
31708 </cell>
31709 </row>
31710 <row topline="true">
31711 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31712 \begin_inset Text
31713
31714 \begin_layout Standard
31715 ISO/IEC DTR 18037
31716 \end_layout
31717
31718 \end_inset
31719 </cell>
31720 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31721 \begin_inset Text
31722
31723 \begin_layout Standard
31724 \begin_inset Quotes sld
31725 \end_inset
31726
31727 Extensions for Embedded C
31728 \begin_inset Quotes srd
31729 \end_inset
31730
31731
31732 \end_layout
31733
31734 \end_inset
31735 </cell>
31736 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31737 \begin_inset Text
31738
31739 \begin_layout Standard
31740
31741 \size footnotesize
31742 \begin_inset LatexCommand \url{http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1021.pdf}
31743
31744 \end_inset
31745
31746
31747 \end_layout
31748
31749 \end_inset
31750 </cell>
31751 </row>
31752 <row topline="true">
31753 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31754 \begin_inset Text
31755
31756 \begin_layout Standard
31757
31758 \end_layout
31759
31760 \end_inset
31761 </cell>
31762 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31763 \begin_inset Text
31764
31765 \begin_layout Standard
31766 Latest datasheet of target CPU
31767 \end_layout
31768
31769 \end_inset
31770 </cell>
31771 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31772 \begin_inset Text
31773
31774 \begin_layout Standard
31775 vendor
31776 \end_layout
31777
31778 \end_inset
31779 </cell>
31780 </row>
31781 <row topline="true" bottomline="true">
31782 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31783 \begin_inset Text
31784
31785 \begin_layout Standard
31786
31787 \end_layout
31788
31789 \end_inset
31790 </cell>
31791 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31792 \begin_inset Text
31793
31794 \begin_layout Standard
31795 Revision history of datasheet
31796 \end_layout
31797
31798 \end_inset
31799 </cell>
31800 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31801 \begin_inset Text
31802
31803 \begin_layout Standard
31804 vendor
31805 \end_layout
31806
31807 \end_inset
31808 </cell>
31809 </row>
31810 </lyxtabular>
31811
31812 \end_inset
31813
31814
31815 \newline
31816
31817 \end_layout
31818
31819 \begin_layout Section
31820 Application notes specifically for SDCC
31821 \end_layout
31822
31823 \begin_layout Standard
31824 SDCC makes no claims about the completeness of this list and about up-to-datenes
31825 s or correctness of the application notes
31826 \begin_inset LatexCommand \index{Application notes}
31827
31828 \end_inset
31829
31830 .
31831 \end_layout
31832
31833 \begin_layout Standard
31834 \align left
31835
31836 \size footnotesize
31837 \begin_inset Tabular
31838 <lyxtabular version="3" rows="7" columns="3">
31839 <features>
31840 <column alignment="block" valignment="top" leftline="true" width="17col%">
31841 <column alignment="block" valignment="top" leftline="true" width="27col%">
31842 <column alignment="block" valignment="top" leftline="true" rightline="true" width="57col%">
31843 <row topline="true" bottomline="true">
31844 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31845 \begin_inset Text
31846
31847 \begin_layout Standard
31848
31849 \series bold
31850 \size footnotesize
31851 Vendor
31852 \end_layout
31853
31854 \end_inset
31855 </cell>
31856 <cell alignment="left" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
31857 \begin_inset Text
31858
31859 \begin_layout Standard
31860
31861 \series bold
31862 \size footnotesize
31863 Subject / Title
31864 \end_layout
31865
31866 \end_inset
31867 </cell>
31868 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31869 \begin_inset Text
31870
31871 \begin_layout Standard
31872
31873 \series bold
31874 \size footnotesize
31875 Where to get
31876 \end_layout
31877
31878 \end_inset
31879 </cell>
31880 </row>
31881 <row topline="true">
31882 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31883 \begin_inset Text
31884
31885 \begin_layout Standard
31886
31887 \size footnotesize
31888 Maxim / Dallas
31889 \end_layout
31890
31891 \end_inset
31892 </cell>
31893 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31894 \begin_inset Text
31895
31896 \begin_layout Standard
31897
31898 \size footnotesize
31899 Using the SDCC Compiler for the DS80C400
31900 \begin_inset LatexCommand \index{DS80C400}
31901
31902 \end_inset
31903
31904
31905 \end_layout
31906
31907 \end_inset
31908 </cell>
31909 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31910 \begin_inset Text
31911
31912 \begin_layout Standard
31913
31914 \size footnotesize
31915 \begin_inset LatexCommand \url{http://pdfserv.maxim-ic.com/en/an/AN3346.pdf}
31916
31917 \end_inset
31918
31919
31920 \end_layout
31921
31922 \end_inset
31923 </cell>
31924 </row>
31925 <row topline="true">
31926 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31927 \begin_inset Text
31928
31929 \begin_layout Standard
31930
31931 \size footnotesize
31932 Maxim / Dallas
31933 \end_layout
31934
31935 \end_inset
31936 </cell>
31937 <cell multicolumn="1" alignment="left" valignment="top" topline="true" leftline="true" usebox="none" width="30line%">
31938 \begin_inset Text
31939
31940 \begin_layout Standard
31941
31942 \size footnotesize
31943 Using the Free SDCC C Compiler to Develop Firmware for the DS89C420/430/440/450
31944 \begin_inset LatexCommand \index{DS89C4x0}
31945
31946 \end_inset
31947
31948  Family of Microcontrollers
31949 \end_layout
31950
31951 \end_inset
31952 </cell>
31953 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31954 \begin_inset Text
31955
31956 \begin_layout Standard
31957
31958 \size footnotesize
31959 \begin_inset LatexCommand \url{http://pdfserv.maxim-ic.com/en/an/AN3477.pdf}
31960
31961 \end_inset
31962
31963
31964 \end_layout
31965
31966 \end_inset
31967 </cell>
31968 </row>
31969 <row topline="true">
31970 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31971 \begin_inset Text
31972
31973 \begin_layout Standard
31974
31975 \size footnotesize
31976 Silicon Laboratories / Cygnal
31977 \end_layout
31978
31979 \end_inset
31980 </cell>
31981 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
31982 \begin_inset Text
31983
31984 \begin_layout Standard
31985
31986 \size footnotesize
31987 Integrating SDCC 8051 Tools Into The Silicon Labs IDE
31988 \begin_inset LatexCommand \index{IDE}
31989
31990 \end_inset
31991
31992
31993 \end_layout
31994
31995 \end_inset
31996 </cell>
31997 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
31998 \begin_inset Text
31999
32000 \begin_layout Standard
32001
32002 \size footnotesize
32003 \begin_inset LatexCommand \url{http://www.silabs.com/public/documents/tpub_doc/anote/Microcontrollers/en/an198.pdf}
32004
32005 \end_inset
32006
32007
32008 \end_layout
32009
32010 \end_inset
32011 </cell>
32012 </row>
32013 <row topline="true">
32014 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32015 \begin_inset Text
32016
32017 \begin_layout Standard
32018
32019 \size footnotesize
32020 Ramtron / Goal Semiconductor
32021 \end_layout
32022
32023 \end_inset
32024 </cell>
32025 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32026 \begin_inset Text
32027
32028 \begin_layout Standard
32029
32030 \size footnotesize
32031 Interfacing SDCC to Syn and Textpad
32032 \end_layout
32033
32034 \end_inset
32035 </cell>
32036 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32037 \begin_inset Text
32038
32039 \begin_layout Standard
32040
32041 \size footnotesize
32042 \begin_inset LatexCommand \url{http://www.ramtron.com/doc/Products/Microcontroller/Support_Tools.asp}
32043
32044 \end_inset
32045
32046
32047 \end_layout
32048
32049 \end_inset
32050 </cell>
32051 </row>
32052 <row topline="true">
32053 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32054 \begin_inset Text
32055
32056 \begin_layout Standard
32057
32058 \size footnotesize
32059 Ramtron / Goal Semiconductor
32060 \end_layout
32061
32062 \end_inset
32063 </cell>
32064 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32065 \begin_inset Text
32066
32067 \begin_layout Standard
32068
32069 \size footnotesize
32070 Installing and Configuring SDCC and Crimson Editor 
32071 \end_layout
32072
32073 \end_inset
32074 </cell>
32075 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32076 \begin_inset Text
32077
32078 \begin_layout Standard
32079
32080 \size footnotesize
32081 \begin_inset LatexCommand \url{http://www.ramtron.com/doc/Products/Microcontroller/Support_Tools.asp}
32082
32083 \end_inset
32084
32085
32086 \end_layout
32087
32088 \end_inset
32089 </cell>
32090 </row>
32091 <row topline="true" bottomline="true">
32092 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32093 \begin_inset Text
32094
32095 \begin_layout Standard
32096
32097 \size footnotesize
32098 Texas Instruments
32099 \end_layout
32100
32101 \end_inset
32102 </cell>
32103 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32104 \begin_inset Text
32105
32106 \begin_layout Standard
32107
32108 \size footnotesize
32109 MSC12xx Programming with SDCC
32110 \end_layout
32111
32112 \end_inset
32113 </cell>
32114 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32115 \begin_inset Text
32116
32117 \begin_layout Standard
32118
32119 \size footnotesize
32120 \begin_inset LatexCommand \url{http://focus.ti.com/general/docs/lit/getliterature.tsp?literatureNumber=sbaa109&fileType=pdf}
32121
32122 \end_inset
32123
32124
32125 \end_layout
32126
32127 \end_inset
32128 </cell>
32129 </row>
32130 </lyxtabular>
32131
32132 \end_inset
32133
32134
32135 \end_layout
32136
32137 \begin_layout Section
32138 Some Questions
32139 \end_layout
32140
32141 \begin_layout Standard
32142 Some questions answered, some pointers given - it might be time to in turn
32143  ask 
32144 \emph on
32145 you
32146 \emph default
32147  some questions: 
32148 \end_layout
32149
32150 \begin_layout Itemize
32151 can you solve your project with the selected microcontroller? Would you
32152  find out early or rather late that your target is too small/slow/whatever?
32153  Can you switch to a slightly better device if it doesn't fit?
32154 \end_layout
32155
32156 \begin_layout Itemize
32157 should you solve the problem with an 8 bit CPU? Or would a 16/32 bit CPU
32158  and/or another programming language be more adequate? Would an operating
32159  system on the target device help?
32160 \end_layout
32161
32162 \begin_layout Itemize
32163 if you solved the problem, will the marketing department be happy?
32164 \end_layout
32165
32166 \begin_layout Itemize
32167 if the marketing department is happy, will customers be happy?
32168 \end_layout
32169
32170 \begin_layout Itemize
32171 if you're the project manager, marketing department and maybe even the customer
32172  in one person, have you tried to see the project from the outside?
32173 \end_layout
32174
32175 \begin_layout Itemize
32176 is the project done if you think it is done? Or is just that other interface/pro
32177 tocol/feature/configuration/option missing? How about website, manual(s),
32178  internationali(z|s)ation, packaging, labels, 2nd source for components,
32179  electromagnetic compatability/interference, documentation for production,
32180  production test software, update mechanism, patent issues?
32181 \end_layout
32182
32183 \begin_layout Itemize
32184 is your project adequately positioned in that magic triangle: fame, fortune,
32185  fun?
32186 \end_layout
32187
32188 \begin_layout Standard
32189 Maybe not all answers to these questions are known and some answers may
32190  even be 
32191 \emph on
32192 no
32193 \emph default
32194 , nevertheless knowing these questions may help you to avoid burnout
32195 \begin_inset Foot
32196 status open
32197
32198 \begin_layout Standard
32199 burnout is bad for electronic devices, programmers and motorcycle tyres
32200 \end_layout
32201
32202 \end_inset
32203
32204 .
32205  Chances are you didn't want to hear some of them...
32206 \end_layout
32207
32208 \begin_layout Chapter
32209 Support
32210 \begin_inset LatexCommand \index{Support}
32211
32212 \end_inset
32213
32214
32215 \end_layout
32216
32217 \begin_layout Standard
32218 SDCC has grown to be a large project.
32219  The compiler alone (without the preprocessor, assembler and linker) is
32220  well over 150,000 lines of code (blank stripped).
32221  The open source nature of this project is a key to its continued growth
32222  and support.
32223  You gain the benefit and support of many active software developers and
32224  end users.
32225  Is SDCC perfect? No, that's why we need your help.
32226  The developers take pride in fixing reported bugs.
32227  You can help by reporting the bugs and helping other SDCC users.
32228  There are lots of ways to contribute, and we encourage you to take part
32229  in making SDCC a great software package.
32230  
32231 \end_layout
32232
32233 \begin_layout Standard
32234 The SDCC project is hosted on the SDCC sourceforge site at 
32235 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/projects/sdcc}
32236
32237 \end_inset
32238
32239 .
32240  You'll find the complete set of mailing lists
32241 \begin_inset LatexCommand \index{Mailing list(s)}
32242
32243 \end_inset
32244
32245 , forums, bug reporting system, patch submission
32246 \begin_inset LatexCommand \index{Patch submission}
32247
32248 \end_inset
32249
32250  system, download
32251 \begin_inset LatexCommand \index{download}
32252
32253 \end_inset
32254
32255  area and Subversion code repository
32256 \begin_inset LatexCommand \index{Subversion code repository}
32257
32258 \end_inset
32259
32260  there.
32261 \end_layout
32262
32263 \begin_layout Section
32264 Reporting Bugs
32265 \begin_inset LatexCommand \index{Bug reporting}
32266
32267 \end_inset
32268
32269
32270 \begin_inset LatexCommand \index{Reporting bugs}
32271
32272 \end_inset
32273
32274
32275 \end_layout
32276
32277 \begin_layout Standard
32278 The recommended way of reporting bugs is using the infrastructure of the
32279  sourceforge site.
32280  You can follow the status of bug reports there and have an overview about
32281  the known bugs.
32282 \end_layout
32283
32284 \begin_layout Standard
32285 Bug reports are automatically forwarded to the developer mailing list and
32286  will be fixed ASAP.
32287  When reporting a bug, it is very useful to include a small test program
32288  (the smaller the better) which reproduces the problem.
32289  If you can isolate the problem by looking at the generated assembly code,
32290  this can be very helpful.
32291  Compiling your program with the -
32292 \begin_inset ERT
32293 status collapsed
32294
32295 \begin_layout Standard
32296
32297
32298 \backslash
32299 /
32300 \end_layout
32301
32302 \end_inset
32303
32304 -dumpall
32305 \begin_inset LatexCommand \index{-\\/-dumpall}
32306
32307 \end_inset
32308
32309  option can sometimes be useful in locating optimization problems.
32310  When reporting a bug please make sure you:
32311 \end_layout
32312
32313 \begin_layout Enumerate
32314 Attach the code you are compiling with SDCC.
32315  
32316 \end_layout
32317
32318 \begin_layout Enumerate
32319 Specify the exact command you use to run SDCC, or attach your Makefile.
32320  
32321 \end_layout
32322
32323 \begin_layout Enumerate
32324 Specify the SDCC version (type "
32325 \family sans
32326 \series bold
32327 sdcc -v
32328 \family default
32329 \series default
32330 "), your platform, and operating system.
32331  
32332 \end_layout
32333
32334 \begin_layout Enumerate
32335 Provide an exact copy of any error message or incorrect output.
32336  
32337 \end_layout
32338
32339 \begin_layout Enumerate
32340 Put something meaningful in the subject of your message.
32341 \end_layout
32342
32343 \begin_layout Standard
32344 Please attempt to include these 5 important parts, as applicable, in all
32345  requests for support or when reporting any problems or bugs with SDCC.
32346  Though this will make your message lengthy, it will greatly improve your
32347  chance that SDCC users and developers will be able to help you.
32348  Some SDCC developers are frustrated by bug reports without code provided
32349  that they can use to reproduce and ultimately fix the problem, so please
32350  be sure to provide sample code if you are reporting a bug! 
32351 \end_layout
32352
32353 \begin_layout Standard
32354 Please have a short check that you are using a recent version of SDCC and
32355  the bug is not yet known.
32356  This is the link for reporting bugs: 
32357 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/tracker/?group_id=599&atid=100599}
32358
32359 \end_inset
32360
32361 .
32362  With SDCC on average having more than 200 downloads
32363 \begin_inset LatexCommand \index{download}
32364
32365 \end_inset
32366
32367  on sourceforge per day
32368 \begin_inset Foot
32369 status open
32370
32371 \begin_layout Standard
32372 220 daily downloads on average Jan-Sept 2006 and about 150 daily downloads
32373  between 2002 and 2005.
32374  This does not include other methods of distribution.
32375 \end_layout
32376
32377 \end_inset
32378
32379  there must be some users.
32380  So it's not exactly easy to find a new bug.
32381  If you find one we need it: 
32382 \emph on
32383 reporting bugs is good
32384 \emph default
32385 .
32386 \end_layout
32387
32388 \begin_layout Section
32389 Requesting Features
32390 \begin_inset LatexCommand \label{sub:Requesting-Features}
32391
32392 \end_inset
32393
32394
32395 \begin_inset LatexCommand \index{Feature request}
32396
32397 \end_inset
32398
32399
32400 \begin_inset LatexCommand \index{Requesting features}
32401
32402 \end_inset
32403
32404
32405 \end_layout
32406
32407 \begin_layout Standard
32408 Like bug reports feature requests are forwarded to the developer mailing
32409  list.
32410  This is the link for requesting features: 
32411 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/tracker/?group_id=599&atid=350599}
32412
32413 \end_inset
32414
32415 .
32416 \end_layout
32417
32418 \begin_layout Section
32419 Submitting patches
32420 \end_layout
32421
32422 \begin_layout Standard
32423 Like bug reports contributed patches are forwarded to the developer mailing
32424  list.
32425  This is the link for submitting patches
32426 \begin_inset LatexCommand \index{Patch submission}
32427
32428 \end_inset
32429
32430
32431 \begin_inset LatexCommand \url{http://sourceforge.net/tracker/?group_id=599&atid=300599}
32432
32433 \end_inset
32434
32435 .
32436 \end_layout
32437
32438 \begin_layout Standard
32439 You need to specify some parameters to the 
32440 \family typewriter
32441 diff
32442 \family default
32443  command for the patches to be useful.
32444  If you modified more than one file a patch created f.e.
32445  with 
32446 \family sans
32447 \series bold
32448
32449 \begin_inset Quotes sld
32450 \end_inset
32451
32452 diff -Naur unmodified_directory modified_directory >my_changes.patch
32453 \begin_inset Quotes srd
32454 \end_inset
32455
32456
32457 \family default
32458 \series default
32459  will be fine, otherwise 
32460 \family sans
32461 \series bold
32462
32463 \begin_inset Quotes sld
32464 \end_inset
32465
32466 diff -u sourcefile.c.orig sourcefile.c >my_changes.patch
32467 \begin_inset Quotes srd
32468 \end_inset
32469
32470
32471 \family default
32472 \series default
32473  will do.
32474 \end_layout
32475
32476 \begin_layout Section
32477 Getting Help
32478 \end_layout
32479
32480 \begin_layout Standard
32481 These links should take you directly to the 
32482 \begin_inset LatexCommand \url[Mailing lists]{http://sourceforge.net/mail/?group_id=599}
32483
32484 \end_inset
32485
32486
32487 \begin_inset Foot
32488 status open
32489
32490 \begin_layout Standard
32491 Traffic on sdcc-devel and sdcc-user is about 100 mails/month each not counting
32492  automated messages (mid 2003)
32493 \end_layout
32494
32495 \end_inset
32496
32497  and the 
32498 \begin_inset LatexCommand \url[Forums]{http://sourceforge.net/forum/?group_id=599}
32499
32500 \end_inset
32501
32502 , lists
32503 \begin_inset LatexCommand \index{Mailing list(s)}
32504
32505 \end_inset
32506
32507  and forums are archived and searchable so if you are lucky someone already
32508  had a similar problem.
32509  While mails to the lists themselves are delivered promptly their web front
32510  end on sourceforge sometimes shows a severe time lag (up to several weeks),
32511  if you're seriously using SDCC please consider subscribing to the lists.
32512 \end_layout
32513
32514 \begin_layout Section
32515 ChangeLog
32516 \end_layout
32517
32518 \begin_layout Standard
32519 You can follow the status of the Subversion version
32520 \begin_inset LatexCommand \index{version}
32521
32522 \end_inset
32523
32524  of SDCC by watching the Changelog
32525 \begin_inset LatexCommand \index{Changelog}
32526
32527 \end_inset
32528
32529  in the Subversion repository
32530 \size footnotesize
32531  
32532 \begin_inset LatexCommand \htmlurl{http://sdcc.svn.sourceforge.net/viewcvs.cgi/*checkout*/sdcc/trunk/sdcc/ChangeLog}
32533
32534 \end_inset
32535
32536 .
32537 \end_layout
32538
32539 \begin_layout Section
32540 Subversion Source Code Repository
32541 \end_layout
32542
32543 \begin_layout Standard
32544 The output of 
32545 \family sans
32546 \series bold
32547 sdcc -
32548 \family default
32549
32550 \begin_inset ERT
32551 status open
32552
32553 \begin_layout Standard
32554
32555
32556 \backslash
32557 /
32558 \end_layout
32559
32560 \end_inset
32561
32562
32563 \family sans
32564 -version
32565 \family default
32566 \series default
32567  or the filenames of the snapshot versions of SDCC include date and its
32568  Subversion
32569 \begin_inset LatexCommand \index{Subversion code repository}
32570
32571 \end_inset
32572
32573  number.
32574  Subversion allows to download the source of recent or previous versions
32575  
32576 \begin_inset LatexCommand \url{http://sourceforge.net/svn/?group_id=599}
32577
32578 \end_inset
32579
32580  (by number or by date).
32581  An on-line source code browser and detailled instructions are also available
32582  there.
32583  SDCC versions starting from 1999 up to now are available (currently the
32584  versions prior to the conversion from cvs
32585 \begin_inset LatexCommand \index{cvs|see{Subversion}}
32586
32587 \end_inset
32588
32589  to Subversion (April 2006) are either by accessible by Subversion or by
32590  cvs).
32591 \end_layout
32592
32593 \begin_layout Section
32594 Release policy
32595 \begin_inset LatexCommand \index{Release policy}
32596
32597 \end_inset
32598
32599
32600 \end_layout
32601
32602 \begin_layout Standard
32603 Historically there often were long delays between official releases and
32604  the sourceforge download area tends to get not updated at all.
32605  Excuses in the past might have referred to problems with live range analysis,
32606  but as this was fixed a while ago, the current problem is that another
32607  excuse has to be found.
32608  Kidding aside, we have to get better there! On the other hand there are
32609  daily snapshots available at 
32610 \begin_inset LatexCommand \htmlurl[snap]{http://sdcc.sourceforge.net/snap.php}
32611
32612 \end_inset
32613
32614 , and you can always build the very last version (hopefully with many bugs
32615  fixed, and features added) from the source code available at 
32616 \begin_inset LatexCommand \htmlurl[Source]{http://sdcc.sourceforge.net/snap.php#Source}
32617
32618 \end_inset
32619
32620 .
32621  The SDCC Wiki
32622 \begin_inset LatexCommand \index{wiki}
32623
32624 \end_inset
32625
32626
32627 \begin_inset LatexCommand \index{SDCC Wiki}
32628
32629 \end_inset
32630
32631  at 
32632 \begin_inset LatexCommand \url{http://sdcc.wiki.sourceforge.net/}
32633
32634 \end_inset
32635
32636  also holds some information about past and future releases.
32637 \end_layout
32638
32639 \begin_layout Section
32640 Examples
32641 \begin_inset LatexCommand \index{Examples}
32642
32643 \end_inset
32644
32645
32646 \end_layout
32647
32648 \begin_layout Standard
32649 You'll find some small examples in the directory 
32650 \emph on
32651 sdcc/device/examples/.
32652
32653 \emph default
32654  More examples and libraries are available at 
32655 \emph on
32656 The SDCC Open Knowledge Resource 
32657 \begin_inset LatexCommand \url{http://sdccokr.dl9sec.de/}
32658
32659 \end_inset
32660
32661
32662 \emph default
32663  web site or at 
32664 \begin_inset LatexCommand \url{http://www.pjrc.com/tech/8051/}
32665
32666 \end_inset
32667
32668 .
32669 \end_layout
32670
32671 \begin_layout Standard
32672 \begin_inset Note Note
32673 status collapsed
32674
32675 \begin_layout Standard
32676 I did insert a reference to Paul's web site here although it seems rather
32677  dedicated to a specific 8032 board (I think it's okay because it f.e.
32678  shows LCD/Harddisc interface and has a free 8051 monitor.
32679  Independent 8032 board vendors face hard competition of heavily subsidized
32680  development boards anyway).
32681 \end_layout
32682
32683 \begin_layout Standard
32684 Maybe we should include some links to real world applications.
32685  Preferably pointer to pointers (one for each architecture) so this stays
32686  manageable here?
32687 \end_layout
32688
32689 \end_inset
32690
32691
32692 \end_layout
32693
32694 \begin_layout Section
32695 Quality control
32696 \begin_inset LatexCommand \label{sec:Quality-control}
32697
32698 \end_inset
32699
32700
32701 \begin_inset LatexCommand \index{Quality control}
32702
32703 \end_inset
32704
32705
32706 \end_layout
32707
32708 \begin_layout Standard
32709 The compiler is passed through snaphot build compile and build checks.
32710  The so called 
32711 \shape italic
32712 regression tests
32713 \shape default
32714
32715 \begin_inset LatexCommand \index{Regression test}
32716
32717 \end_inset
32718
32719  check that SDCC itself compiles flawlessly on several host platforms (i386,
32720  Opteron, 64 bit Alpha, ppc64, Mac OS X on PPC, Solaris on Sparc) and checks
32721  the quality of the code generated by SDCC by running the code for several
32722  target platforms through simulators.
32723  The regression test suite comprises more than 100 files which expand to
32724  more than 500 test cases which include more than 4500 tests.
32725  The results of these tests are published daily on SDCC's snapshot page
32726  (click on the red or green symbols on the right side of 
32727 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/snap.php}
32728
32729 \end_inset
32730
32731 ).
32732 \end_layout
32733
32734 \begin_layout Standard
32735 There is a separate document 
32736 \shape italic
32737 test_suite.pdf 
32738 \begin_inset LatexCommand \index{Test suite}
32739
32740 \end_inset
32741
32742
32743 \shape default
32744  
32745 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net/doc/test_suite_spec.pdf}
32746
32747 \end_inset
32748
32749  about the regression test suite.
32750 \end_layout
32751
32752 \begin_layout Standard
32753 You'll find the test code in the directory 
32754 \shape italic
32755 sdcc/support/regression
32756 \shape default
32757 .
32758  You can run these tests manually by running 
32759 \family sans
32760 make
32761 \family default
32762  in this directory (or f.e.
32763  
32764 \family sans
32765 \series bold
32766
32767 \begin_inset Quotes sld
32768 \end_inset
32769
32770 make test-mcs51
32771 \begin_inset Quotes srd
32772 \end_inset
32773
32774
32775 \family default
32776 \series default
32777  if you don't want to run the complete tests).
32778  The test code might also be interesting if you want to look for examples
32779 \begin_inset LatexCommand \index{Examples}
32780
32781 \end_inset
32782
32783  checking corner cases of SDCC or if you plan to submit patches
32784 \begin_inset LatexCommand \index{Patch submission}
32785
32786 \end_inset
32787
32788 .
32789 \end_layout
32790
32791 \begin_layout Standard
32792 The PIC14 port uses a different set of regression tests 
32793 \begin_inset LatexCommand \index{Regression test (PIC14)}
32794
32795 \end_inset
32796
32797 , you'll find them in the directory 
32798 \shape italic
32799 sdcc/src/regression
32800 \shape default
32801 .
32802 \end_layout
32803
32804 \begin_layout Section
32805 Use of SDCC in Education
32806 \end_layout
32807
32808 \begin_layout Standard
32809 In short: 
32810 \emph on
32811 highly
32812 \emph default
32813  encouraged
32814 \begin_inset Foot
32815 status open
32816
32817 \begin_layout Standard
32818 the phrase "use in education" might evoke the association "
32819 \emph on
32820 only
32821 \emph default
32822  fit for use in education".
32823  This connotation is not intended but nevertheless risked as the licensing
32824  of SDCC makes it difficult to offer educational discounts
32825 \end_layout
32826
32827 \end_inset
32828
32829 .
32830  If your rationales are to:
32831 \end_layout
32832
32833 \begin_layout Enumerate
32834 give students a chance to understand the 
32835 \emph on
32836 complete
32837 \emph default
32838  steps of code generation
32839 \end_layout
32840
32841 \begin_layout Enumerate
32842 have a curriculum that can be extended for years.
32843  Then you could use an fpga board as target and your curriculum will seamlessly
32844  extend from logic synthesis (
32845 \begin_inset LatexCommand \url[http://www.opencores.org]{opencores.org}
32846
32847 \end_inset
32848
32849
32850 \begin_inset LatexCommand \url[Oregano]{http://www.oregano.at/ip/ip01.htm}
32851
32852 \end_inset
32853
32854 ), over assembly programming, to C to FPGA compilers (
32855 \begin_inset LatexCommand \url[FPGAC]{http://sf.net/projects/fpgac}
32856
32857 \end_inset
32858
32859 ) and to C.
32860 \end_layout
32861
32862 \begin_layout Enumerate
32863 be able to insert excursions about skills like using a revision control
32864  system, submitting/applying patches, using a type-setting (as opposed to
32865  word-processing) engine LyX/LaTeX, using 
32866 \begin_inset LatexCommand \url[SourceForge]{http://www.sf.net}
32867
32868 \end_inset
32869
32870 , following some 
32871 \begin_inset LatexCommand \url[netiquette]{http://en.wikipedia.org/wiki/Netiquette}
32872
32873 \end_inset
32874
32875 , understanding BSD/LGPL/GPL/Proprietary licensing, growth models of Open
32876  Source Software, CPU simulation, compiler regression tests
32877 \begin_inset LatexCommand \index{Regression test}
32878
32879 \end_inset
32880
32881 .
32882  
32883 \newline
32884 And if there should be a shortage of ideas then you can always point students
32885  to the ever-growing feature request list 
32886 \begin_inset LatexCommand \htmlurl{http://sourceforge.net/tracker/?group_id=599&atid=350599}
32887
32888 \end_inset
32889
32890 .
32891 \end_layout
32892
32893 \begin_layout Enumerate
32894 not tie students to a specific host platform and instead allow them to use
32895  a host platform of 
32896 \emph on
32897 their
32898 \emph default
32899  choice (among them Alpha, i386, i386_64, Mac OS X, Mips, Sparc, Windows
32900  and eventually 
32901 \begin_inset LatexCommand \url[OLPC]{http://www.laptop.org}
32902
32903 \end_inset
32904
32905 )
32906 \end_layout
32907
32908 \begin_layout Enumerate
32909 not encourage students to use illegal copies of educational software
32910 \end_layout
32911
32912 \begin_layout Enumerate
32913 be immune to licensing/availability/price changes of the chosen tool chain
32914 \end_layout
32915
32916 \begin_layout Enumerate
32917 be able to change to a new target platform without having to adopt a new
32918  tool chain
32919 \end_layout
32920
32921 \begin_layout Enumerate
32922 have complete control over and insight into the tool chain
32923 \end_layout
32924
32925 \begin_layout Enumerate
32926 make your students aware about the pros and cons of open source software
32927  development
32928 \end_layout
32929
32930 \begin_layout Enumerate
32931 give back to the public as you are probably at least partially publically
32932  funded
32933 \end_layout
32934
32935 \begin_layout Enumerate
32936 give students a chance to publically prove their skills and to possibly
32937  see a world wide impact
32938 \end_layout
32939
32940 \begin_layout Standard
32941 then SDCC is probably among the first choices.
32942  Well, probably SDCC might be the only choice.
32943 \newpage
32944
32945 \end_layout
32946
32947 \begin_layout Chapter
32948 SDCC Technical Data
32949 \end_layout
32950
32951 \begin_layout Section
32952 Optimizations
32953 \begin_inset LatexCommand \index{Optimizations}
32954
32955 \end_inset
32956
32957
32958 \end_layout
32959
32960 \begin_layout Standard
32961 SDCC performs a host of standard optimizations in addition to some MCU specific
32962  optimizations.
32963  
32964 \end_layout
32965
32966 \begin_layout Subsection
32967 Sub-expression Elimination
32968 \begin_inset LatexCommand \index{Subexpression elimination}
32969
32970 \end_inset
32971
32972
32973 \end_layout
32974
32975 \begin_layout Standard
32976 The compiler does local and 
32977 \emph on
32978 g
32979 \emph default
32980 lobal 
32981 \emph on
32982 c
32983 \emph default
32984 ommon 
32985 \emph on
32986 s
32987 \emph default
32988 ubexpression 
32989 \emph on
32990 e
32991 \emph default
32992 limination, e.g.: 
32993 \end_layout
32994
32995 \begin_layout Verse
32996
32997 \family typewriter
32998 i = x + y + 1; 
32999 \newline
33000 j = x + y;
33001 \end_layout
33002
33003 \begin_layout Standard
33004 will be translated to
33005 \end_layout
33006
33007 \begin_layout Verse
33008
33009 \family typewriter
33010 iTemp = x + y; 
33011 \newline
33012 i = iTemp + 1; 
33013 \newline
33014 j = iTemp;
33015 \end_layout
33016
33017 \begin_layout Standard
33018 Some subexpressions are not as obvious as the above example, e.g.:
33019 \end_layout
33020
33021 \begin_layout Verse
33022
33023 \family typewriter
33024 a->b[i].c = 10; 
33025 \newline
33026 a->b[i].d = 11;
33027 \end_layout
33028
33029 \begin_layout Standard
33030 In this case the address arithmetic a->b[i] will be computed only once;
33031  the equivalent code in C would be.
33032 \end_layout
33033
33034 \begin_layout Verse
33035
33036 \family typewriter
33037 iTemp = a->b[i]; 
33038 \newline
33039 iTemp.c = 10; 
33040 \newline
33041 iTemp.d = 11;
33042 \end_layout
33043
33044 \begin_layout Standard
33045 The compiler will try to keep these temporary variables in registers.
33046 \end_layout
33047
33048 \begin_layout Subsection
33049 Dead-Code Elimination
33050 \begin_inset LatexCommand \index{Dead-code elimination}
33051
33052 \end_inset
33053
33054
33055 \end_layout
33056
33057 \begin_layout Verse
33058
33059 \family typewriter
33060 int global;
33061 \newline
33062
33063 \newline
33064 void f () { 
33065 \newline
33066 \InsetSpace ~
33067 \InsetSpace ~
33068 int i; 
33069 \newline
33070 \InsetSpace ~
33071 \InsetSpace ~
33072 i = 1; \InsetSpace ~
33073 \InsetSpace ~
33074 \InsetSpace ~
33075 \InsetSpace ~
33076 \InsetSpace ~
33077 /* dead store */ 
33078 \newline
33079 \InsetSpace ~
33080 \InsetSpace ~
33081 global = 1;\InsetSpace ~
33082 /* dead
33083  store */ 
33084 \newline
33085 \InsetSpace ~
33086 \InsetSpace ~
33087 global = 2; 
33088 \newline
33089 \InsetSpace ~
33090 \InsetSpace ~
33091 return; 
33092 \newline
33093 \InsetSpace ~
33094 \InsetSpace ~
33095 global = 3;\InsetSpace ~
33096 /* unreachable */ 
33097 \newline
33098 }
33099 \end_layout
33100
33101 \begin_layout Standard
33102 will be changed to
33103 \end_layout
33104
33105 \begin_layout Verse
33106
33107 \family typewriter
33108 int global;
33109 \newline
33110
33111 \newline
33112 void f () {
33113 \newline
33114 \InsetSpace ~
33115 \InsetSpace ~
33116 global = 2; 
33117 \newline
33118 }
33119 \end_layout
33120
33121 \begin_layout Subsection
33122 Copy-Propagation
33123 \begin_inset LatexCommand \index{Copy propagation}
33124
33125 \end_inset
33126
33127
33128 \end_layout
33129
33130 \begin_layout Verse
33131
33132 \family typewriter
33133 int f() { 
33134 \newline
33135 \InsetSpace ~
33136 \InsetSpace ~
33137 int i, j; 
33138 \newline
33139 \InsetSpace ~
33140 \InsetSpace ~
33141 i = 10; 
33142 \newline
33143 \InsetSpace ~
33144 \InsetSpace ~
33145 j = i; 
33146 \newline
33147 \InsetSpace ~
33148 \InsetSpace ~
33149 return j; 
33150 \newline
33151 }
33152 \end_layout
33153
33154 \begin_layout Standard
33155 will be changed to 
33156 \end_layout
33157
33158 \begin_layout Verse
33159
33160 \family typewriter
33161 int f() { 
33162 \newline
33163 \InsetSpace ~
33164 \InsetSpace ~
33165 int i, j; 
33166 \newline
33167 \InsetSpace ~
33168 \InsetSpace ~
33169 i = 10; 
33170 \newline
33171 \InsetSpace ~
33172 \InsetSpace ~
33173 j = 10; 
33174 \newline
33175 \InsetSpace ~
33176 \InsetSpace ~
33177 return 10; 
33178 \newline
33179 }
33180 \end_layout
33181
33182 \begin_layout Standard
33183 Note: the dead stores created by this copy propagation will be eliminated
33184  by dead-code elimination.
33185 \end_layout
33186
33187 \begin_layout Subsection
33188 Loop Optimizations
33189 \begin_inset LatexCommand \index{Loop optimization}
33190
33191 \end_inset
33192
33193
33194 \begin_inset LatexCommand \label{sub:Loop-Optimizations}
33195
33196 \end_inset
33197
33198
33199 \end_layout
33200
33201 \begin_layout Standard
33202 Two types of loop optimizations are done by SDCC 
33203 \emph on
33204 loop invariant
33205 \emph default
33206  lifting and 
33207 \emph on
33208 strength reduction
33209 \emph default
33210  of loop induction variables.
33211  In addition to the strength reduction the optimizer marks the induction
33212  variables and the register allocator tries to keep the induction variables
33213  in registers for the duration of the loop.
33214  Because of this preference of the register allocator
33215 \begin_inset LatexCommand \index{Register allocation}
33216
33217 \end_inset
33218
33219 , loop induction optimization causes an increase in register pressure, which
33220  may cause unwanted spilling of other temporary variables into the stack
33221 \begin_inset LatexCommand \index{stack}
33222
33223 \end_inset
33224
33225  / data space.
33226  The compiler will generate a warning message when it is forced to allocate
33227  extra space either on the stack or data space.
33228  If this extra space allocation is undesirable then induction optimization
33229  can be eliminated either for the entire source file (with -
33230 \begin_inset ERT
33231 status collapsed
33232
33233 \begin_layout Standard
33234
33235
33236 \backslash
33237 /
33238 \end_layout
33239
33240 \end_inset
33241
33242 -noinduction option) or for a given function only using #pragma\InsetSpace ~
33243 noinduction
33244 \begin_inset LatexCommand \index{\\#pragma noinduction}
33245
33246 \end_inset
33247
33248 .
33249 \newline
33250
33251 \newline
33252 Loop Invariant:
33253 \end_layout
33254
33255 \begin_layout Verse
33256
33257 \family typewriter
33258 for (i = 0 ; i < 100 ; i ++) 
33259 \newline
33260 \InsetSpace ~
33261 \InsetSpace ~
33262 \InsetSpace ~
33263 \InsetSpace ~
33264 f += k + l;
33265 \end_layout
33266
33267 \begin_layout Standard
33268 changed to
33269 \end_layout
33270
33271 \begin_layout Verse
33272
33273 \family typewriter
33274 itemp = k + l; 
33275 \newline
33276 for (i = 0; i < 100; i++) 
33277 \newline
33278 \InsetSpace ~
33279 \InsetSpace ~
33280 \InsetSpace ~
33281 \InsetSpace ~
33282 f += itemp;
33283 \end_layout
33284
33285 \begin_layout Standard
33286 As mentioned previously some loop invariants are not as apparent, all static
33287  address computations are also moved out of the loop.
33288 \newline
33289
33290 \newline
33291 Strength Reduction
33292 \begin_inset LatexCommand \index{Strength reduction}
33293
33294 \end_inset
33295
33296 , this optimization substitutes an expression by a cheaper expression:
33297 \end_layout
33298
33299 \begin_layout Verse
33300
33301 \family typewriter
33302 for (i=0;i < 100; i++)
33303 \newline
33304 \InsetSpace ~
33305 \InsetSpace ~
33306 \InsetSpace ~
33307 \InsetSpace ~
33308 ar[i*5] = i*3;
33309 \end_layout
33310
33311 \begin_layout Standard
33312 changed to
33313 \end_layout
33314
33315 \begin_layout Verse
33316
33317 \family typewriter
33318 itemp1 = 0; 
33319 \newline
33320 itemp2 = 0; 
33321 \newline
33322 for (i=0;i< 100;i++) { 
33323 \newline
33324 \InsetSpace ~
33325 \InsetSpace ~
33326 \InsetSpace ~
33327 \InsetSpace ~
33328 ar[itemp1] = itemp2; 
33329 \newline
33330 \InsetSpace ~
33331 \InsetSpace ~
33332 \InsetSpace ~
33333 \InsetSpace ~
33334 itemp1
33335  += 5; 
33336 \newline
33337 \InsetSpace ~
33338 \InsetSpace ~
33339 \InsetSpace ~
33340 \InsetSpace ~
33341 itemp2 += 3; 
33342 \newline
33343 }
33344 \end_layout
33345
33346 \begin_layout Standard
33347 The more expensive multiplication
33348 \begin_inset LatexCommand \index{Multiplication}
33349
33350 \end_inset
33351
33352  is changed to a less expensive addition.
33353 \end_layout
33354
33355 \begin_layout Subsection
33356 Loop Reversing
33357 \begin_inset LatexCommand \index{Loop reversing}
33358
33359 \end_inset
33360
33361
33362 \end_layout
33363
33364 \begin_layout Standard
33365 This optimization is done to reduce the overhead of checking loop boundaries
33366  for every iteration.
33367  Some simple loops can be reversed and implemented using a 
33368 \begin_inset Quotes eld
33369 \end_inset
33370
33371 decrement and jump if not zero
33372 \begin_inset Quotes erd
33373 \end_inset
33374
33375  instruction.
33376  SDCC checks for the following criterion to determine if a loop is reversible
33377  (note: more sophisticated compilers use data-dependency analysis to make
33378  this determination, SDCC uses a more simple minded analysis).
33379 \end_layout
33380
33381 \begin_layout Itemize
33382 The 'for' loop is of the form 
33383 \newline
33384
33385 \newline
33386
33387 \family typewriter
33388 for(<symbol> = <expression>; <sym> [< | <=] <expression>; [<sym>++ | <sym>
33389  += 1])
33390 \newline
33391 \InsetSpace ~
33392 \InsetSpace ~
33393 \InsetSpace ~
33394 \InsetSpace ~
33395 <for body>
33396 \end_layout
33397
33398 \begin_layout Itemize
33399 The <for body> does not contain 
33400 \begin_inset Quotes eld
33401 \end_inset
33402
33403 continue
33404 \begin_inset Quotes erd
33405 \end_inset
33406
33407  or 'break
33408 \begin_inset Quotes erd
33409 \end_inset
33410
33411 .
33412 \end_layout
33413
33414 \begin_layout Itemize
33415 All goto's are contained within the loop.
33416 \end_layout
33417
33418 \begin_layout Itemize
33419 No function calls within the loop.
33420 \end_layout
33421
33422 \begin_layout Itemize
33423 The loop control variable <sym> is not assigned any value within the loop
33424 \end_layout
33425
33426 \begin_layout Itemize
33427 The loop control variable does NOT participate in any arithmetic operation
33428  within the loop.
33429 \end_layout
33430
33431 \begin_layout Itemize
33432 There are NO switch statements in the loop.
33433 \end_layout
33434
33435 \begin_layout Subsection
33436 Algebraic Simplifications
33437 \end_layout
33438
33439 \begin_layout Standard
33440 SDCC does numerous algebraic simplifications, the following is a small sub-set
33441  of these optimizations.
33442 \end_layout
33443
33444 \begin_layout Verse
33445
33446 \family typewriter
33447 i = j + 0;\InsetSpace ~
33448 \InsetSpace ~
33449 \InsetSpace ~
33450 \InsetSpace ~
33451  /* changed to: */\InsetSpace ~
33452 \InsetSpace ~
33453 \InsetSpace ~
33454 \InsetSpace ~
33455  i = j; 
33456 \newline
33457 i /= 2;\InsetSpace ~
33458 \InsetSpace ~
33459 \InsetSpace ~
33460 \InsetSpace ~
33461 \InsetSpace ~
33462 \InsetSpace ~
33463 \InsetSpace ~
33464  /* changed to: */\InsetSpace ~
33465 \InsetSpace ~
33466 \InsetSpace ~
33467 \InsetSpace ~
33468  i >>= 1; 
33469 \newline
33470 i
33471  = j - j;\InsetSpace ~
33472 \InsetSpace ~
33473 \InsetSpace ~
33474 \InsetSpace ~
33475  /* changed to: */\InsetSpace ~
33476 \InsetSpace ~
33477 \InsetSpace ~
33478 \InsetSpace ~
33479  i = 0; 
33480 \newline
33481 i = j / 1;\InsetSpace ~
33482 \InsetSpace ~
33483 \InsetSpace ~
33484 \InsetSpace ~
33485  /* changed to: */\InsetSpace ~
33486 \InsetSpace ~
33487 \InsetSpace ~
33488 \InsetSpace ~
33489  i = j;
33490 \end_layout
33491
33492 \begin_layout Standard
33493 Note the subexpressions
33494 \begin_inset LatexCommand \index{Subexpression}
33495
33496 \end_inset
33497
33498  given above are generally introduced by macro expansions or as a result
33499  of copy/constant propagation.
33500 \end_layout
33501
33502 \begin_layout Subsection
33503 'switch' Statements
33504 \begin_inset LatexCommand \label{sub:'switch'-Statements}
33505
33506 \end_inset
33507
33508
33509 \begin_inset LatexCommand \index{switch statement}
33510
33511 \end_inset
33512
33513
33514 \end_layout
33515
33516 \begin_layout Standard
33517 SDCC can optimize switch statements to jump tables
33518 \begin_inset LatexCommand \index{jump tables}
33519
33520 \end_inset
33521
33522 .
33523  It makes the decision based on an estimate of the generated code size.
33524  SDCC is quite liberal in the requirements for jump table generation: 
33525 \end_layout
33526
33527 \begin_layout Itemize
33528 The labels need not be in order, and the starting number need not be one
33529  or zero, the case labels are in numerical sequence or not too many case
33530  labels are missing.
33531 \end_layout
33532
33533 \begin_deeper
33534 \begin_layout Verse
33535
33536 \family typewriter
33537 switch(i) {\InsetSpace ~
33538 \InsetSpace ~
33539 \InsetSpace ~
33540 \InsetSpace ~
33541 \InsetSpace ~
33542 \InsetSpace ~
33543 \InsetSpace ~
33544 \InsetSpace ~
33545 \InsetSpace ~
33546 \InsetSpace ~
33547 \InsetSpace ~
33548 \InsetSpace ~
33549 \InsetSpace ~
33550 \InsetSpace ~
33551 \InsetSpace ~
33552 \InsetSpace ~
33553 \InsetSpace ~
33554 \InsetSpace ~
33555 \InsetSpace ~
33556 \InsetSpace ~
33557 \InsetSpace ~
33558 \InsetSpace ~
33559 \InsetSpace ~
33560 \InsetSpace ~
33561 \InsetSpace ~
33562 \InsetSpace ~
33563 switch (i) { 
33564 \newline
33565 \InsetSpace ~
33566 \InsetSpace ~
33567 \InsetSpace ~
33568 case 4: ...\InsetSpace ~
33569 \InsetSpace ~
33570 \InsetSpace ~
33571 \InsetSpace ~
33572 \InsetSpace ~
33573 \InsetSpace ~
33574 \InsetSpace ~
33575 \InsetSpace ~
33576 \InsetSpace ~
33577 \InsetSpace ~
33578 \InsetSpace ~
33579 \InsetSpace ~
33580 \InsetSpace ~
33581 \InsetSpace ~
33582 \InsetSpace ~
33583 \InsetSpace ~
33584 \InsetSpace ~
33585 \InsetSpace ~
33586 \InsetSpace ~
33587 \InsetSpace ~
33588 \InsetSpace ~
33589 \InsetSpace ~
33590 \InsetSpace ~
33591 \InsetSpace ~
33592 \InsetSpace ~
33593 \InsetSpace ~
33594 case 0: ...
33595  
33596 \newline
33597 \InsetSpace ~
33598 \InsetSpace ~
33599 \InsetSpace ~
33600 case 5: ...\InsetSpace ~
33601 \InsetSpace ~
33602 \InsetSpace ~
33603 \InsetSpace ~
33604 \InsetSpace ~
33605 \InsetSpace ~
33606 \InsetSpace ~
33607 \InsetSpace ~
33608 \InsetSpace ~
33609 \InsetSpace ~
33610 \InsetSpace ~
33611 \InsetSpace ~
33612 \InsetSpace ~
33613 \InsetSpace ~
33614 \InsetSpace ~
33615 \InsetSpace ~
33616 \InsetSpace ~
33617 \InsetSpace ~
33618 \InsetSpace ~
33619 \InsetSpace ~
33620 \InsetSpace ~
33621 \InsetSpace ~
33622 \InsetSpace ~
33623 \InsetSpace ~
33624 \InsetSpace ~
33625 \InsetSpace ~
33626 case 1: ...
33627  
33628 \newline
33629 \InsetSpace ~
33630 \InsetSpace ~
33631 \InsetSpace ~
33632 case 3: ...\InsetSpace ~
33633 \InsetSpace ~
33634 \InsetSpace ~
33635 \InsetSpace ~
33636 \InsetSpace ~
33637 \InsetSpace ~
33638 \InsetSpace ~
33639 \InsetSpace ~
33640 \InsetSpace ~
33641 \InsetSpace ~
33642 \InsetSpace ~
33643 \InsetSpace ~
33644 \InsetSpace ~
33645 \InsetSpace ~
33646 \InsetSpace ~
33647 \InsetSpace ~
33648 \InsetSpace ~
33649 \InsetSpace ~
33650 \InsetSpace ~
33651 \InsetSpace ~
33652 \InsetSpace ~
33653 \InsetSpace ~
33654 \InsetSpace ~
33655 \InsetSpace ~
33656 \InsetSpace ~
33657 \InsetSpace ~
33658
33659 \newline
33660 \InsetSpace ~
33661 \InsetSpace ~
33662 \InsetSpace ~
33663 case 6: ...\InsetSpace ~
33664 \InsetSpace ~
33665 \InsetSpace ~
33666 \InsetSpace ~
33667 \InsetSpace ~
33668 \InsetSpace ~
33669 \InsetSpace ~
33670 \InsetSpace ~
33671 \InsetSpace ~
33672 \InsetSpace ~
33673 \InsetSpace ~
33674 \InsetSpace ~
33675 \InsetSpace ~
33676 \InsetSpace ~
33677 \InsetSpace ~
33678 \InsetSpace ~
33679 \InsetSpace ~
33680 \InsetSpace ~
33681 \InsetSpace ~
33682 \InsetSpace ~
33683 \InsetSpace ~
33684 \InsetSpace ~
33685 \InsetSpace ~
33686 \InsetSpace ~
33687 \InsetSpace ~
33688 \InsetSpace ~
33689 case 3: ...
33690  
33691 \newline
33692 \InsetSpace ~
33693 \InsetSpace ~
33694 \InsetSpace ~
33695 case 7: ...\InsetSpace ~
33696 \InsetSpace ~
33697 \InsetSpace ~
33698 \InsetSpace ~
33699 \InsetSpace ~
33700 \InsetSpace ~
33701 \InsetSpace ~
33702 \InsetSpace ~
33703 \InsetSpace ~
33704 \InsetSpace ~
33705 \InsetSpace ~
33706 \InsetSpace ~
33707 \InsetSpace ~
33708 \InsetSpace ~
33709 \InsetSpace ~
33710 \InsetSpace ~
33711 \InsetSpace ~
33712 \InsetSpace ~
33713 \InsetSpace ~
33714 \InsetSpace ~
33715 \InsetSpace ~
33716 \InsetSpace ~
33717 \InsetSpace ~
33718 \InsetSpace ~
33719 \InsetSpace ~
33720 \InsetSpace ~
33721 case 4: ...
33722  
33723 \newline
33724 \InsetSpace ~
33725 \InsetSpace ~
33726 \InsetSpace ~
33727 case 8: ...\InsetSpace ~
33728 \InsetSpace ~
33729 \InsetSpace ~
33730 \InsetSpace ~
33731 \InsetSpace ~
33732 \InsetSpace ~
33733 \InsetSpace ~
33734 \InsetSpace ~
33735 \InsetSpace ~
33736 \InsetSpace ~
33737 \InsetSpace ~
33738 \InsetSpace ~
33739 \InsetSpace ~
33740 \InsetSpace ~
33741 \InsetSpace ~
33742 \InsetSpace ~
33743 \InsetSpace ~
33744 \InsetSpace ~
33745 \InsetSpace ~
33746 \InsetSpace ~
33747 \InsetSpace ~
33748 \InsetSpace ~
33749 \InsetSpace ~
33750 \InsetSpace ~
33751 \InsetSpace ~
33752 \InsetSpace ~
33753 case 5: ...
33754  
33755 \newline
33756 \InsetSpace ~
33757 \InsetSpace ~
33758 \InsetSpace ~
33759 case 9: ...\InsetSpace ~
33760 \InsetSpace ~
33761 \InsetSpace ~
33762 \InsetSpace ~
33763 \InsetSpace ~
33764 \InsetSpace ~
33765 \InsetSpace ~
33766 \InsetSpace ~
33767 \InsetSpace ~
33768 \InsetSpace ~
33769 \InsetSpace ~
33770 \InsetSpace ~
33771 \InsetSpace ~
33772 \InsetSpace ~
33773 \InsetSpace ~
33774 \InsetSpace ~
33775 \InsetSpace ~
33776 \InsetSpace ~
33777 \InsetSpace ~
33778 \InsetSpace ~
33779 \InsetSpace ~
33780 \InsetSpace ~
33781 \InsetSpace ~
33782 \InsetSpace ~
33783 \InsetSpace ~
33784 \InsetSpace ~
33785 case 6: ...
33786  
33787 \newline
33788 \InsetSpace ~
33789 \InsetSpace ~
33790 \InsetSpace ~
33791 case 10: ...\InsetSpace ~
33792 \InsetSpace ~
33793 \InsetSpace ~
33794 \InsetSpace ~
33795 \InsetSpace ~
33796 \InsetSpace ~
33797 \InsetSpace ~
33798 \InsetSpace ~
33799 \InsetSpace ~
33800 \InsetSpace ~
33801 \InsetSpace ~
33802 \InsetSpace ~
33803 \InsetSpace ~
33804 \InsetSpace ~
33805 \InsetSpace ~
33806 \InsetSpace ~
33807 \InsetSpace ~
33808 \InsetSpace ~
33809 \InsetSpace ~
33810 \InsetSpace ~
33811 \InsetSpace ~
33812 \InsetSpace ~
33813 \InsetSpace ~
33814 \InsetSpace ~
33815 \InsetSpace ~
33816 case 7: ...
33817  
33818 \newline
33819 \InsetSpace ~
33820 \InsetSpace ~
33821 \InsetSpace ~
33822 case 11: ...\InsetSpace ~
33823 \InsetSpace ~
33824 \InsetSpace ~
33825 \InsetSpace ~
33826 \InsetSpace ~
33827 \InsetSpace ~
33828 \InsetSpace ~
33829 \InsetSpace ~
33830 \InsetSpace ~
33831 \InsetSpace ~
33832 \InsetSpace ~
33833 \InsetSpace ~
33834 \InsetSpace ~
33835 \InsetSpace ~
33836 \InsetSpace ~
33837 \InsetSpace ~
33838 \InsetSpace ~
33839 \InsetSpace ~
33840 \InsetSpace ~
33841 \InsetSpace ~
33842 \InsetSpace ~
33843 \InsetSpace ~
33844 \InsetSpace ~
33845 \InsetSpace ~
33846 \InsetSpace ~
33847 case 8: ...
33848  
33849 \newline
33850 }\InsetSpace ~
33851 \InsetSpace ~
33852 \InsetSpace ~
33853 \InsetSpace ~
33854 \InsetSpace ~
33855 \InsetSpace ~
33856 \InsetSpace ~
33857 \InsetSpace ~
33858 \InsetSpace ~
33859 \InsetSpace ~
33860 \InsetSpace ~
33861 \InsetSpace ~
33862 \InsetSpace ~
33863 \InsetSpace ~
33864 \InsetSpace ~
33865 \InsetSpace ~
33866 \InsetSpace ~
33867 \InsetSpace ~
33868 \InsetSpace ~
33869 \InsetSpace ~
33870 \InsetSpace ~
33871 \InsetSpace ~
33872 \InsetSpace ~
33873 \InsetSpace ~
33874 \InsetSpace ~
33875 \InsetSpace ~
33876 \InsetSpace ~
33877 \InsetSpace ~
33878 \InsetSpace ~
33879 \InsetSpace ~
33880 \InsetSpace ~
33881 \InsetSpace ~
33882 \InsetSpace ~
33883 \InsetSpace ~
33884 \InsetSpace ~
33885 \InsetSpace ~
33886 }
33887 \end_layout
33888
33889 \begin_layout Standard
33890 Both the above switch statements will be implemented using a jump-table.
33891  The example to the right side is slightly more efficient as the check for
33892  the lower boundary of the jump-table is not needed.
33893 \end_layout
33894
33895 \end_deeper
33896 \begin_layout Itemize
33897 The number of case labels is not larger than supported by the target architectur
33898 e.
33899 \end_layout
33900
33901 \begin_layout Itemize
33902 If the case labels are not in numerical sequence ('gaps' between cases)
33903  SDCC checks whether a jump table with additionally inserted dummy cases
33904  is still attractive.
33905  
33906 \end_layout
33907
33908 \begin_layout Itemize
33909 If the starting number is not zero and a check for the lower boundary of
33910  the jump-table can thus be eliminated SDCC might insert dummy cases 0,
33911  ...
33912  .
33913 \end_layout
33914
33915 \begin_layout Standard
33916 Switch statements which have large gaps in the numeric sequence or those
33917  that have too many case labels can be split into more than one switch statement
33918  for efficient code generation, e.g.:
33919 \end_layout
33920
33921 \begin_layout Verse
33922
33923 \family typewriter
33924 switch (i) { 
33925 \newline
33926 \InsetSpace ~
33927 \InsetSpace ~
33928 case 1: ...
33929  
33930 \newline
33931 \InsetSpace ~
33932 \InsetSpace ~
33933 case 2: ...
33934  
33935 \newline
33936 \InsetSpace ~
33937 \InsetSpace ~
33938 case 3: ...
33939  
33940 \newline
33941 \InsetSpace ~
33942 \InsetSpace ~
33943 case 4: ...
33944  
33945 \newline
33946 \InsetSpace ~
33947 \InsetSpace ~
33948 case 5: ...
33949  
33950 \newline
33951 \InsetSpace ~
33952 \InsetSpace ~
33953 case 6: ...
33954  
33955 \newline
33956 \InsetSpace ~
33957 \InsetSpace ~
33958 case 7: ...
33959  
33960 \newline
33961 \InsetSpace ~
33962 \InsetSpace ~
33963 case 101: ...
33964  
33965 \newline
33966 \InsetSpace ~
33967 \InsetSpace ~
33968 case 102: ...
33969  
33970 \newline
33971 \InsetSpace ~
33972 \InsetSpace ~
33973 case 103: ...
33974  
33975 \newline
33976 \InsetSpace ~
33977 \InsetSpace ~
33978 case 104: ...
33979  
33980 \newline
33981 \InsetSpace ~
33982 \InsetSpace ~
33983 case 105: ...
33984  
33985 \newline
33986 \InsetSpace ~
33987 \InsetSpace ~
33988 case 106: ...
33989  
33990 \newline
33991 \InsetSpace ~
33992 \InsetSpace ~
33993 case 107: ...
33994  
33995 \newline
33996 }
33997 \end_layout
33998
33999 \begin_layout Standard
34000 If the above switch statement is broken down into two switch statements
34001 \end_layout
34002
34003 \begin_layout Verse
34004
34005 \family typewriter
34006 switch (i) { 
34007 \newline
34008 \InsetSpace ~
34009 \InsetSpace ~
34010 case 1: ...
34011  
34012 \newline
34013 \InsetSpace ~
34014 \InsetSpace ~
34015 case 2: ...
34016  
34017 \newline
34018 \InsetSpace ~
34019 \InsetSpace ~
34020 case 3: ...
34021  
34022 \newline
34023 \InsetSpace ~
34024 \InsetSpace ~
34025 case 4: ...
34026  
34027 \newline
34028 \InsetSpace ~
34029 \InsetSpace ~
34030 case 5: ...
34031  
34032 \newline
34033 \InsetSpace ~
34034 \InsetSpace ~
34035 case 6: ...
34036  
34037 \newline
34038 \InsetSpace ~
34039 \InsetSpace ~
34040 case 7: ...
34041  
34042 \newline
34043 }
34044 \end_layout
34045
34046 \begin_layout Standard
34047 and
34048 \end_layout
34049
34050 \begin_layout Verse
34051
34052 \family typewriter
34053 switch (i) { 
34054 \newline
34055 \InsetSpace ~
34056 \InsetSpace ~
34057 case 101: ...
34058  
34059 \newline
34060 \InsetSpace ~
34061 \InsetSpace ~
34062 case 102: ...
34063  
34064 \newline
34065 \InsetSpace ~
34066 \InsetSpace ~
34067 case 103: ...
34068  
34069 \newline
34070 \InsetSpace ~
34071 \InsetSpace ~
34072 case 104: ...
34073  
34074 \newline
34075 \InsetSpace ~
34076 \InsetSpace ~
34077 case 105: ...
34078  
34079 \newline
34080 \InsetSpace ~
34081 \InsetSpace ~
34082 case 106: ...
34083  
34084 \newline
34085 \InsetSpace ~
34086 \InsetSpace ~
34087 case 107: ...
34088  
34089 \newline
34090 }
34091 \end_layout
34092
34093 \begin_layout Standard
34094 then both the switch statements will be implemented using jump-tables whereas
34095  the unmodified switch statement will not be.
34096 \end_layout
34097
34098 \begin_layout Standard
34099 \begin_inset Note Note
34100 status collapsed
34101
34102 \begin_layout Standard
34103 There might be reasons which SDCC cannot know about to either favour or
34104  not favour jump tables.
34105  If the target system has to be as quick for the last switch case as for
34106  the first (pro jump table), or if the switch argument is known to be zero
34107  in the majority of the cases (contra jump table).
34108 \end_layout
34109
34110 \end_inset
34111
34112
34113 \end_layout
34114
34115 \begin_layout Standard
34116 The pragma nojtbound
34117 \begin_inset LatexCommand \index{\\#pragma nojtbound}
34118
34119 \end_inset
34120
34121  can be used to turn off checking the 
34122 \emph on
34123 j
34124 \emph default
34125 ump 
34126 \emph on
34127 t
34128 \emph default
34129 able 
34130 \emph on
34131 bound
34132 \emph default
34133 aries.
34134  It has no effect if a default label is supplied.
34135  Use of this pragma is dangerous: if the switch
34136 \begin_inset LatexCommand \index{switch statement}
34137
34138 \end_inset
34139
34140  argument is not matched by a case statement the processor will happily
34141  jump into Nirvana.
34142 \end_layout
34143
34144 \begin_layout Subsection
34145 Bit-shifting Operations
34146 \begin_inset LatexCommand \index{Bit shifting}
34147
34148 \end_inset
34149
34150 .
34151 \end_layout
34152
34153 \begin_layout Standard
34154 Bit shifting is one of the most frequently used operation in embedded programmin
34155 g.
34156  SDCC tries to implement bit-shift operations in the most efficient way
34157  possible, e.g.:
34158 \end_layout
34159
34160 \begin_layout Verse
34161
34162 \family typewriter
34163 unsigned char i;
34164 \newline
34165 ...
34166  
34167 \newline
34168 i >>= 4; 
34169 \newline
34170 ...
34171 \end_layout
34172
34173 \begin_layout Standard
34174 generates the following code:
34175 \end_layout
34176
34177 \begin_layout Verse
34178
34179 \family typewriter
34180 mov\InsetSpace ~
34181  a,_i 
34182 \newline
34183 swap a 
34184 \newline
34185 anl\InsetSpace ~
34186  a,#0x0f 
34187 \newline
34188 mov\InsetSpace ~
34189  _i,a
34190 \end_layout
34191
34192 \begin_layout Standard
34193 In general SDCC will never setup a loop if the shift count is known.
34194  Another example:
34195 \end_layout
34196
34197 \begin_layout Verse
34198
34199 \family typewriter
34200 unsigned int i; 
34201 \newline
34202 ...
34203  
34204 \newline
34205 i >>= 9; 
34206 \newline
34207 ...
34208 \end_layout
34209
34210 \begin_layout Standard
34211 will generate:
34212 \end_layout
34213
34214 \begin_layout Verse
34215
34216 \family typewriter
34217 mov\InsetSpace ~
34218 \InsetSpace ~
34219 a,(_i + 1) 
34220 \newline
34221 mov\InsetSpace ~
34222 \InsetSpace ~
34223 (_i + 1),#0x00 
34224 \newline
34225 clr\InsetSpace ~
34226 \InsetSpace ~
34227
34228 \newline
34229 rrc\InsetSpace ~
34230 \InsetSpace ~
34231
34232 \newline
34233 mov\InsetSpace ~
34234 \InsetSpace ~
34235 _i,a
34236 \end_layout
34237
34238 \begin_layout Subsection
34239 Bit-rotation
34240 \begin_inset LatexCommand \index{Bit rotation}
34241
34242 \end_inset
34243
34244
34245 \end_layout
34246
34247 \begin_layout Standard
34248 A special case of the bit-shift operation is bit rotation
34249 \begin_inset LatexCommand \index{rotating bits}
34250
34251 \end_inset
34252
34253 , SDCC recognizes the following expression to be a left bit-rotation:
34254 \end_layout
34255
34256 \begin_layout Verse
34257
34258 \family typewriter
34259 \series bold
34260 unsigned
34261 \series default
34262 \InsetSpace ~
34263 \InsetSpace ~
34264 char i;\InsetSpace ~
34265 \InsetSpace ~
34266 \InsetSpace ~
34267 \InsetSpace ~
34268 \InsetSpace ~
34269 \InsetSpace ~
34270 \InsetSpace ~
34271 \InsetSpace ~
34272 \InsetSpace ~
34273 \InsetSpace ~
34274 \InsetSpace ~
34275 /* unsigned is needed for rotation */ 
34276 \newline
34277 ...
34278  
34279 \newline
34280 i = ((i << 1) | (i >> 7));
34281 \family default
34282  
34283 \newline
34284
34285 \family typewriter
34286 ...
34287 \end_layout
34288
34289 \begin_layout Standard
34290 will generate the following code:
34291 \end_layout
34292
34293 \begin_layout Verse
34294
34295 \family typewriter
34296 mov\InsetSpace ~
34297 \InsetSpace ~
34298 a,_i 
34299 \newline
34300 rl\InsetSpace ~
34301 \InsetSpace ~
34302 \InsetSpace ~
34303
34304 \newline
34305 mov\InsetSpace ~
34306 \InsetSpace ~
34307 _i,a
34308 \end_layout
34309
34310 \begin_layout Standard
34311 SDCC uses pattern matching on the parse tree to determine this operation.Variatio
34312 ns of this case will also be recognized as bit-rotation, i.e.: 
34313 \end_layout
34314
34315 \begin_layout Verse
34316
34317 \family typewriter
34318 i = ((i >> 7) | (i << 1)); /* left-bit rotation */
34319 \end_layout
34320
34321 \begin_layout Subsection
34322 Nibble and Byte Swapping
34323 \end_layout
34324
34325 \begin_layout Standard
34326 Other special cases of the bit-shift operations are nibble or byte swapping
34327 \begin_inset LatexCommand \index{swapping nibbles/bytes}
34328
34329 \end_inset
34330
34331 , SDCC recognizes the following expressions:
34332 \end_layout
34333
34334 \begin_layout Verse
34335
34336 \family typewriter
34337 \series bold
34338 unsigned
34339 \series default
34340 \InsetSpace ~
34341 \InsetSpace ~
34342 char i; 
34343 \newline
34344
34345 \series bold
34346 unsigned
34347 \series default
34348 \InsetSpace ~
34349 \InsetSpace ~
34350 int j; 
34351 \newline
34352 ...
34353  
34354 \newline
34355 i = ((i << 4) | (i >> 4));
34356 \family default
34357  
34358 \newline
34359
34360 \family typewriter
34361 j = ((j << 8) | (j >> 8)); 
34362 \end_layout
34363
34364 \begin_layout Standard
34365 and generates a swap instruction for the nibble swapping
34366 \begin_inset LatexCommand \index{Nibble swapping}
34367
34368 \end_inset
34369
34370  or move instructions for the byte swapping
34371 \begin_inset LatexCommand \index{Byte swapping}
34372
34373 \end_inset
34374
34375 .
34376  The 
34377 \begin_inset Quotes sld
34378 \end_inset
34379
34380 j
34381 \begin_inset Quotes srd
34382 \end_inset
34383
34384  example can be used to convert from little to big-endian or vice versa.
34385  If you want to change the endianness of a 
34386 \emph on
34387 signed
34388 \emph default
34389  integer you have to cast to 
34390 \family typewriter
34391 (unsigned int)
34392 \family default
34393  first.
34394 \end_layout
34395
34396 \begin_layout Standard
34397 Note that SDCC stores numbers in little-endian
34398 \begin_inset Foot
34399 status open
34400
34401 \begin_layout Standard
34402 Usually 8-bit processors don't care much about endianness.
34403  This is not the case for the standard 8051 which only has an instruction
34404  to increment its 
34405 \emph on
34406 dptr
34407 \emph default
34408
34409 \begin_inset LatexCommand \index{DPTR}
34410
34411 \end_inset
34412
34413 -datapointer so little-endian is the more efficient byte order.
34414 \end_layout
34415
34416 \end_inset
34417
34418
34419 \begin_inset LatexCommand \index{little-endian}
34420
34421 \end_inset
34422
34423
34424 \begin_inset LatexCommand \index{Endianness}
34425
34426 \end_inset
34427
34428  format (i.e.
34429  lowest order first).
34430 \end_layout
34431
34432 \begin_layout Subsection
34433 Highest Order Bit
34434 \begin_inset LatexCommand \index{Highest Order Bit}
34435
34436 \end_inset
34437
34438  / Any Order Bit
34439 \begin_inset LatexCommand \index{Any Order Bit}
34440
34441 \end_inset
34442
34443
34444 \end_layout
34445
34446 \begin_layout Standard
34447 It is frequently required to obtain the highest order bit of an integral
34448  type (long, int, short or char types).
34449  Also obtaining any other order bit is not uncommon.
34450  SDCC recognizes the following expressions to yield the highest order bit
34451  and generates optimized code for it, e.g.:
34452 \end_layout
34453
34454 \begin_layout Verse
34455
34456 \family typewriter
34457 unsigned int gint; 
34458 \newline
34459
34460 \newline
34461 foo () { 
34462 \newline
34463 \InsetSpace ~
34464 \InsetSpace ~
34465 unsigned char hob1, aob1; 
34466 \newline
34467 \InsetSpace ~
34468 \InsetSpace ~
34469 bit hob2, hob3, aob2,
34470  aob3; 
34471 \newline
34472 \InsetSpace ~
34473 \InsetSpace ~
34474 ...
34475  
34476 \newline
34477 \InsetSpace ~
34478 \InsetSpace ~
34479 hob1 = (gint >> 15) & 1; 
34480 \newline
34481 \InsetSpace ~
34482 \InsetSpace ~
34483 hob2 = (gint >> 15) & 1; 
34484 \newline
34485 \InsetSpace ~
34486 \InsetSpace ~
34487 hob3 = gint & 0x8000;
34488  
34489 \newline
34490 \InsetSpace ~
34491 \InsetSpace ~
34492 aob1 = (gint >> 9) & 1; 
34493 \newline
34494 \InsetSpace ~
34495 \InsetSpace ~
34496 aob2 = (gint >> 8) & 1; 
34497 \newline
34498 \InsetSpace ~
34499 \InsetSpace ~
34500 aob3 = gint & 0x0800; 
34501 \newline
34502 \InsetSpace ~
34503 \InsetSpace ~
34504 ..
34505  
34506 \newline
34507 }
34508 \end_layout
34509
34510 \begin_layout Standard
34511 will generate the following code:
34512 \end_layout
34513
34514 \begin_layout Verse
34515
34516 \family typewriter
34517 \InsetSpace ~
34518 \InsetSpace ~
34519 \InsetSpace ~
34520 \InsetSpace ~
34521 \InsetSpace ~
34522 \InsetSpace ~
34523 \InsetSpace ~
34524 \InsetSpace ~
34525 \InsetSpace ~
34526 \InsetSpace ~
34527 \InsetSpace ~
34528 \InsetSpace ~
34529 \InsetSpace ~
34530 \InsetSpace ~
34531 \InsetSpace ~
34532 \InsetSpace ~
34533 \InsetSpace ~
34534 \InsetSpace ~
34535 \InsetSpace ~
34536 \InsetSpace ~
34537 \InsetSpace ~
34538 \InsetSpace ~
34539 \InsetSpace ~
34540 \InsetSpace ~
34541 \InsetSpace ~
34542  61 ;\InsetSpace ~
34543  hob.c 7 
34544 \newline
34545 000A E5*01\InsetSpace ~
34546 \InsetSpace ~
34547 \InsetSpace ~
34548 \InsetSpace ~
34549 \InsetSpace ~
34550 \InsetSpace ~
34551 \InsetSpace ~
34552 \InsetSpace ~
34553 \InsetSpace ~
34554 \InsetSpace ~
34555 \InsetSpace ~
34556 \InsetSpace ~
34557 \InsetSpace ~
34558 \InsetSpace ~
34559 \InsetSpace ~
34560  62\InsetSpace ~
34561 \InsetSpace ~
34562 \InsetSpace ~
34563 \InsetSpace ~
34564 \InsetSpace ~
34565 \InsetSpace ~
34566 \InsetSpace ~
34567 \InsetSpace ~
34568  mov\InsetSpace ~
34569 \InsetSpace ~
34570  a,(_gint + 1) 
34571 \newline
34572 000C 23\InsetSpace ~
34573 \InsetSpace ~
34574 \InsetSpace ~
34575 \InsetSpace ~
34576 \InsetSpace ~
34577 \InsetSpace ~
34578 \InsetSpace ~
34579 \InsetSpace ~
34580 \InsetSpace ~
34581 \InsetSpace ~
34582 \InsetSpace ~
34583 \InsetSpace ~
34584 \InsetSpace ~
34585 \InsetSpace ~
34586 \InsetSpace ~
34587 \InsetSpace ~
34588 \InsetSpace ~
34589 \InsetSpace ~
34590  63\InsetSpace ~
34591 \InsetSpace ~
34592 \InsetSpace ~
34593 \InsetSpace ~
34594 \InsetSpace ~
34595 \InsetSpace ~
34596 \InsetSpace ~
34597 \InsetSpace ~
34598  rl\InsetSpace ~
34599 \InsetSpace ~
34600 \InsetSpace ~
34601  a 
34602 \newline
34603 000D 54 01\InsetSpace ~
34604 \InsetSpace ~
34605 \InsetSpace ~
34606 \InsetSpace ~
34607 \InsetSpace ~
34608 \InsetSpace ~
34609 \InsetSpace ~
34610 \InsetSpace ~
34611 \InsetSpace ~
34612 \InsetSpace ~
34613 \InsetSpace ~
34614 \InsetSpace ~
34615 \InsetSpace ~
34616 \InsetSpace ~
34617 \InsetSpace ~
34618
34619  64\InsetSpace ~
34620 \InsetSpace ~
34621 \InsetSpace ~
34622 \InsetSpace ~
34623 \InsetSpace ~
34624 \InsetSpace ~
34625 \InsetSpace ~
34626 \InsetSpace ~
34627  anl\InsetSpace ~
34628 \InsetSpace ~
34629  a,#0x01 
34630 \newline
34631 000F F5*02\InsetSpace ~
34632 \InsetSpace ~
34633 \InsetSpace ~
34634 \InsetSpace ~
34635 \InsetSpace ~
34636 \InsetSpace ~
34637 \InsetSpace ~
34638 \InsetSpace ~
34639 \InsetSpace ~
34640 \InsetSpace ~
34641 \InsetSpace ~
34642 \InsetSpace ~
34643 \InsetSpace ~
34644 \InsetSpace ~
34645 \InsetSpace ~
34646  65\InsetSpace ~
34647 \InsetSpace ~
34648 \InsetSpace ~
34649 \InsetSpace ~
34650 \InsetSpace ~
34651 \InsetSpace ~
34652 \InsetSpace ~
34653 \InsetSpace ~
34654  mov\InsetSpace ~
34655 \InsetSpace ~
34656  _foo_hob1_1_1,a 
34657 \newline
34658 \InsetSpace ~
34659 \InsetSpace ~
34660 \InsetSpace ~
34661 \InsetSpace ~
34662 \InsetSpace ~
34663 \InsetSpace ~
34664 \InsetSpace ~
34665 \InsetSpace ~
34666 \InsetSpace ~
34667 \InsetSpace ~
34668 \InsetSpace ~
34669 \InsetSpace ~
34670 \InsetSpace ~
34671 \InsetSpace ~
34672 \InsetSpace ~
34673 \InsetSpace ~
34674 \InsetSpace ~
34675 \InsetSpace ~
34676 \InsetSpace ~
34677 \InsetSpace ~
34678 \InsetSpace ~
34679 \InsetSpace ~
34680 \InsetSpace ~
34681 \InsetSpace ~
34682 \InsetSpace ~
34683  66 ;\InsetSpace ~
34684  hob.c 8 
34685 \newline
34686 0011 E5*01\InsetSpace ~
34687 \InsetSpace ~
34688 \InsetSpace ~
34689 \InsetSpace ~
34690 \InsetSpace ~
34691 \InsetSpace ~
34692 \InsetSpace ~
34693 \InsetSpace ~
34694 \InsetSpace ~
34695 \InsetSpace ~
34696 \InsetSpace ~
34697 \InsetSpace ~
34698 \InsetSpace ~
34699 \InsetSpace ~
34700 \InsetSpace ~
34701
34702  67\InsetSpace ~
34703 \InsetSpace ~
34704 \InsetSpace ~
34705 \InsetSpace ~
34706 \InsetSpace ~
34707 \InsetSpace ~
34708 \InsetSpace ~
34709 \InsetSpace ~
34710  mov\InsetSpace ~
34711 \InsetSpace ~
34712  a,(_gint + 1) 
34713 \newline
34714 0013 33\InsetSpace ~
34715 \InsetSpace ~
34716 \InsetSpace ~
34717 \InsetSpace ~
34718 \InsetSpace ~
34719 \InsetSpace ~
34720 \InsetSpace ~
34721 \InsetSpace ~
34722 \InsetSpace ~
34723 \InsetSpace ~
34724 \InsetSpace ~
34725 \InsetSpace ~
34726 \InsetSpace ~
34727 \InsetSpace ~
34728 \InsetSpace ~
34729 \InsetSpace ~
34730 \InsetSpace ~
34731 \InsetSpace ~
34732  68\InsetSpace ~
34733 \InsetSpace ~
34734 \InsetSpace ~
34735 \InsetSpace ~
34736 \InsetSpace ~
34737 \InsetSpace ~
34738 \InsetSpace ~
34739 \InsetSpace ~
34740  rlc\InsetSpace ~
34741 \InsetSpace ~
34742  a 
34743 \newline
34744 0014 92*00\InsetSpace ~
34745 \InsetSpace ~
34746 \InsetSpace ~
34747 \InsetSpace ~
34748 \InsetSpace ~
34749 \InsetSpace ~
34750 \InsetSpace ~
34751 \InsetSpace ~
34752 \InsetSpace ~
34753 \InsetSpace ~
34754 \InsetSpace ~
34755 \InsetSpace ~
34756 \InsetSpace ~
34757 \InsetSpace ~
34758 \InsetSpace ~
34759  69\InsetSpace ~
34760 \InsetSpace ~
34761 \InsetSpace ~
34762 \InsetSpace ~
34763 \InsetSpace ~
34764 \InsetSpace ~
34765 \InsetSpace ~
34766 \InsetSpace ~
34767  mov\InsetSpace ~
34768 \InsetSpace ~
34769  _foo_hob2_1_1,c
34770  
34771 \newline
34772 \InsetSpace ~
34773 \InsetSpace ~
34774 \InsetSpace ~
34775 \InsetSpace ~
34776 \InsetSpace ~
34777 \InsetSpace ~
34778 \InsetSpace ~
34779 \InsetSpace ~
34780 \InsetSpace ~
34781 \InsetSpace ~
34782 \InsetSpace ~
34783 \InsetSpace ~
34784 \InsetSpace ~
34785 \InsetSpace ~
34786 \InsetSpace ~
34787 \InsetSpace ~
34788 \InsetSpace ~
34789 \InsetSpace ~
34790 \InsetSpace ~
34791 \InsetSpace ~
34792 \InsetSpace ~
34793 \InsetSpace ~
34794 \InsetSpace ~
34795 \InsetSpace ~
34796 \InsetSpace ~
34797  66 ;\InsetSpace ~
34798  hob.c 9 
34799 \newline
34800 0016 E5*01\InsetSpace ~
34801 \InsetSpace ~
34802 \InsetSpace ~
34803 \InsetSpace ~
34804 \InsetSpace ~
34805 \InsetSpace ~
34806 \InsetSpace ~
34807 \InsetSpace ~
34808 \InsetSpace ~
34809 \InsetSpace ~
34810 \InsetSpace ~
34811 \InsetSpace ~
34812 \InsetSpace ~
34813 \InsetSpace ~
34814 \InsetSpace ~
34815  67\InsetSpace ~
34816 \InsetSpace ~
34817 \InsetSpace ~
34818 \InsetSpace ~
34819 \InsetSpace ~
34820 \InsetSpace ~
34821 \InsetSpace ~
34822 \InsetSpace ~
34823  mov\InsetSpace ~
34824 \InsetSpace ~
34825  a,(_gint + 1) 
34826 \newline
34827 0018 33\InsetSpace ~
34828 \InsetSpace ~
34829 \InsetSpace ~
34830 \InsetSpace ~
34831 \InsetSpace ~
34832 \InsetSpace ~
34833 \InsetSpace ~
34834 \InsetSpace ~
34835 \InsetSpace ~
34836 \InsetSpace ~
34837 \InsetSpace ~
34838 \InsetSpace ~
34839 \InsetSpace ~
34840 \InsetSpace ~
34841 \InsetSpace ~
34842 \InsetSpace ~
34843 \InsetSpace ~
34844 \InsetSpace ~
34845  68\InsetSpace ~
34846 \InsetSpace ~
34847 \InsetSpace ~
34848 \InsetSpace ~
34849 \InsetSpace ~
34850 \InsetSpace ~
34851 \InsetSpace ~
34852 \InsetSpace ~
34853  rlc\InsetSpace ~
34854 \InsetSpace ~
34855  a 
34856 \newline
34857 0019 92*01\InsetSpace ~
34858 \InsetSpace ~
34859 \InsetSpace ~
34860 \InsetSpace ~
34861 \InsetSpace ~
34862 \InsetSpace ~
34863 \InsetSpace ~
34864 \InsetSpace ~
34865 \InsetSpace ~
34866 \InsetSpace ~
34867 \InsetSpace ~
34868 \InsetSpace ~
34869 \InsetSpace ~
34870 \InsetSpace ~
34871 \InsetSpace ~
34872
34873  69\InsetSpace ~
34874 \InsetSpace ~
34875 \InsetSpace ~
34876 \InsetSpace ~
34877 \InsetSpace ~
34878 \InsetSpace ~
34879 \InsetSpace ~
34880 \InsetSpace ~
34881  mov\InsetSpace ~
34882 \InsetSpace ~
34883  _foo_hob3_1_1,c 
34884 \newline
34885 \InsetSpace ~
34886 \InsetSpace ~
34887 \InsetSpace ~
34888 \InsetSpace ~
34889 \InsetSpace ~
34890 \InsetSpace ~
34891 \InsetSpace ~
34892 \InsetSpace ~
34893 \InsetSpace ~
34894 \InsetSpace ~
34895 \InsetSpace ~
34896 \InsetSpace ~
34897 \InsetSpace ~
34898 \InsetSpace ~
34899 \InsetSpace ~
34900 \InsetSpace ~
34901 \InsetSpace ~
34902 \InsetSpace ~
34903 \InsetSpace ~
34904 \InsetSpace ~
34905 \InsetSpace ~
34906 \InsetSpace ~
34907 \InsetSpace ~
34908 \InsetSpace ~
34909 \InsetSpace ~
34910  70 ;\InsetSpace ~
34911  hob.c 10 
34912 \newline
34913 001B E5*01\InsetSpace ~
34914 \InsetSpace ~
34915 \InsetSpace ~
34916 \InsetSpace ~
34917 \InsetSpace ~
34918 \InsetSpace ~
34919 \InsetSpace ~
34920 \InsetSpace ~
34921 \InsetSpace ~
34922 \InsetSpace ~
34923 \InsetSpace ~
34924 \InsetSpace ~
34925 \InsetSpace ~
34926 \InsetSpace ~
34927 \InsetSpace ~
34928  71\InsetSpace ~
34929 \InsetSpace ~
34930 \InsetSpace ~
34931 \InsetSpace ~
34932 \InsetSpace ~
34933 \InsetSpace ~
34934 \InsetSpace ~
34935 \InsetSpace ~
34936  mov\InsetSpace ~
34937 \InsetSpace ~
34938  a,(_gint + 1) 
34939 \newline
34940 001D
34941  03\InsetSpace ~
34942 \InsetSpace ~
34943 \InsetSpace ~
34944 \InsetSpace ~
34945 \InsetSpace ~
34946 \InsetSpace ~
34947 \InsetSpace ~
34948 \InsetSpace ~
34949 \InsetSpace ~
34950 \InsetSpace ~
34951 \InsetSpace ~
34952 \InsetSpace ~
34953 \InsetSpace ~
34954 \InsetSpace ~
34955 \InsetSpace ~
34956 \InsetSpace ~
34957 \InsetSpace ~
34958 \InsetSpace ~
34959  72\InsetSpace ~
34960 \InsetSpace ~
34961 \InsetSpace ~
34962 \InsetSpace ~
34963 \InsetSpace ~
34964 \InsetSpace ~
34965 \InsetSpace ~
34966 \InsetSpace ~
34967  rr\InsetSpace ~
34968 \InsetSpace ~
34969 \InsetSpace ~
34970  a 
34971 \newline
34972 001E 54 01\InsetSpace ~
34973 \InsetSpace ~
34974 \InsetSpace ~
34975 \InsetSpace ~
34976 \InsetSpace ~
34977 \InsetSpace ~
34978 \InsetSpace ~
34979 \InsetSpace ~
34980 \InsetSpace ~
34981 \InsetSpace ~
34982 \InsetSpace ~
34983 \InsetSpace ~
34984 \InsetSpace ~
34985 \InsetSpace ~
34986 \InsetSpace ~
34987  73\InsetSpace ~
34988 \InsetSpace ~
34989 \InsetSpace ~
34990 \InsetSpace ~
34991 \InsetSpace ~
34992 \InsetSpace ~
34993 \InsetSpace ~
34994 \InsetSpace ~
34995  anl\InsetSpace ~
34996 \InsetSpace ~
34997  a,#0x01 
34998 \newline
34999 0020 F5*03\InsetSpace ~
35000 \InsetSpace ~
35001 \InsetSpace ~
35002 \InsetSpace ~
35003 \InsetSpace ~
35004 \InsetSpace ~
35005 \InsetSpace ~
35006 \InsetSpace ~
35007 \InsetSpace ~
35008 \InsetSpace ~
35009 \InsetSpace ~
35010 \InsetSpace ~
35011 \InsetSpace ~
35012 \InsetSpace ~
35013 \InsetSpace ~
35014  74\InsetSpace ~
35015 \InsetSpace ~
35016 \InsetSpace ~
35017 \InsetSpace ~
35018 \InsetSpace ~
35019 \InsetSpace ~
35020 \InsetSpace ~
35021 \InsetSpace ~
35022  mov\InsetSpace ~
35023 \InsetSpace ~
35024  _foo_aob1_1_1,a
35025  
35026 \newline
35027 \InsetSpace ~
35028 \InsetSpace ~
35029 \InsetSpace ~
35030 \InsetSpace ~
35031 \InsetSpace ~
35032 \InsetSpace ~
35033 \InsetSpace ~
35034 \InsetSpace ~
35035 \InsetSpace ~
35036 \InsetSpace ~
35037 \InsetSpace ~
35038 \InsetSpace ~
35039 \InsetSpace ~
35040 \InsetSpace ~
35041 \InsetSpace ~
35042 \InsetSpace ~
35043 \InsetSpace ~
35044 \InsetSpace ~
35045 \InsetSpace ~
35046 \InsetSpace ~
35047 \InsetSpace ~
35048 \InsetSpace ~
35049 \InsetSpace ~
35050 \InsetSpace ~
35051 \InsetSpace ~
35052  75 ;\InsetSpace ~
35053  hob.c 11 
35054 \newline
35055 0022 E5*01\InsetSpace ~
35056 \InsetSpace ~
35057 \InsetSpace ~
35058 \InsetSpace ~
35059 \InsetSpace ~
35060 \InsetSpace ~
35061 \InsetSpace ~
35062 \InsetSpace ~
35063 \InsetSpace ~
35064 \InsetSpace ~
35065 \InsetSpace ~
35066 \InsetSpace ~
35067 \InsetSpace ~
35068 \InsetSpace ~
35069 \InsetSpace ~
35070  76\InsetSpace ~
35071 \InsetSpace ~
35072 \InsetSpace ~
35073 \InsetSpace ~
35074 \InsetSpace ~
35075 \InsetSpace ~
35076 \InsetSpace ~
35077 \InsetSpace ~
35078  mov\InsetSpace ~
35079 \InsetSpace ~
35080  a,(_gint + 1) 
35081 \newline
35082 0024 13\InsetSpace ~
35083 \InsetSpace ~
35084 \InsetSpace ~
35085 \InsetSpace ~
35086 \InsetSpace ~
35087 \InsetSpace ~
35088 \InsetSpace ~
35089 \InsetSpace ~
35090 \InsetSpace ~
35091 \InsetSpace ~
35092 \InsetSpace ~
35093 \InsetSpace ~
35094 \InsetSpace ~
35095 \InsetSpace ~
35096 \InsetSpace ~
35097 \InsetSpace ~
35098 \InsetSpace ~
35099 \InsetSpace ~
35100  77\InsetSpace ~
35101 \InsetSpace ~
35102 \InsetSpace ~
35103 \InsetSpace ~
35104 \InsetSpace ~
35105 \InsetSpace ~
35106 \InsetSpace ~
35107 \InsetSpace ~
35108  rrc\InsetSpace ~
35109 \InsetSpace ~
35110  a 
35111 \newline
35112 0025 92*02\InsetSpace ~
35113 \InsetSpace ~
35114 \InsetSpace ~
35115 \InsetSpace ~
35116 \InsetSpace ~
35117 \InsetSpace ~
35118 \InsetSpace ~
35119 \InsetSpace ~
35120 \InsetSpace ~
35121 \InsetSpace ~
35122 \InsetSpace ~
35123 \InsetSpace ~
35124 \InsetSpace ~
35125 \InsetSpace ~
35126 \InsetSpace ~
35127
35128  78\InsetSpace ~
35129 \InsetSpace ~
35130 \InsetSpace ~
35131 \InsetSpace ~
35132 \InsetSpace ~
35133 \InsetSpace ~
35134 \InsetSpace ~
35135 \InsetSpace ~
35136  mov\InsetSpace ~
35137 \InsetSpace ~
35138  _foo_aob2_1_1,c 
35139 \newline
35140 \InsetSpace ~
35141 \InsetSpace ~
35142 \InsetSpace ~
35143 \InsetSpace ~
35144 \InsetSpace ~
35145 \InsetSpace ~
35146 \InsetSpace ~
35147 \InsetSpace ~
35148 \InsetSpace ~
35149 \InsetSpace ~
35150 \InsetSpace ~
35151 \InsetSpace ~
35152 \InsetSpace ~
35153 \InsetSpace ~
35154 \InsetSpace ~
35155 \InsetSpace ~
35156 \InsetSpace ~
35157 \InsetSpace ~
35158 \InsetSpace ~
35159 \InsetSpace ~
35160 \InsetSpace ~
35161 \InsetSpace ~
35162 \InsetSpace ~
35163 \InsetSpace ~
35164 \InsetSpace ~
35165  79 ;\InsetSpace ~
35166  hob.c 12 
35167 \newline
35168 0027 E5*01\InsetSpace ~
35169 \InsetSpace ~
35170 \InsetSpace ~
35171 \InsetSpace ~
35172 \InsetSpace ~
35173 \InsetSpace ~
35174 \InsetSpace ~
35175 \InsetSpace ~
35176 \InsetSpace ~
35177 \InsetSpace ~
35178 \InsetSpace ~
35179 \InsetSpace ~
35180 \InsetSpace ~
35181 \InsetSpace ~
35182 \InsetSpace ~
35183  80\InsetSpace ~
35184 \InsetSpace ~
35185 \InsetSpace ~
35186 \InsetSpace ~
35187 \InsetSpace ~
35188 \InsetSpace ~
35189 \InsetSpace ~
35190 \InsetSpace ~
35191  mov\InsetSpace ~
35192 \InsetSpace ~
35193  a,(_gint + 1) 
35194 \newline
35195 0029
35196  A2 E3\InsetSpace ~
35197 \InsetSpace ~
35198 \InsetSpace ~
35199 \InsetSpace ~
35200 \InsetSpace ~
35201 \InsetSpace ~
35202 \InsetSpace ~
35203 \InsetSpace ~
35204 \InsetSpace ~
35205 \InsetSpace ~
35206 \InsetSpace ~
35207 \InsetSpace ~
35208 \InsetSpace ~
35209 \InsetSpace ~
35210 \InsetSpace ~
35211  81\InsetSpace ~
35212 \InsetSpace ~
35213 \InsetSpace ~
35214 \InsetSpace ~
35215 \InsetSpace ~
35216 \InsetSpace ~
35217 \InsetSpace ~
35218 \InsetSpace ~
35219  mov\InsetSpace ~
35220 \InsetSpace ~
35221  c,acc[3] 
35222 \newline
35223 002B 92*03\InsetSpace ~
35224 \InsetSpace ~
35225 \InsetSpace ~
35226 \InsetSpace ~
35227 \InsetSpace ~
35228 \InsetSpace ~
35229 \InsetSpace ~
35230 \InsetSpace ~
35231 \InsetSpace ~
35232 \InsetSpace ~
35233 \InsetSpace ~
35234 \InsetSpace ~
35235 \InsetSpace ~
35236 \InsetSpace ~
35237 \InsetSpace ~
35238  82\InsetSpace ~
35239 \InsetSpace ~
35240 \InsetSpace ~
35241 \InsetSpace ~
35242 \InsetSpace ~
35243 \InsetSpace ~
35244 \InsetSpace ~
35245 \InsetSpace ~
35246  mov\InsetSpace ~
35247 \InsetSpace ~
35248  _foo_aob3_1_1,c 
35249 \end_layout
35250
35251 \begin_layout Standard
35252 Other variations of these cases however will 
35253 \emph on
35254 not
35255 \emph default
35256  be recognized.
35257  They are standard C expressions, so I heartily recommend these be the only
35258  way to get the highest order bit, (it is portable).
35259  Of course it will be recognized even if it is embedded in other expressions,
35260  e.g.:
35261 \end_layout
35262
35263 \begin_layout Verse
35264
35265 \family typewriter
35266 xyz = gint + ((gint >> 15) & 1);
35267 \end_layout
35268
35269 \begin_layout Standard
35270 will still be recognized.
35271 \end_layout
35272
35273 \begin_layout Subsection
35274 Higher Order Byte
35275 \begin_inset LatexCommand \index{Higher Order Byte}
35276
35277 \end_inset
35278
35279  / Higher Order Word
35280 \begin_inset LatexCommand \index{Higher Order Word}
35281
35282 \end_inset
35283
35284
35285 \end_layout
35286
35287 \begin_layout Standard
35288 It is also frequently required to obtain a higher order byte or word of
35289  a larger integral type (long, int or short types).
35290  SDCC recognizes the following expressions to yield the higher order byte
35291  or word and generates optimized code for it, e.g.:
35292 \end_layout
35293
35294 \begin_layout Verse
35295
35296 \family typewriter
35297 unsigned int gint; 
35298 \newline
35299 unsigned long int glong; 
35300 \newline
35301
35302 \newline
35303 foo () { 
35304 \newline
35305 \InsetSpace ~
35306 \InsetSpace ~
35307 unsigned char hob1,
35308  hob2; 
35309 \newline
35310 \InsetSpace ~
35311 \InsetSpace ~
35312 unsigned int how1, how2; 
35313 \newline
35314 \InsetSpace ~
35315 \InsetSpace ~
35316 ...
35317  
35318 \newline
35319 \InsetSpace ~
35320 \InsetSpace ~
35321 hob1 = (gint >> 8) & 0xFF; 
35322 \newline
35323 \InsetSpace ~
35324 \InsetSpace ~
35325 hob2 = glong >> 24; 
35326 \newline
35327 \InsetSpace ~
35328 \InsetSpace ~
35329 how1 = (glong >> 16) & 0xFFFF;
35330  
35331 \newline
35332 \InsetSpace ~
35333 \InsetSpace ~
35334 how2 = glong >> 8; 
35335 \newline
35336 \InsetSpace ~
35337 \InsetSpace ~
35338 ..
35339  
35340 \newline
35341 }
35342 \end_layout
35343
35344 \begin_layout Standard
35345 will generate the following code:
35346 \end_layout
35347
35348 \begin_layout Verse
35349
35350 \family typewriter
35351 \InsetSpace ~
35352 \InsetSpace ~
35353 \InsetSpace ~
35354 \InsetSpace ~
35355 \InsetSpace ~
35356 \InsetSpace ~
35357 \InsetSpace ~
35358 \InsetSpace ~
35359 \InsetSpace ~
35360 \InsetSpace ~
35361 \InsetSpace ~
35362 \InsetSpace ~
35363 \InsetSpace ~
35364 \InsetSpace ~
35365 \InsetSpace ~
35366 \InsetSpace ~
35367 \InsetSpace ~
35368 \InsetSpace ~
35369 \InsetSpace ~
35370 \InsetSpace ~
35371 \InsetSpace ~
35372 \InsetSpace ~
35373 \InsetSpace ~
35374 \InsetSpace ~
35375 \InsetSpace ~
35376  91 ;\InsetSpace ~
35377  hob.c 15 
35378 \newline
35379 0037 85*01*06\InsetSpace ~
35380 \InsetSpace ~
35381 \InsetSpace ~
35382 \InsetSpace ~
35383 \InsetSpace ~
35384 \InsetSpace ~
35385 \InsetSpace ~
35386 \InsetSpace ~
35387 \InsetSpace ~
35388 \InsetSpace ~
35389 \InsetSpace ~
35390 \InsetSpace ~
35391  92\InsetSpace ~
35392 \InsetSpace ~
35393 \InsetSpace ~
35394 \InsetSpace ~
35395 \InsetSpace ~
35396 \InsetSpace ~
35397 \InsetSpace ~
35398 \InsetSpace ~
35399  mov\InsetSpace ~
35400 \InsetSpace ~
35401  _foo_hob1_1_1,(_gint + 1) 
35402 \newline
35403 \InsetSpace ~
35404 \InsetSpace ~
35405 \InsetSpace ~
35406 \InsetSpace ~
35407 \InsetSpace ~
35408 \InsetSpace ~
35409 \InsetSpace ~
35410 \InsetSpace ~
35411 \InsetSpace ~
35412 \InsetSpace ~
35413 \InsetSpace ~
35414 \InsetSpace ~
35415 \InsetSpace ~
35416 \InsetSpace ~
35417 \InsetSpace ~
35418 \InsetSpace ~
35419 \InsetSpace ~
35420 \InsetSpace ~
35421 \InsetSpace ~
35422 \InsetSpace ~
35423 \InsetSpace ~
35424 \InsetSpace ~
35425 \InsetSpace ~
35426 \InsetSpace ~
35427 \InsetSpace ~
35428  93 ;\InsetSpace ~
35429  hob.c
35430  16 
35431 \newline
35432 003A 85*05*07\InsetSpace ~
35433 \InsetSpace ~
35434 \InsetSpace ~
35435 \InsetSpace ~
35436 \InsetSpace ~
35437 \InsetSpace ~
35438 \InsetSpace ~
35439 \InsetSpace ~
35440 \InsetSpace ~
35441 \InsetSpace ~
35442 \InsetSpace ~
35443 \InsetSpace ~
35444  94\InsetSpace ~
35445 \InsetSpace ~
35446 \InsetSpace ~
35447 \InsetSpace ~
35448 \InsetSpace ~
35449 \InsetSpace ~
35450 \InsetSpace ~
35451 \InsetSpace ~
35452  mov\InsetSpace ~
35453 \InsetSpace ~
35454  _foo_hob2_1_1,(_glong + 3) 
35455 \newline
35456 \InsetSpace ~
35457 \InsetSpace ~
35458 \InsetSpace ~
35459 \InsetSpace ~
35460 \InsetSpace ~
35461 \InsetSpace ~
35462 \InsetSpace ~
35463 \InsetSpace ~
35464 \InsetSpace ~
35465 \InsetSpace ~
35466 \InsetSpace ~
35467 \InsetSpace ~
35468 \InsetSpace ~
35469 \InsetSpace ~
35470 \InsetSpace ~
35471 \InsetSpace ~
35472 \InsetSpace ~
35473 \InsetSpace ~
35474 \InsetSpace ~
35475 \InsetSpace ~
35476 \InsetSpace ~
35477 \InsetSpace ~
35478 \InsetSpace ~
35479 \InsetSpace ~
35480 \InsetSpace ~
35481  95 ;\InsetSpace ~
35482  hob.c 17 
35483 \newline
35484 003D 85*04*08\InsetSpace ~
35485 \InsetSpace ~
35486 \InsetSpace ~
35487 \InsetSpace ~
35488 \InsetSpace ~
35489 \InsetSpace ~
35490 \InsetSpace ~
35491 \InsetSpace ~
35492 \InsetSpace ~
35493 \InsetSpace ~
35494 \InsetSpace ~
35495 \InsetSpace ~
35496
35497  96\InsetSpace ~
35498 \InsetSpace ~
35499 \InsetSpace ~
35500 \InsetSpace ~
35501 \InsetSpace ~
35502 \InsetSpace ~
35503 \InsetSpace ~
35504 \InsetSpace ~
35505  mov\InsetSpace ~
35506 \InsetSpace ~
35507  _foo_how1_1_1,(_glong + 2) 
35508 \newline
35509 0040 85*05*09\InsetSpace ~
35510 \InsetSpace ~
35511 \InsetSpace ~
35512 \InsetSpace ~
35513 \InsetSpace ~
35514 \InsetSpace ~
35515 \InsetSpace ~
35516 \InsetSpace ~
35517 \InsetSpace ~
35518 \InsetSpace ~
35519 \InsetSpace ~
35520 \InsetSpace ~
35521  97\InsetSpace ~
35522 \InsetSpace ~
35523 \InsetSpace ~
35524 \InsetSpace ~
35525 \InsetSpace ~
35526 \InsetSpace ~
35527 \InsetSpace ~
35528 \InsetSpace ~
35529  mov\InsetSpace ~
35530 \InsetSpace ~
35531  (_foo_how1_1_1 +
35532  1),(_glong + 3) 
35533 \newline
35534 0043 85*03*0A\InsetSpace ~
35535 \InsetSpace ~
35536 \InsetSpace ~
35537 \InsetSpace ~
35538 \InsetSpace ~
35539 \InsetSpace ~
35540 \InsetSpace ~
35541 \InsetSpace ~
35542 \InsetSpace ~
35543 \InsetSpace ~
35544 \InsetSpace ~
35545 \InsetSpace ~
35546  98\InsetSpace ~
35547 \InsetSpace ~
35548 \InsetSpace ~
35549 \InsetSpace ~
35550 \InsetSpace ~
35551 \InsetSpace ~
35552 \InsetSpace ~
35553 \InsetSpace ~
35554  mov\InsetSpace ~
35555 \InsetSpace ~
35556  _foo_how2_1_1,(_glong + 1) 
35557 \newline
35558 0046 85*04*0B\InsetSpace ~
35559 \InsetSpace ~
35560 \InsetSpace ~
35561 \InsetSpace ~
35562 \InsetSpace ~
35563 \InsetSpace ~
35564 \InsetSpace ~
35565 \InsetSpace ~
35566 \InsetSpace ~
35567 \InsetSpace ~
35568 \InsetSpace ~
35569 \InsetSpace ~
35570
35571  99\InsetSpace ~
35572 \InsetSpace ~
35573 \InsetSpace ~
35574 \InsetSpace ~
35575 \InsetSpace ~
35576 \InsetSpace ~
35577 \InsetSpace ~
35578 \InsetSpace ~
35579  mov\InsetSpace ~
35580 \InsetSpace ~
35581  (_foo_how2_1_1 + 1),(_glong + 2) 
35582 \end_layout
35583
35584 \begin_layout Standard
35585 Again, variations of these cases may 
35586 \emph on
35587 not
35588 \emph default
35589  be recognized.
35590  They are standard C expressions, so I heartily recommend these be the only
35591  way to get the higher order byte/word, (it is portable).
35592  Of course it will be recognized even if it is embedded in other expressions,
35593  e.g.:
35594 \end_layout
35595
35596 \begin_layout Verse
35597
35598 \family typewriter
35599 xyz = gint + ((gint >> 8) & 0xFF);
35600 \end_layout
35601
35602 \begin_layout Standard
35603 will still be recognized.
35604 \end_layout
35605
35606 \begin_layout Subsection
35607 Peephole Optimizer
35608 \begin_inset LatexCommand \label{sub:Peephole-Optimizer}
35609
35610 \end_inset
35611
35612
35613 \begin_inset LatexCommand \index{Peephole optimizer}
35614
35615 \end_inset
35616
35617
35618 \end_layout
35619
35620 \begin_layout Standard
35621 The compiler uses a rule based, pattern matching and re-writing mechanism
35622  for peep-hole optimization.
35623  It is inspired by 
35624 \emph on
35625 copt
35626 \emph default
35627  a peep-hole optimizer by Christopher W.
35628  Fraser (cwfraser\InsetSpace ~
35629 @\InsetSpace ~
35630 microsoft.com).
35631  A default set of rules are compiled into the compiler, additional rules
35632  may be added with the 
35633 \emph on
35634 -
35635 \begin_inset ERT
35636 status collapsed
35637
35638 \begin_layout Standard
35639
35640
35641 \backslash
35642 /
35643 \end_layout
35644
35645 \end_inset
35646
35647 -peep-file
35648 \begin_inset LatexCommand \index{-\\/-peep-file}
35649
35650 \end_inset
35651
35652  <filename>
35653 \emph default
35654  option.
35655  The rule language is best illustrated with examples.
35656 \end_layout
35657
35658 \begin_layout Verse
35659
35660 \family typewriter
35661 replace { 
35662 \newline
35663 \InsetSpace ~
35664 \InsetSpace ~
35665 mov %1,a 
35666 \newline
35667 \InsetSpace ~
35668 \InsetSpace ~
35669 mov a,%1
35670 \newline
35671 } by {
35672 \newline
35673 \InsetSpace ~
35674 \InsetSpace ~
35675 mov %1,a
35676 \newline
35677 }
35678 \end_layout
35679
35680 \begin_layout Standard
35681 The above rule will change the following assembly
35682 \begin_inset LatexCommand \index{Assembler routines}
35683
35684 \end_inset
35685
35686  sequence:
35687 \end_layout
35688
35689 \begin_layout Verse
35690
35691 \family typewriter
35692 mov r1,a 
35693 \newline
35694 mov a,r1
35695 \end_layout
35696
35697 \begin_layout Standard
35698 to
35699 \end_layout
35700
35701 \begin_layout Verse
35702
35703 \family typewriter
35704 mov r1,a
35705 \end_layout
35706
35707 \begin_layout Standard
35708 Note: All occurrences of a 
35709 \emph on
35710 %n
35711 \emph default
35712  (pattern variable) must denote the same string.
35713  With the above rule, the assembly sequence:
35714 \end_layout
35715
35716 \begin_layout Verse
35717
35718 \family typewriter
35719 mov r1,a 
35720 \newline
35721 mov a,r2
35722 \end_layout
35723
35724 \begin_layout Standard
35725 will remain unmodified.
35726 \newline
35727
35728 \newline
35729 Other special case optimizations may be added by the
35730  user (via 
35731 \emph on
35732 -
35733 \begin_inset ERT
35734 status collapsed
35735
35736 \begin_layout Standard
35737
35738
35739 \backslash
35740 /
35741 \end_layout
35742
35743 \end_inset
35744
35745 -peep-file option
35746 \emph default
35747 ).
35748  E.g.
35749  some variants of the 8051 MCU
35750 \begin_inset LatexCommand \index{MCS51 variants}
35751
35752 \end_inset
35753
35754  allow only 
35755 \family typewriter
35756 ajmp
35757 \family default
35758  and 
35759 \family typewriter
35760 acall
35761 \family default
35762 .
35763  The following two rules will change all 
35764 \family typewriter
35765 ljmp
35766 \family default
35767  and 
35768 \family typewriter
35769 lcall
35770 \family default
35771  to 
35772 \family typewriter
35773 ajmp
35774 \family default
35775  and 
35776 \family typewriter
35777 acall
35778 \end_layout
35779
35780 \begin_layout Verse
35781
35782 \family typewriter
35783 replace { lcall %1 } by { acall %1 } 
35784 \newline
35785 replace { ljmp %1 } by { ajmp %1 }
35786 \end_layout
35787
35788 \begin_layout Standard
35789 (NOTE: from version 2.7.3 on, you can use option -
35790 \emph on
35791
35792 \begin_inset ERT
35793 status collapsed
35794
35795 \begin_layout Standard
35796
35797
35798 \backslash
35799 /
35800 \end_layout
35801
35802 \end_inset
35803
35804
35805 \emph default
35806 -acall-ajmp
35807 \begin_inset LatexCommand \index{ajmp}
35808
35809 \end_inset
35810
35811 , which also takes care of aligning the interrupt vectors properly.)
35812 \newline
35813
35814 \end_layout
35815
35816 \begin_layout Standard
35817 The 
35818 \emph on
35819 inline-assembler code
35820 \emph default
35821  is also passed through the peep hole optimizer, thus the peephole optimizer
35822  can also be used as an assembly level macro expander.
35823  The rules themselves are MCU dependent whereas the rule language infra-structur
35824 e is MCU independent.
35825  Peephole optimization rules for other MCU can be easily programmed using
35826  the rule language.
35827 \newline
35828
35829 \newline
35830 The syntax for a rule is as follows:
35831 \end_layout
35832
35833 \begin_layout Verse
35834
35835 \family typewriter
35836 rule := replace [ restart ] '{' <assembly sequence> '
35837 \backslash
35838 n' 
35839 \newline
35840 \InsetSpace ~
35841  \InsetSpace ~
35842  \InsetSpace ~
35843  \InsetSpace ~
35844  \InsetSpace ~
35845  \InsetSpace ~
35846  \InsetSpace ~
35847  \InsetSpace ~
35848  \InsetSpace ~
35849  \InsetSpace ~
35850  \InsetSpace ~
35851  \InsetSpace ~
35852  \InsetSpace ~
35853  \InsetSpace ~
35854  '}' by '{' '
35855 \backslash
35856 n' 
35857 \newline
35858 \InsetSpace ~
35859  \InsetSpace ~
35860  \InsetSpace ~
35861  \InsetSpace ~
35862  \InsetSpace ~
35863  \InsetSpace ~
35864  \InsetSpace ~
35865  \InsetSpace ~
35866  \InsetSpace ~
35867  \InsetSpace ~
35868  \InsetSpace ~
35869  \InsetSpace ~
35870  \InsetSpace ~
35871  \InsetSpace ~
35872  \InsetSpace ~
35873  \InsetSpace ~
35874  <assembly sequence> '
35875 \backslash
35876 n' 
35877 \newline
35878 \InsetSpace ~
35879  \InsetSpace ~
35880  \InsetSpace ~
35881  \InsetSpace ~
35882  \InsetSpace ~
35883  \InsetSpace ~
35884  \InsetSpace ~
35885  \InsetSpace ~
35886  \InsetSpace ~
35887  \InsetSpace ~
35888  \InsetSpace ~
35889  \InsetSpace ~
35890  \InsetSpace ~
35891  \InsetSpace ~
35892  '}' [if <functionName> ] '
35893 \backslash
35894 n' 
35895 \end_layout
35896
35897 \begin_layout Standard
35898 <assembly sequence> := assembly instruction (each instruction including
35899  labels must be on a separate line).
35900 \newline
35901
35902 \newline
35903 The optimizer will apply to the rules
35904  one by one from the top in the sequence of their appearance, it will terminate
35905  when all rules are exhausted.
35906  If the 'restart' option is specified, then the optimizer will start matching
35907  the rules again from the top, this option for a rule is expensive (performance)
35908 , it is intended to be used in situations where a transformation will trigger
35909  the same rule again.
35910  An example of this (not a good one, it has side effects) is the following
35911  rule:
35912 \end_layout
35913
35914 \begin_layout Verse
35915
35916 \family typewriter
35917 replace restart { 
35918 \newline
35919 \InsetSpace ~
35920 \InsetSpace ~
35921 pop %1 
35922 \newline
35923 \InsetSpace ~
35924 \InsetSpace ~
35925 push %1 } by { 
35926 \newline
35927 \InsetSpace ~
35928 \InsetSpace ~
35929 ; nop 
35930 \newline
35931 }
35932 \end_layout
35933
35934 \begin_layout Standard
35935 Note that the replace pattern cannot be a blank, but can be a comment line.
35936  Without the 'restart' option only the innermost 'pop' 'push' pair would
35937  be eliminated, i.e.:
35938 \end_layout
35939
35940 \begin_layout Verse
35941
35942 \family typewriter
35943 pop ar1 
35944 \newline
35945 pop ar2 
35946 \newline
35947 push ar2 
35948 \newline
35949 push ar1
35950 \end_layout
35951
35952 \begin_layout Standard
35953 would result in:
35954 \end_layout
35955
35956 \begin_layout Verse
35957
35958 \family typewriter
35959 pop ar1 
35960 \newline
35961 ; nop 
35962 \newline
35963 push ar1
35964 \end_layout
35965
35966 \begin_layout Standard
35967
35968 \emph on
35969 with
35970 \emph default
35971  the restart option the rule will be applied again to the resulting code
35972  and then all the pop-push pairs will be eliminated to yield:
35973 \end_layout
35974
35975 \begin_layout Verse
35976
35977 \family typewriter
35978 ; nop 
35979 \newline
35980 ; nop
35981 \end_layout
35982
35983 \begin_layout Standard
35984 A conditional function can be attached to a rule.
35985  Attaching rules are somewhat more involved, let me illustrate this with
35986  an example.
35987 \end_layout
35988
35989 \begin_layout Verse
35990
35991 \family typewriter
35992 replace { 
35993 \newline
35994 \InsetSpace ~
35995  \InsetSpace ~
35996  \InsetSpace ~
35997 ljmp %5 
35998 \newline
35999 %2:
36000 \newline
36001 } by { 
36002 \newline
36003 \InsetSpace ~
36004  \InsetSpace ~
36005  \InsetSpace ~
36006 sjmp %5 
36007 \newline
36008 %2:
36009 \newline
36010 } if labelInRange
36011 \end_layout
36012
36013 \begin_layout Standard
36014 The optimizer does a look-up of a function name table defined in function
36015  
36016 \emph on
36017 callFuncByName
36018 \emph default
36019  in the source file SDCCpeeph.c, with the name 
36020 \emph on
36021 labelInRange
36022 \emph default
36023 .
36024  If it finds a corresponding entry the function is called.
36025  Note there can be no parameters specified for these functions, in this
36026  case the use of 
36027 \emph on
36028 %5
36029 \emph default
36030  is crucial, since the function 
36031 \emph on
36032 labelInRange
36033 \emph default
36034  expects to find the label in that particular variable (the hash table containin
36035 g the variable bindings is passed as a parameter).
36036  If you want to code more such functions, take a close look at the function
36037  labelInRange and the calling mechanism in source file SDCCpeeph.c.
36038  Currently implemented are 
36039 \emph on
36040 labelInRange, labelRefCount, labelIsReturnOnly, operandsNotSame, xramMovcOption,
36041  24bitMode, portIsDS390, 24bitModeAndPortDS390
36042 \emph default
36043  and 
36044 \emph on
36045 notVolatile
36046 \emph default
36047 .
36048 \end_layout
36049
36050 \begin_layout Standard
36051 I know this whole thing is a little kludgey, but maybe some day we will
36052  have some better means.
36053  If you are looking at this file, you will see the default rules that are
36054  compiled into the compiler, you can add your own rules in the default set
36055  there if you get tired of specifying the -
36056 \begin_inset ERT
36057 status collapsed
36058
36059 \begin_layout Standard
36060
36061
36062 \backslash
36063 /
36064 \end_layout
36065
36066 \end_inset
36067
36068 -peep-file option.
36069 \end_layout
36070
36071 \begin_layout Section
36072 ANSI-Compliance
36073 \begin_inset LatexCommand \index{ANSI-compliance}
36074
36075 \end_inset
36076
36077
36078 \begin_inset LatexCommand \label{sub:ANSI-Compliance}
36079
36080 \end_inset
36081
36082
36083 \end_layout
36084
36085 \begin_layout Standard
36086 The latest publically available version of the standard 
36087 \emph on
36088 ISO/IEC 9899 - Programming languages - C
36089 \emph default
36090  should be available at: 
36091 \begin_inset LatexCommand \url{http://www.open-std.org/jtc1/sc22/wg14/www/standards.html#9899}
36092
36093 \end_inset
36094
36095 .
36096 \newline
36097
36098 \end_layout
36099
36100 \begin_layout Standard
36101 Deviations from the compliance:
36102 \end_layout
36103
36104 \begin_layout Itemize
36105 functions are not reentrant
36106 \begin_inset LatexCommand \index{reentrant}
36107
36108 \end_inset
36109
36110  unless explicitly declared as such or the 
36111 \series bold
36112 -
36113 \begin_inset ERT
36114 status collapsed
36115
36116 \begin_layout Standard
36117
36118
36119 \backslash
36120 /
36121 \end_layout
36122
36123 \end_inset
36124
36125 -stack-auto
36126 \begin_inset LatexCommand \index{-\\/-stack-auto}
36127
36128 \end_inset
36129
36130
36131 \series default
36132  command line option is specified.
36133 \end_layout
36134
36135 \begin_layout Itemize
36136 structures
36137 \begin_inset LatexCommand \index{struct}
36138
36139 \end_inset
36140
36141  and unions
36142 \begin_inset LatexCommand \index{union}
36143
36144 \end_inset
36145
36146  cannot be assigned values directly, cannot be passed as function parameters
36147  or assigned to each other and cannot be a return value
36148 \begin_inset LatexCommand \index{return value}
36149
36150 \end_inset
36151
36152  from a function, e.g.:
36153 \end_layout
36154
36155 \begin_deeper
36156 \begin_layout Verse
36157
36158 \family typewriter
36159 struct s { ...
36160  }; 
36161 \newline
36162 struct s s1, s2; 
36163 \newline
36164 foo() 
36165 \newline
36166
36167 \newline
36168 \InsetSpace ~
36169 \InsetSpace ~
36170 \InsetSpace ~
36171 \InsetSpace ~
36172 ...
36173  
36174 \newline
36175 \InsetSpace ~
36176 \InsetSpace ~
36177 \InsetSpace ~
36178 \InsetSpace ~
36179 s1 = s2 ; /* is invalid in SDCC although allowed in ANSI */ 
36180 \newline
36181 \InsetSpace ~
36182 \InsetSpace ~
36183 \InsetSpace ~
36184 \InsetSpace ~
36185 ...
36186  
36187 \newline
36188 }
36189 \newline
36190
36191 \series bold
36192 struct
36193 \family default
36194 \series default
36195  
36196 \family typewriter
36197 s foo1 (
36198 \series bold
36199 struct
36200 \family default
36201 \series default
36202  
36203 \family typewriter
36204 s parms) /* invalid in SDCC although allowed in ANSI */
36205 \newline
36206
36207 \newline
36208 \InsetSpace ~
36209 \InsetSpace ~
36210 \InsetSpace ~
36211 \InsetSpace ~
36212 struct s rets;
36213  
36214 \newline
36215 \InsetSpace ~
36216 \InsetSpace ~
36217 \InsetSpace ~
36218 \InsetSpace ~
36219 ...
36220  
36221 \newline
36222 \InsetSpace ~
36223 \InsetSpace ~
36224 \InsetSpace ~
36225 \InsetSpace ~
36226 return rets; /* is invalid in SDCC although allowed in ANSI */ 
36227 \newline
36228 }
36229 \end_layout
36230
36231 \end_deeper
36232 \begin_layout Itemize
36233 initialization of structure arrays must be fully braced.
36234 \end_layout
36235
36236 \begin_deeper
36237 \begin_layout Verse
36238
36239 \family typewriter
36240 struct s { char x } a[] = {1, 2};\InsetSpace ~
36241 \InsetSpace ~
36242 \InsetSpace ~
36243 \InsetSpace ~
36244 \InsetSpace ~
36245 /* invalid in SDCC */
36246 \newline
36247 struct s { char x
36248  } a[] = {{1}, {2}}; /* OK */
36249 \end_layout
36250
36251 \end_deeper
36252 \begin_layout Itemize
36253 'long long
36254 \begin_inset LatexCommand \index{long long (not supported)}
36255
36256 \end_inset
36257
36258 ' (64 bit integers
36259 \begin_inset LatexCommand \index{int (64 bit) (not supported)}
36260
36261 \end_inset
36262
36263 ) not supported.
36264 \end_layout
36265
36266 \begin_layout Itemize
36267 'double
36268 \begin_inset LatexCommand \index{double (not supported)}
36269
36270 \end_inset
36271
36272 ' precision floating point 
36273 \begin_inset LatexCommand \index{Floating point support}
36274
36275 \end_inset
36276
36277 not supported.
36278 \end_layout
36279
36280 \begin_layout Itemize
36281 Old K&R style
36282 \begin_inset LatexCommand \index{K\\&R style}
36283
36284 \end_inset
36285
36286  function declarations are NOT allowed.
36287 \end_layout
36288
36289 \begin_deeper
36290 \begin_layout Verse
36291
36292 \family typewriter
36293 foo(i,j) /* this old style of function declarations */ 
36294 \newline
36295 int i,j; /* is valid
36296  in ANSI but not valid in SDCC */ 
36297 \newline
36298
36299 \newline
36300 \InsetSpace ~
36301 \InsetSpace ~
36302 \InsetSpace ~
36303 \InsetSpace ~
36304 ...
36305  
36306 \newline
36307 }
36308 \end_layout
36309
36310 \end_deeper
36311 \begin_layout Itemize
36312 Most enhancements in C99 are not supported, e.g.:
36313 \end_layout
36314
36315 \begin_deeper
36316 \begin_layout Verse
36317
36318 \family typewriter
36319 for (
36320 \series bold
36321 int
36322 \family default
36323 \series default
36324  
36325 \family typewriter
36326 i=0; i<10; i++) /* is invalid in SDCC although allowed in C99 */
36327 \end_layout
36328
36329 \end_deeper
36330 \begin_layout Itemize
36331 But some have been added recently in SDCC 2.7.0.
36332  They must be considered alpha quality however.
36333 \end_layout
36334
36335 \begin_deeper
36336 \begin_layout Verse
36337
36338 \family typewriter
36339 \series bold
36340 inline
36341 \begin_inset LatexCommand \index{inline (not supported)}
36342
36343 \end_inset
36344
36345
36346 \family default
36347 \series default
36348  
36349 \family typewriter
36350 int increment (int a) { return a+1; } /* inlines the increment without function
36351  call overhead */
36352 \newline
36353 int *
36354 \family default
36355  
36356 \family typewriter
36357 \series bold
36358 restrict
36359 \begin_inset LatexCommand \index{inline (not supported)}
36360
36361 \end_inset
36362
36363
36364 \family default
36365 \series default
36366  
36367 \family typewriter
36368 p; /* accepted but ignored */
36369 \end_layout
36370
36371 \end_deeper
36372 \begin_layout Itemize
36373 Certain words that are valid identifiers in the standard may be reserved
36374  words in SDCC unless the 
36375 \series bold
36376 -
36377 \begin_inset ERT
36378 status collapsed
36379
36380 \begin_layout Standard
36381
36382
36383 \backslash
36384 /
36385 \end_layout
36386
36387 \end_inset
36388
36389 -std-c89
36390 \begin_inset LatexCommand \index{-\\/-std-c89}
36391
36392 \end_inset
36393
36394  or -
36395 \begin_inset ERT
36396 status collapsed
36397
36398 \begin_layout Standard
36399
36400
36401 \backslash
36402 /
36403 \end_layout
36404
36405 \end_inset
36406
36407 -std-c99
36408 \begin_inset LatexCommand \index{-\\/-std-c99}
36409
36410 \end_inset
36411
36412
36413 \series default
36414  command line options are used.
36415  These may include (depending on the selected processor): 'at', 'banked',
36416  'bit', 'code', 'critical', 'data', 'eeprom', 'far', 'flash', 'idata', 'interrup
36417 t', 'near', 'nonbanked', 'pdata', 'reentrant', 'sbit', 'sfr', 'shadowregs',
36418  'sram', 'using', 'wparam', 'xdata', '_overlay', '_asm', '_endasm', and
36419  '_naked'.
36420  Compliant equivalents of these keywords are always available in a form
36421  that begin with two underscores
36422 \begin_inset LatexCommand \index{\\_\\_ (prefix for extended keywords)}
36423
36424 \end_inset
36425
36426 , f.e.
36427  '__data' instead of 'data'.
36428 \end_layout
36429
36430 \begin_layout Section
36431 Cyclomatic Complexity
36432 \begin_inset LatexCommand \index{Cyclomatic complexity}
36433
36434 \end_inset
36435
36436
36437 \end_layout
36438
36439 \begin_layout Standard
36440 Cyclomatic complexity of a function is defined as the number of independent
36441  paths the program can take during execution of the function.
36442  This is an important number since it defines the number test cases you
36443  have to generate to validate the function.
36444  The accepted industry standard for complexity number is 10, if the cyclomatic
36445  complexity reported by SDCC exceeds 10 you should think about simplification
36446  of the function logic.
36447  Note that the complexity level is not related to the number of lines of
36448  code in a function.
36449  Large functions can have low complexity, and small functions can have large
36450  complexity levels.
36451  
36452 \newline
36453
36454 \newline
36455 SDCC uses the following formula to compute the complexity:
36456 \newline
36457
36458 \end_layout
36459
36460 \begin_layout Standard
36461 complexity = (number of edges in control flow graph) - (number of nodes
36462  in control flow graph) + 2;
36463 \newline
36464
36465 \newline
36466 Having said that the industry standard is 10,
36467  you should be aware that in some cases it be may unavoidable to have a
36468  complexity level of less than 10.
36469  For example if you have switch statement with more than 10 case labels,
36470  each case label adds one to the complexity level.
36471  The complexity level is by no means an absolute measure of the algorithmic
36472  complexity of the function, it does however provide a good starting point
36473  for which functions you might look at for further optimization.
36474 \end_layout
36475
36476 \begin_layout Section
36477 Retargetting for other Processors
36478 \end_layout
36479
36480 \begin_layout Standard
36481 The issues for retargetting the compiler are far too numerous to be covered
36482  by this document.
36483  What follows is a brief description of each of the seven phases of the
36484  compiler and its MCU dependency.
36485 \end_layout
36486
36487 \begin_layout Itemize
36488 Parsing the source and building the annotated parse tree.
36489  This phase is largely MCU independent (except for the language extensions).
36490  Syntax & semantic checks are also done in this phase, along with some initial
36491  optimizations like back patching labels and the pattern matching optimizations
36492  like bit-rotation etc.
36493 \end_layout
36494
36495 \begin_layout Itemize
36496 The second phase involves generating an intermediate code which can be easy
36497  manipulated during the later phases.
36498  This phase is entirely MCU independent.
36499  The intermediate code generation assumes the target machine has unlimited
36500  number of registers, and designates them with the name iTemp.
36501  The compiler can be made to dump a human readable form of the code generated
36502  by using the -
36503 \begin_inset ERT
36504 status collapsed
36505
36506 \begin_layout Standard
36507
36508
36509 \backslash
36510 /
36511 \end_layout
36512
36513 \end_inset
36514
36515 -dumpraw option.
36516 \end_layout
36517
36518 \begin_layout Itemize
36519 This phase does the bulk of the standard optimizations and is also MCU independe
36520 nt.
36521  This phase can be broken down into several sub-phases:
36522 \newline
36523
36524 \newline
36525 Break down intermediate
36526  code (iCode) into basic blocks.
36527 \newline
36528 Do control flow & data flow analysis on the
36529  basic blocks.
36530 \newline
36531 Do local common subexpression elimination, then global subexpressio
36532 n elimination
36533 \newline
36534 Dead code elimination
36535 \newline
36536 Loop optimizations
36537 \newline
36538 If loop optimizations
36539  caused any changes then do 'global subexpression elimination' and 'dead
36540  code elimination' again.
36541 \end_layout
36542
36543 \begin_layout Itemize
36544 This phase determines the live-ranges; by live range I mean those iTemp
36545  variables defined by the compiler that still survive after all the optimization
36546 s.
36547  Live range analysis
36548 \begin_inset LatexCommand \index{Live range analysis}
36549
36550 \end_inset
36551
36552  is essential for register allocation, since these computation determines
36553  which of these iTemps will be assigned to registers, and for how long.
36554 \end_layout
36555
36556 \begin_layout Itemize
36557 Phase five is register allocation.
36558  There are two parts to this process.
36559 \newline
36560
36561 \newline
36562 The first part I call 'register packing'
36563  (for lack of a better term).
36564  In this case several MCU specific expression folding is done to reduce
36565  register pressure.
36566 \newline
36567
36568 \newline
36569 The second part is more MCU independent and deals with
36570  allocating registers to the remaining live ranges.
36571  A lot of MCU specific code does creep into this phase because of the limited
36572  number of index registers available in the 8051.
36573 \end_layout
36574
36575 \begin_layout Itemize
36576 The Code generation phase is (unhappily), entirely MCU dependent and very
36577  little (if any at all) of this code can be reused for other MCU.
36578  However the scheme for allocating a homogenized assembler operand for each
36579  iCode operand may be reused.
36580 \end_layout
36581
36582 \begin_layout Itemize
36583 As mentioned in the optimization section the peep-hole optimizer is rule
36584  based system, which can reprogrammed for other MCUs.
36585 \end_layout
36586
36587 \begin_layout Standard
36588 More information is available on SDCC Wiki
36589 \begin_inset LatexCommand \index{wiki}
36590
36591 \end_inset
36592
36593  (preliminary link 
36594 \begin_inset LatexCommand \url{http://sdcc.wiki.sourceforge.net/SDCC+internals+and+porting}
36595
36596 \end_inset
36597
36598 ) and in the thread 
36599 \begin_inset LatexCommand \url{http://sf.net/mailarchive/message.php?msg_id=13954144}
36600
36601 \end_inset
36602
36603  .
36604 \end_layout
36605
36606 \begin_layout Chapter
36607 Compiler internals
36608 \begin_inset LatexCommand \index{Compiler internals}
36609
36610 \end_inset
36611
36612
36613 \end_layout
36614
36615 \begin_layout Section
36616 The anatomy of the compiler
36617 \begin_inset LatexCommand \label{sub:The-anatomy-of}
36618
36619 \end_inset
36620
36621
36622 \end_layout
36623
36624 \begin_layout Standard
36625
36626 \shape italic
36627 This is an excerpt from an article published in Circuit Cellar Magazine
36628  in
36629 \shape default
36630  
36631 \series bold
36632 \shape italic
36633 August 2000
36634 \series default
36635 .
36636  It's a little outdated (the compiler is much more efficient now and user/develo
36637 per friendly), but pretty well exposes the guts of it all.
36638 \shape default
36639
36640 \newline
36641
36642 \newline
36643 The current version of SDCC can generate code for Intel 8051 and Z80 MCU.
36644  It is fairly easy to retarget for other 8-bit MCU.
36645  Here we take a look at some of the internals of the compiler.
36646  
36647 \end_layout
36648
36649 \begin_layout Paragraph*
36650 Parsing
36651 \begin_inset LatexCommand \index{Parsing}
36652
36653 \end_inset
36654
36655  
36656 \end_layout
36657
36658 \begin_layout Standard
36659 Parsing the input source file and creating an AST (Annotated Syntax Tree
36660 \begin_inset LatexCommand \index{Annotated syntax tree}
36661
36662 \end_inset
36663
36664 ).
36665  This phase also involves propagating types (annotating each node of the
36666  parse tree with type information) and semantic analysis.
36667  There are some MCU specific parsing rules.
36668  For example the storage classes, the extended storage classes are MCU specific
36669  while there may be a xdata storage class for 8051 there is no such storage
36670  class for z80 or Atmel AVR.
36671  SDCC allows MCU specific storage class extensions, i.e.
36672  xdata will be treated as a storage class specifier when parsing 8051 C
36673  code but will be treated as a C identifier when parsing z80 or ATMEL AVR
36674  C code.
36675 \end_layout
36676
36677 \begin_layout Paragraph*
36678 Generating iCode
36679 \begin_inset LatexCommand \index{iCode}
36680
36681 \end_inset
36682
36683
36684 \end_layout
36685
36686 \begin_layout Standard
36687 Intermediate code generation.
36688  In this phase the AST is broken down into three-operand form (iCode).
36689  These three operand forms are represented as doubly linked lists.
36690  ICode is the term given to the intermediate form generated by the compiler.
36691  ICode example section shows some examples of iCode generated for some simple
36692  C source functions.
36693 \end_layout
36694
36695 \begin_layout Paragraph*
36696 Optimizations
36697 \begin_inset LatexCommand \index{Optimizations}
36698
36699 \end_inset
36700
36701 .
36702 \end_layout
36703
36704 \begin_layout Standard
36705 Bulk of the target independent optimizations is performed in this phase.
36706  The optimizations include constant propagation, common sub-expression eliminati
36707 on, loop invariant code movement, strength reduction of loop induction variables
36708  and dead-code elimination.
36709 \end_layout
36710
36711 \begin_layout Paragraph*
36712 Live range analysis
36713 \begin_inset LatexCommand \index{Live range analysis}
36714
36715 \end_inset
36716
36717
36718 \end_layout
36719
36720 \begin_layout Standard
36721 During intermediate code generation phase, the compiler assumes the target
36722  machine has infinite number of registers and generates a lot of temporary
36723  variables.
36724  The live range computation determines the lifetime of each of these compiler-ge
36725 nerated temporaries.
36726  A picture speaks a thousand words.
36727  ICode example sections show the live range annotations for each of the
36728  operand.
36729  It is important to note here, each iCode is assigned a number in the order
36730  of its execution in the function.
36731  The live ranges are computed in terms of these numbers.
36732  The from number is the number of the iCode which first defines the operand
36733  and the to number signifies the iCode which uses this operand last.
36734 \end_layout
36735
36736 \begin_layout Paragraph*
36737 Register Allocation
36738 \begin_inset LatexCommand \index{Register allocation}
36739
36740 \end_inset
36741
36742
36743 \end_layout
36744
36745 \begin_layout Standard
36746 The register allocation determines the type and number of registers needed
36747  by each operand.
36748  In most MCUs only a few registers can be used for indirect addressing.
36749  In case of 8051 for example the registers R0 & R1 can be used to indirectly
36750  address the internal ram and DPTR to indirectly address the external ram.
36751  The compiler will try to allocate the appropriate register to pointer variables
36752  if it can.
36753  ICode example section shows the operands annotated with the registers assigned
36754  to them.
36755  The compiler will try to keep operands in registers as much as possible;
36756  there are several schemes the compiler uses to do achieve this.
36757  When the compiler runs out of registers the compiler will check to see
36758  if there are any live operands which is not used or defined in the current
36759  basic block being processed, if there are any found then it will push that
36760  operand and use the registers in this block, the operand will then be popped
36761  at the end of the basic block.
36762  
36763 \end_layout
36764
36765 \begin_layout Standard
36766 There are other MCU specific considerations in this phase.
36767  Some MCUs have an accumulator; very short-lived operands could be assigned
36768  to the accumulator instead of a general-purpose register.
36769 \end_layout
36770
36771 \begin_layout Paragraph*
36772 Code generation
36773 \end_layout
36774
36775 \begin_layout Standard
36776 Figure II gives a table of iCode
36777 \begin_inset LatexCommand \index{iCode}
36778
36779 \end_inset
36780
36781  operations supported by the compiler.
36782  The code generation involves translating these operations into corresponding
36783  assembly code for the processor.
36784  This sounds overly simple but that is the essence of code generation.
36785  Some of the iCode operations are generated on a MCU specific manner for
36786  example, the z80 port does not use registers to pass parameters so the
36787  SEND and RECV iCode operations will not be generated, and it also does
36788  not support JUMPTABLES.
36789  
36790 \newline
36791
36792 \end_layout
36793
36794 \begin_layout Standard
36795
36796 \size footnotesize
36797 Figure II 
36798 \begin_inset Tabular
36799 <lyxtabular version="3" rows="39" columns="4">
36800 <features islongtable="true" headBottomDL="true">
36801 <column alignment="block" valignment="top" leftline="true" width="13col%">
36802 <column alignment="left" valignment="top" leftline="true" width="13col%">
36803 <column alignment="block" valignment="top" leftline="true" width="22col%">
36804 <column alignment="block" valignment="top" leftline="true" rightline="true" width="40col%">
36805 <row topline="true" bottomline="true" endhead="true">
36806 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
36807 \begin_inset Text
36808
36809 \begin_layout Standard
36810
36811 \series bold
36812 iCode
36813 \series default
36814
36815 \begin_inset LatexCommand \index{iCode}
36816
36817 \end_inset
36818
36819
36820 \end_layout
36821
36822 \end_inset
36823 </cell>
36824 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
36825 \begin_inset Text
36826
36827 \begin_layout Standard
36828
36829 \series bold
36830 Operands
36831 \end_layout
36832
36833 \end_inset
36834 </cell>
36835 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
36836 \begin_inset Text
36837
36838 \begin_layout Standard
36839
36840 \series bold
36841 Description
36842 \end_layout
36843
36844 \end_inset
36845 </cell>
36846 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
36847 \begin_inset Text
36848
36849 \begin_layout Standard
36850
36851 \series bold
36852 C Equivalent
36853 \end_layout
36854
36855 \end_inset
36856 </cell>
36857 </row>
36858 <row topline="true">
36859 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
36860 \begin_inset Text
36861
36862 \begin_layout Standard
36863
36864 \size footnotesize
36865 '!'
36866 \end_layout
36867
36868 \end_inset
36869 </cell>
36870 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
36871 \begin_inset Text
36872
36873 \begin_layout Standard
36874
36875 \size footnotesize
36876 IC_LEFT() IC_RESULT()
36877 \end_layout
36878
36879 \end_inset
36880 </cell>
36881 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
36882 \begin_inset Text
36883
36884 \begin_layout Standard
36885
36886 \size footnotesize
36887 NOT operation 
36888 \end_layout
36889
36890 \end_inset
36891 </cell>
36892 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
36893 \begin_inset Text
36894
36895 \begin_layout Standard
36896
36897 \size footnotesize
36898 IC_RESULT = ! IC_LEFT;
36899 \end_layout
36900
36901 \end_inset
36902 </cell>
36903 </row>
36904 <row topline="true">
36905 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
36906 \begin_inset Text
36907
36908 \begin_layout Standard
36909
36910 \size footnotesize
36911 '~'
36912 \end_layout
36913
36914 \end_inset
36915 </cell>
36916 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
36917 \begin_inset Text
36918
36919 \begin_layout Standard
36920
36921 \size footnotesize
36922 IC_LEFT() IC_RESULT()
36923 \end_layout
36924
36925 \end_inset
36926 </cell>
36927 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
36928 \begin_inset Text
36929
36930 \begin_layout Standard
36931
36932 \size footnotesize
36933 Bitwise complement of 
36934 \end_layout
36935
36936 \end_inset
36937 </cell>
36938 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
36939 \begin_inset Text
36940
36941 \begin_layout Standard
36942
36943 \size footnotesize
36944 IC_RESULT = ~IC_LEFT;
36945 \end_layout
36946
36947 \end_inset
36948 </cell>
36949 </row>
36950 <row topline="true">
36951 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
36952 \begin_inset Text
36953
36954 \begin_layout Standard
36955
36956 \size footnotesize
36957 RRC
36958 \end_layout
36959
36960 \end_inset
36961 </cell>
36962 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
36963 \begin_inset Text
36964
36965 \begin_layout Standard
36966
36967 \size footnotesize
36968 IC_LEFT() IC_RESULT()
36969 \end_layout
36970
36971 \end_inset
36972 </cell>
36973 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
36974 \begin_inset Text
36975
36976 \begin_layout Standard
36977
36978 \size footnotesize
36979 Rotate right with carry
36980 \end_layout
36981
36982 \end_inset
36983 </cell>
36984 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
36985 \begin_inset Text
36986
36987 \begin_layout Standard
36988
36989 \size footnotesize
36990 IC_RESULT = (IC_LEFT << 1) | (IC_LEFT >> (sizeof(IC_LEFT)*8-1));
36991 \end_layout
36992
36993 \end_inset
36994 </cell>
36995 </row>
36996 <row topline="true">
36997 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
36998 \begin_inset Text
36999
37000 \begin_layout Standard
37001
37002 \size footnotesize
37003 RLC
37004 \end_layout
37005
37006 \end_inset
37007 </cell>
37008 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37009 \begin_inset Text
37010
37011 \begin_layout Standard
37012
37013 \size footnotesize
37014 IC_LEFT() IC_RESULT()
37015 \end_layout
37016
37017 \end_inset
37018 </cell>
37019 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37020 \begin_inset Text
37021
37022 \begin_layout Standard
37023
37024 \size footnotesize
37025 Rotate left with carry
37026 \end_layout
37027
37028 \end_inset
37029 </cell>
37030 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37031 \begin_inset Text
37032
37033 \begin_layout Standard
37034
37035 \size footnotesize
37036 IC_RESULT = (IC_LEFT << (sizeof(LC_LEFT)*8-1) ) | (IC_LEFT >> 1);
37037 \end_layout
37038
37039 \end_inset
37040 </cell>
37041 </row>
37042 <row topline="true">
37043 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37044 \begin_inset Text
37045
37046 \begin_layout Standard
37047
37048 \size footnotesize
37049 GETHBIT
37050 \end_layout
37051
37052 \end_inset
37053 </cell>
37054 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37055 \begin_inset Text
37056
37057 \begin_layout Standard
37058
37059 \size footnotesize
37060 IC_LEFT() IC_RESULT()
37061 \end_layout
37062
37063 \end_inset
37064 </cell>
37065 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37066 \begin_inset Text
37067
37068 \begin_layout Standard
37069
37070 \size footnotesize
37071 Get the highest order bit of IC_LEFT
37072 \end_layout
37073
37074 \end_inset
37075 </cell>
37076 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37077 \begin_inset Text
37078
37079 \begin_layout Standard
37080
37081 \size footnotesize
37082 IC_RESULT = (IC_LEFT >> (sizeof(IC_LEFT)*8 -1));
37083 \end_layout
37084
37085 \end_inset
37086 </cell>
37087 </row>
37088 <row topline="true">
37089 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37090 \begin_inset Text
37091
37092 \begin_layout Standard
37093
37094 \size footnotesize
37095 UNARYMINUS
37096 \end_layout
37097
37098 \end_inset
37099 </cell>
37100 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37101 \begin_inset Text
37102
37103 \begin_layout Standard
37104
37105 \size footnotesize
37106 IC_LEFT() IC_RESULT()
37107 \end_layout
37108
37109 \end_inset
37110 </cell>
37111 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37112 \begin_inset Text
37113
37114 \begin_layout Standard
37115
37116 \size footnotesize
37117 Unary minus
37118 \end_layout
37119
37120 \end_inset
37121 </cell>
37122 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37123 \begin_inset Text
37124
37125 \begin_layout Standard
37126
37127 \size footnotesize
37128 IC_RESULT = - IC_LEFT;
37129 \end_layout
37130
37131 \end_inset
37132 </cell>
37133 </row>
37134 <row topline="true">
37135 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37136 \begin_inset Text
37137
37138 \begin_layout Standard
37139
37140 \size footnotesize
37141 IPUSH
37142 \end_layout
37143
37144 \end_inset
37145 </cell>
37146 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37147 \begin_inset Text
37148
37149 \begin_layout Standard
37150
37151 \size footnotesize
37152 IC_LEFT()
37153 \end_layout
37154
37155 \end_inset
37156 </cell>
37157 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37158 \begin_inset Text
37159
37160 \begin_layout Standard
37161
37162 \size footnotesize
37163 Push the operand into stack
37164 \end_layout
37165
37166 \end_inset
37167 </cell>
37168 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37169 \begin_inset Text
37170
37171 \begin_layout Standard
37172
37173 \size footnotesize
37174 NONE
37175 \end_layout
37176
37177 \end_inset
37178 </cell>
37179 </row>
37180 <row topline="true">
37181 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37182 \begin_inset Text
37183
37184 \begin_layout Standard
37185
37186 \size footnotesize
37187 IPOP
37188 \end_layout
37189
37190 \end_inset
37191 </cell>
37192 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37193 \begin_inset Text
37194
37195 \begin_layout Standard
37196
37197 \size footnotesize
37198 IC_LEFT()
37199 \end_layout
37200
37201 \end_inset
37202 </cell>
37203 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37204 \begin_inset Text
37205
37206 \begin_layout Standard
37207
37208 \size footnotesize
37209 Pop the operand from the stack 
37210 \end_layout
37211
37212 \end_inset
37213 </cell>
37214 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37215 \begin_inset Text
37216
37217 \begin_layout Standard
37218
37219 \size footnotesize
37220 NONE
37221 \end_layout
37222
37223 \end_inset
37224 </cell>
37225 </row>
37226 <row topline="true">
37227 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37228 \begin_inset Text
37229
37230 \begin_layout Standard
37231
37232 \size footnotesize
37233 CALL
37234 \end_layout
37235
37236 \end_inset
37237 </cell>
37238 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37239 \begin_inset Text
37240
37241 \begin_layout Standard
37242
37243 \size footnotesize
37244 IC_LEFT() IC_RESULT()
37245 \end_layout
37246
37247 \end_inset
37248 </cell>
37249 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37250 \begin_inset Text
37251
37252 \begin_layout Standard
37253
37254 \size footnotesize
37255 Call the function represented by IC_LEFT 
37256 \end_layout
37257
37258 \end_inset
37259 </cell>
37260 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37261 \begin_inset Text
37262
37263 \begin_layout Standard
37264
37265 \size footnotesize
37266 IC_RESULT = IC_LEFT();
37267 \end_layout
37268
37269 \end_inset
37270 </cell>
37271 </row>
37272 <row topline="true">
37273 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37274 \begin_inset Text
37275
37276 \begin_layout Standard
37277
37278 \size footnotesize
37279 PCALL
37280 \end_layout
37281
37282 \end_inset
37283 </cell>
37284 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37285 \begin_inset Text
37286
37287 \begin_layout Standard
37288
37289 \size footnotesize
37290 IC_LEFT() IC_RESULT()
37291 \end_layout
37292
37293 \end_inset
37294 </cell>
37295 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37296 \begin_inset Text
37297
37298 \begin_layout Standard
37299
37300 \size footnotesize
37301 Call via function pointer
37302 \end_layout
37303
37304 \end_inset
37305 </cell>
37306 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37307 \begin_inset Text
37308
37309 \begin_layout Standard
37310
37311 \size footnotesize
37312 IC_RESULT = (*IC_LEFT)();
37313 \end_layout
37314
37315 \end_inset
37316 </cell>
37317 </row>
37318 <row topline="true">
37319 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37320 \begin_inset Text
37321
37322 \begin_layout Standard
37323
37324 \size footnotesize
37325 RETURN
37326 \end_layout
37327
37328 \end_inset
37329 </cell>
37330 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37331 \begin_inset Text
37332
37333 \begin_layout Standard
37334
37335 \size footnotesize
37336 IC_LEFT()
37337 \end_layout
37338
37339 \end_inset
37340 </cell>
37341 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37342 \begin_inset Text
37343
37344 \begin_layout Standard
37345
37346 \size footnotesize
37347 Return the value in operand IC_LEFT 
37348 \end_layout
37349
37350 \end_inset
37351 </cell>
37352 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37353 \begin_inset Text
37354
37355 \begin_layout Standard
37356
37357 \size footnotesize
37358 return IC_LEFT;
37359 \end_layout
37360
37361 \end_inset
37362 </cell>
37363 </row>
37364 <row topline="true">
37365 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37366 \begin_inset Text
37367
37368 \begin_layout Standard
37369
37370 \size footnotesize
37371 LABEL
37372 \end_layout
37373
37374 \end_inset
37375 </cell>
37376 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37377 \begin_inset Text
37378
37379 \begin_layout Standard
37380
37381 \size footnotesize
37382 IC_LABEL() 
37383 \end_layout
37384
37385 \end_inset
37386 </cell>
37387 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37388 \begin_inset Text
37389
37390 \begin_layout Standard
37391
37392 \size footnotesize
37393 Label
37394 \end_layout
37395
37396 \end_inset
37397 </cell>
37398 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37399 \begin_inset Text
37400
37401 \begin_layout Standard
37402
37403 \size footnotesize
37404 IC_LABEL:
37405 \end_layout
37406
37407 \end_inset
37408 </cell>
37409 </row>
37410 <row topline="true">
37411 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37412 \begin_inset Text
37413
37414 \begin_layout Standard
37415
37416 \size footnotesize
37417 GOTO
37418 \end_layout
37419
37420 \end_inset
37421 </cell>
37422 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37423 \begin_inset Text
37424
37425 \begin_layout Standard
37426
37427 \size footnotesize
37428 IC_LABEL() 
37429 \end_layout
37430
37431 \end_inset
37432 </cell>
37433 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37434 \begin_inset Text
37435
37436 \begin_layout Standard
37437
37438 \size footnotesize
37439 Goto label
37440 \end_layout
37441
37442 \end_inset
37443 </cell>
37444 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37445 \begin_inset Text
37446
37447 \begin_layout Standard
37448
37449 \size footnotesize
37450 goto IC_LABEL();
37451 \end_layout
37452
37453 \end_inset
37454 </cell>
37455 </row>
37456 <row topline="true">
37457 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37458 \begin_inset Text
37459
37460 \begin_layout Standard
37461
37462 \size footnotesize
37463 '+'
37464 \end_layout
37465
37466 \end_inset
37467 </cell>
37468 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37469 \begin_inset Text
37470
37471 \begin_layout Standard
37472
37473 \size footnotesize
37474 IC_LEFT() IC_RIGHT() IC_RESULT()
37475 \end_layout
37476
37477 \end_inset
37478 </cell>
37479 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37480 \begin_inset Text
37481
37482 \begin_layout Standard
37483
37484 \size footnotesize
37485 Addition
37486 \end_layout
37487
37488 \end_inset
37489 </cell>
37490 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37491 \begin_inset Text
37492
37493 \begin_layout Standard
37494
37495 \size footnotesize
37496 IC_RESULT = IC_LEFT + IC_RIGHT
37497 \end_layout
37498
37499 \end_inset
37500 </cell>
37501 </row>
37502 <row topline="true">
37503 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37504 \begin_inset Text
37505
37506 \begin_layout Standard
37507
37508 \size footnotesize
37509 '-'
37510 \end_layout
37511
37512 \end_inset
37513 </cell>
37514 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37515 \begin_inset Text
37516
37517 \begin_layout Standard
37518
37519 \size footnotesize
37520 IC_LEFT() IC_RIGHT() IC_RESULT()
37521 \end_layout
37522
37523 \end_inset
37524 </cell>
37525 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37526 \begin_inset Text
37527
37528 \begin_layout Standard
37529
37530 \size footnotesize
37531 Subtraction
37532 \end_layout
37533
37534 \end_inset
37535 </cell>
37536 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37537 \begin_inset Text
37538
37539 \begin_layout Standard
37540
37541 \size footnotesize
37542 IC_RESULT = IC_LEFT - IC_RIGHT 
37543 \end_layout
37544
37545 \end_inset
37546 </cell>
37547 </row>
37548 <row topline="true">
37549 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37550 \begin_inset Text
37551
37552 \begin_layout Standard
37553
37554 \size footnotesize
37555 '*'
37556 \end_layout
37557
37558 \end_inset
37559 </cell>
37560 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37561 \begin_inset Text
37562
37563 \begin_layout Standard
37564
37565 \size footnotesize
37566 IC_LEFT() IC_RIGHT() IC_RESULT()
37567 \end_layout
37568
37569 \end_inset
37570 </cell>
37571 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37572 \begin_inset Text
37573
37574 \begin_layout Standard
37575
37576 \size footnotesize
37577 Multiplication 
37578 \end_layout
37579
37580 \end_inset
37581 </cell>
37582 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37583 \begin_inset Text
37584
37585 \begin_layout Standard
37586
37587 \size footnotesize
37588 IC_RESULT = IC_LEFT * IC_RIGHT;
37589 \end_layout
37590
37591 \end_inset
37592 </cell>
37593 </row>
37594 <row topline="true">
37595 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37596 \begin_inset Text
37597
37598 \begin_layout Standard
37599
37600 \size footnotesize
37601 '/'
37602 \end_layout
37603
37604 \end_inset
37605 </cell>
37606 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37607 \begin_inset Text
37608
37609 \begin_layout Standard
37610
37611 \size footnotesize
37612 IC_LEFT() IC_RIGHT() IC_RESULT()
37613 \end_layout
37614
37615 \end_inset
37616 </cell>
37617 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37618 \begin_inset Text
37619
37620 \begin_layout Standard
37621
37622 \size footnotesize
37623 Division
37624 \end_layout
37625
37626 \end_inset
37627 </cell>
37628 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37629 \begin_inset Text
37630
37631 \begin_layout Standard
37632
37633 \size footnotesize
37634 IC_RESULT = IC_LEFT / IC_RIGHT;
37635 \end_layout
37636
37637 \end_inset
37638 </cell>
37639 </row>
37640 <row topline="true">
37641 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37642 \begin_inset Text
37643
37644 \begin_layout Standard
37645
37646 \size footnotesize
37647 '%'
37648 \end_layout
37649
37650 \end_inset
37651 </cell>
37652 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37653 \begin_inset Text
37654
37655 \begin_layout Standard
37656
37657 \size footnotesize
37658 IC_LEFT() IC_RIGHT() IC_RESULT()
37659 \end_layout
37660
37661 \end_inset
37662 </cell>
37663 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37664 \begin_inset Text
37665
37666 \begin_layout Standard
37667
37668 \size footnotesize
37669 Modulus
37670 \end_layout
37671
37672 \end_inset
37673 </cell>
37674 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37675 \begin_inset Text
37676
37677 \begin_layout Standard
37678
37679 \size footnotesize
37680 IC_RESULT = IC_LEFT % IC_RIGHT;
37681 \end_layout
37682
37683 \end_inset
37684 </cell>
37685 </row>
37686 <row topline="true">
37687 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37688 \begin_inset Text
37689
37690 \begin_layout Standard
37691
37692 \size footnotesize
37693 '<'
37694 \end_layout
37695
37696 \end_inset
37697 </cell>
37698 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37699 \begin_inset Text
37700
37701 \begin_layout Standard
37702
37703 \size footnotesize
37704 IC_LEFT() IC_RIGHT() IC_RESULT()
37705 \end_layout
37706
37707 \end_inset
37708 </cell>
37709 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37710 \begin_inset Text
37711
37712 \begin_layout Standard
37713
37714 \size footnotesize
37715 Less than
37716 \end_layout
37717
37718 \end_inset
37719 </cell>
37720 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37721 \begin_inset Text
37722
37723 \begin_layout Standard
37724
37725 \size footnotesize
37726 IC_RESULT = IC_LEFT < IC_RIGHT;
37727 \end_layout
37728
37729 \end_inset
37730 </cell>
37731 </row>
37732 <row topline="true">
37733 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37734 \begin_inset Text
37735
37736 \begin_layout Standard
37737
37738 \size footnotesize
37739 '>'
37740 \end_layout
37741
37742 \end_inset
37743 </cell>
37744 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37745 \begin_inset Text
37746
37747 \begin_layout Standard
37748
37749 \size footnotesize
37750 IC_LEFT() IC_RIGHT() IC_RESULT()
37751 \end_layout
37752
37753 \end_inset
37754 </cell>
37755 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37756 \begin_inset Text
37757
37758 \begin_layout Standard
37759
37760 \size footnotesize
37761 Greater than 
37762 \end_layout
37763
37764 \end_inset
37765 </cell>
37766 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37767 \begin_inset Text
37768
37769 \begin_layout Standard
37770
37771 \size footnotesize
37772 IC_RESULT = IC_LEFT > IC_RIGHT;
37773 \end_layout
37774
37775 \end_inset
37776 </cell>
37777 </row>
37778 <row topline="true">
37779 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37780 \begin_inset Text
37781
37782 \begin_layout Standard
37783
37784 \size footnotesize
37785 EQ_OP
37786 \end_layout
37787
37788 \end_inset
37789 </cell>
37790 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37791 \begin_inset Text
37792
37793 \begin_layout Standard
37794
37795 \size footnotesize
37796 IC_LEFT() IC_RIGHT() IC_RESULT()
37797 \end_layout
37798
37799 \end_inset
37800 </cell>
37801 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37802 \begin_inset Text
37803
37804 \begin_layout Standard
37805
37806 \size footnotesize
37807 Equal to 
37808 \end_layout
37809
37810 \end_inset
37811 </cell>
37812 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37813 \begin_inset Text
37814
37815 \begin_layout Standard
37816
37817 \size footnotesize
37818 IC_RESULT = IC_LEFT == IC_RIGHT;
37819 \end_layout
37820
37821 \end_inset
37822 </cell>
37823 </row>
37824 <row topline="true">
37825 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37826 \begin_inset Text
37827
37828 \begin_layout Standard
37829
37830 \size footnotesize
37831 AND_OP
37832 \end_layout
37833
37834 \end_inset
37835 </cell>
37836 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37837 \begin_inset Text
37838
37839 \begin_layout Standard
37840
37841 \size footnotesize
37842 IC_LEFT() IC_RIGHT() IC_RESULT() 
37843 \end_layout
37844
37845 \end_inset
37846 </cell>
37847 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37848 \begin_inset Text
37849
37850 \begin_layout Standard
37851
37852 \size footnotesize
37853 Logical and operation
37854 \end_layout
37855
37856 \end_inset
37857 </cell>
37858 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37859 \begin_inset Text
37860
37861 \begin_layout Standard
37862
37863 \size footnotesize
37864 IC_RESULT = IC_LEFT && IC_RIGHT; 
37865 \end_layout
37866
37867 \end_inset
37868 </cell>
37869 </row>
37870 <row topline="true">
37871 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37872 \begin_inset Text
37873
37874 \begin_layout Standard
37875
37876 \size footnotesize
37877 OR_OP
37878 \end_layout
37879
37880 \end_inset
37881 </cell>
37882 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37883 \begin_inset Text
37884
37885 \begin_layout Standard
37886
37887 \size footnotesize
37888 IC_LEFT() IC_RIGHT() IC_RESULT() 
37889 \end_layout
37890
37891 \end_inset
37892 </cell>
37893 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37894 \begin_inset Text
37895
37896 \begin_layout Standard
37897
37898 \size footnotesize
37899 Logical or operation 
37900 \end_layout
37901
37902 \end_inset
37903 </cell>
37904 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37905 \begin_inset Text
37906
37907 \begin_layout Standard
37908
37909 \size footnotesize
37910 IC_RESULT = IC_LEFT || IC_RIGHT; 
37911 \end_layout
37912
37913 \end_inset
37914 </cell>
37915 </row>
37916 <row topline="true">
37917 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37918 \begin_inset Text
37919
37920 \begin_layout Standard
37921
37922 \size footnotesize
37923 '^'
37924 \end_layout
37925
37926 \end_inset
37927 </cell>
37928 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37929 \begin_inset Text
37930
37931 \begin_layout Standard
37932
37933 \size footnotesize
37934 IC_LEFT() IC_RIGHT() IC_RESULT() 
37935 \end_layout
37936
37937 \end_inset
37938 </cell>
37939 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37940 \begin_inset Text
37941
37942 \begin_layout Standard
37943
37944 \size footnotesize
37945 Exclusive OR
37946 \end_layout
37947
37948 \end_inset
37949 </cell>
37950 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37951 \begin_inset Text
37952
37953 \begin_layout Standard
37954
37955 \size footnotesize
37956 IC_RESULT = IC_LEFT ^ IC_RIGHT;
37957 \end_layout
37958
37959 \end_inset
37960 </cell>
37961 </row>
37962 <row topline="true">
37963 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37964 \begin_inset Text
37965
37966 \begin_layout Standard
37967
37968 \size footnotesize
37969 '|'
37970 \end_layout
37971
37972 \end_inset
37973 </cell>
37974 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37975 \begin_inset Text
37976
37977 \begin_layout Standard
37978
37979 \size footnotesize
37980 IC_LEFT() IC_RIGHT() IC_RESULT() 
37981 \end_layout
37982
37983 \end_inset
37984 </cell>
37985 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
37986 \begin_inset Text
37987
37988 \begin_layout Standard
37989
37990 \size footnotesize
37991 Bitwise OR 
37992 \end_layout
37993
37994 \end_inset
37995 </cell>
37996 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
37997 \begin_inset Text
37998
37999 \begin_layout Standard
38000
38001 \size footnotesize
38002 IC_RESULT = IC_LEFT | IC_RIGHT;
38003 \end_layout
38004
38005 \end_inset
38006 </cell>
38007 </row>
38008 <row topline="true">
38009 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38010 \begin_inset Text
38011
38012 \begin_layout Standard
38013
38014 \size footnotesize
38015 BITWISEAND
38016 \end_layout
38017
38018 \end_inset
38019 </cell>
38020 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38021 \begin_inset Text
38022
38023 \begin_layout Standard
38024
38025 \size footnotesize
38026 IC_LEFT() IC_RIGHT() IC_RESULT()
38027 \end_layout
38028
38029 \end_inset
38030 </cell>
38031 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38032 \begin_inset Text
38033
38034 \begin_layout Standard
38035
38036 \size footnotesize
38037 Bitwise AND 
38038 \end_layout
38039
38040 \end_inset
38041 </cell>
38042 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38043 \begin_inset Text
38044
38045 \begin_layout Standard
38046
38047 \size footnotesize
38048 IC_RESULT = IC_LEFT & IC_RIGHT;
38049 \end_layout
38050
38051 \end_inset
38052 </cell>
38053 </row>
38054 <row topline="true">
38055 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38056 \begin_inset Text
38057
38058 \begin_layout Standard
38059
38060 \size footnotesize
38061 LEFT_OP
38062 \end_layout
38063
38064 \end_inset
38065 </cell>
38066 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38067 \begin_inset Text
38068
38069 \begin_layout Standard
38070
38071 \size footnotesize
38072 IC_LEFT() IC_RIGHT() IC_RESULT()
38073 \end_layout
38074
38075 \end_inset
38076 </cell>
38077 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38078 \begin_inset Text
38079
38080 \begin_layout Standard
38081
38082 \size footnotesize
38083 Left shift 
38084 \end_layout
38085
38086 \end_inset
38087 </cell>
38088 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38089 \begin_inset Text
38090
38091 \begin_layout Standard
38092
38093 \size footnotesize
38094 IC_RESULT = IC_LEFT << IC_RIGHT 
38095 \end_layout
38096
38097 \end_inset
38098 </cell>
38099 </row>
38100 <row topline="true">
38101 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38102 \begin_inset Text
38103
38104 \begin_layout Standard
38105
38106 \size footnotesize
38107 RIGHT_OP
38108 \end_layout
38109
38110 \end_inset
38111 </cell>
38112 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38113 \begin_inset Text
38114
38115 \begin_layout Standard
38116
38117 \size footnotesize
38118 IC_LEFT() IC_RIGHT() IC_RESULT()
38119 \end_layout
38120
38121 \end_inset
38122 </cell>
38123 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38124 \begin_inset Text
38125
38126 \begin_layout Standard
38127
38128 \size footnotesize
38129 Right shift
38130 \end_layout
38131
38132 \end_inset
38133 </cell>
38134 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38135 \begin_inset Text
38136
38137 \begin_layout Standard
38138
38139 \size footnotesize
38140 IC_RESULT = IC_LEFT >> IC_RIGHT 
38141 \end_layout
38142
38143 \end_inset
38144 </cell>
38145 </row>
38146 <row topline="true">
38147 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38148 \begin_inset Text
38149
38150 \begin_layout Standard
38151
38152 \size footnotesize
38153 GET_VALUE_
38154 \newline
38155 AT_ ADDRESS
38156 \end_layout
38157
38158 \end_inset
38159 </cell>
38160 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38161 \begin_inset Text
38162
38163 \begin_layout Standard
38164
38165 \size footnotesize
38166 IC_LEFT() IC_RESULT()
38167 \end_layout
38168
38169 \end_inset
38170 </cell>
38171 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38172 \begin_inset Text
38173
38174 \begin_layout Standard
38175
38176 \size footnotesize
38177 Indirect fetch 
38178 \end_layout
38179
38180 \end_inset
38181 </cell>
38182 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38183 \begin_inset Text
38184
38185 \begin_layout Standard
38186
38187 \size footnotesize
38188 IC_RESULT = (*IC_LEFT);
38189 \end_layout
38190
38191 \end_inset
38192 </cell>
38193 </row>
38194 <row topline="true">
38195 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38196 \begin_inset Text
38197
38198 \begin_layout Standard
38199
38200 \size footnotesize
38201 POINTER_SET
38202 \end_layout
38203
38204 \end_inset
38205 </cell>
38206 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38207 \begin_inset Text
38208
38209 \begin_layout Standard
38210
38211 \size footnotesize
38212 IC_RIGHT() IC_RESULT() 
38213 \end_layout
38214
38215 \end_inset
38216 </cell>
38217 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38218 \begin_inset Text
38219
38220 \begin_layout Standard
38221
38222 \size footnotesize
38223 Indirect set
38224 \end_layout
38225
38226 \end_inset
38227 </cell>
38228 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38229 \begin_inset Text
38230
38231 \begin_layout Standard
38232
38233 \size footnotesize
38234 (*IC_RESULT) = IC_RIGHT;
38235 \end_layout
38236
38237 \end_inset
38238 </cell>
38239 </row>
38240 <row topline="true">
38241 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38242 \begin_inset Text
38243
38244 \begin_layout Standard
38245
38246 \size footnotesize
38247 '='
38248 \end_layout
38249
38250 \end_inset
38251 </cell>
38252 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38253 \begin_inset Text
38254
38255 \begin_layout Standard
38256
38257 \size footnotesize
38258 IC_RIGHT() IC_RESULT()
38259 \end_layout
38260
38261 \end_inset
38262 </cell>
38263 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38264 \begin_inset Text
38265
38266 \begin_layout Standard
38267
38268 \size footnotesize
38269 Assignment
38270 \end_layout
38271
38272 \end_inset
38273 </cell>
38274 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38275 \begin_inset Text
38276
38277 \begin_layout Standard
38278
38279 \size footnotesize
38280 IC_RESULT = IC_RIGHT;
38281 \end_layout
38282
38283 \end_inset
38284 </cell>
38285 </row>
38286 <row topline="true">
38287 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38288 \begin_inset Text
38289
38290 \begin_layout Standard
38291
38292 \size footnotesize
38293 IFX
38294 \end_layout
38295
38296 \end_inset
38297 </cell>
38298 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38299 \begin_inset Text
38300
38301 \begin_layout Standard
38302
38303 \size footnotesize
38304 IC_COND IC_TRUE IC_LABEL
38305 \end_layout
38306
38307 \end_inset
38308 </cell>
38309 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38310 \begin_inset Text
38311
38312 \begin_layout Standard
38313
38314 \size footnotesize
38315 Conditional jump.
38316  If true label is present then jump to true label if condition is true else
38317  jump to false label if condition is false 
38318 \end_layout
38319
38320 \end_inset
38321 </cell>
38322 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38323 \begin_inset Text
38324
38325 \begin_layout Standard
38326
38327 \size footnotesize
38328 if (IC_COND) goto IC_TRUE; 
38329 \newline
38330 \InsetSpace ~
38331 \InsetSpace ~
38332 Or 
38333 \newline
38334 If (!IC_COND) goto IC_FALSE;
38335 \end_layout
38336
38337 \end_inset
38338 </cell>
38339 </row>
38340 <row topline="true">
38341 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38342 \begin_inset Text
38343
38344 \begin_layout Standard
38345
38346 \size footnotesize
38347 ADDRESS_OF
38348 \end_layout
38349
38350 \end_inset
38351 </cell>
38352 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38353 \begin_inset Text
38354
38355 \begin_layout Standard
38356
38357 \size footnotesize
38358 IC_LEFT() IC_RESULT()
38359 \end_layout
38360
38361 \end_inset
38362 </cell>
38363 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38364 \begin_inset Text
38365
38366 \begin_layout Standard
38367
38368 \size footnotesize
38369 Address of 
38370 \end_layout
38371
38372 \end_inset
38373 </cell>
38374 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38375 \begin_inset Text
38376
38377 \begin_layout Standard
38378
38379 \size footnotesize
38380 IC_RESULT = &IC_LEFT();
38381 \end_layout
38382
38383 \end_inset
38384 </cell>
38385 </row>
38386 <row topline="true">
38387 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38388 \begin_inset Text
38389
38390 \begin_layout Standard
38391
38392 \size footnotesize
38393 JUMPTABLE
38394 \end_layout
38395
38396 \end_inset
38397 </cell>
38398 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38399 \begin_inset Text
38400
38401 \begin_layout Standard
38402
38403 \size footnotesize
38404 IC_JTCOND IC_JTLABELS
38405 \end_layout
38406
38407 \end_inset
38408 </cell>
38409 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38410 \begin_inset Text
38411
38412 \begin_layout Standard
38413
38414 \size footnotesize
38415 Jump to list of labels depending on the value of JTCOND
38416 \end_layout
38417
38418 \end_inset
38419 </cell>
38420 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38421 \begin_inset Text
38422
38423 \begin_layout Standard
38424
38425 \size footnotesize
38426 Switch statement
38427 \end_layout
38428
38429 \end_inset
38430 </cell>
38431 </row>
38432 <row topline="true">
38433 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38434 \begin_inset Text
38435
38436 \begin_layout Standard
38437
38438 \size footnotesize
38439 CAST
38440 \end_layout
38441
38442 \end_inset
38443 </cell>
38444 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38445 \begin_inset Text
38446
38447 \begin_layout Standard
38448
38449 \size footnotesize
38450 IC_RIGHT() IC_LEFT() IC_RESULT()
38451 \end_layout
38452
38453 \end_inset
38454 </cell>
38455 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38456 \begin_inset Text
38457
38458 \begin_layout Standard
38459
38460 \size footnotesize
38461 Cast types 
38462 \end_layout
38463
38464 \end_inset
38465 </cell>
38466 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38467 \begin_inset Text
38468
38469 \begin_layout Standard
38470
38471 \size footnotesize
38472 IC_RESULT = (typeof IC_LEFT) IC_RIGHT;
38473 \end_layout
38474
38475 \end_inset
38476 </cell>
38477 </row>
38478 <row topline="true">
38479 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38480 \begin_inset Text
38481
38482 \begin_layout Standard
38483
38484 \size footnotesize
38485 SEND
38486 \end_layout
38487
38488 \end_inset
38489 </cell>
38490 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38491 \begin_inset Text
38492
38493 \begin_layout Standard
38494
38495 \size footnotesize
38496 IC_LEFT()
38497 \end_layout
38498
38499 \end_inset
38500 </cell>
38501 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38502 \begin_inset Text
38503
38504 \begin_layout Standard
38505
38506 \size footnotesize
38507 This is used for passing parameters in registers; 
38508 \newline
38509 move IC_LEFT to the next
38510  available parameter register.
38511 \end_layout
38512
38513 \end_inset
38514 </cell>
38515 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38516 \begin_inset Text
38517
38518 \begin_layout Standard
38519
38520 \size footnotesize
38521 None
38522 \end_layout
38523
38524 \end_inset
38525 </cell>
38526 </row>
38527 <row topline="true">
38528 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38529 \begin_inset Text
38530
38531 \begin_layout Standard
38532
38533 \size footnotesize
38534 RECV
38535 \end_layout
38536
38537 \end_inset
38538 </cell>
38539 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38540 \begin_inset Text
38541
38542 \begin_layout Standard
38543
38544 \size footnotesize
38545 IC_RESULT()
38546 \end_layout
38547
38548 \end_inset
38549 </cell>
38550 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38551 \begin_inset Text
38552
38553 \begin_layout Standard
38554
38555 \size footnotesize
38556 This is used for receiving parameters passed in registers;
38557 \newline
38558 Move the values
38559  in the next parameter register to IC_RESULT 
38560 \end_layout
38561
38562 \end_inset
38563 </cell>
38564 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38565 \begin_inset Text
38566
38567 \begin_layout Standard
38568
38569 \size footnotesize
38570 None
38571 \end_layout
38572
38573 \end_inset
38574 </cell>
38575 </row>
38576 <row topline="true" bottomline="true">
38577 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38578 \begin_inset Text
38579
38580 \begin_layout Standard
38581
38582 \shape slanted
38583 \size footnotesize
38584 (some more have been added)
38585 \end_layout
38586
38587 \end_inset
38588 </cell>
38589 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38590 \begin_inset Text
38591
38592 \begin_layout Standard
38593
38594 \end_layout
38595
38596 \end_inset
38597 </cell>
38598 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
38599 \begin_inset Text
38600
38601 \begin_layout Standard
38602
38603 \end_layout
38604
38605 \end_inset
38606 </cell>
38607 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
38608 \begin_inset Text
38609
38610 \begin_layout Standard
38611
38612 \shape slanted
38613 \size footnotesize
38614 see f.e.
38615
38616 \shape default
38617  
38618 \family typewriter
38619 \shape slanted
38620 gen51Code()
38621 \family default
38622 \shape default
38623  
38624 \shape slanted
38625 in
38626 \shape default
38627  
38628 \family typewriter
38629 \shape slanted
38630 src/mcs51/gen.c
38631 \end_layout
38632
38633 \end_inset
38634 </cell>
38635 </row>
38636 </lyxtabular>
38637
38638 \end_inset
38639
38640
38641 \end_layout
38642
38643 \begin_layout Standard
38644 \begin_inset Note Note
38645 status collapsed
38646
38647 \begin_layout Standard
38648 In the original article Figure II was announced to be downloadable on 
38649 \shape italic
38650 Circuit Cellar
38651 \shape default
38652 's web site.
38653  ftp://ftp.circuitcellar.com/pub/Circuit_Cellar/2000/121/dutta.ZIP
38654 \end_layout
38655
38656 \end_inset
38657
38658
38659 \end_layout
38660
38661 \begin_layout Paragraph*
38662 ICode Example
38663 \begin_inset LatexCommand \index{iCode}
38664
38665 \end_inset
38666
38667
38668 \end_layout
38669
38670 \begin_layout Standard
38671 This section shows some details of iCode.
38672  The example C code does not do anything useful; it is used as an example
38673  to illustrate the intermediate code generated by the compiler.
38674 \end_layout
38675
38676 \begin_layout Verse
38677
38678 \family typewriter
38679 1.\InsetSpace ~
38680 xdata int * p;
38681 \newline
38682 2.\InsetSpace ~
38683 int gint;
38684 \newline
38685 3.\InsetSpace ~
38686 /* This function does nothing useful.
38687  It is used
38688 \newline
38689 4.\InsetSpace ~
38690 \InsetSpace ~
38691 \InsetSpace ~
38692 \InsetSpace ~
38693 for the purpose of explaining iCode */
38694 \newline
38695 5.\InsetSpace ~
38696 short function (data
38697  int *x)
38698 \newline
38699 6.\InsetSpace ~
38700 {
38701 \newline
38702 7.\InsetSpace ~
38703 \InsetSpace ~
38704 \InsetSpace ~
38705 short i=10; \InsetSpace ~
38706 \InsetSpace ~
38707 /* dead initialization eliminated */
38708 \newline
38709 8.\InsetSpace ~
38710 \InsetSpace ~
38711 \InsetSpace ~
38712 short sum=10;
38713  /* dead initialization eliminated */
38714 \newline
38715 9.\InsetSpace ~
38716 \InsetSpace ~
38717 \InsetSpace ~
38718 short mul;
38719 \newline
38720 10.\InsetSpace ~
38721 \InsetSpace ~
38722 int j ;
38723 \newline
38724 11.\InsetSpace ~
38725 \InsetSpace ~
38726 while (*x) *x++
38727  = *p++; 
38728 \newline
38729 12.\InsetSpace ~
38730 \InsetSpace ~
38731 \InsetSpace ~
38732 \InsetSpace ~
38733 sum = 0 ; 
38734 \newline
38735 13.\InsetSpace ~
38736 \InsetSpace ~
38737 mul = 0;
38738 \newline
38739 14.\InsetSpace ~
38740 \InsetSpace ~
38741 /* compiler detects i,j to be induction
38742  variables */
38743 \newline
38744 15.\InsetSpace ~
38745 \InsetSpace ~
38746 for (i = 0, j = 10 ; i < 10 ; i++, j
38747 \family default
38748 -
38749 \begin_inset ERT
38750 status collapsed
38751
38752 \begin_layout Standard
38753
38754
38755 \backslash
38756 /
38757 \end_layout
38758
38759 \end_inset
38760
38761 -
38762 \family typewriter
38763 ) {
38764 \newline
38765 16.\InsetSpace ~
38766 \InsetSpace ~
38767 \InsetSpace ~
38768 \InsetSpace ~
38769 sum += i;
38770 \newline
38771 17.\InsetSpace ~
38772 \InsetSpace ~
38773 \InsetSpace ~
38774 \InsetSpace ~
38775 mul += i * 3; \InsetSpace ~
38776 \InsetSpace ~
38777 /* this multiplication remains */
38778 \newline
38779 18.\InsetSpace ~
38780 \InsetSpace ~
38781 \InsetSpace ~
38782 \InsetSpace ~
38783 gint +=
38784  j * 3;\InsetSpace ~
38785 \InsetSpace ~
38786 /* this multiplication changed to addition */
38787 \newline
38788 19.\InsetSpace ~
38789 \InsetSpace ~
38790 }
38791 \newline
38792 20.\InsetSpace ~
38793 \InsetSpace ~
38794 return sum+mul;
38795 \newline
38796 21.\InsetSpace ~
38797 }
38798 \end_layout
38799
38800 \begin_layout Standard
38801 In addition to the operands each iCode contains information about the filename
38802  and line it corresponds to in the source file.
38803  The first field in the listing should be interpreted as follows:
38804 \newline
38805
38806 \shape italic
38807 \size footnotesize
38808 Filename(linenumber: iCode Execution sequence number : ICode hash table
38809  key : loop depth of the iCode).
38810 \shape default
38811 \size default
38812
38813 \newline
38814 Then follows the human readable form of the ICode operation.
38815  Each operand of this triplet form can be of three basic types a) compiler
38816  generated temporary b) user defined variable c) a constant value.
38817  Note that local variables and parameters are replaced by compiler generated
38818  temporaries.
38819  Live ranges
38820 \begin_inset LatexCommand \index{Live range analysis}
38821
38822 \end_inset
38823
38824  are computed only for temporaries (i.e.
38825  live ranges are not computed for global variables).
38826  Registers
38827 \begin_inset LatexCommand \index{Register allocation}
38828
38829 \end_inset
38830
38831  are allocated for temporaries only.
38832  Operands are formatted in the following manner:
38833 \newline
38834
38835 \shape italic
38836 \size footnotesize
38837 Operand Name [lr live-from : live-to ] { type information } [ registers
38838  allocated ].
38839 \shape default
38840 \size default
38841
38842 \newline
38843 As mentioned earlier the live ranges are computed in terms of the execution
38844  sequence number of the iCodes, for example 
38845 \newline
38846 the iTemp0 is live from (i.e.
38847  first defined in iCode with execution sequence number 3, and is last used
38848  in the iCode with sequence number 5).
38849  For induction variables such as iTemp21 the live range computation extends
38850  the lifetime from the start to the end of the loop.
38851 \newline
38852 The register allocator
38853  used the live range information to allocate registers, the same registers
38854  may be used for different temporaries if their live ranges do not overlap,
38855  for example r0 is allocated to both iTemp6 and to iTemp17 since their live
38856  ranges do not overlap.
38857  In addition the allocator also takes into consideration the type and usage
38858  of a temporary, for example itemp6 is a pointer to near space and is used
38859  as to fetch data from (i.e.
38860  used in GET_VALUE_AT_ADDRESS) so it is allocated a pointer register (r0).
38861  Some short lived temporaries are allocated to special registers which have
38862  meaning to the code generator e.g.
38863  iTemp13 is allocated to a pseudo register CC which tells the back end that
38864  the temporary is used only for a conditional jump the code generation makes
38865  use of this information to optimize a compare and jump ICode.
38866 \newline
38867 There are several
38868  loop optimizations
38869 \begin_inset LatexCommand \index{Loop optimization}
38870
38871 \end_inset
38872
38873  performed by the compiler.
38874  It can detect induction variables iTemp21(i) and iTemp23(j).
38875  Also note the compiler does selective strength reduction
38876 \begin_inset LatexCommand \index{Strength reduction}
38877
38878 \end_inset
38879
38880 , i.e.
38881  the multiplication of an induction variable in line 18 (gint = j * 3) is
38882  changed to addition, a new temporary iTemp17 is allocated and assigned
38883  a initial value, a constant 3 is then added for each iteration of the loop.
38884  The compiler does not change the multiplication
38885 \begin_inset LatexCommand \index{Multiplication}
38886
38887 \end_inset
38888
38889  in line 17 however since the processor does support an 8 * 8 bit multiplication.
38890 \newline
38891
38892 Note the dead code elimination
38893 \begin_inset LatexCommand \index{Dead-code elimination}
38894
38895 \end_inset
38896
38897  optimization eliminated the dead assignments in line 7 & 8 to I and sum
38898  respectively.
38899 \newline
38900
38901 \end_layout
38902
38903 \begin_layout Standard
38904
38905 \size footnotesize
38906 Sample.c (5:1:0:0) _entry($9) :
38907 \end_layout
38908
38909 \begin_layout Standard
38910
38911 \size footnotesize
38912 Sample.c(5:2:1:0) proc _function [lr0:0]{function short}
38913 \end_layout
38914
38915 \begin_layout Standard
38916
38917 \size footnotesize
38918 Sample.c(11:3:2:0) iTemp0 [lr3:5]{_near * int}[r2] = recv 
38919 \end_layout
38920
38921 \begin_layout Standard
38922
38923 \size footnotesize
38924 Sample.c(11:4:53:0) preHeaderLbl0($11) :
38925 \end_layout
38926
38927 \begin_layout Standard
38928
38929 \size footnotesize
38930 Sample.c(11:5:55:0) iTemp6 [lr5:16]{_near * int}[r0] := iTemp0 [lr3:5]{_near
38931  * int}[r2]
38932 \end_layout
38933
38934 \begin_layout Standard
38935
38936 \size footnotesize
38937 Sample.c(11:6:5:1) _whilecontinue_0($1) :
38938 \end_layout
38939
38940 \begin_layout Standard
38941
38942 \size footnotesize
38943 Sample.c(11:7:7:1) iTemp4 [lr7:8]{int}[r2 r3] = @[iTemp6 [lr5:16]{_near *
38944  int}[r0]]
38945 \end_layout
38946
38947 \begin_layout Standard
38948
38949 \size footnotesize
38950 Sample.c(11:8:8:1) if iTemp4 [lr7:8]{int}[r2 r3] == 0 goto _whilebreak_0($3)
38951 \end_layout
38952
38953 \begin_layout Standard
38954
38955 \size footnotesize
38956 Sample.c(11:9:14:1) iTemp7 [lr9:13]{_far * int}[DPTR] := _p [lr0:0]{_far
38957  * int}
38958 \end_layout
38959
38960 \begin_layout Standard
38961
38962 \size footnotesize
38963 Sample.c(11:10:15:1) _p [lr0:0]{_far * int} = _p [lr0:0]{_far * int} + 0x2
38964  {short}
38965 \end_layout
38966
38967 \begin_layout Standard
38968
38969 \size footnotesize
38970 Sample.c(11:13:18:1) iTemp10 [lr13:14]{int}[r2 r3] = @[iTemp7 [lr9:13]{_far
38971  * int}[DPTR]]
38972 \end_layout
38973
38974 \begin_layout Standard
38975
38976 \size footnotesize
38977 Sample.c(11:14:19:1) *(iTemp6 [lr5:16]{_near * int}[r0]) := iTemp10 [lr13:14]{int
38978 }[r2 r3]
38979 \end_layout
38980
38981 \begin_layout Standard
38982
38983 \size footnotesize
38984 Sample.c(11:15:12:1) iTemp6 [lr5:16]{_near * int}[r0] = iTemp6 [lr5:16]{_near
38985  * int}[r0] + 0x2 {short}
38986 \end_layout
38987
38988 \begin_layout Standard
38989
38990 \size footnotesize
38991 Sample.c(11:16:20:1) goto _whilecontinue_0($1)
38992 \end_layout
38993
38994 \begin_layout Standard
38995
38996 \size footnotesize
38997 Sample.c(11:17:21:0)_whilebreak_0($3) :
38998 \end_layout
38999
39000 \begin_layout Standard
39001
39002 \size footnotesize
39003 Sample.c(12:18:22:0) iTemp2 [lr18:40]{short}[r2] := 0x0 {short}
39004 \end_layout
39005
39006 \begin_layout Standard
39007
39008 \size footnotesize
39009 Sample.c(13:19:23:0) iTemp11 [lr19:40]{short}[r3] := 0x0 {short}
39010 \end_layout
39011
39012 \begin_layout Standard
39013
39014 \size footnotesize
39015 Sample.c(15:20:54:0)preHeaderLbl1($13) :
39016 \end_layout
39017
39018 \begin_layout Standard
39019
39020 \size footnotesize
39021 Sample.c(15:21:56:0) iTemp21 [lr21:38]{short}[r4] := 0x0 {short}
39022 \end_layout
39023
39024 \begin_layout Standard
39025
39026 \size footnotesize
39027 Sample.c(15:22:57:0) iTemp23 [lr22:38]{int}[r5 r6] := 0xa {int}
39028 \end_layout
39029
39030 \begin_layout Standard
39031
39032 \size footnotesize
39033 Sample.c(15:23:58:0) iTemp17 [lr23:38]{int}[r7 r0] := 0x1e {int}
39034 \end_layout
39035
39036 \begin_layout Standard
39037
39038 \size footnotesize
39039 Sample.c(15:24:26:1)_forcond_0($4) :
39040 \end_layout
39041
39042 \begin_layout Standard
39043
39044 \size footnotesize
39045 Sample.c(15:25:27:1) iTemp13 [lr25:26]{char}[CC] = iTemp21 [lr21:38]{short}[r4]
39046  < 0xa {short}
39047 \end_layout
39048
39049 \begin_layout Standard
39050
39051 \size footnotesize
39052 Sample.c(15:26:28:1) if iTemp13 [lr25:26]{char}[CC] == 0 goto _forbreak_0($7)
39053 \end_layout
39054
39055 \begin_layout Standard
39056
39057 \size footnotesize
39058 Sample.c(16:27:31:1) iTemp2 [lr18:40]{short}[r2] = iTemp2 [lr18:40]{short}[r2]
39059  + ITemp21 [lr21:38]{short}[r4]
39060 \end_layout
39061
39062 \begin_layout Standard
39063
39064 \size footnotesize
39065 Sample.c(17:29:33:1) iTemp15 [lr29:30]{short}[r1] = iTemp21 [lr21:38]{short}[r4]
39066  * 0x3 {short}
39067 \end_layout
39068
39069 \begin_layout Standard
39070
39071 \size footnotesize
39072 Sample.c(17:30:34:1) iTemp11 [lr19:40]{short}[r3] = iTemp11 [lr19:40]{short}[r3]
39073  + iTemp15 [lr29:30]{short}[r1]
39074 \end_layout
39075
39076 \begin_layout Standard
39077
39078 \size footnotesize
39079 Sample.c(18:32:36:1:1) iTemp17 [lr23:38]{int}[r7 r0]= iTemp17 [lr23:38]{int}[r7
39080  r0]- 0x3 {short}
39081 \end_layout
39082
39083 \begin_layout Standard
39084
39085 \size footnotesize
39086 Sample.c(18:33:37:1) _gint [lr0:0]{int} = _gint [lr0:0]{int} + iTemp17 [lr23:38]{
39087 int}[r7 r0]
39088 \end_layout
39089
39090 \begin_layout Standard
39091
39092 \size footnotesize
39093 Sample.c(15:36:42:1) iTemp21 [lr21:38]{short}[r4] = iTemp21 [lr21:38]{short}[r4]
39094  + 0x1 {short}
39095 \end_layout
39096
39097 \begin_layout Standard
39098
39099 \size footnotesize
39100 Sample.c(15:37:45:1) iTemp23 [lr22:38]{int}[r5 r6]= iTemp23 [lr22:38]{int}[r5
39101  r6]- 0x1 {short}
39102 \end_layout
39103
39104 \begin_layout Standard
39105
39106 \size footnotesize
39107 Sample.c(19:38:47:1) goto _forcond_0($4)
39108 \end_layout
39109
39110 \begin_layout Standard
39111
39112 \size footnotesize
39113 Sample.c(19:39:48:0)_forbreak_0($7) :
39114 \end_layout
39115
39116 \begin_layout Standard
39117
39118 \size footnotesize
39119 Sample.c(20:40:49:0) iTemp24 [lr40:41]{short}[DPTR] = iTemp2 [lr18:40]{short}[r2]
39120  + ITemp11 [lr19:40]{short}[r3]
39121 \end_layout
39122
39123 \begin_layout Standard
39124
39125 \size footnotesize
39126 Sample.c(20:41:50:0) ret iTemp24 [lr40:41]{short}
39127 \end_layout
39128
39129 \begin_layout Standard
39130
39131 \size footnotesize
39132 Sample.c(20:42:51:0)_return($8) :
39133 \end_layout
39134
39135 \begin_layout Standard
39136
39137 \size footnotesize
39138 Sample.c(20:43:52:0) eproc _function [lr0:0]{ ia0 re0 rm0}{function short}
39139 \size default
39140
39141 \newline
39142
39143 \newline
39144 Finally the code generated for this function:
39145 \newline
39146
39147 \end_layout
39148
39149 \begin_layout Standard
39150
39151 \size footnotesize
39152 .area DSEG (DATA)
39153 \end_layout
39154
39155 \begin_layout Standard
39156
39157 \size footnotesize
39158 _p::
39159 \end_layout
39160
39161 \begin_layout Standard
39162
39163 \size footnotesize
39164 \InsetSpace ~
39165 \InsetSpace ~
39166 .ds 2
39167 \end_layout
39168
39169 \begin_layout Standard
39170
39171 \size footnotesize
39172 _gint::
39173 \end_layout
39174
39175 \begin_layout Standard
39176
39177 \size footnotesize
39178 \InsetSpace ~
39179 \InsetSpace ~
39180 .ds 2
39181 \end_layout
39182
39183 \begin_layout Standard
39184
39185 \size footnotesize
39186 ; sample.c 5
39187 \end_layout
39188
39189 \begin_layout Standard
39190
39191 \size footnotesize
39192 ; ----------------------------------------------
39193 \end_layout
39194
39195 \begin_layout Standard
39196
39197 \size footnotesize
39198 ; function function
39199 \end_layout
39200
39201 \begin_layout Standard
39202
39203 \size footnotesize
39204 ; ----------------------------------------------
39205 \end_layout
39206
39207 \begin_layout Standard
39208
39209 \size footnotesize
39210 _function:
39211 \end_layout
39212
39213 \begin_layout Standard
39214
39215 \size footnotesize
39216 ; iTemp0 [lr3:5]{_near * int}[r2] = recv 
39217 \end_layout
39218
39219 \begin_layout Standard
39220
39221 \size footnotesize
39222 \InsetSpace ~
39223 \InsetSpace ~
39224 mov r2,dpl
39225 \end_layout
39226
39227 \begin_layout Standard
39228
39229 \size footnotesize
39230 ; iTemp6 [lr5:16]{_near * int}[r0] := iTemp0 [lr3:5]{_near * int}[r2]
39231 \end_layout
39232
39233 \begin_layout Standard
39234
39235 \size footnotesize
39236 \InsetSpace ~
39237 \InsetSpace ~
39238 mov ar0,r2
39239 \end_layout
39240
39241 \begin_layout Standard
39242
39243 \size footnotesize
39244 ;_whilecontinue_0($1) :
39245 \end_layout
39246
39247 \begin_layout Standard
39248
39249 \size footnotesize
39250 00101$:
39251 \end_layout
39252
39253 \begin_layout Standard
39254
39255 \size footnotesize
39256 ; iTemp4 [lr7:8]{int}[r2 r3] = @[iTemp6 [lr5:16]{_near * int}[r0]]
39257 \end_layout
39258
39259 \begin_layout Standard
39260
39261 \size footnotesize
39262 ; if iTemp4 [lr7:8]{int}[r2 r3] == 0 goto _whilebreak_0($3)
39263 \end_layout
39264
39265 \begin_layout Standard
39266
39267 \size footnotesize
39268 \InsetSpace ~
39269 \InsetSpace ~
39270 mov ar2,@r0
39271 \end_layout
39272
39273 \begin_layout Standard
39274
39275 \size footnotesize
39276 \InsetSpace ~
39277 \InsetSpace ~
39278 inc r0
39279 \end_layout
39280
39281 \begin_layout Standard
39282
39283 \size footnotesize
39284 \InsetSpace ~
39285 \InsetSpace ~
39286 mov ar3,@r0
39287 \end_layout
39288
39289 \begin_layout Standard
39290
39291 \size footnotesize
39292 \InsetSpace ~
39293 \InsetSpace ~
39294 dec r0
39295 \end_layout
39296
39297 \begin_layout Standard
39298
39299 \size footnotesize
39300 \InsetSpace ~
39301 \InsetSpace ~
39302 mov a,r2
39303 \end_layout
39304
39305 \begin_layout Standard
39306
39307 \size footnotesize
39308 \InsetSpace ~
39309 \InsetSpace ~
39310 orl a,r3
39311 \end_layout
39312
39313 \begin_layout Standard
39314
39315 \size footnotesize
39316 \InsetSpace ~
39317 \InsetSpace ~
39318 jz 00103$
39319 \end_layout
39320
39321 \begin_layout Standard
39322
39323 \size footnotesize
39324 00114$:
39325 \end_layout
39326
39327 \begin_layout Standard
39328
39329 \size footnotesize
39330 ; iTemp7 [lr9:13]{_far * int}[DPTR] := _p [lr0:0]{_far * int}
39331 \end_layout
39332
39333 \begin_layout Standard
39334
39335 \size footnotesize
39336 \InsetSpace ~
39337 \InsetSpace ~
39338 mov dpl,_p
39339 \end_layout
39340
39341 \begin_layout Standard
39342
39343 \size footnotesize
39344 \InsetSpace ~
39345 \InsetSpace ~
39346 mov dph,(_p + 1)
39347 \end_layout
39348
39349 \begin_layout Standard
39350
39351 \size footnotesize
39352 ; _p [lr0:0]{_far * int} = _p [lr0:0]{_far * int} + 0x2 {short}
39353 \end_layout
39354
39355 \begin_layout Standard
39356
39357 \size footnotesize
39358 \InsetSpace ~
39359 \InsetSpace ~
39360 mov a,#0x02
39361 \end_layout
39362
39363 \begin_layout Standard
39364
39365 \size footnotesize
39366 \InsetSpace ~
39367 \InsetSpace ~
39368 add a,_p
39369 \end_layout
39370
39371 \begin_layout Standard
39372
39373 \size footnotesize
39374 \InsetSpace ~
39375 \InsetSpace ~
39376 mov _p,a
39377 \end_layout
39378
39379 \begin_layout Standard
39380
39381 \size footnotesize
39382 \InsetSpace ~
39383 \InsetSpace ~
39384 clr a
39385 \end_layout
39386
39387 \begin_layout Standard
39388
39389 \size footnotesize
39390 \InsetSpace ~
39391 \InsetSpace ~
39392 addc a,(_p + 1)
39393 \end_layout
39394
39395 \begin_layout Standard
39396
39397 \size footnotesize
39398 \InsetSpace ~
39399 \InsetSpace ~
39400 mov (_p + 1),a
39401 \end_layout
39402
39403 \begin_layout Standard
39404
39405 \size footnotesize
39406 ; iTemp10 [lr13:14]{int}[r2 r3] = @[iTemp7 [lr9:13]{_far * int}[DPTR]]
39407 \end_layout
39408
39409 \begin_layout Standard
39410
39411 \size footnotesize
39412 \InsetSpace ~
39413 \InsetSpace ~
39414 movx a,@dptr
39415 \end_layout
39416
39417 \begin_layout Standard
39418
39419 \size footnotesize
39420 \InsetSpace ~
39421 \InsetSpace ~
39422 mov r2,a
39423 \end_layout
39424
39425 \begin_layout Standard
39426
39427 \size footnotesize
39428 \InsetSpace ~
39429 \InsetSpace ~
39430 inc dptr
39431 \end_layout
39432
39433 \begin_layout Standard
39434
39435 \size footnotesize
39436 \InsetSpace ~
39437 \InsetSpace ~
39438 movx a,@dptr
39439 \end_layout
39440
39441 \begin_layout Standard
39442
39443 \size footnotesize
39444 \InsetSpace ~
39445 \InsetSpace ~
39446 mov r3,a
39447 \end_layout
39448
39449 \begin_layout Standard
39450
39451 \size footnotesize
39452 ; *(iTemp6 [lr5:16]{_near * int}[r0]) := iTemp10 [lr13:14]{int}[r2 r3]
39453 \end_layout
39454
39455 \begin_layout Standard
39456
39457 \size footnotesize
39458 \InsetSpace ~
39459 \InsetSpace ~
39460 mov @r0,ar2
39461 \end_layout
39462
39463 \begin_layout Standard
39464
39465 \size footnotesize
39466 \InsetSpace ~
39467 \InsetSpace ~
39468 inc r0
39469 \end_layout
39470
39471 \begin_layout Standard
39472
39473 \size footnotesize
39474 \InsetSpace ~
39475 \InsetSpace ~
39476 mov @r0,ar3
39477 \end_layout
39478
39479 \begin_layout Standard
39480
39481 \size footnotesize
39482 ; iTemp6 [lr5:16]{_near * int}[r0] = 
39483 \end_layout
39484
39485 \begin_layout Standard
39486
39487 \size footnotesize
39488 ; iTemp6 [lr5:16]{_near * int}[r0] + 
39489 \end_layout
39490
39491 \begin_layout Standard
39492
39493 \size footnotesize
39494 ; 0x2 {short}
39495 \end_layout
39496
39497 \begin_layout Standard
39498
39499 \size footnotesize
39500 \InsetSpace ~
39501 \InsetSpace ~
39502 inc r0
39503 \end_layout
39504
39505 \begin_layout Standard
39506
39507 \size footnotesize
39508 ; goto _whilecontinue_0($1)
39509 \end_layout
39510
39511 \begin_layout Standard
39512
39513 \size footnotesize
39514 \InsetSpace ~
39515 \InsetSpace ~
39516 sjmp 00101$
39517 \end_layout
39518
39519 \begin_layout Standard
39520
39521 \size footnotesize
39522 ; _whilebreak_0($3) :
39523 \end_layout
39524
39525 \begin_layout Standard
39526
39527 \size footnotesize
39528 00103$:
39529 \end_layout
39530
39531 \begin_layout Standard
39532
39533 \size footnotesize
39534 ; iTemp2 [lr18:40]{short}[r2] := 0x0 {short}
39535 \end_layout
39536
39537 \begin_layout Standard
39538
39539 \size footnotesize
39540 \InsetSpace ~
39541 \InsetSpace ~
39542 mov r2,#0x00
39543 \end_layout
39544
39545 \begin_layout Standard
39546
39547 \size footnotesize
39548 ; iTemp11 [lr19:40]{short}[r3] := 0x0 {short}
39549 \end_layout
39550
39551 \begin_layout Standard
39552
39553 \size footnotesize
39554 \InsetSpace ~
39555 \InsetSpace ~
39556 mov r3,#0x00
39557 \end_layout
39558
39559 \begin_layout Standard
39560
39561 \size footnotesize
39562 ; iTemp21 [lr21:38]{short}[r4] := 0x0 {short}
39563 \end_layout
39564
39565 \begin_layout Standard
39566
39567 \size footnotesize
39568 \InsetSpace ~
39569 \InsetSpace ~
39570 mov r4,#0x00
39571 \end_layout
39572
39573 \begin_layout Standard
39574
39575 \size footnotesize
39576 ; iTemp23 [lr22:38]{int}[r5 r6] := 0xa {int}
39577 \end_layout
39578
39579 \begin_layout Standard
39580
39581 \size footnotesize
39582 \InsetSpace ~
39583 \InsetSpace ~
39584 mov r5,#0x0A
39585 \end_layout
39586
39587 \begin_layout Standard
39588
39589 \size footnotesize
39590 \InsetSpace ~
39591 \InsetSpace ~
39592 mov r6,#0x00
39593 \end_layout
39594
39595 \begin_layout Standard
39596
39597 \size footnotesize
39598 ; iTemp17 [lr23:38]{int}[r7 r0] := 0x1e {int}
39599 \end_layout
39600
39601 \begin_layout Standard
39602
39603 \size footnotesize
39604 \InsetSpace ~
39605 \InsetSpace ~
39606 mov r7,#0x1E
39607 \end_layout
39608
39609 \begin_layout Standard
39610
39611 \size footnotesize
39612 \InsetSpace ~
39613 \InsetSpace ~
39614 mov r0,#0x00
39615 \end_layout
39616
39617 \begin_layout Standard
39618
39619 \size footnotesize
39620 ; _forcond_0($4) :
39621 \end_layout
39622
39623 \begin_layout Standard
39624
39625 \size footnotesize
39626 00104$:
39627 \end_layout
39628
39629 \begin_layout Standard
39630
39631 \size footnotesize
39632 ; iTemp13 [lr25:26]{char}[CC] = iTemp21 [lr21:38]{short}[r4] < 0xa {short}
39633 \end_layout
39634
39635 \begin_layout Standard
39636
39637 \size footnotesize
39638 ; if iTemp13 [lr25:26]{char}[CC] == 0 goto _forbreak_0($7)
39639 \end_layout
39640
39641 \begin_layout Standard
39642
39643 \size footnotesize
39644 \InsetSpace ~
39645 \InsetSpace ~
39646 clr c
39647 \end_layout
39648
39649 \begin_layout Standard
39650
39651 \size footnotesize
39652 \InsetSpace ~
39653 \InsetSpace ~
39654 mov a,r4
39655 \end_layout
39656
39657 \begin_layout Standard
39658
39659 \size footnotesize
39660 \InsetSpace ~
39661 \InsetSpace ~
39662 xrl a,#0x80
39663 \end_layout
39664
39665 \begin_layout Standard
39666
39667 \size footnotesize
39668 \InsetSpace ~
39669 \InsetSpace ~
39670 subb a,#0x8a
39671 \end_layout
39672
39673 \begin_layout Standard
39674
39675 \size footnotesize
39676 \InsetSpace ~
39677 \InsetSpace ~
39678 jnc 00107$
39679 \end_layout
39680
39681 \begin_layout Standard
39682
39683 \size footnotesize
39684 00115$:
39685 \end_layout
39686
39687 \begin_layout Standard
39688
39689 \size footnotesize
39690 ; iTemp2 [lr18:40]{short}[r2] = iTemp2 [lr18:40]{short}[r2] + 
39691 \end_layout
39692
39693 \begin_layout Standard
39694
39695 \size footnotesize
39696 ; iTemp21 [lr21:38]{short}[r4]
39697 \end_layout
39698
39699 \begin_layout Standard
39700
39701 \size footnotesize
39702 \InsetSpace ~
39703 \InsetSpace ~
39704 mov a,r4
39705 \end_layout
39706
39707 \begin_layout Standard
39708
39709 \size footnotesize
39710 \InsetSpace ~
39711 \InsetSpace ~
39712 add a,r2
39713 \end_layout
39714
39715 \begin_layout Standard
39716
39717 \size footnotesize
39718 \InsetSpace ~
39719 \InsetSpace ~
39720 mov r2,a
39721 \end_layout
39722
39723 \begin_layout Standard
39724
39725 \size footnotesize
39726 ; iTemp15 [lr29:30]{short}[r1] = iTemp21 [lr21:38]{short}[r4] * 0x3 {short}
39727 \end_layout
39728
39729 \begin_layout Standard
39730
39731 \size footnotesize
39732 \InsetSpace ~
39733 \InsetSpace ~
39734 mov b,#0x03
39735 \end_layout
39736
39737 \begin_layout Standard
39738
39739 \size footnotesize
39740 \InsetSpace ~
39741 \InsetSpace ~
39742 mov a,r4
39743 \end_layout
39744
39745 \begin_layout Standard
39746
39747 \size footnotesize
39748 \InsetSpace ~
39749 \InsetSpace ~
39750 mul ab
39751 \end_layout
39752
39753 \begin_layout Standard
39754
39755 \size footnotesize
39756 \InsetSpace ~
39757 \InsetSpace ~
39758 mov r1,a
39759 \end_layout
39760
39761 \begin_layout Standard
39762
39763 \size footnotesize
39764 ; iTemp11 [lr19:40]{short}[r3] = iTemp11 [lr19:40]{short}[r3] + 
39765 \end_layout
39766
39767 \begin_layout Standard
39768
39769 \size footnotesize
39770 ; iTemp15 [lr29:30]{short}[r1]
39771 \end_layout
39772
39773 \begin_layout Standard
39774
39775 \size footnotesize
39776 \InsetSpace ~
39777 \InsetSpace ~
39778 add a,r3
39779 \end_layout
39780
39781 \begin_layout Standard
39782
39783 \size footnotesize
39784 \InsetSpace ~
39785 \InsetSpace ~
39786 mov r3,a
39787 \end_layout
39788
39789 \begin_layout Standard
39790
39791 \size footnotesize
39792 ; iTemp17 [lr23:38]{int}[r7 r0]= iTemp17 [lr23:38]{int}[r7 r0]- 0x3 {short}
39793 \end_layout
39794
39795 \begin_layout Standard
39796
39797 \size footnotesize
39798 \InsetSpace ~
39799 \InsetSpace ~
39800 mov a,r7
39801 \end_layout
39802
39803 \begin_layout Standard
39804
39805 \size footnotesize
39806 \InsetSpace ~
39807 \InsetSpace ~
39808 add a,#0xfd
39809 \end_layout
39810
39811 \begin_layout Standard
39812
39813 \size footnotesize
39814 \InsetSpace ~
39815 \InsetSpace ~
39816 mov r7,a
39817 \end_layout
39818
39819 \begin_layout Standard
39820
39821 \size footnotesize
39822 \InsetSpace ~
39823 \InsetSpace ~
39824 mov a,r0
39825 \end_layout
39826
39827 \begin_layout Standard
39828
39829 \size footnotesize
39830 \InsetSpace ~
39831 \InsetSpace ~
39832 addc a,#0xff
39833 \end_layout
39834
39835 \begin_layout Standard
39836
39837 \size footnotesize
39838 \InsetSpace ~
39839 \InsetSpace ~
39840 mov r0,a
39841 \end_layout
39842
39843 \begin_layout Standard
39844
39845 \size footnotesize
39846 ; _gint [lr0:0]{int} = _gint [lr0:0]{int} + iTemp17 [lr23:38]{int}[r7 r0]
39847 \end_layout
39848
39849 \begin_layout Standard
39850
39851 \size footnotesize
39852 \InsetSpace ~
39853 \InsetSpace ~
39854 mov a,r7
39855 \end_layout
39856
39857 \begin_layout Standard
39858
39859 \size footnotesize
39860 \InsetSpace ~
39861 \InsetSpace ~
39862 add a,_gint
39863 \end_layout
39864
39865 \begin_layout Standard
39866
39867 \size footnotesize
39868 \InsetSpace ~
39869 \InsetSpace ~
39870 mov _gint,a
39871 \end_layout
39872
39873 \begin_layout Standard
39874
39875 \size footnotesize
39876 \InsetSpace ~
39877 \InsetSpace ~
39878 mov a,r0
39879 \end_layout
39880
39881 \begin_layout Standard
39882
39883 \size footnotesize
39884 \InsetSpace ~
39885 \InsetSpace ~
39886 addc a,(_gint + 1)
39887 \end_layout
39888
39889 \begin_layout Standard
39890
39891 \size footnotesize
39892 \InsetSpace ~
39893 \InsetSpace ~
39894 mov (_gint + 1),a
39895 \end_layout
39896
39897 \begin_layout Standard
39898
39899 \size footnotesize
39900 ; iTemp21 [lr21:38]{short}[r4] = iTemp21 [lr21:38]{short}[r4] + 0x1 {short}
39901 \end_layout
39902
39903 \begin_layout Standard
39904
39905 \size footnotesize
39906 \InsetSpace ~
39907 \InsetSpace ~
39908 inc r4
39909 \end_layout
39910
39911 \begin_layout Standard
39912
39913 \size footnotesize
39914 ; iTemp23 [lr22:38]{int}[r5 r6]= iTemp23 [lr22:38]{int}[r5 r6]- 0x1 {short}
39915 \end_layout
39916
39917 \begin_layout Standard
39918
39919 \size footnotesize
39920 \InsetSpace ~
39921 \InsetSpace ~
39922 dec r5
39923 \end_layout
39924
39925 \begin_layout Standard
39926
39927 \size footnotesize
39928 \InsetSpace ~
39929 \InsetSpace ~
39930 cjne r5,#0xff,00104$
39931 \end_layout
39932
39933 \begin_layout Standard
39934
39935 \size footnotesize
39936 \InsetSpace ~
39937 \InsetSpace ~
39938 dec r6
39939 \end_layout
39940
39941 \begin_layout Standard
39942
39943 \size footnotesize
39944 ; goto _forcond_0($4)
39945 \end_layout
39946
39947 \begin_layout Standard
39948
39949 \size footnotesize
39950 \InsetSpace ~
39951 \InsetSpace ~
39952 sjmp 00104$
39953 \end_layout
39954
39955 \begin_layout Standard
39956
39957 \size footnotesize
39958 ; _forbreak_0($7) :
39959 \end_layout
39960
39961 \begin_layout Standard
39962
39963 \size footnotesize
39964 00107$:
39965 \end_layout
39966
39967 \begin_layout Standard
39968
39969 \size footnotesize
39970 ; ret iTemp24 [lr40:41]{short}
39971 \end_layout
39972
39973 \begin_layout Standard
39974
39975 \size footnotesize
39976 \InsetSpace ~
39977 \InsetSpace ~
39978 mov a,r3
39979 \end_layout
39980
39981 \begin_layout Standard
39982
39983 \size footnotesize
39984 \InsetSpace ~
39985 \InsetSpace ~
39986 add a,r2
39987 \end_layout
39988
39989 \begin_layout Standard
39990
39991 \size footnotesize
39992 \InsetSpace ~
39993 \InsetSpace ~
39994 mov dpl,a
39995 \end_layout
39996
39997 \begin_layout Standard
39998
39999 \size footnotesize
40000 ; _return($8) :
40001 \end_layout
40002
40003 \begin_layout Standard
40004
40005 \size footnotesize
40006 00108$:
40007 \end_layout
40008
40009 \begin_layout Standard
40010
40011 \size footnotesize
40012 \InsetSpace ~
40013 \InsetSpace ~
40014 ret
40015 \newline
40016
40017 \end_layout
40018
40019 \begin_layout Section
40020 A few words about basic block successors, predecessors and dominators
40021 \end_layout
40022
40023 \begin_layout Standard
40024 Successors are basic blocks
40025 \begin_inset LatexCommand \index{Basic blocks}
40026
40027 \end_inset
40028
40029  that might execute after this basic block.
40030 \newline
40031 Predecessors are basic blocks
40032  that might execute before reaching this basic block.
40033 \newline
40034 Dominators are basic
40035  blocks that WILL execute before reaching this basic block.
40036 \newline
40037
40038 \end_layout
40039
40040 \begin_layout Standard
40041 [basic block 1]
40042 \end_layout
40043
40044 \begin_layout Standard
40045 if (something)
40046 \end_layout
40047
40048 \begin_layout Standard
40049 \InsetSpace ~
40050 \InsetSpace ~
40051 \InsetSpace ~
40052 \InsetSpace ~
40053 [basic block 2]
40054 \end_layout
40055
40056 \begin_layout Standard
40057 else
40058 \end_layout
40059
40060 \begin_layout Standard
40061 \InsetSpace ~
40062 \InsetSpace ~
40063 \InsetSpace ~
40064 \InsetSpace ~
40065 [basic block 3]
40066 \end_layout
40067
40068 \begin_layout Standard
40069 [basic block 4]
40070 \newline
40071
40072 \end_layout
40073
40074 \begin_layout Standard
40075 a) succList of [BB2] = [BB4], of [BB3] = [BB4], of [BB1] = [BB2,BB3]
40076 \end_layout
40077
40078 \begin_layout Standard
40079 b) predList of [BB2] = [BB1], of [BB3] = [BB1], of [BB4] = [BB2,BB3]
40080 \end_layout
40081
40082 \begin_layout Standard
40083 c) domVect of [BB4] = BB1 ...
40084  here we are not sure if BB2 or BB3 was executed but we are SURE that BB1
40085  was executed.
40086 \end_layout
40087
40088 \begin_layout Chapter
40089 Acknowledgments
40090 \end_layout
40091
40092 \begin_layout Standard
40093 \begin_inset LatexCommand \url{http://sdcc.sourceforge.net#Who}
40094
40095 \end_inset
40096
40097
40098 \newline
40099
40100 \newline
40101
40102 \emph on
40103 Thanks to all the other volunteer developers who have helped with coding,
40104  testing, web-page creation, distribution sets, etc.
40105  You know who you are :-)
40106 \emph default
40107
40108 \newline
40109
40110 \newline
40111
40112 \emph on
40113 Thanks to Sourceforge 
40114 \begin_inset LatexCommand \url{http://www.sf.net}
40115
40116 \end_inset
40117
40118  which has hosted the project since 1999 and donates significant download
40119  bandwidth.
40120 \emph default
40121
40122 \newline
40123
40124 \newline
40125
40126 \emph on
40127 Also thanks to all SDCC Distributed Compile Farm members for donating CPU
40128  cycles and bandwidth for snapshot builds.
40129 \newline
40130
40131 \end_layout
40132
40133 \begin_layout Standard
40134 This document was initially written by Sandeep Dutta
40135 \end_layout
40136
40137 \begin_layout Standard
40138 All product names mentioned herein may be trademarks
40139 \begin_inset LatexCommand \index{Trademarks}
40140
40141 \end_inset
40142
40143  of their respective companies.
40144  
40145 \end_layout
40146
40147 \begin_layout Section*
40148 Alphabetical index
40149 \end_layout
40150
40151 \begin_layout Standard
40152 To avoid confusion, the installation and building options for SDCC itself
40153  (chapter 2) are not part of the index.
40154 \end_layout
40155
40156 \begin_layout Standard
40157 \begin_inset LatexCommand \printindex{}
40158
40159 \end_inset
40160
40161
40162 \end_layout
40163
40164 \end_body
40165 \end_document