b56653144808da2d1636e42195587531d998474d
[fw/sdcc] / doc / sdccman.lyx
1 #LyX 1.5.7 created this file. For more info see http://www.lyx.org/
2 \lyxformat 276
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 \font_roman times
26 \font_sans helvet
27 \font_typewriter courier
28 \font_default_family default
29 \font_sc false
30 \font_osf false
31 \font_sf_scale 100
32 \font_tt_scale 100
33 \graphics default
34 \paperfontsize default
35 \spacing single
36 \papersize letterpaper
37 \use_geometry true
38 \use_amsmath 1
39 \use_esint 0
40 \cite_engine basic
41 \use_bibtopic false
42 \paperorientation portrait
43 \leftmargin 30mm
44 \topmargin 20mm
45 \rightmargin 25mm
46 \bottommargin 20mm
47 \secnumdepth 3
48 \tocdepth 3
49 \paragraph_separation indent
50 \defskip medskip
51 \quotes_language swedish
52 \papercolumns 1
53 \papersides 1
54 \paperpagestyle fancy
55 \tracking_changes false
56 \output_changes false
57 \author "" 
58 \author "" 
59 \end_header
60
61 \begin_body
62
63 \begin_layout Standard
64 \begin_inset Note Note
65 status collapsed
66
67 \begin_layout Standard
68 Please note: double dashed longoptions (e.g.
69  --version) are written this way: -
70 \begin_inset ERT
71 status collapsed
72
73 \begin_layout Standard
74
75
76 \backslash
77 /
78 \end_layout
79
80 \end_inset
81
82 -
83 \end_layout
84
85 \begin_layout Standard
86 Two resp.
87  three consecutive dashes would otherwise result in a long resp.
88  extra long dash.
89 \end_layout
90
91 \begin_layout Standard
92 Architecture specific stuff (like memory models, code examples) should maybe
93  later go
94 \end_layout
95
96 \begin_layout Standard
97 into separate sections/chapters/appendices (it is hard to document PIC or
98  Z80 in 
99 \end_layout
100
101 \begin_layout Standard
102 a 8051 centered document) - for now simply add.
103 \end_layout
104
105 \end_inset
106
107
108 \end_layout
109
110 \begin_layout Title
111 SDCC Compiler User Guide
112 \end_layout
113
114 \begin_layout Date
115
116 \size normal
117 SDCC 2.9.0
118 \size footnotesize
119
120 \newline
121 $Date::             $ 
122 \newline
123 $Revision$
124 \end_layout
125
126 \begin_layout Standard
127 \begin_inset Note Note
128 status collapsed
129
130 \begin_layout Standard
131 The above strings enclosed in $ are automatically updated by Subversion
132 \end_layout
133
134 \end_inset
135
136
137 \end_layout
138
139 \begin_layout Standard
140 \begin_inset LatexCommand tableofcontents
141
142 \end_inset
143
144
145 \end_layout
146
147 \begin_layout Chapter
148 Introduction
149 \end_layout
150
151 \begin_layout Section
152 About SDCC
153 \end_layout
154
155 \begin_layout Standard
156
157 \series bold
158 SDCC
159 \series default
160  (
161 \emph on
162 S
163 \emph default
164 mall 
165 \emph on
166 D
167 \emph default
168 evice 
169 \emph on
170 C
171 \emph default
172  
173 \emph on
174 C
175 \emph default
176 ompiler) is free open source, retargettable, optimizing ANSI-C compiler
177  by 
178 \series bold
179 Sandeep Dutta
180 \series default
181  designed for 8 bit Microprocessors.
182  The current version targets Intel MCS51 based Microprocessors (8031, 8032,
183  8051, 8052
184 \begin_inset LatexCommand index
185 name "8031, 8032, 8051, 8052, mcs51 CPU"
186
187 \end_inset
188
189 , etc.), Dallas DS80C390 variants, Freescale (formerly Motorola) HC08 and
190  Zilog Z80 based MCUs.
191  It can be retargeted for other microprocessors, support for Microchip PIC,
192  Atmel AVR is under development.
193  The entire source code for the compiler is distributed under GPL.
194  SDCC uses ASXXXX
195 \begin_inset LatexCommand index
196 name "asXXXX (as-gbz80, as-hc08, asx8051, as-z80)"
197
198 \end_inset
199
200  & ASLINK
201 \begin_inset LatexCommand index
202 name "aslink"
203
204 \end_inset
205
206 , an free open source retargetable assembler & linker.
207  SDCC has extensive language extensions suitable for utilizing various microcont
208 rollers and underlying hardware effectively.
209  
210 \newline
211
212 \newline
213 In addition to the MCU specific optimizations SDCC also does a host of
214  standard optimizations like:
215 \end_layout
216
217 \begin_layout Itemize
218 global sub expression elimination, 
219 \end_layout
220
221 \begin_layout Itemize
222 loop optimizations (loop invariant, strength reduction of induction variables
223  and loop reversing), 
224 \end_layout
225
226 \begin_layout Itemize
227 constant folding & propagation, 
228 \end_layout
229
230 \begin_layout Itemize
231 copy propagation, 
232 \end_layout
233
234 \begin_layout Itemize
235 dead code elimination 
236 \end_layout
237
238 \begin_layout Itemize
239 jump tables for 
240 \emph on
241 switch
242 \emph default
243  statements.
244 \end_layout
245
246 \begin_layout Standard
247 For the back-end SDCC uses a global register allocation scheme which should
248  be well suited for other 8 bit MCUs.
249  
250 \newline
251
252 \newline
253 The peep hole optimizer uses a rule based substitution mechanism which
254  is MCU independent.
255  
256 \newline
257
258 \newline
259 Supported data-types are:
260 \end_layout
261
262 \begin_layout Standard
263 \begin_inset Tabular
264 <lyxtabular version="3" rows="8" columns="5">
265 <features>
266 <column alignment="center" valignment="top" leftline="true" width="0">
267 <column alignment="center" valignment="top" leftline="true" width="0">
268 <column alignment="center" valignment="top" leftline="true" width="0">
269 <column alignment="center" valignment="top" leftline="true" width="0">
270 <column alignment="block" valignment="top" leftline="true" rightline="true" width="20text%">
271 <row topline="true" bottomline="true">
272 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
273 \begin_inset Text
274
275 \begin_layout Standard
276 type
277 \end_layout
278
279 \end_inset
280 </cell>
281 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
282 \begin_inset Text
283
284 \begin_layout Standard
285 width
286 \end_layout
287
288 \end_inset
289 </cell>
290 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
291 \begin_inset Text
292
293 \begin_layout Standard
294 default
295 \end_layout
296
297 \end_inset
298 </cell>
299 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
300 \begin_inset Text
301
302 \begin_layout Standard
303 signed range
304 \end_layout
305
306 \end_inset
307 </cell>
308 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
309 \begin_inset Text
310
311 \begin_layout Standard
312 unsigned range
313 \end_layout
314
315 \end_inset
316 </cell>
317 </row>
318 <row topline="true">
319 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
320 \begin_inset Text
321
322 \begin_layout Standard
323 bool
324 \end_layout
325
326 \end_inset
327 </cell>
328 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
329 \begin_inset Text
330
331 \begin_layout Standard
332 1 bit
333 \end_layout
334
335 \end_inset
336 </cell>
337 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
338 \begin_inset Text
339
340 \begin_layout Standard
341 unsigned
342 \end_layout
343
344 \end_inset
345 </cell>
346 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
347 \begin_inset Text
348
349 \begin_layout Standard
350 -
351 \end_layout
352
353 \end_inset
354 </cell>
355 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
356 \begin_inset Text
357
358 \begin_layout Standard
359 0, 1
360 \end_layout
361
362 \end_inset
363 </cell>
364 </row>
365 <row topline="true">
366 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
367 \begin_inset Text
368
369 \begin_layout Standard
370 char
371 \end_layout
372
373 \end_inset
374 </cell>
375 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
376 \begin_inset Text
377
378 \begin_layout Standard
379 8 bits, 1 byte
380 \end_layout
381
382 \end_inset
383 </cell>
384 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
385 \begin_inset Text
386
387 \begin_layout Standard
388 signed
389 \end_layout
390
391 \end_inset
392 </cell>
393 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
394 \begin_inset Text
395
396 \begin_layout Standard
397 -128, +127
398 \end_layout
399
400 \end_inset
401 </cell>
402 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
403 \begin_inset Text
404
405 \begin_layout Standard
406 0, +255
407 \end_layout
408
409 \end_inset
410 </cell>
411 </row>
412 <row topline="true">
413 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
414 \begin_inset Text
415
416 \begin_layout Standard
417 short
418 \end_layout
419
420 \end_inset
421 </cell>
422 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
423 \begin_inset Text
424
425 \begin_layout Standard
426 16 bits, 2 bytes
427 \end_layout
428
429 \end_inset
430 </cell>
431 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
432 \begin_inset Text
433
434 \begin_layout Standard
435 signed
436 \end_layout
437
438 \end_inset
439 </cell>
440 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
441 \begin_inset Text
442
443 \begin_layout Standard
444 -32.768, +32.767
445 \end_layout
446
447 \end_inset
448 </cell>
449 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
450 \begin_inset Text
451
452 \begin_layout Standard
453 0, +65.535
454 \end_layout
455
456 \end_inset
457 </cell>
458 </row>
459 <row topline="true">
460 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
461 \begin_inset Text
462
463 \begin_layout Standard
464 int
465 \end_layout
466
467 \end_inset
468 </cell>
469 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
470 \begin_inset Text
471
472 \begin_layout Standard
473 16 bits, 2 bytes
474 \end_layout
475
476 \end_inset
477 </cell>
478 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
479 \begin_inset Text
480
481 \begin_layout Standard
482 signed
483 \end_layout
484
485 \end_inset
486 </cell>
487 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
488 \begin_inset Text
489
490 \begin_layout Standard
491 -32.768, +32.767
492 \end_layout
493
494 \end_inset
495 </cell>
496 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
497 \begin_inset Text
498
499 \begin_layout Standard
500 0, +65.535
501 \end_layout
502
503 \end_inset
504 </cell>
505 </row>
506 <row topline="true" bottomline="true">
507 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
508 \begin_inset Text
509
510 \begin_layout Standard
511 long
512 \end_layout
513
514 \end_inset
515 </cell>
516 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
517 \begin_inset Text
518
519 \begin_layout Standard
520 32 bits, 4 bytes
521 \end_layout
522
523 \end_inset
524 </cell>
525 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
526 \begin_inset Text
527
528 \begin_layout Standard
529 signed
530 \end_layout
531
532 \end_inset
533 </cell>
534 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
535 \begin_inset Text
536
537 \begin_layout Standard
538 -2.147.483.648, +2.147.483.647
539 \end_layout
540
541 \end_inset
542 </cell>
543 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
544 \begin_inset Text
545
546 \begin_layout Standard
547 0, +4.294.967.295
548 \end_layout
549
550 \end_inset
551 </cell>
552 </row>
553 <row topline="true" bottomline="true">
554 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
555 \begin_inset Text
556
557 \begin_layout Standard
558 float
559 \end_layout
560
561 \end_inset
562 </cell>
563 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
564 \begin_inset Text
565
566 \begin_layout Standard
567 4 bytes IEEE 754
568 \end_layout
569
570 \end_inset
571 </cell>
572 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
573 \begin_inset Text
574
575 \begin_layout Standard
576 signed
577 \end_layout
578
579 \end_inset
580 </cell>
581 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
582 \begin_inset Text
583
584 \begin_layout Standard
585
586 \end_layout
587
588 \end_inset
589 </cell>
590 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
591 \begin_inset Text
592
593 \begin_layout Standard
594 1.175494351E-38, 
595 \family roman
596 \series medium
597 \shape up
598 \size normal
599 \emph off
600 \bar no
601 \noun off
602 \color none
603 3.402823466E+38
604 \end_layout
605
606 \end_inset
607 </cell>
608 </row>
609 <row topline="true" bottomline="true">
610 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
611 \begin_inset Text
612
613 \begin_layout Standard
614 pointer
615 \end_layout
616
617 \end_inset
618 </cell>
619 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
620 \begin_inset Text
621
622 \begin_layout Standard
623 1, 2, 3 or 4 bytes
624 \end_layout
625
626 \end_inset
627 </cell>
628 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
629 \begin_inset Text
630
631 \begin_layout Standard
632 generic
633 \end_layout
634
635 \end_inset
636 </cell>
637 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
638 \begin_inset Text
639
640 \begin_layout Standard
641
642 \end_layout
643
644 \end_inset
645 </cell>
646 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
647 \begin_inset Text
648
649 \begin_layout Standard
650
651 \end_layout
652
653 \end_inset
654 </cell>
655 </row>
656 </lyxtabular>
657
658 \end_inset
659
660
661 \newline
662 The compiler also allows 
663 \emph on
664 inline assembler code
665 \emph default
666  to be embedded anywhere in a function.
667  In addition, routines developed in assembly can also be called.
668 \newline
669
670 \newline
671 SDCC also
672  provides an option (-
673 \begin_inset ERT
674 status collapsed
675
676 \begin_layout Standard
677
678
679 \backslash
680 /
681 \end_layout
682
683 \end_inset
684
685 -cyclomatic) to report the relative complexity of a function.
686  These functions can then be further optimized, or hand coded in assembly
687  if needed.
688  
689 \newline
690
691 \newline
692 SDCC also comes with a companion source level debugger SDCDB.
693  The debugger currently uses ucSim, a free open source simulator for 8051
694  and other micro-controllers.
695 \newline
696
697 \newline
698 The latest SDCC version can be downloaded from
699  
700 \begin_inset LatexCommand url
701 target "http://sdcc.sourceforge.net/snap.php"
702
703 \end_inset
704
705 .
706  
707 \emph on
708 Please note: the compiler will probably always be some steps ahead of this
709  documentation
710 \series bold
711 \emph default
712
713 \begin_inset LatexCommand index
714 name "Status of documentation"
715
716 \end_inset
717
718
719 \begin_inset Foot
720 status open
721
722 \begin_layout Standard
723 Obviously this has pros and cons
724 \end_layout
725
726 \end_inset
727
728 .
729 \end_layout
730
731 \begin_layout Section
732 Open Source
733 \end_layout
734
735 \begin_layout Standard
736 All packages used in this compiler system are 
737 \emph on
738 free open source
739 \emph default
740 ; source code for all the sub-packages (pre-processor, assemblers, linkers
741  etc.) is distributed with the package.
742  This documentation is maintained using a free open source word processor
743  (LyX).
744 \newline
745 This program is free software; you can redistribute it and/or modify
746  it under the terms of the GNU General Public License
747 \begin_inset LatexCommand index
748 name "GNU General Public License, GPL"
749
750 \end_inset
751
752  as published by the Free Software Foundation; either version 2, or (at
753  your option) any later version.
754  This program is distributed in the hope that it will be useful, but WITHOUT
755  ANY WARRANTY; without even the implied warranty
756 \begin_inset LatexCommand index
757 name "warranty"
758
759 \end_inset
760
761  of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
762  See the GNU General Public License for more details.
763  You should have received a copy of the GNU General Public License along
764  with this program; if not, write to the Free Software Foundation, 59 Temple
765  Place - Suite 330, Boston, MA 02111-1307, USA.
766  In other words, you are welcome to use, share and improve this program.
767  You are forbidden to forbid anyone else to use, share and improve what
768  you give them.
769  Help stamp out software-hoarding! 
770 \end_layout
771
772 \begin_layout Section
773 Typographic conventions
774 \begin_inset LatexCommand index
775 name "Typographic conventions"
776
777 \end_inset
778
779
780 \end_layout
781
782 \begin_layout Standard
783 Throughout this manual, we will use the following convention.
784  Commands you have to type in are printed in 
785 \family sans
786 \series bold
787 "sans serif"
788 \series default
789 .
790
791 \family default
792  Code samples are printed in 
793 \family typewriter
794 typewriter font.
795
796 \family default
797  Interesting items and new terms are printed in 
798 \emph on
799 italic.
800 \end_layout
801
802 \begin_layout Section
803 Compatibility
804 \begin_inset LatexCommand label
805 name "sec:Compatibility-with-previous"
806
807 \end_inset
808
809  with previous versions
810 \begin_inset LatexCommand index
811 name "Compatibility with previous versions"
812
813 \end_inset
814
815
816 \end_layout
817
818 \begin_layout Standard
819 Newer versions have usually numerous bug fixes compared with the previous
820  version.
821  But we also sometimes introduce some incompatibilities with older versions.
822  Not just for the fun of it, but to make the compiler more stable, efficient
823  and ANSI compliant
824 \begin_inset LatexCommand index
825 name "ANSI-compliance"
826
827 \end_inset
828
829  (see section 
830 \begin_inset LatexCommand ref
831 reference "sub:ANSI-Compliance"
832
833 \end_inset
834
835  for ANSI-Compliance).
836  
837 \begin_inset Note Note
838 status collapsed
839
840 \begin_layout Standard
841 It would be fine to add to each item, in which version was it changed.
842 \end_layout
843
844 \end_inset
845
846
847 \newline
848
849 \end_layout
850
851 \begin_layout Itemize
852 short is now equivalent to int (16 bits), it used to be equivalent to char
853  (8 bits) which is not ANSI compliant.
854  To maintain compatibility, old programs may be compiled using the -
855 \begin_inset ERT
856 status collapsed
857
858 \begin_layout Standard
859
860
861 \backslash
862 /
863 \end_layout
864
865 \end_inset
866
867 -short-is-8bits commandline option (see 
868 \begin_inset LatexCommand vref
869 reference "lyx:--short-is-8bits"
870
871 \end_inset
872
873 ).
874 \end_layout
875
876 \begin_layout Itemize
877 the default directory for gcc-builds where include, library and documentation
878  files are stored is now in /usr/local/share.
879 \end_layout
880
881 \begin_layout Itemize
882 char type parameters to vararg
883 \begin_inset LatexCommand index
884 name "vararg, va\\_arg"
885
886 \end_inset
887
888  functions are casted to int unless explicitly casted and 
889 \series bold
890 -
891 \begin_inset ERT
892 status collapsed
893
894 \begin_layout Standard
895
896
897 \backslash
898 /
899 \end_layout
900
901 \end_inset
902
903 -std-c89
904 \begin_inset LatexCommand index
905 name "-\\/-std-c89"
906
907 \end_inset
908
909
910 \series default
911  and 
912 \series bold
913 -
914 \begin_inset ERT
915 status collapsed
916
917 \begin_layout Standard
918
919
920 \backslash
921 /
922 \end_layout
923
924 \end_inset
925
926 -std-c99
927 \begin_inset LatexCommand index
928 name "-\\/-std-c99"
929
930 \end_inset
931
932
933 \series default
934  command line option are not defined 
935 \begin_inset Marginal
936 status collapsed
937
938 \begin_layout Standard
939
940 \series bold
941 \InsetSpace ~
942 !
943 \end_layout
944
945 \end_inset
946
947 , e.g.: 
948 \newline
949
950 \family typewriter
951 \InsetSpace ~
952 \InsetSpace ~
953 char a=3;
954 \newline
955 \InsetSpace ~
956 \InsetSpace ~
957 printf ("%d %c
958 \backslash
959 n", a, (char)a);
960 \family default
961
962 \newline
963  will push a as an int and as a char resp if 
964 \series bold
965 -
966 \begin_inset ERT
967 status collapsed
968
969 \begin_layout Standard
970
971
972 \backslash
973 /
974 \end_layout
975
976 \end_inset
977
978 -std-c89
979 \begin_inset LatexCommand index
980 name "-\\/-std-c89"
981
982 \end_inset
983
984
985 \series default
986  and 
987 \series bold
988 -
989 \begin_inset ERT
990 status collapsed
991
992 \begin_layout Standard
993
994
995 \backslash
996 /
997 \end_layout
998
999 \end_inset
1000
1001 -std-c99
1002 \begin_inset LatexCommand index
1003 name "-\\/-std-c99"
1004
1005 \end_inset
1006
1007
1008 \series default
1009  command line options are not defined,
1010 \newline
1011  will push a as two ints if 
1012 \series bold
1013 -
1014 \begin_inset ERT
1015 status collapsed
1016
1017 \begin_layout Standard
1018
1019
1020 \backslash
1021 /
1022 \end_layout
1023
1024 \end_inset
1025
1026 -std-c89
1027 \begin_inset LatexCommand index
1028 name "-\\/-std-c89"
1029
1030 \end_inset
1031
1032
1033 \series default
1034  or 
1035 \series bold
1036 -
1037 \begin_inset ERT
1038 status collapsed
1039
1040 \begin_layout Standard
1041
1042
1043 \backslash
1044 /
1045 \end_layout
1046
1047 \end_inset
1048
1049 -std-c99
1050 \begin_inset LatexCommand index
1051 name "-\\/-std-c99"
1052
1053 \end_inset
1054
1055
1056 \series default
1057  command line option is defined.
1058 \end_layout
1059
1060 \begin_layout Itemize
1061 option -
1062 \begin_inset ERT
1063 status collapsed
1064
1065 \begin_layout Standard
1066
1067
1068 \backslash
1069 /
1070 \end_layout
1071
1072 \end_inset
1073
1074 -regextend has been removed.
1075 \end_layout
1076
1077 \begin_layout Itemize
1078 option -
1079 \begin_inset ERT
1080 status collapsed
1081
1082 \begin_layout Standard
1083
1084
1085 \backslash
1086 /
1087 \end_layout
1088
1089 \end_inset
1090
1091 -noregparms has been removed.
1092 \end_layout
1093
1094 \begin_layout Itemize
1095 option -
1096 \begin_inset ERT
1097 status collapsed
1098
1099 \begin_layout Standard
1100
1101
1102 \backslash
1103 /
1104 \end_layout
1105
1106 \end_inset
1107
1108 -stack-after-data has been removed.
1109 \end_layout
1110
1111 \begin_layout Itemize
1112 bit
1113 \begin_inset LatexCommand index
1114 name "bit"
1115
1116 \end_inset
1117
1118  and sbit
1119 \begin_inset LatexCommand index
1120 name "sbit"
1121
1122 \end_inset
1123
1124
1125 \begin_inset LatexCommand index
1126 name "\\_\\_sbit"
1127
1128 \end_inset
1129
1130  types now consistently behave like the C99 _Bool type with respect to type
1131  conversion
1132 \begin_inset LatexCommand index
1133 name "type conversion"
1134
1135 \end_inset
1136
1137
1138 \begin_inset LatexCommand index
1139 name "type promotion"
1140
1141 \end_inset
1142
1143 .
1144  The most common incompatibility resulting from this change is related to
1145  bit toggling
1146 \begin_inset LatexCommand index
1147 name "Bit toggling"
1148
1149 \end_inset
1150
1151  idioms, e.g.:
1152 \newline
1153
1154 \family typewriter
1155 \InsetSpace ~
1156 \InsetSpace ~
1157 bit b;
1158 \newline
1159 \InsetSpace ~
1160 \InsetSpace ~
1161 b = ~
1162 \begin_inset LatexCommand index
1163 name "\\~\\/ Operator"
1164
1165 \end_inset
1166
1167 b; /* equivalent to b=1 instead of toggling b */
1168 \begin_inset Marginal
1169 status collapsed
1170
1171 \begin_layout Standard
1172
1173 \series bold
1174 \InsetSpace ~
1175 !
1176 \end_layout
1177
1178 \end_inset
1179
1180
1181 \newline
1182 \InsetSpace ~
1183 \InsetSpace ~
1184 b = !b; /* toggles b */
1185 \newline
1186
1187 \family default
1188 In previous versions, both forms would have toggled the bit.
1189 \end_layout
1190
1191 \begin_layout Itemize
1192 in older versions, the preprocessor was always called with 
1193 \series bold
1194 -
1195 \begin_inset ERT
1196 status collapsed
1197
1198 \begin_layout Standard
1199
1200
1201 \backslash
1202 /
1203 \end_layout
1204
1205 \end_inset
1206
1207 -std-c99
1208 \begin_inset LatexCommand index
1209 name "-\\/-std-c99"
1210
1211 \end_inset
1212
1213
1214 \series default
1215  regardless of the 
1216 \series bold
1217 -
1218 \begin_inset ERT
1219 status collapsed
1220
1221 \begin_layout Standard
1222
1223
1224 \backslash
1225 /
1226 \end_layout
1227
1228 \end_inset
1229
1230 -std-xxx
1231 \series default
1232  setting.
1233  This is no longer true, and can cause compilation failures on code built
1234  with 
1235 \series bold
1236 -
1237 \begin_inset ERT
1238 status collapsed
1239
1240 \begin_layout Standard
1241
1242
1243 \backslash
1244 /
1245 \end_layout
1246
1247 \end_inset
1248
1249 -std-c89
1250 \begin_inset LatexCommand index
1251 name "-\\/-std-c89"
1252
1253 \end_inset
1254
1255
1256 \series default
1257  but using c99 preprocessor features, such as one-line (//) comments
1258 \end_layout
1259
1260 \begin_layout Itemize
1261 in versions older then 2.8.4 the pic16 *printf() and printf_tiny() library
1262  functions supported undocumented and not standard compliant 'b' binary
1263  format specifier ("%b", "%hb" and "%lb").
1264  The 'b' specifier is now disabled by default.
1265  It can be enabled by defining BINARY_SPECIFIER macro in files device/lib/pic16/
1266 libc/stdio/vfprintf.c and device/lib/pic16/libc/stdio/printf_tiny.c and recompilin
1267 g the library.
1268 \end_layout
1269
1270 \begin_layout Itemize
1271 in versions older then 2.8.5 the unnamed bitfield structure members participated
1272  in initialization, which is not conforming with ISO/IEC 9899:1999 standard
1273  (see section Section 6.7.8 Initialization, clause 9)
1274 \newline
1275
1276 \newline
1277 Old behavior, before
1278  version 2.8.5:
1279 \family typewriter
1280
1281 \newline
1282 \InsetSpace ~
1283 \InsetSpace ~
1284 struct {
1285 \newline
1286 \InsetSpace ~
1287 \InsetSpace ~
1288 \InsetSpace ~
1289 \InsetSpace ~
1290 int a : 2;
1291 \newline
1292 \InsetSpace ~
1293 \InsetSpace ~
1294 \InsetSpace ~
1295 \InsetSpace ~
1296 char\InsetSpace ~
1297  : 2;
1298 \newline
1299 \InsetSpace ~
1300 \InsetSpace ~
1301 \InsetSpace ~
1302 \InsetSpace ~
1303 int b : 2;
1304 \newline
1305 \InsetSpace ~
1306 \InsetSpace ~
1307 } s = {1, 2, 3};
1308 \family default
1309
1310 \newline
1311
1312 \family typewriter
1313 /* s.a = 1, s.b = 3 */
1314 \family default
1315
1316 \newline
1317
1318 \newline
1319 New behavior:
1320 \family typewriter
1321
1322 \newline
1323 \InsetSpace ~
1324 \InsetSpace ~
1325 struct {
1326 \newline
1327 \InsetSpace ~
1328 \InsetSpace ~
1329 \InsetSpace ~
1330 \InsetSpace ~
1331 int a : 2;
1332 \newline
1333 \InsetSpace ~
1334 \InsetSpace ~
1335 \InsetSpace ~
1336 \InsetSpace ~
1337 char\InsetSpace ~
1338  : 2;
1339 \newline
1340 \InsetSpace ~
1341 \InsetSpace ~
1342 \InsetSpace ~
1343 \InsetSpace ~
1344 int b : 2;
1345 \newline
1346 \InsetSpace ~
1347 \InsetSpace ~
1348 } s = {1, 2};
1349 \family default
1350
1351 \newline
1352
1353 \family typewriter
1354 /* s.a = 1, s.b = 2 */
1355 \end_layout
1356
1357 \begin_layout Section
1358 System Requirements
1359 \end_layout
1360
1361 \begin_layout Standard
1362 What do you need before you start installation of SDCC? A computer, and
1363  a desire to compute.
1364  The preferred method of installation is to compile SDCC from source using
1365  GNU gcc and make.
1366  For Windows some pre-compiled binary distributions are available for your
1367  convenience.
1368  You should have some experience with command line tools and compiler use.
1369 \end_layout
1370
1371 \begin_layout Section
1372 Other Resources
1373 \end_layout
1374
1375 \begin_layout Standard
1376 The SDCC home page at 
1377 \begin_inset LatexCommand url
1378 target "http://sdcc.sourceforge.net/"
1379
1380 \end_inset
1381
1382  is a great place to find distribution sets.
1383  You can also find links to the user mailing lists that offer help or discuss
1384  SDCC with other SDCC users.
1385  Web links to other SDCC related sites can also be found here.
1386  This document can be found in the DOC directory of the source package as
1387  a text or HTML file.
1388  A pdf version of this document is available at 
1389 \begin_inset LatexCommand url
1390 target "http://sdcc.sourceforge.net/doc/sdccman.pdf"
1391
1392 \end_inset
1393
1394 .
1395  Some of the other tools (simulator and assembler) included with SDCC contain
1396  their own documentation and can be found in the source distribution.
1397  If you want the latest unreleased software, the complete source package
1398  is available directly from Subversion on https://sdcc.svn.sourceforge.net/svnroot/
1399 sdcc/trunk/sdcc.
1400 \end_layout
1401
1402 \begin_layout Section
1403 Wishes for the future
1404 \end_layout
1405
1406 \begin_layout Standard
1407 There are (and always will be) some things that could be done.
1408  Here are some I can think of:
1409 \newline
1410
1411 \end_layout
1412
1413 \begin_layout Standard
1414
1415 \family typewriter
1416 char KernelFunction3(char p) at 0x340;
1417 \newline
1418
1419 \end_layout
1420
1421 \begin_layout Standard
1422
1423 \family typewriter
1424 better code banking
1425 \begin_inset LatexCommand index
1426 name "code banking (limited support)"
1427
1428 \end_inset
1429
1430  support for mcs51
1431 \newline
1432
1433 \newline
1434
1435 \family default
1436 If you can think of some more, please see the section 
1437 \begin_inset LatexCommand ref
1438 reference "sub:Requesting-Features"
1439
1440 \end_inset
1441
1442  about filing feature requests
1443 \begin_inset LatexCommand index
1444 name "Requesting features"
1445
1446 \end_inset
1447
1448
1449 \begin_inset LatexCommand index
1450 name "Feature request"
1451
1452 \end_inset
1453
1454 .
1455 \newline
1456
1457 \end_layout
1458
1459 \begin_layout Chapter
1460 Installing SDCC
1461 \begin_inset LatexCommand index
1462 name "Installation"
1463
1464 \end_inset
1465
1466
1467 \end_layout
1468
1469 \begin_layout Standard
1470 For most users it is sufficient to skip to either section 
1471 \begin_inset LatexCommand ref
1472 reference "sub:Building-SDCC-on-Linux"
1473
1474 \end_inset
1475
1476  (Unix) or section 
1477 \begin_inset LatexCommand ref
1478 reference "sub:Windows-Install"
1479
1480 \end_inset
1481
1482  (Windows).
1483  More detailed instructions follow below.
1484 \end_layout
1485
1486 \begin_layout Section
1487 Configure Options
1488 \begin_inset LatexCommand index
1489 name "Options SDCC configuration"
1490
1491 \end_inset
1492
1493
1494 \end_layout
1495
1496 \begin_layout Standard
1497 The install paths, search paths and other options are defined when running
1498  'configure'.
1499  The defaults can be overridden by:
1500 \end_layout
1501
1502 \begin_layout List
1503 \labelwidthstring 00.00.0000
1504 -
1505 \begin_inset ERT
1506 status collapsed
1507
1508 \begin_layout Standard
1509
1510
1511 \backslash
1512 /
1513 \end_layout
1514
1515 \end_inset
1516
1517 -prefix see table below
1518 \end_layout
1519
1520 \begin_layout List
1521 \labelwidthstring 00.00.0000
1522 -
1523 \begin_inset ERT
1524 status collapsed
1525
1526 \begin_layout Standard
1527
1528
1529 \backslash
1530 /
1531 \end_layout
1532
1533 \end_inset
1534
1535 -exec_prefix see table below
1536 \end_layout
1537
1538 \begin_layout List
1539 \labelwidthstring 00.00.0000
1540 -
1541 \begin_inset ERT
1542 status collapsed
1543
1544 \begin_layout Standard
1545
1546
1547 \backslash
1548 /
1549 \end_layout
1550
1551 \end_inset
1552
1553 -bindir see table below
1554 \end_layout
1555
1556 \begin_layout List
1557 \labelwidthstring 00.00.0000
1558 -
1559 \begin_inset ERT
1560 status collapsed
1561
1562 \begin_layout Standard
1563
1564
1565 \backslash
1566 /
1567 \end_layout
1568
1569 \end_inset
1570
1571 -datadir see table below
1572 \end_layout
1573
1574 \begin_layout List
1575 \labelwidthstring 00.00.0000
1576 -
1577 \begin_inset ERT
1578 status collapsed
1579
1580 \begin_layout Standard
1581
1582
1583 \backslash
1584 /
1585 \end_layout
1586
1587 \end_inset
1588
1589 -datarootdir see table below
1590 \newline
1591
1592 \end_layout
1593
1594 \begin_layout List
1595 \labelwidthstring 00.00.0000
1596 \InsetSpace ~
1597 \InsetSpace ~
1598 docdir environment variable, see table below
1599 \end_layout
1600
1601 \begin_layout List
1602 \labelwidthstring 00.00.0000
1603 \InsetSpace ~
1604 \InsetSpace ~
1605 include_dir_suffix environment variable, see table below
1606 \end_layout
1607
1608 \begin_layout List
1609 \labelwidthstring 00.00.0000
1610 \InsetSpace ~
1611 \InsetSpace ~
1612 lib_dir_suffix environment variable, see table below
1613 \end_layout
1614
1615 \begin_layout List
1616 \labelwidthstring 00.00.0000
1617 \InsetSpace ~
1618 \InsetSpace ~
1619 sdccconf_h_dir_separator environment variable, either / or 
1620 \backslash
1621
1622 \backslash
1623  makes sense here.
1624  This character will only be used in sdccconf.h; don't forget it's a C-header,
1625  therefore a double-backslash is needed there.
1626 \newline
1627
1628 \end_layout
1629
1630 \begin_layout List
1631 \labelwidthstring 00.00.0000
1632 -
1633 \begin_inset ERT
1634 status collapsed
1635
1636 \begin_layout Standard
1637
1638
1639 \backslash
1640 /
1641 \end_layout
1642
1643 \end_inset
1644
1645 -disable-mcs51-port Excludes the Intel mcs51 port
1646 \end_layout
1647
1648 \begin_layout List
1649 \labelwidthstring 00.00.0000
1650 -
1651 \begin_inset ERT
1652 status collapsed
1653
1654 \begin_layout Standard
1655
1656
1657 \backslash
1658 /
1659 \end_layout
1660
1661 \end_inset
1662
1663 -disable-gbz80-port Excludes the Gameboy gbz80 port
1664 \end_layout
1665
1666 \begin_layout List
1667 \labelwidthstring 00.00.0000
1668 -
1669 \begin_inset ERT
1670 status collapsed
1671
1672 \begin_layout Standard
1673
1674
1675 \backslash
1676 /
1677 \end_layout
1678
1679 \end_inset
1680
1681 -disable-z80-port Excludes the z80 port
1682 \end_layout
1683
1684 \begin_layout List
1685 \labelwidthstring 00.00.0000
1686 -
1687 \begin_inset ERT
1688 status collapsed
1689
1690 \begin_layout Standard
1691
1692
1693 \backslash
1694 /
1695 \end_layout
1696
1697 \end_inset
1698
1699 -disable-avr-port Excludes the AVR port
1700 \end_layout
1701
1702 \begin_layout List
1703 \labelwidthstring 00.00.0000
1704 -
1705 \begin_inset ERT
1706 status collapsed
1707
1708 \begin_layout Standard
1709
1710
1711 \backslash
1712 /
1713 \end_layout
1714
1715 \end_inset
1716
1717 -disable-ds390-port Excludes the DS390 port
1718 \end_layout
1719
1720 \begin_layout List
1721 \labelwidthstring 00.00.0000
1722 -
1723 \begin_inset ERT
1724 status collapsed
1725
1726 \begin_layout Standard
1727
1728
1729 \backslash
1730 /
1731 \end_layout
1732
1733 \end_inset
1734
1735 -disable-hc08-port Excludes the HC08 port
1736 \end_layout
1737
1738 \begin_layout List
1739 \labelwidthstring 00.00.0000
1740 -
1741 \begin_inset ERT
1742 status collapsed
1743
1744 \begin_layout Standard
1745
1746
1747 \backslash
1748 /
1749 \end_layout
1750
1751 \end_inset
1752
1753 -disable-pic-port Excludes the PIC14 port
1754 \end_layout
1755
1756 \begin_layout List
1757 \labelwidthstring 00.00.0000
1758 -
1759 \begin_inset ERT
1760 status collapsed
1761
1762 \begin_layout Standard
1763
1764
1765 \backslash
1766 /
1767 \end_layout
1768
1769 \end_inset
1770
1771 -disable-pic16-port Excludes the PIC16 port
1772 \end_layout
1773
1774 \begin_layout List
1775 \labelwidthstring 00.00.0000
1776 -
1777 \begin_inset ERT
1778 status collapsed
1779
1780 \begin_layout Standard
1781
1782
1783 \backslash
1784 /
1785 \end_layout
1786
1787 \end_inset
1788
1789 -disable-xa51-port Excludes the XA51 port
1790 \end_layout
1791
1792 \begin_layout List
1793 \labelwidthstring 00.00.0000
1794 -
1795 \begin_inset ERT
1796 status collapsed
1797
1798 \begin_layout Standard
1799
1800
1801 \backslash
1802 /
1803 \end_layout
1804
1805 \end_inset
1806
1807 -disable-ucsim Disables configuring and building of ucsim
1808 \end_layout
1809
1810 \begin_layout List
1811 \labelwidthstring 00.00.0000
1812 -
1813 \begin_inset ERT
1814 status collapsed
1815
1816 \begin_layout Standard
1817
1818
1819 \backslash
1820 /
1821 \end_layout
1822
1823 \end_inset
1824
1825 -disable-device-lib Disables automatically building device libraries
1826 \end_layout
1827
1828 \begin_layout List
1829 \labelwidthstring 00.00.0000
1830 -
1831 \begin_inset ERT
1832 status collapsed
1833
1834 \begin_layout Standard
1835
1836
1837 \backslash
1838 /
1839 \end_layout
1840
1841 \end_inset
1842
1843 -disable-packihx Disables building packihx
1844 \newline
1845
1846 \end_layout
1847
1848 \begin_layout List
1849 \labelwidthstring 00.00.0000
1850 -
1851 \begin_inset ERT
1852 status collapsed
1853
1854 \begin_layout Standard
1855
1856
1857 \backslash
1858 /
1859 \end_layout
1860
1861 \end_inset
1862
1863 -enable-doc Build pdf, html and txt files from the lyx sources
1864 \end_layout
1865
1866 \begin_layout List
1867 \labelwidthstring 00.00.0000
1868 -
1869 \begin_inset ERT
1870 status collapsed
1871
1872 \begin_layout Standard
1873
1874
1875 \backslash
1876 /
1877 \end_layout
1878
1879 \end_inset
1880
1881 -enable-libgc Use the Bohem memory allocator.
1882  Lower runtime footprint.
1883 \end_layout
1884
1885 \begin_layout List
1886 \labelwidthstring 00.00.0000
1887 -
1888 \begin_inset ERT
1889 status collapsed
1890
1891 \begin_layout Standard
1892
1893
1894 \backslash
1895 /
1896 \end_layout
1897
1898 \end_inset
1899
1900 -without-ccache Do not use ccache even if available
1901 \end_layout
1902
1903 \begin_layout Standard
1904 Furthermore the environment variables CC, CFLAGS, ...
1905  the tools and their arguments can be influenced.
1906  Please see `configure -
1907 \begin_inset ERT
1908 status collapsed
1909
1910 \begin_layout Standard
1911
1912
1913 \backslash
1914 /
1915 \end_layout
1916
1917 \end_inset
1918
1919 -help' and the man/info pages of `configure' for details.
1920 \newline
1921
1922 \newline
1923 The names of the
1924  standard libraries STD_LIB, STD_INT_LIB, STD_LONG_LIB, STD_FP_LIB, STD_DS390_LI
1925 B, STD_XA51_LIB and the environment variables SDCC_DIR_NAME, SDCC_INCLUDE_NAME,
1926  SDCC_LIB_NAME are defined by `configure' too.
1927  At the moment it's not possible to change the default settings (it was
1928  simply never required).
1929 \newline
1930
1931 \newline
1932 These configure options are compiled into the binaries,
1933  and can only be changed by rerunning 'configure' and recompiling SDCC.
1934  The configure options are written in 
1935 \emph on
1936 italics
1937 \emph default
1938  to distinguish them from run time environment variables (see section search
1939  paths).
1940 \newline
1941
1942 \newline
1943 The settings for 
1944 \begin_inset Quotes sld
1945 \end_inset
1946
1947 Win32 builds
1948 \begin_inset Quotes srd
1949 \end_inset
1950
1951  are used by the SDCC team to build the official Win32 binaries.
1952  The SDCC team uses Mingw32 to build the official Windows binaries, because
1953  it's
1954 \end_layout
1955
1956 \begin_layout Enumerate
1957 open source, 
1958 \end_layout
1959
1960 \begin_layout Enumerate
1961 a gcc compiler and last but not least
1962 \end_layout
1963
1964 \begin_layout Enumerate
1965 the binaries can be built by cross compiling on SDCC Distributed Compile
1966  Farm.
1967 \end_layout
1968
1969 \begin_layout Standard
1970 See the examples, how to pass the Win32 settings to 'configure'.
1971  The other Win32 builds using Borland, VC or whatever don't use 'configure',
1972  but a header file sdcc_vc_in.h is the same as sdccconf.h built by 'configure'
1973  for Win32.
1974 \newline
1975
1976 \newline
1977 These defaults are:
1978 \newline
1979
1980 \end_layout
1981
1982 \begin_layout Standard
1983 \align center
1984 \begin_inset Tabular
1985 <lyxtabular version="3" rows="9" columns="3">
1986 <features>
1987 <column alignment="block" valignment="top" leftline="true" width="0in">
1988 <column alignment="block" valignment="top" leftline="true" width="0in">
1989 <column alignment="block" valignment="top" leftline="true" rightline="true" width="0in">
1990 <row topline="true" bottomline="true">
1991 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
1992 \begin_inset Text
1993
1994 \begin_layout Standard
1995 Variable
1996 \end_layout
1997
1998 \end_inset
1999 </cell>
2000 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2001 \begin_inset Text
2002
2003 \begin_layout Standard
2004 default
2005 \end_layout
2006
2007 \end_inset
2008 </cell>
2009 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2010 \begin_inset Text
2011
2012 \begin_layout Standard
2013 Win32 builds
2014 \end_layout
2015
2016 \end_inset
2017 </cell>
2018 </row>
2019 <row topline="true">
2020 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2021 \begin_inset Text
2022
2023 \begin_layout Standard
2024
2025 \emph on
2026 PREFIX
2027 \end_layout
2028
2029 \end_inset
2030 </cell>
2031 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2032 \begin_inset Text
2033
2034 \begin_layout Standard
2035 /usr/local
2036 \end_layout
2037
2038 \end_inset
2039 </cell>
2040 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2041 \begin_inset Text
2042
2043 \begin_layout Standard
2044
2045 \backslash
2046 sdcc
2047 \end_layout
2048
2049 \end_inset
2050 </cell>
2051 </row>
2052 <row topline="true">
2053 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2054 \begin_inset Text
2055
2056 \begin_layout Standard
2057
2058 \emph on
2059 EXEC_PREFIX
2060 \end_layout
2061
2062 \end_inset
2063 </cell>
2064 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2065 \begin_inset Text
2066
2067 \begin_layout Standard
2068
2069 \emph on
2070 $PREFIX
2071 \end_layout
2072
2073 \end_inset
2074 </cell>
2075 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2076 \begin_inset Text
2077
2078 \begin_layout Standard
2079
2080 \emph on
2081 $PREFIX
2082 \end_layout
2083
2084 \end_inset
2085 </cell>
2086 </row>
2087 <row topline="true">
2088 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2089 \begin_inset Text
2090
2091 \begin_layout Standard
2092
2093 \emph on
2094 BINDIR
2095 \end_layout
2096
2097 \end_inset
2098 </cell>
2099 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2100 \begin_inset Text
2101
2102 \begin_layout Standard
2103
2104 \emph on
2105 $EXEC_PREFIX
2106 \emph default
2107 /bin
2108 \end_layout
2109
2110 \end_inset
2111 </cell>
2112 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2113 \begin_inset Text
2114
2115 \begin_layout Standard
2116
2117 \emph on
2118 $EXEC_PREFIX
2119 \emph default
2120
2121 \backslash
2122 bin
2123 \end_layout
2124
2125 \end_inset
2126 </cell>
2127 </row>
2128 <row topline="true">
2129 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2130 \begin_inset Text
2131
2132 \begin_layout Standard
2133
2134 \emph on
2135 DATADIR
2136 \end_layout
2137
2138 \end_inset
2139 </cell>
2140 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2141 \begin_inset Text
2142
2143 \begin_layout Standard
2144
2145 \emph on
2146 $DATAROOTDIR
2147 \end_layout
2148
2149 \end_inset
2150 </cell>
2151 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2152 \begin_inset Text
2153
2154 \begin_layout Standard
2155
2156 \emph on
2157 $DATAROOTDIR
2158 \end_layout
2159
2160 \end_inset
2161 </cell>
2162 </row>
2163 <row topline="true">
2164 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2165 \begin_inset Text
2166
2167 \begin_layout Standard
2168
2169 \emph on
2170 DATAROOTDIR
2171 \end_layout
2172
2173 \end_inset
2174 </cell>
2175 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2176 \begin_inset Text
2177
2178 \begin_layout Standard
2179
2180 \emph on
2181 $PREFIX
2182 \emph default
2183 /share
2184 \end_layout
2185
2186 \end_inset
2187 </cell>
2188 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2189 \begin_inset Text
2190
2191 \begin_layout Standard
2192
2193 \emph on
2194 $PREFIX
2195 \end_layout
2196
2197 \end_inset
2198 </cell>
2199 </row>
2200 <row topline="true">
2201 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2202 \begin_inset Text
2203
2204 \begin_layout Standard
2205
2206 \emph on
2207 DOCDIR
2208 \end_layout
2209
2210 \end_inset
2211 </cell>
2212 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2213 \begin_inset Text
2214
2215 \begin_layout Standard
2216
2217 \emph on
2218 $DATAROOTDIR
2219 \emph default
2220 /sdcc/doc
2221 \end_layout
2222
2223 \end_inset
2224 </cell>
2225 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2226 \begin_inset Text
2227
2228 \begin_layout Standard
2229
2230 \emph on
2231 $DATAROOTDIR
2232 \emph default
2233
2234 \backslash
2235 doc
2236 \end_layout
2237
2238 \end_inset
2239 </cell>
2240 </row>
2241 <row topline="true">
2242 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2243 \begin_inset Text
2244
2245 \begin_layout Standard
2246
2247 \emph on
2248 INCLUDE_DIR_SUFFIX
2249 \end_layout
2250
2251 \end_inset
2252 </cell>
2253 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2254 \begin_inset Text
2255
2256 \begin_layout Standard
2257 sdcc/include
2258 \end_layout
2259
2260 \end_inset
2261 </cell>
2262 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2263 \begin_inset Text
2264
2265 \begin_layout Standard
2266 include
2267 \end_layout
2268
2269 \end_inset
2270 </cell>
2271 </row>
2272 <row topline="true" bottomline="true">
2273 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2274 \begin_inset Text
2275
2276 \begin_layout Standard
2277
2278 \emph on
2279 LIB_DIR_SUFFIX
2280 \end_layout
2281
2282 \end_inset
2283 </cell>
2284 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2285 \begin_inset Text
2286
2287 \begin_layout Standard
2288 sdcc/lib
2289 \end_layout
2290
2291 \end_inset
2292 </cell>
2293 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2294 \begin_inset Text
2295
2296 \begin_layout Standard
2297 lib
2298 \end_layout
2299
2300 \end_inset
2301 </cell>
2302 </row>
2303 </lyxtabular>
2304
2305 \end_inset
2306
2307
2308 \newline
2309
2310 \end_layout
2311
2312 \begin_layout Standard
2313 \noindent
2314 'configure' also computes relative paths.
2315  This is needed for full relocatability of a binary package and to complete
2316  search paths (see section search paths below):
2317 \newline
2318  
2319 \end_layout
2320
2321 \begin_layout Standard
2322 \align center
2323 \begin_inset Tabular
2324 <lyxtabular version="3" rows="4" columns="3">
2325 <features>
2326 <column alignment="block" valignment="top" leftline="true" width="0in">
2327 <column alignment="block" valignment="top" leftline="true" width="0in">
2328 <column alignment="block" valignment="top" leftline="true" rightline="true" width="0in">
2329 <row topline="true" bottomline="true">
2330 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2331 \begin_inset Text
2332
2333 \begin_layout Standard
2334 Variable (computed)
2335 \end_layout
2336
2337 \end_inset
2338 </cell>
2339 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2340 \begin_inset Text
2341
2342 \begin_layout Standard
2343 default
2344 \end_layout
2345
2346 \end_inset
2347 </cell>
2348 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2349 \begin_inset Text
2350
2351 \begin_layout Standard
2352 Win32 builds
2353 \end_layout
2354
2355 \end_inset
2356 </cell>
2357 </row>
2358 <row topline="true" bottomline="true">
2359 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2360 \begin_inset Text
2361
2362 \begin_layout Standard
2363
2364 \emph on
2365 BIN2DATA_DIR
2366 \end_layout
2367
2368 \end_inset
2369 </cell>
2370 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2371 \begin_inset Text
2372
2373 \begin_layout Standard
2374 ../share
2375 \end_layout
2376
2377 \end_inset
2378 </cell>
2379 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2380 \begin_inset Text
2381
2382 \begin_layout Standard
2383 ..
2384 \end_layout
2385
2386 \end_inset
2387 </cell>
2388 </row>
2389 <row bottomline="true">
2390 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2391 \begin_inset Text
2392
2393 \begin_layout Standard
2394
2395 \emph on
2396 PREFIX2BIN_DIR
2397 \end_layout
2398
2399 \end_inset
2400 </cell>
2401 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2402 \begin_inset Text
2403
2404 \begin_layout Standard
2405 bin
2406 \end_layout
2407
2408 \end_inset
2409 </cell>
2410 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2411 \begin_inset Text
2412
2413 \begin_layout Standard
2414 bin
2415 \end_layout
2416
2417 \end_inset
2418 </cell>
2419 </row>
2420 <row bottomline="true">
2421 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2422 \begin_inset Text
2423
2424 \begin_layout Standard
2425
2426 \emph on
2427 PREFIX2DATA_DIR
2428 \end_layout
2429
2430 \end_inset
2431 </cell>
2432 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2433 \begin_inset Text
2434
2435 \begin_layout Standard
2436 share/sdcc
2437 \end_layout
2438
2439 \end_inset
2440 </cell>
2441 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2442 \begin_inset Text
2443
2444 \begin_layout Standard
2445
2446 \end_layout
2447
2448 \end_inset
2449 </cell>
2450 </row>
2451 </lyxtabular>
2452
2453 \end_inset
2454
2455
2456 \newline
2457
2458 \end_layout
2459
2460 \begin_layout Standard
2461 \noindent
2462 Examples:
2463 \end_layout
2464
2465 \begin_layout LyX-Code
2466 ./configure
2467 \newline
2468 ./configure -
2469 \begin_inset ERT
2470 status collapsed
2471
2472 \begin_layout Standard
2473
2474
2475 \backslash
2476 /
2477 \end_layout
2478
2479 \end_inset
2480
2481 -prefix=
2482 \begin_inset Quotes srd
2483 \end_inset
2484
2485 /usr/bin
2486 \begin_inset Quotes srd
2487 \end_inset
2488
2489  -
2490 \begin_inset ERT
2491 status collapsed
2492
2493 \begin_layout Standard
2494
2495
2496 \backslash
2497 /
2498 \end_layout
2499
2500 \end_inset
2501
2502 -datarootdir=
2503 \begin_inset Quotes srd
2504 \end_inset
2505
2506 /usr/share
2507 \begin_inset Quotes srd
2508 \end_inset
2509
2510
2511 \newline
2512 ./configure -
2513 \begin_inset ERT
2514 status collapsed
2515
2516 \begin_layout Standard
2517
2518
2519 \backslash
2520 /
2521 \end_layout
2522
2523 \end_inset
2524
2525 -disable-avr-port -
2526 \begin_inset ERT
2527 status collapsed
2528
2529 \begin_layout Standard
2530
2531
2532 \backslash
2533 /
2534 \end_layout
2535
2536 \end_inset
2537
2538 -disable-xa51-port
2539 \end_layout
2540
2541 \begin_layout Standard
2542 To cross compile on linux for Mingw32 (see also 'sdcc/support/scripts/sdcc_mingw
2543 32'):
2544 \end_layout
2545
2546 \begin_layout LyX-Code
2547 ./configure 
2548 \backslash
2549
2550 \newline
2551 CC=
2552 \begin_inset Quotes srd
2553 \end_inset
2554
2555 i586-mingw32msvc-gcc
2556 \begin_inset Quotes srd
2557 \end_inset
2558
2559  CXX=
2560 \begin_inset Quotes srd
2561 \end_inset
2562
2563 i586-mingw32msvc-g++
2564 \begin_inset Quotes srd
2565 \end_inset
2566
2567  
2568 \backslash
2569  
2570 \newline
2571 RANLIB=
2572 \begin_inset Quotes srd
2573 \end_inset
2574
2575 i586-mingw32msvc-ranlib
2576 \begin_inset Quotes srd
2577 \end_inset
2578
2579  
2580 \backslash
2581
2582 \newline
2583 STRIP=
2584 \begin_inset Quotes srd
2585 \end_inset
2586
2587 i586-mingw32msvc-strip
2588 \begin_inset Quotes srd
2589 \end_inset
2590
2591  
2592 \backslash
2593
2594 \newline
2595 -
2596 \begin_inset ERT
2597 status collapsed
2598
2599 \begin_layout Standard
2600
2601
2602 \backslash
2603 /
2604 \end_layout
2605
2606 \end_inset
2607
2608 -prefix=
2609 \begin_inset Quotes srd
2610 \end_inset
2611
2612 /sdcc
2613 \begin_inset Quotes srd
2614 \end_inset
2615
2616  
2617 \backslash
2618
2619 \newline
2620 -
2621 \begin_inset ERT
2622 status collapsed
2623
2624 \begin_layout Standard
2625
2626
2627 \backslash
2628 /
2629 \end_layout
2630
2631 \end_inset
2632
2633 -datarootdir=
2634 \begin_inset Quotes srd
2635 \end_inset
2636
2637 /sdcc
2638 \begin_inset Quotes srd
2639 \end_inset
2640
2641  
2642 \backslash
2643
2644 \newline
2645 docdir=
2646 \begin_inset Quotes srd
2647 \end_inset
2648
2649
2650 \backslash
2651 ${datarootdir}/doc
2652 \begin_inset Quotes srd
2653 \end_inset
2654
2655  
2656 \backslash
2657
2658 \newline
2659 include_dir_suffix=
2660 \begin_inset Quotes srd
2661 \end_inset
2662
2663 include
2664 \begin_inset Quotes srd
2665 \end_inset
2666
2667  
2668 \backslash
2669
2670 \newline
2671 lib_dir_suffix=
2672 \begin_inset Quotes srd
2673 \end_inset
2674
2675 lib
2676 \begin_inset Quotes srd
2677 \end_inset
2678
2679  
2680 \backslash
2681
2682 \newline
2683 sdccconf_h_dir_separator=
2684 \begin_inset Quotes srd
2685 \end_inset
2686
2687
2688 \backslash
2689
2690 \backslash
2691
2692 \backslash
2693
2694 \backslash
2695
2696 \begin_inset Quotes srd
2697 \end_inset
2698
2699  
2700 \backslash
2701
2702 \newline
2703 -
2704 \begin_inset ERT
2705 status collapsed
2706
2707 \begin_layout Standard
2708
2709
2710 \backslash
2711 /
2712 \end_layout
2713
2714 \end_inset
2715
2716 -disable-device-lib
2717 \backslash
2718
2719 \newline
2720 -
2721 \begin_inset ERT
2722 status collapsed
2723
2724 \begin_layout Standard
2725
2726
2727 \backslash
2728 /
2729 \end_layout
2730
2731 \end_inset
2732
2733 -host=i586-mingw32msvc
2734 \backslash
2735
2736 \newline
2737 -
2738 \begin_inset ERT
2739 status collapsed
2740
2741 \begin_layout Standard
2742
2743
2744 \backslash
2745 /
2746 \end_layout
2747
2748 \end_inset
2749
2750 -build=unknown-unknown-linux-gnu
2751 \end_layout
2752
2753 \begin_layout Standard
2754 To 
2755 \begin_inset Quotes sld
2756 \end_inset
2757
2758 cross
2759 \begin_inset Quotes srd
2760 \end_inset
2761
2762 compile on Cygwin for Mingw32 (see also sdcc/support/scripts/sdcc_cygwin_mingw32
2763 ):
2764 \end_layout
2765
2766 \begin_layout LyX-Code
2767 ./configure -C 
2768 \backslash
2769
2770 \newline
2771 -
2772 \begin_inset ERT
2773 status collapsed
2774
2775 \begin_layout Standard
2776
2777
2778 \backslash
2779 /
2780 \end_layout
2781
2782 \end_inset
2783
2784 -prefix=
2785 \begin_inset Quotes srd
2786 \end_inset
2787
2788 /sdcc
2789 \begin_inset Quotes srd
2790 \end_inset
2791
2792  
2793 \backslash
2794
2795 \newline
2796 -
2797 \begin_inset ERT
2798 status collapsed
2799
2800 \begin_layout Standard
2801
2802
2803 \backslash
2804 /
2805 \end_layout
2806
2807 \end_inset
2808
2809 -datarootdir=
2810 \begin_inset Quotes srd
2811 \end_inset
2812
2813 /sdcc
2814 \begin_inset Quotes srd
2815 \end_inset
2816
2817  
2818 \backslash
2819
2820 \newline
2821 docdir=
2822 \begin_inset Quotes srd
2823 \end_inset
2824
2825
2826 \backslash
2827 ${datarootdir}/doc
2828 \begin_inset Quotes srd
2829 \end_inset
2830
2831  
2832 \backslash
2833  
2834 \newline
2835 include_dir_suffix=
2836 \begin_inset Quotes srd
2837 \end_inset
2838
2839 include
2840 \begin_inset Quotes srd
2841 \end_inset
2842
2843  
2844 \backslash
2845
2846 \newline
2847 lib_dir_suffix=
2848 \begin_inset Quotes srd
2849 \end_inset
2850
2851 lib
2852 \begin_inset Quotes srd
2853 \end_inset
2854
2855  
2856 \backslash
2857
2858 \newline
2859 sdccconf_h_dir_separator=
2860 \begin_inset Quotes srd
2861 \end_inset
2862
2863
2864 \backslash
2865
2866 \backslash
2867
2868 \backslash
2869
2870 \backslash
2871
2872 \begin_inset Quotes srd
2873 \end_inset
2874
2875  
2876 \backslash
2877
2878 \newline
2879 CC=
2880 \begin_inset Quotes srd
2881 \end_inset
2882
2883 gcc -mno-cygwin
2884 \begin_inset Quotes srd
2885 \end_inset
2886
2887  
2888 \backslash
2889
2890 \newline
2891 CXX=
2892 \begin_inset Quotes srd
2893 \end_inset
2894
2895 g++ -mno-cygwin
2896 \begin_inset Quotes srd
2897 \end_inset
2898
2899  
2900 \end_layout
2901
2902 \begin_layout Standard
2903 'configure' is quite slow on Cygwin (at least on windows before Win2000/XP).
2904  The option '-
2905 \begin_inset ERT
2906 status collapsed
2907
2908 \begin_layout Standard
2909
2910
2911 \backslash
2912 /
2913 \end_layout
2914
2915 \end_inset
2916
2917 -C' turns on caching, which gives a little bit extra speed.
2918  However if options are changed, it can be necessary to delete the config.cache
2919  file.
2920 \end_layout
2921
2922 \begin_layout Section
2923 Install paths
2924 \begin_inset LatexCommand label
2925 name "sub:Install-paths"
2926
2927 \end_inset
2928
2929
2930 \begin_inset LatexCommand index
2931 name "Install paths"
2932
2933 \end_inset
2934
2935
2936 \end_layout
2937
2938 \begin_layout Standard
2939 \begin_inset VSpace medskip
2940 \end_inset
2941
2942
2943 \end_layout
2944
2945 \begin_layout Standard
2946 \align center
2947 \begin_inset Tabular
2948 <lyxtabular version="3" rows="5" columns="4">
2949 <features>
2950 <column alignment="left" valignment="top" leftline="true" width="0">
2951 <column alignment="left" valignment="top" leftline="true" width="0">
2952 <column alignment="left" valignment="top" leftline="true" width="0">
2953 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0">
2954 <row topline="true" bottomline="true">
2955 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2956 \begin_inset Text
2957
2958 \begin_layout Standard
2959
2960 \series bold
2961 Description
2962 \end_layout
2963
2964 \end_inset
2965 </cell>
2966 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2967 \begin_inset Text
2968
2969 \begin_layout Standard
2970
2971 \series bold
2972 Path
2973 \end_layout
2974
2975 \end_inset
2976 </cell>
2977 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
2978 \begin_inset Text
2979
2980 \begin_layout Standard
2981
2982 \series bold
2983 Default
2984 \end_layout
2985
2986 \end_inset
2987 </cell>
2988 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
2989 \begin_inset Text
2990
2991 \begin_layout Standard
2992
2993 \series bold
2994 Win32 builds
2995 \end_layout
2996
2997 \end_inset
2998 </cell>
2999 </row>
3000 <row topline="true">
3001 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3002 \begin_inset Text
3003
3004 \begin_layout Standard
3005 Binary files*
3006 \end_layout
3007
3008 \end_inset
3009 </cell>
3010 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3011 \begin_inset Text
3012
3013 \begin_layout Standard
3014
3015 \emph on
3016 $EXEC_PREFIX
3017 \end_layout
3018
3019 \end_inset
3020 </cell>
3021 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3022 \begin_inset Text
3023
3024 \begin_layout Standard
3025 /usr/local/bin
3026 \end_layout
3027
3028 \end_inset
3029 </cell>
3030 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3031 \begin_inset Text
3032
3033 \begin_layout Standard
3034
3035 \backslash
3036 sdcc
3037 \backslash
3038 bin
3039 \end_layout
3040
3041 \end_inset
3042 </cell>
3043 </row>
3044 <row topline="true">
3045 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3046 \begin_inset Text
3047
3048 \begin_layout Standard
3049 Include files
3050 \end_layout
3051
3052 \end_inset
3053 </cell>
3054 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3055 \begin_inset Text
3056
3057 \begin_layout Standard
3058
3059 \emph on
3060 $DATADIR/ $INCLUDE_DIR_SUFFIX
3061 \end_layout
3062
3063 \end_inset
3064 </cell>
3065 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3066 \begin_inset Text
3067
3068 \begin_layout Standard
3069 /usr/local/share/sdcc/include
3070 \end_layout
3071
3072 \end_inset
3073 </cell>
3074 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3075 \begin_inset Text
3076
3077 \begin_layout Standard
3078
3079 \backslash
3080 sdcc
3081 \backslash
3082 include
3083 \end_layout
3084
3085 \end_inset
3086 </cell>
3087 </row>
3088 <row topline="true">
3089 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3090 \begin_inset Text
3091
3092 \begin_layout Standard
3093 Library file**
3094 \end_layout
3095
3096 \end_inset
3097 </cell>
3098 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3099 \begin_inset Text
3100
3101 \begin_layout Standard
3102
3103 \emph on
3104 $DATADIR/$LIB_DIR_SUFFIX
3105 \end_layout
3106
3107 \end_inset
3108 </cell>
3109 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3110 \begin_inset Text
3111
3112 \begin_layout Standard
3113 /usr/local/share/sdcc/lib
3114 \end_layout
3115
3116 \end_inset
3117 </cell>
3118 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3119 \begin_inset Text
3120
3121 \begin_layout Standard
3122
3123 \backslash
3124 sdcc
3125 \backslash
3126 lib
3127 \end_layout
3128
3129 \end_inset
3130 </cell>
3131 </row>
3132 <row topline="true" bottomline="true">
3133 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3134 \begin_inset Text
3135
3136 \begin_layout Standard
3137 Documentation
3138 \end_layout
3139
3140 \end_inset
3141 </cell>
3142 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3143 \begin_inset Text
3144
3145 \begin_layout Standard
3146
3147 \emph on
3148 $DOCDIR
3149 \end_layout
3150
3151 \end_inset
3152 </cell>
3153 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3154 \begin_inset Text
3155
3156 \begin_layout Standard
3157 /usr/local/share/sdcc/doc
3158 \end_layout
3159
3160 \end_inset
3161 </cell>
3162 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3163 \begin_inset Text
3164
3165 \begin_layout Standard
3166
3167 \backslash
3168 sdcc
3169 \backslash
3170 doc
3171 \end_layout
3172
3173 \end_inset
3174 </cell>
3175 </row>
3176 </lyxtabular>
3177
3178 \end_inset
3179
3180
3181 \end_layout
3182
3183 \begin_layout Verse
3184
3185 \size footnotesize
3186 *compiler, preprocessor, assembler, and linker
3187 \newline
3188 **the 
3189 \shape italic
3190 model
3191 \shape default
3192  is auto-appended by the compiler, e.g.
3193  small, large, z80, ds390 etc
3194 \end_layout
3195
3196 \begin_layout Standard
3197 \noindent
3198 The install paths can still be changed during `make install' with e.g.:
3199 \end_layout
3200
3201 \begin_layout LyX-Code
3202 make install prefix=$(HOME)/local/sdcc
3203 \end_layout
3204
3205 \begin_layout Standard
3206 Of course this doesn't change the search paths compiled into the binaries.
3207 \newline
3208
3209 \newline
3210 Moreove
3211 r the install path can be changed by defining DESTDIR
3212 \begin_inset LatexCommand index
3213 name "DESTDIR"
3214
3215 \end_inset
3216
3217 :
3218 \end_layout
3219
3220 \begin_layout LyX-Code
3221 make install DESTDIR=$(HOME)/sdcc.rpm/
3222 \end_layout
3223
3224 \begin_layout Standard
3225 Please note that DESTDIR must have a trailing slash!
3226 \end_layout
3227
3228 \begin_layout Section
3229 Search Paths
3230 \begin_inset LatexCommand label
3231 name "sub:Search-Paths"
3232
3233 \end_inset
3234
3235
3236 \begin_inset LatexCommand index
3237 name "Search path"
3238
3239 \end_inset
3240
3241
3242 \end_layout
3243
3244 \begin_layout Standard
3245 Some search paths or parts of them are determined by configure variables
3246  (in 
3247 \emph on
3248 italics
3249 \emph default
3250 , see section above).
3251  Further search paths are determined by environment variables during runtime.
3252  
3253 \newline
3254 The paths searched when running the compiler are as follows (the first
3255  catch wins):
3256 \newline
3257
3258 \newline
3259 1.
3260  Binary files (preprocessor, assembler and linker)
3261 \newline
3262
3263 \end_layout
3264
3265 \begin_layout Standard
3266 \align center
3267 \begin_inset Tabular
3268 <lyxtabular version="3" rows="4" columns="3">
3269 <features>
3270 <column alignment="block" valignment="top" leftline="true" width="0in">
3271 <column alignment="block" valignment="top" leftline="true" width="0in">
3272 <column alignment="block" valignment="top" leftline="true" rightline="true" width="0in">
3273 <row topline="true" bottomline="true">
3274 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3275 \begin_inset Text
3276
3277 \begin_layout Standard
3278 Search path
3279 \end_layout
3280
3281 \end_inset
3282 </cell>
3283 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3284 \begin_inset Text
3285
3286 \begin_layout Standard
3287 default
3288 \end_layout
3289
3290 \end_inset
3291 </cell>
3292 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3293 \begin_inset Text
3294
3295 \begin_layout Standard
3296 Win32 builds
3297 \end_layout
3298
3299 \end_inset
3300 </cell>
3301 </row>
3302 <row topline="true">
3303 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3304 \begin_inset Text
3305
3306 \begin_layout Standard
3307 $SDCC_HOME/
3308 \emph on
3309 $PPREFIX2BIN_DIR
3310 \end_layout
3311
3312 \end_inset
3313 </cell>
3314 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3315 \begin_inset Text
3316
3317 \begin_layout Standard
3318 $SDCC_HOME/bin
3319 \end_layout
3320
3321 \end_inset
3322 </cell>
3323 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3324 \begin_inset Text
3325
3326 \begin_layout Standard
3327 $SDCC_HOME
3328 \backslash
3329 bin
3330 \end_layout
3331
3332 \end_inset
3333 </cell>
3334 </row>
3335 <row topline="true">
3336 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3337 \begin_inset Text
3338
3339 \begin_layout Standard
3340 Path of argv[0] (if available)
3341 \end_layout
3342
3343 \end_inset
3344 </cell>
3345 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3346 \begin_inset Text
3347
3348 \begin_layout Standard
3349 Path of argv[0]
3350 \end_layout
3351
3352 \end_inset
3353 </cell>
3354 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3355 \begin_inset Text
3356
3357 \begin_layout Standard
3358 Path of argv[0]
3359 \end_layout
3360
3361 \end_inset
3362 </cell>
3363 </row>
3364 <row topline="true" bottomline="true">
3365 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3366 \begin_inset Text
3367
3368 \begin_layout Standard
3369 $PATH
3370 \end_layout
3371
3372 \end_inset
3373 </cell>
3374 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3375 \begin_inset Text
3376
3377 \begin_layout Standard
3378 $PATH
3379 \end_layout
3380
3381 \end_inset
3382 </cell>
3383 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3384 \begin_inset Text
3385
3386 \begin_layout Standard
3387 $PATH
3388 \end_layout
3389
3390 \end_inset
3391 </cell>
3392 </row>
3393 </lyxtabular>
3394
3395 \end_inset
3396
3397  
3398 \newline
3399
3400 \end_layout
3401
3402 \begin_layout Standard
3403 \noindent
3404 2.
3405  Include files
3406 \newline
3407
3408 \end_layout
3409
3410 \begin_layout Standard
3411 \align center
3412 \begin_inset Tabular
3413 <lyxtabular version="3" rows="6" columns="3">
3414 <features>
3415 <column alignment="block" valignment="top" leftline="true" width="1.5in">
3416 <column alignment="block" valignment="top" leftline="true" width="1.5in">
3417 <column alignment="block" valignment="top" leftline="true" rightline="true" width="0in">
3418 <row topline="true" bottomline="true">
3419 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3420 \begin_inset Text
3421
3422 \begin_layout Standard
3423 Search path
3424 \end_layout
3425
3426 \end_inset
3427 </cell>
3428 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3429 \begin_inset Text
3430
3431 \begin_layout Standard
3432 default
3433 \end_layout
3434
3435 \end_inset
3436 </cell>
3437 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3438 \begin_inset Text
3439
3440 \begin_layout Standard
3441 Win32 builds
3442 \end_layout
3443
3444 \end_inset
3445 </cell>
3446 </row>
3447 <row topline="true">
3448 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3449 \begin_inset Text
3450
3451 \begin_layout Standard
3452 -
3453 \begin_inset ERT
3454 status collapsed
3455
3456 \begin_layout Standard
3457
3458
3459 \backslash
3460 /
3461 \end_layout
3462
3463 \end_inset
3464
3465 -I dir
3466 \end_layout
3467
3468 \end_inset
3469 </cell>
3470 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3471 \begin_inset Text
3472
3473 \begin_layout Standard
3474 -
3475 \begin_inset ERT
3476 status collapsed
3477
3478 \begin_layout Standard
3479
3480
3481 \backslash
3482 /
3483 \end_layout
3484
3485 \end_inset
3486
3487 -I dir
3488 \end_layout
3489
3490 \end_inset
3491 </cell>
3492 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3493 \begin_inset Text
3494
3495 \begin_layout Standard
3496 -
3497 \begin_inset ERT
3498 status collapsed
3499
3500 \begin_layout Standard
3501
3502
3503 \backslash
3504 /
3505 \end_layout
3506
3507 \end_inset
3508
3509 -I dir
3510 \end_layout
3511
3512 \end_inset
3513 </cell>
3514 </row>
3515 <row topline="true">
3516 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3517 \begin_inset Text
3518
3519 \begin_layout Standard
3520 $SDCC_INCLUDE
3521 \end_layout
3522
3523 \end_inset
3524 </cell>
3525 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3526 \begin_inset Text
3527
3528 \begin_layout Standard
3529 $SDCC_INCLUDE
3530 \end_layout
3531
3532 \end_inset
3533 </cell>
3534 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3535 \begin_inset Text
3536
3537 \begin_layout Standard
3538 $SDCC_INCLUDE
3539 \end_layout
3540
3541 \end_inset
3542 </cell>
3543 </row>
3544 <row topline="true">
3545 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3546 \begin_inset Text
3547
3548 \begin_layout Standard
3549 $SDCC_HOME/
3550 \newline
3551
3552 \emph on
3553 $PREFIX2DATA_DIR/
3554 \newline
3555 $INCLUDE_DIR_SUFFIX
3556 \end_layout
3557
3558 \end_inset
3559 </cell>
3560 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3561 \begin_inset Text
3562
3563 \begin_layout Standard
3564 $SDCC_ HOME/
3565 \newline
3566 share/sdcc/
3567 \newline
3568 include
3569 \end_layout
3570
3571 \end_inset
3572 </cell>
3573 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3574 \begin_inset Text
3575
3576 \begin_layout Standard
3577 $SDCC_HOME
3578 \backslash
3579 include
3580 \end_layout
3581
3582 \end_inset
3583 </cell>
3584 </row>
3585 <row topline="true">
3586 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3587 \begin_inset Text
3588
3589 \begin_layout Standard
3590 path(argv[0])/
3591 \newline
3592
3593 \emph on
3594 $BIN2DATADIR/
3595 \emph default
3596
3597 \newline
3598
3599 \emph on
3600 $INCLUDE_DIR_SUFFIX
3601 \end_layout
3602
3603 \end_inset
3604 </cell>
3605 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3606 \begin_inset Text
3607
3608 \begin_layout Standard
3609 path(argv[0])/
3610 \newline
3611 ../sdcc/include
3612 \newline
3613 \InsetSpace ~
3614 \InsetSpace ~
3615 \InsetSpace ~
3616 \InsetSpace ~
3617 \InsetSpace ~
3618 \InsetSpace ~
3619 \InsetSpace ~
3620 \InsetSpace ~
3621 \InsetSpace ~
3622 \InsetSpace ~
3623 \InsetSpace ~
3624 \InsetSpace ~
3625 \InsetSpace ~
3626 \InsetSpace ~
3627 \InsetSpace ~
3628 \InsetSpace ~
3629 \InsetSpace ~
3630 \InsetSpace ~
3631 \InsetSpace ~
3632 \InsetSpace ~
3633 \InsetSpace ~
3634 \InsetSpace ~
3635 \InsetSpace ~
3636 \InsetSpace ~
3637 \InsetSpace ~
3638 \InsetSpace ~
3639 \InsetSpace ~
3640 \InsetSpace ~
3641 \InsetSpace ~
3642 \InsetSpace ~
3643 \InsetSpace ~
3644 \InsetSpace ~
3645 \InsetSpace ~
3646 \InsetSpace ~
3647 \InsetSpace ~
3648 \InsetSpace ~
3649 \InsetSpace ~
3650 \InsetSpace ~
3651
3652 \end_layout
3653
3654 \end_inset
3655 </cell>
3656 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3657 \begin_inset Text
3658
3659 \begin_layout Standard
3660 path(argv[0])
3661 \backslash
3662 ..
3663 \backslash
3664 include
3665 \end_layout
3666
3667 \end_inset
3668 </cell>
3669 </row>
3670 <row topline="true" bottomline="true">
3671 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3672 \begin_inset Text
3673
3674 \begin_layout Standard
3675
3676 \emph on
3677 $DATADIR/
3678 \emph default
3679
3680 \newline
3681
3682 \emph on
3683 $INCLUDE_DIR_SUFFIX
3684 \end_layout
3685
3686 \end_inset
3687 </cell>
3688 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3689 \begin_inset Text
3690
3691 \begin_layout Standard
3692 /usr/local/share/sdcc/
3693 \newline
3694 include
3695 \end_layout
3696
3697 \end_inset
3698 </cell>
3699 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3700 \begin_inset Text
3701
3702 \begin_layout Standard
3703 (not on Win32)
3704 \end_layout
3705
3706 \end_inset
3707 </cell>
3708 </row>
3709 </lyxtabular>
3710
3711 \end_inset
3712
3713  
3714 \newline
3715
3716 \end_layout
3717
3718 \begin_layout Standard
3719 \noindent
3720 The option -
3721 \begin_inset ERT
3722 status collapsed
3723
3724 \begin_layout Standard
3725
3726
3727 \backslash
3728 /
3729 \end_layout
3730
3731 \end_inset
3732
3733 -nostdinc disables the last two search paths.
3734 \newline
3735
3736 \newline
3737 3.
3738  Library files 
3739 \newline
3740
3741 \end_layout
3742
3743 \begin_layout Standard
3744 With the exception of 
3745 \begin_inset Quotes sld
3746 \end_inset
3747
3748 -
3749 \begin_inset ERT
3750 status collapsed
3751
3752 \begin_layout Standard
3753
3754
3755 \backslash
3756 /
3757 \end_layout
3758
3759 \end_inset
3760
3761 -L dir
3762 \begin_inset Quotes srd
3763 \end_inset
3764
3765  the 
3766 \shape italic
3767 model
3768 \shape default
3769  is auto-appended by the compiler (e.g.
3770  small, large, z80, ds390 etc.).
3771  
3772 \newline
3773
3774 \end_layout
3775
3776 \begin_layout Standard
3777 \align center
3778 \begin_inset Tabular
3779 <lyxtabular version="3" rows="6" columns="3">
3780 <features>
3781 <column alignment="block" valignment="top" leftline="true" width="1.7in">
3782 <column alignment="block" valignment="top" leftline="true" width="1.2in">
3783 <column alignment="block" valignment="top" leftline="true" rightline="true" width="1.2in">
3784 <row topline="true" bottomline="true">
3785 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3786 \begin_inset Text
3787
3788 \begin_layout Standard
3789 Search path
3790 \end_layout
3791
3792 \end_inset
3793 </cell>
3794 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3795 \begin_inset Text
3796
3797 \begin_layout Standard
3798 default
3799 \end_layout
3800
3801 \end_inset
3802 </cell>
3803 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3804 \begin_inset Text
3805
3806 \begin_layout Standard
3807 Win32 builds
3808 \end_layout
3809
3810 \end_inset
3811 </cell>
3812 </row>
3813 <row topline="true">
3814 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3815 \begin_inset Text
3816
3817 \begin_layout Standard
3818 -
3819 \begin_inset ERT
3820 status collapsed
3821
3822 \begin_layout Standard
3823
3824
3825 \backslash
3826 /
3827 \end_layout
3828
3829 \end_inset
3830
3831 -L dir
3832 \end_layout
3833
3834 \end_inset
3835 </cell>
3836 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3837 \begin_inset Text
3838
3839 \begin_layout Standard
3840 -
3841 \begin_inset ERT
3842 status collapsed
3843
3844 \begin_layout Standard
3845
3846
3847 \backslash
3848 /
3849 \end_layout
3850
3851 \end_inset
3852
3853 -L dir
3854 \end_layout
3855
3856 \end_inset
3857 </cell>
3858 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3859 \begin_inset Text
3860
3861 \begin_layout Standard
3862 -
3863 \begin_inset ERT
3864 status collapsed
3865
3866 \begin_layout Standard
3867
3868
3869 \backslash
3870 /
3871 \end_layout
3872
3873 \end_inset
3874
3875 -L dir
3876 \end_layout
3877
3878 \end_inset
3879 </cell>
3880 </row>
3881 <row topline="true">
3882 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
3883 \begin_inset Text
3884
3885 \begin_layout Standard
3886 $SDCC_LIB/
3887 \newline
3888
3889 \emph on
3890 <model>
3891 \end_layout
3892
3893 \end_inset
3894 </cell>
3895 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3896 \begin_inset Text
3897
3898 \begin_layout Standard
3899 $SDCC_LIB/
3900 \newline
3901
3902 \emph on
3903 <model>
3904 \end_layout
3905
3906 \end_inset
3907 </cell>
3908 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3909 \begin_inset Text
3910
3911 \begin_layout Standard
3912 $SDCC_LIB
3913 \backslash
3914
3915 \newline
3916
3917 \emph on
3918 <model>
3919 \end_layout
3920
3921 \end_inset
3922 </cell>
3923 </row>
3924 <row topline="true">
3925 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3926 \begin_inset Text
3927
3928 \begin_layout Standard
3929 $SDCC_HOME/
3930 \newline
3931
3932 \emph on
3933 $PREFIX2DATA_DIR/
3934 \newline
3935 $LIB_DIR_SUFFIX/<model>
3936 \end_layout
3937
3938 \end_inset
3939 </cell>
3940 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3941 \begin_inset Text
3942
3943 \begin_layout Standard
3944 $SDCC_HOME/
3945 \newline
3946 share/sdcc/
3947 \newline
3948 lib/
3949 \emph on
3950 <model>
3951 \end_layout
3952
3953 \end_inset
3954 </cell>
3955 <cell alignment="left" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
3956 \begin_inset Text
3957
3958 \begin_layout Standard
3959 $SDCC_HOME
3960 \backslash
3961 lib
3962 \backslash
3963
3964 \emph on
3965
3966 \newline
3967 <model>
3968 \end_layout
3969
3970 \end_inset
3971 </cell>
3972 </row>
3973 <row topline="true">
3974 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3975 \begin_inset Text
3976
3977 \begin_layout Standard
3978 path(argv[0])/
3979 \newline
3980
3981 \emph on
3982 $BIN2DATADIR/
3983 \emph default
3984
3985 \newline
3986
3987 \emph on
3988 $LIB_DIR_SUFFIX/<model>
3989 \end_layout
3990
3991 \end_inset
3992 </cell>
3993 <cell alignment="left" valignment="top" topline="true" leftline="true" usebox="none">
3994 \begin_inset Text
3995
3996 \begin_layout Standard
3997 path(argv[0])/
3998 \newline
3999 ../sdcc/lib/
4000 \emph on
4001 <model>
4002 \newline
4003 \InsetSpace ~
4004 \InsetSpace ~
4005 \InsetSpace ~
4006 \InsetSpace ~
4007 \InsetSpace ~
4008 \InsetSpace ~
4009 \InsetSpace ~
4010 \InsetSpace ~
4011 \InsetSpace ~
4012 \InsetSpace ~
4013 \InsetSpace ~
4014 \InsetSpace ~
4015 \InsetSpace ~
4016 \InsetSpace ~
4017 \InsetSpace ~
4018 \InsetSpace ~
4019 \InsetSpace ~
4020 \InsetSpace ~
4021 \InsetSpace ~
4022 \InsetSpace ~
4023 \InsetSpace ~
4024 \InsetSpace ~
4025 \InsetSpace ~
4026 \InsetSpace ~
4027 \InsetSpace ~
4028 \InsetSpace ~
4029 \InsetSpace ~
4030 \InsetSpace ~
4031 \InsetSpace ~
4032 \InsetSpace ~
4033 \InsetSpace ~
4034 \InsetSpace ~
4035 \InsetSpace ~
4036 \InsetSpace ~
4037 \InsetSpace ~
4038 \InsetSpace ~
4039 \InsetSpace ~
4040 \InsetSpace ~
4041 \InsetSpace ~
4042
4043 \end_layout
4044
4045 \end_inset
4046 </cell>
4047 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
4048 \begin_inset Text
4049
4050 \begin_layout Standard
4051 path(argv[0])
4052 \backslash
4053
4054 \newline
4055 ..
4056 \backslash
4057 lib
4058 \backslash
4059
4060 \emph on
4061 <model>
4062 \newline
4063 \InsetSpace ~
4064 \InsetSpace ~
4065 \InsetSpace ~
4066 \InsetSpace ~
4067 \InsetSpace ~
4068 \InsetSpace ~
4069 \InsetSpace ~
4070 \InsetSpace ~
4071 \InsetSpace ~
4072 \InsetSpace ~
4073 \InsetSpace ~
4074 \InsetSpace ~
4075 \InsetSpace ~
4076 \InsetSpace ~
4077 \InsetSpace ~
4078 \InsetSpace ~
4079 \InsetSpace ~
4080 \InsetSpace ~
4081 \InsetSpace ~
4082 \InsetSpace ~
4083 \InsetSpace ~
4084 \InsetSpace ~
4085 \InsetSpace ~
4086 \InsetSpace ~
4087 \InsetSpace ~
4088 \InsetSpace ~
4089 \InsetSpace ~
4090 \InsetSpace ~
4091 \InsetSpace ~
4092 \InsetSpace ~
4093 \InsetSpace ~
4094 \InsetSpace ~
4095 \InsetSpace ~
4096 \InsetSpace ~
4097 \InsetSpace ~
4098
4099 \end_layout
4100
4101 \end_inset
4102 </cell>
4103 </row>
4104 <row topline="true" bottomline="true">
4105 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4106 \begin_inset Text
4107
4108 \begin_layout Standard
4109
4110 \emph on
4111 $DATADIR/
4112 \newline
4113 $LIB_DIR_SUFFIX/<model>
4114 \end_layout
4115
4116 \end_inset
4117 </cell>
4118 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
4119 \begin_inset Text
4120
4121 \begin_layout Standard
4122 /usr/local/share/sdcc/
4123 \newline
4124 lib/
4125 \emph on
4126 <model>
4127 \end_layout
4128
4129 \end_inset
4130 </cell>
4131 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
4132 \begin_inset Text
4133
4134 \begin_layout Standard
4135 (not on Win32)
4136 \end_layout
4137
4138 \end_inset
4139 </cell>
4140 </row>
4141 </lyxtabular>
4142
4143 \end_inset
4144
4145
4146 \newline
4147
4148 \end_layout
4149
4150 \begin_layout Standard
4151 \begin_inset Note Note
4152 status collapsed
4153
4154 \begin_layout Standard
4155 Don't delete any of the stray spaces in the table above without checking
4156  the HTML output (last line)!
4157 \end_layout
4158
4159 \end_inset
4160
4161
4162 \end_layout
4163
4164 \begin_layout Standard
4165 \InsetSpace ~
4166
4167 \newline
4168 The option -
4169 \begin_inset ERT
4170 status collapsed
4171
4172 \begin_layout Standard
4173
4174
4175 \backslash
4176 /
4177 \end_layout
4178
4179 \end_inset
4180
4181 -nostdlib disables the last two search paths.
4182 \end_layout
4183
4184 \begin_layout Section
4185 Building SDCC
4186 \begin_inset LatexCommand index
4187 name "Building SDCC"
4188
4189 \end_inset
4190
4191
4192 \end_layout
4193
4194 \begin_layout Subsection
4195 Building SDCC on Linux
4196 \begin_inset LatexCommand label
4197 name "sub:Building-SDCC-on-Linux"
4198
4199 \end_inset
4200
4201
4202 \end_layout
4203
4204 \begin_layout Enumerate
4205
4206 \series medium
4207 Download the source package
4208 \series default
4209  either from the SDCC Subversion repository or from snapshot builds
4210 \series medium
4211 , it will be named something like sdcc
4212 \series default
4213 -src
4214 \series medium
4215 -yyyymmdd-rrrr.t
4216 \series default
4217 ar.
4218 \series medium
4219 bz2
4220 \series default
4221  
4222 \begin_inset LatexCommand url
4223 target "http://sdcc.sourceforge.net/snap.php"
4224
4225 \end_inset
4226
4227 .
4228 \end_layout
4229
4230 \begin_layout Enumerate
4231
4232 \series medium
4233 Bring up a command line terminal, such as xterm.
4234 \end_layout
4235
4236 \begin_layout Enumerate
4237
4238 \series medium
4239 Unpack the file using a command like:
4240 \series default
4241  
4242 \family sans
4243 \series bold
4244 "tar -xvjf sdcc-src-yyyymmdd-rrrr.tar.bz2
4245 \begin_inset Quotes srd
4246 \end_inset
4247
4248
4249 \family default
4250 \series medium
4251 , this will create a sub-directory called sdcc with all of the sources.
4252 \end_layout
4253
4254 \begin_layout Enumerate
4255 Change directory into the main SDCC directory, for example type: 
4256 \family sans
4257 \series bold
4258 "cd sdcc
4259 \series default
4260 ".
4261 \end_layout
4262
4263 \begin_layout Enumerate
4264
4265 \series medium
4266 Type
4267 \series default
4268  
4269 \family sans
4270 \series bold
4271 "./configure
4272 \family default
4273 \series default
4274 ".
4275  This configures the package for compilation on your system.
4276 \end_layout
4277
4278 \begin_layout Enumerate
4279
4280 \series medium
4281 Type
4282 \series default
4283  
4284 \family sans
4285 \series bold
4286 "make
4287 \family default
4288 \series default
4289 "
4290 \series medium
4291 .
4292
4293 \series default
4294  All of the source packages will compile, this can take a while.
4295 \end_layout
4296
4297 \begin_layout Enumerate
4298
4299 \series medium
4300 Type
4301 \series default
4302  
4303 \family sans
4304 \series bold
4305 "make install"
4306 \family default
4307 \series default
4308  as root
4309 \series medium
4310 .
4311
4312 \series default
4313  This copies the binary executables, the include files, the libraries and
4314  the documentation to the install directories.
4315  Proceed with section 
4316 \begin_inset LatexCommand ref
4317 reference "sec:Testing-the-SDCC"
4318
4319 \end_inset
4320
4321 .
4322 \end_layout
4323
4324 \begin_layout Subsection
4325 Building SDCC on Mac OS X
4326 \end_layout
4327
4328 \begin_layout Standard
4329 Follow the instruction for Linux.
4330 \newline
4331
4332 \newline
4333 On Mac OS X 10.2.x it was reported, that the
4334  default gcc (version 3.1 20020420 (prerelease)) fails to compile SDCC.
4335  Fortunately there's also gcc 2.9.x installed, which works fine.
4336  This compiler can be selected by running 'configure' with:
4337 \end_layout
4338
4339 \begin_layout LyX-Code
4340 ./configure CC=gcc2 CXX=g++2
4341 \end_layout
4342
4343 \begin_layout Standard
4344 Universal (ppc and i386) binaries can be produced on Mac OS X 10.4.x with
4345  Xcode.
4346  Run 'configure' with:
4347 \end_layout
4348
4349 \begin_layout LyX-Code
4350 ./configure 
4351 \backslash
4352
4353 \end_layout
4354
4355 \begin_layout LyX-Code
4356 LDFLAGS="-Wl,-syslibroot,/Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch
4357  ppc" 
4358 \backslash
4359
4360 \end_layout
4361
4362 \begin_layout LyX-Code
4363 CXXFLAGS = "-O2 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch
4364  ppc" 
4365 \backslash
4366
4367 \end_layout
4368
4369 \begin_layout LyX-Code
4370 CFLAGS = "-O2 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch i386 -arch ppc"
4371 \end_layout
4372
4373 \begin_layout Subsection
4374 Cross compiling SDCC on Linux for Windows
4375 \end_layout
4376
4377 \begin_layout Standard
4378 With the Mingw32 gcc cross compiler it's easy to compile SDCC for Win32.
4379  See section 'Configure Options'.
4380 \end_layout
4381
4382 \begin_layout Subsection
4383 Building SDCC using Cygwin and Mingw32
4384 \end_layout
4385
4386 \begin_layout Standard
4387 For building and installing a Cygwin executable follow the instructions
4388  for Linux.
4389 \newline
4390
4391 \newline
4392 On Cygwin a 
4393 \begin_inset Quotes sld
4394 \end_inset
4395
4396 native
4397 \begin_inset Quotes srd
4398 \end_inset
4399
4400  Win32-binary can be built, which will not need the Cygwin-DLL.
4401  For the necessary 'configure' options see section 'configure options' or
4402  the script 'sdcc/support/scripts/sdcc_cygwin_mingw32'.
4403 \newline
4404
4405 \newline
4406 In order to install
4407  Cygwin on Windows download setup.exe from 
4408 \begin_inset LatexCommand url
4409 name "www.cygwin.com"
4410 target "http://www.cygwin.com/"
4411
4412 \end_inset
4413
4414 .
4415  Run it, set the 
4416 \begin_inset Quotes sld
4417 \end_inset
4418
4419 default text file type
4420 \begin_inset Quotes srd
4421 \end_inset
4422
4423  to 
4424 \begin_inset Quotes sld
4425 \end_inset
4426
4427 unix
4428 \begin_inset Quotes srd
4429 \end_inset
4430
4431  and download/install at least the following packages.
4432  Some packages are selected by default, others will be automatically selected
4433  because of dependencies with the manually selected packages.
4434  Never deselect these packages!
4435 \end_layout
4436
4437 \begin_layout Itemize
4438 flex
4439 \end_layout
4440
4441 \begin_layout Itemize
4442 bison
4443 \end_layout
4444
4445 \begin_layout Itemize
4446 gcc ; version 3.x is fine, no need to use the old 2.9x
4447 \end_layout
4448
4449 \begin_layout Itemize
4450 binutils ; selected with gcc
4451 \end_layout
4452
4453 \begin_layout Itemize
4454 make
4455 \end_layout
4456
4457 \begin_layout Itemize
4458 rxvt ; a nice console, which makes life much easier under windoze (see below)
4459 \end_layout
4460
4461 \begin_layout Itemize
4462 man ; not really needed for building SDCC, but you'll miss it sooner or
4463  later
4464 \end_layout
4465
4466 \begin_layout Itemize
4467 less ; not really needed for building SDCC, but you'll miss it sooner or
4468  later
4469 \end_layout
4470
4471 \begin_layout Itemize
4472 svn ; only if you use Subversion access
4473 \end_layout
4474
4475 \begin_layout Standard
4476 If you want to develop something you'll need:
4477 \end_layout
4478
4479 \begin_layout Itemize
4480 python ; for the regression tests
4481 \end_layout
4482
4483 \begin_layout Itemize
4484 gdb ; the gnu debugger, together with the nice GUI 
4485 \begin_inset Quotes sld
4486 \end_inset
4487
4488 insight
4489 \begin_inset Quotes srd
4490 \end_inset
4491
4492
4493 \end_layout
4494
4495 \begin_layout Itemize
4496 openssh ; to access the CF or commit changes
4497 \end_layout
4498
4499 \begin_layout Itemize
4500 autoconf and autoconf-devel ; if you want to fight with 'configure', don't
4501  use autoconf-stable!
4502 \end_layout
4503
4504 \begin_layout Standard
4505 rxvt is a nice console with history.
4506  Replace in your cygwin.bat the line
4507 \end_layout
4508
4509 \begin_layout LyX-Code
4510 bash -
4511 \begin_inset ERT
4512 status collapsed
4513
4514 \begin_layout Standard
4515
4516
4517 \backslash
4518 /
4519 \end_layout
4520
4521 \end_inset
4522
4523 -login -i 
4524 \end_layout
4525
4526 \begin_layout Standard
4527 with (one line):
4528 \end_layout
4529
4530 \begin_layout LyX-Code
4531 rxvt -sl 1000 -fn "Lucida Console-12" -sr -cr red
4532 \end_layout
4533
4534 \begin_layout LyX-Code
4535      -bg black -fg white -geometry 100x65 -e bash -
4536 \begin_inset ERT
4537 status collapsed
4538
4539 \begin_layout Standard
4540
4541
4542 \backslash
4543 /
4544 \end_layout
4545
4546 \end_inset
4547
4548 -login
4549 \end_layout
4550
4551 \begin_layout Standard
4552 Text selected with the mouse is automatically copied to the clipboard, pasting
4553  works with shift-insert.
4554 \newline
4555
4556 \newline
4557 The other good tip is to make sure you have no //c/-styl
4558 e paths anywhere, use /cygdrive/c/ instead.
4559  Using // invokes a network lookup which is very slow.
4560  If you think 
4561 \begin_inset Quotes sld
4562 \end_inset
4563
4564 cygdrive
4565 \begin_inset Quotes srd
4566 \end_inset
4567
4568  is too long, you can change it with e.g.
4569 \end_layout
4570
4571 \begin_layout LyX-Code
4572 mount -s -u -c /mnt
4573 \end_layout
4574
4575 \begin_layout Standard
4576 SDCC sources use the unix line ending LF.
4577  Life is much easier, if you store the source tree on a drive which is mounted
4578  in binary mode.
4579  And use an editor which can handle LF-only line endings.
4580  Make sure not to commit files with windows line endings.
4581  The tabulator spacing
4582 \begin_inset LatexCommand index
4583 name "tabulator spacing (8 columns)"
4584
4585 \end_inset
4586
4587  used in the project is 8.
4588  Although a tabulator spacing of 8 is a sensible choice for programmers
4589  (it's a power of 2 and allows to display 8/16 bit signed variables without
4590  loosing columns) the plan is to move towards using only spaces in the source.
4591 \end_layout
4592
4593 \begin_layout Subsection
4594 Building SDCC Using Microsoft Visual C++ 6.0/NET (MSVC)
4595 \end_layout
4596
4597 \begin_layout Standard
4598
4599 \series medium
4600 Download the source package
4601 \series default
4602  either from the SDCC Subversion repository or from the 
4603 \begin_inset LatexCommand url
4604 name "snapshot builds"
4605 target "http://sdcc.sourceforge.net/snap.php"
4606
4607 \end_inset
4608
4609
4610 \series medium
4611 , it will be named something like sdcc
4612 \series default
4613 -src
4614 \series medium
4615 -yyyymmdd-rrrr.tar.bz2.
4616
4617 \series default
4618  SDCC is distributed with all the projects, workspaces, and files you need
4619  to build it using Visual C++ 6.0/NET (except for SDCDB and ucSim).
4620  The workspace name is 'sdcc.dsw'.
4621  Please note that as it is now, all the executables are created in a folder
4622  called sdcc
4623 \backslash
4624 bin_vc.
4625  Once built you need to copy the executables from sdcc
4626 \backslash
4627 bin_vc to sdcc
4628 \backslash
4629 bin before running SDCC.
4630  
4631 \newline
4632
4633 \newline
4634 WARNING: Visual studio is very picky with line terminations; it expects
4635  the 0x0d, 0x0a DOS style line endings, not the 0x0a Unix style line endings.
4636  When using the Subversion repository it's easiest to configure the svn
4637  client to convert automatically for you.
4638  If however you are getting a message such as "This makefile was not generated
4639  by Developer Studio etc.
4640  etc.
4641 \begin_inset Quotes srd
4642 \end_inset
4643
4644  when opening the sdcc.dsw workspace or any of the *.dsp projects, then you
4645  need to convert the Unix style line endings to DOS style line endings.
4646  To do so you can use the 
4647 \begin_inset Quotes sld
4648 \end_inset
4649
4650 unix2dos
4651 \begin_inset Quotes srd
4652 \end_inset
4653
4654  utility freely available on the internet.
4655  Doug Hawkins reported in the sdcc-user list that this works:
4656 \newline
4657
4658 \newline
4659 C:
4660 \backslash
4661 Programming
4662 \backslash
4663 SDCC> unix2dos sdcc.dsw
4664 \newline
4665 C:
4666 \backslash
4667 Programming
4668 \backslash
4669 SDCC> for /R %I in (*.dsp) do @unix2dos "%I"
4670 \newline
4671
4672 \newline
4673 In order to build SDCC with MSVC
4674  you need win32 executables of bison.exe, flex.exe, and gawk.exe.
4675  One good place to get them is 
4676 \begin_inset LatexCommand url
4677 name "here"
4678 target "http://unxutils.sourceforge.net"
4679
4680 \end_inset
4681
4682
4683 \newline
4684
4685 \newline
4686 Download the file UnxUtils
4687 \begin_inset LatexCommand index
4688 name "UnxUtils"
4689
4690 \end_inset
4691
4692 .zip.
4693  Now you have to install the utilities and setup MSVC so it can locate the
4694  required programs.
4695  Here there are two alternatives (choose one!):
4696 \end_layout
4697
4698 \begin_layout Enumerate
4699 The easy way:
4700 \newline
4701
4702 \newline
4703 a) Extract UnxUtils.zip to your C:
4704 \backslash
4705  hard disk PRESERVING the original paths, otherwise bison won't work.
4706  (If you are using WinZip make certain that 'Use folder names' is selected)
4707 \newline
4708
4709 \newline
4710 b)
4711  In the Visual C++ IDE click Tools, Options, select the Directory tab, in
4712  'Show directories for:' select 'Executable files', and in the directories
4713  window add a new path: 'C:
4714 \backslash
4715 user
4716 \backslash
4717 local
4718 \backslash
4719 wbin', click ok.
4720 \newline
4721
4722 \newline
4723 (As a side effect, you get a bunch of Unix utilities that
4724  could be useful, such as diff and patch.)
4725 \end_layout
4726
4727 \begin_layout Enumerate
4728 A more compact way:
4729 \newline
4730
4731 \newline
4732 This one avoids extracting a bunch of files you may not
4733  use, but requires some extra work:
4734 \newline
4735
4736 \newline
4737 a) Create a directory were to put the
4738  tools needed, or use a directory already present.
4739  Say for example 'C:
4740 \backslash
4741 util'.
4742 \newline
4743
4744 \newline
4745 b) Extract 'bison.exe', 'bison.hairy', 'bison.simple', 'flex.exe', and
4746  gawk.exe to such directory WITHOUT preserving the original paths.
4747  (If you are using WinZip make certain that 'Use folder names' is not selected)
4748 \newline
4749
4750 \newline
4751 c
4752 ) Rename bison.exe to '_bison.exe'.
4753 \newline
4754
4755 \newline
4756 d) Create a batch file 'bison.bat' in 'C:
4757 \backslash
4758 util
4759 \backslash
4760 ' and add these lines: 
4761 \newline
4762 \InsetSpace ~
4763 \InsetSpace ~
4764 set BISON_SIMPLE=C:
4765 \backslash
4766 util
4767 \backslash
4768 bison.simple 
4769 \newline
4770 \InsetSpace ~
4771 \InsetSpace ~
4772 set BISON_HAIRY=C:
4773 \backslash
4774 util
4775 \backslash
4776 bison.hairy
4777 \newline
4778 \InsetSpace ~
4779 \InsetSpace ~
4780 _bison %1 %2 %3 %4 %5 %6 %7 %8 %9
4781 \newline
4782
4783 \newline
4784 Steps 'c' and 'd' are needed
4785  because bison requires by default that the files 'bison.simple' and 'bison.hairy'
4786  reside in some weird Unix directory, '/usr/local/share/' I think.
4787  So it is necessary to tell bison where those files are located if they
4788  are not in such directory.
4789  That is the function of the environment variables BISON_SIMPLE and BISON_HAIRY.
4790 \newline
4791
4792 \newline
4793 e
4794 ) In the Visual C++ IDE click Tools, Options, select the Directory tab,
4795  in 'Show directories for:' select 'Executable files', and in the directories
4796  window add a new path: 'c:
4797 \backslash
4798 util', click ok.
4799  Note that you can use any other path instead of 'c:
4800 \backslash
4801 util', even the path where the Visual C++ tools are, probably: 'C:
4802 \backslash
4803 Program Files
4804 \backslash
4805 Microsoft Visual Studio
4806 \backslash
4807 Common
4808 \backslash
4809 Tools'.
4810  So you don't have to execute step 'e' :)
4811 \end_layout
4812
4813 \begin_layout Standard
4814 That is it.
4815  Open 'sdcc.dsw' in Visual Studio, click 'build all', when it finishes copy
4816  the executables from sdcc
4817 \backslash
4818 bin_vc to sdcc
4819 \backslash
4820 bin, and you can compile using SDCC.
4821 \end_layout
4822
4823 \begin_layout Subsection
4824 Building SDCC Using Borland
4825 \end_layout
4826
4827 \begin_layout Enumerate
4828 From the sdcc directory, run the command "make -f Makefile.bcc".
4829  This should regenerate all the .exe files in the bin directory except for
4830  SDCDB and ucSim.
4831 \end_layout
4832
4833 \begin_layout Enumerate
4834 If you modify any source files and need to rebuild, be aware that the dependenci
4835 es may not be correctly calculated.
4836  The safest option is to delete all .obj files and run the build again.
4837  From a Cygwin BASH prompt, this can easily be done with the command (be
4838  sure you are in the sdcc directory):
4839 \newline
4840
4841 \newline
4842
4843 \family sans
4844 \series bold
4845 find .
4846  
4847 \backslash
4848 ( -name '*.obj' -o -name '*.lib' -o -name '*.rul' 
4849 \backslash
4850 ) -print -exec rm {} 
4851 \backslash
4852 ;
4853 \family default
4854 \series default
4855
4856 \newline
4857
4858 \newline
4859 or on Windows NT/2000/XP from the command prompt with the command:
4860 \newline
4861
4862 \family sans
4863 \series bold
4864
4865 \newline
4866 del /s *.obj *.lib *.rul
4867 \family default
4868 \series default
4869  from the sdcc directory.
4870 \end_layout
4871
4872 \begin_layout Subsection
4873 Windows Install Using a ZIP Package
4874 \end_layout
4875
4876 \begin_layout Enumerate
4877 Download the binary zip package from 
4878 \begin_inset LatexCommand url
4879 target "http://sdcc.sf.net/snap.php"
4880
4881 \end_inset
4882
4883  and unpack it using your favorite unpacking tool (gunzip, WinZip, etc).
4884  This should unpack to a group of sub-directories.
4885  An example directory structure after unpacking the mingw32 package is:
4886  c:
4887 \backslash
4888 sdcc
4889 \backslash
4890 bin for the executables, c:
4891 \backslash
4892 sdcc
4893 \backslash
4894 include and c:
4895 \backslash
4896 sdcc
4897 \backslash
4898 lib for the include and libraries.
4899 \end_layout
4900
4901 \begin_layout Enumerate
4902 Adjust your environment variable PATH to include the location of the bin
4903  directory or start sdcc using the full path.
4904 \end_layout
4905
4906 \begin_layout Subsection
4907 Windows Install Using the Setup Program
4908 \begin_inset LatexCommand label
4909 name "sub:Windows-Install"
4910
4911 \end_inset
4912
4913
4914 \end_layout
4915
4916 \begin_layout Standard
4917 Download the setup program 
4918 \emph on
4919 sdcc-x.y.z-setup.exe
4920 \emph default
4921  for an official release from 
4922 \newline
4923
4924 \begin_inset LatexCommand url
4925 target "http://sf.net/project/showfiles.php?group_id=599"
4926
4927 \end_inset
4928
4929  or a setup program for one of the snapshots 
4930 \emph on
4931 sdcc-yyyymmdd-xxxx-setup.exe
4932 \emph default
4933  from 
4934 \begin_inset LatexCommand url
4935 target "http://sdcc.sf.net/snap.php"
4936
4937 \end_inset
4938
4939  and execute it.
4940  A windows typical installer will guide you through the installation process.
4941 \end_layout
4942
4943 \begin_layout Subsection
4944 VPATH
4945 \begin_inset LatexCommand index
4946 name "VPATH"
4947
4948 \end_inset
4949
4950  feature
4951 \end_layout
4952
4953 \begin_layout Standard
4954 SDCC supports the VPATH feature provided by configure and make.
4955  It allows to separate the source and build trees.
4956  Here's an example:
4957 \end_layout
4958
4959 \begin_layout Standard
4960
4961 \family typewriter
4962 cd ~\InsetSpace ~
4963 \InsetSpace ~
4964 \InsetSpace ~
4965 \InsetSpace ~
4966 \InsetSpace ~
4967 \InsetSpace ~
4968 \InsetSpace ~
4969 \InsetSpace ~
4970 \InsetSpace ~
4971 \InsetSpace ~
4972 \InsetSpace ~
4973 \InsetSpace ~
4974 \InsetSpace ~
4975 \InsetSpace ~
4976 \InsetSpace ~
4977 \InsetSpace ~
4978 \InsetSpace ~
4979 \InsetSpace ~
4980 \InsetSpace ~
4981 \InsetSpace ~
4982 \InsetSpace ~
4983 \InsetSpace ~
4984 \InsetSpace ~
4985 \InsetSpace ~
4986 \InsetSpace ~
4987 \InsetSpace ~
4988 \InsetSpace ~
4989 \InsetSpace ~
4990 \InsetSpace ~
4991 \InsetSpace ~
4992 \InsetSpace ~
4993 \InsetSpace ~
4994 \InsetSpace ~
4995 \InsetSpace ~
4996 \InsetSpace ~
4997 \InsetSpace ~
4998 # cd $HOME
4999 \end_layout
5000
5001 \begin_layout Standard
5002
5003 \family typewriter
5004 tar -xjf sdcc-src-yyyymmdd-rrrr.tar.bz2\InsetSpace ~
5005 # extract source to directory sdcc
5006 \end_layout
5007
5008 \begin_layout Standard
5009
5010 \family typewriter
5011 mkdir sdcc.build\InsetSpace ~
5012 \InsetSpace ~
5013 \InsetSpace ~
5014 \InsetSpace ~
5015 \InsetSpace ~
5016 \InsetSpace ~
5017 \InsetSpace ~
5018 \InsetSpace ~
5019 \InsetSpace ~
5020 \InsetSpace ~
5021 \InsetSpace ~
5022 \InsetSpace ~
5023 \InsetSpace ~
5024 \InsetSpace ~
5025 \InsetSpace ~
5026 \InsetSpace ~
5027 \InsetSpace ~
5028 \InsetSpace ~
5029 \InsetSpace ~
5030 \InsetSpace ~
5031 \InsetSpace ~
5032 \InsetSpace ~
5033 \InsetSpace ~
5034 \InsetSpace ~
5035 # put output in sdcc.build
5036 \end_layout
5037
5038 \begin_layout Standard
5039
5040 \family typewriter
5041 cd sdcc.build
5042 \end_layout
5043
5044 \begin_layout Standard
5045
5046 \family typewriter
5047 ../sdcc/configure\InsetSpace ~
5048 \InsetSpace ~
5049 \InsetSpace ~
5050 \InsetSpace ~
5051 \InsetSpace ~
5052 \InsetSpace ~
5053 \InsetSpace ~
5054 \InsetSpace ~
5055 \InsetSpace ~
5056 \InsetSpace ~
5057 \InsetSpace ~
5058 \InsetSpace ~
5059 \InsetSpace ~
5060 \InsetSpace ~
5061 \InsetSpace ~
5062 \InsetSpace ~
5063 \InsetSpace ~
5064 \InsetSpace ~
5065 \InsetSpace ~
5066 \InsetSpace ~
5067 \InsetSpace ~
5068 \InsetSpace ~
5069 \InsetSpace ~
5070 # configure is doing all the magic!
5071 \end_layout
5072
5073 \begin_layout Standard
5074
5075 \family typewriter
5076 make
5077 \end_layout
5078
5079 \begin_layout Standard
5080 \noindent
5081 That's it! 
5082 \series bold
5083 configure
5084 \series default
5085  will create the directory tree will all the necessary Makefiles in ~/sdcc.build.
5086  It automagically computes the variables srcdir, top_srcdir and top_buildir
5087  for each directory.
5088  After running 
5089 \series bold
5090 make
5091 \series default
5092  the generated files will be in ~/sdcc.build, while the source files stay
5093  in ~/sdcc.
5094 \newline
5095 This is not only usefull for building different binaries, e.g.
5096  when cross compiling.
5097  It also gives you a much better overview in the source tree when all the
5098  generated files are not scattered between the source files.
5099  And the best thing is: if you want to change a file you can leave the original
5100  file untouched in the source directory.
5101  Simply copy it to the build directory, edit it, enter `make clean', `rm
5102  Makefile.dep' and `make'.
5103  
5104 \series bold
5105 make
5106 \series default
5107  will do the rest for you!
5108 \end_layout
5109
5110 \begin_layout Section
5111 Building the Documentation
5112 \end_layout
5113
5114 \begin_layout Standard
5115 Add -
5116 \begin_inset ERT
5117 status collapsed
5118
5119 \begin_layout Standard
5120
5121
5122 \backslash
5123 /
5124 \end_layout
5125
5126 \end_inset
5127
5128 -enable-doc to the configure arguments to build the documentation together
5129  with all the other stuff.
5130  You will need several tools (LyX, LaTeX, LaTeX2HTML, pdflatex, dvipdf,
5131  dvips and makeindex) to get the job done.
5132  Another possibility is to change to the doc directory and to type 
5133 \family sans
5134 \series bold
5135
5136 \begin_inset Quotes srd
5137 \end_inset
5138
5139 make
5140 \begin_inset Quotes srd
5141 \end_inset
5142
5143
5144 \family default
5145 \series default
5146  there.
5147  You're invited to make changes and additions to this manual (sdcc/doc/sdccman.ly
5148 x).
5149  Using LyX 
5150 \begin_inset LatexCommand url
5151 target "http://www.lyx.org"
5152
5153 \end_inset
5154
5155  as editor is straightforward.
5156  Prebuilt documentation in html and pdf format is available from 
5157 \begin_inset LatexCommand url
5158 target "http://sdcc.sf.net/snap.php"
5159
5160 \end_inset
5161
5162 .
5163 \end_layout
5164
5165 \begin_layout Section
5166 Reading the Documentation
5167 \begin_inset LatexCommand index
5168 name "Documentation"
5169
5170 \end_inset
5171
5172
5173 \end_layout
5174
5175 \begin_layout Standard
5176 Currently reading the document in pdf format is recommended, as for unknown
5177  reason the hyperlinks are working there whereas in the html version they
5178  are not
5179 \begin_inset Foot
5180 status open
5181
5182 \begin_layout Standard
5183 If you should know why please drop us a note
5184 \end_layout
5185
5186 \end_inset
5187
5188 .
5189  
5190 \newline
5191 You'll find the pdf version
5192 \begin_inset LatexCommand index
5193 name "PDF version of this document"
5194
5195 \end_inset
5196
5197  at 
5198 \begin_inset LatexCommand url
5199 target "http://sdcc.sf.net/doc/sdccman.pdf"
5200
5201 \end_inset
5202
5203 .
5204  
5205 \newline
5206 A html version
5207 \begin_inset LatexCommand index
5208 name "HTML version of this document"
5209
5210 \end_inset
5211
5212  should be online at 
5213 \begin_inset LatexCommand url
5214 target "http://sdcc.sf.net/doc/sdccman.html/index.html"
5215
5216 \end_inset
5217
5218 .
5219 \newline
5220 This documentation is in some aspects different from a commercial documentation:
5221  
5222 \end_layout
5223
5224 \begin_layout Itemize
5225 It tries to document SDCC for several processor architectures in one document
5226  (commercially these probably would be separate documents/products).
5227  This document
5228 \begin_inset LatexCommand index
5229 name "Status of documentation"
5230
5231 \end_inset
5232
5233  currently matches SDCC for mcs51 and DS390 best and does give too few informati
5234 on about f.e.
5235  Z80, PIC14, PIC16 and HC08.
5236 \end_layout
5237
5238 \begin_layout Itemize
5239 There are many references pointing away from this documentation.
5240  Don't let this distract you.
5241  If there f.e.
5242  was a reference like 
5243 \begin_inset LatexCommand url
5244 target "http://www.opencores.org"
5245
5246 \end_inset
5247
5248  together with a statement 
5249 \begin_inset Quotes sld
5250 \end_inset
5251
5252 some processors which are targetted by SDCC can be implemented in a 
5253 \emph on
5254 f
5255 \emph default
5256 ield 
5257 \emph on
5258 p
5259 \emph default
5260 rogrammable 
5261 \emph on
5262 g
5263 \emph default
5264 ate 
5265 \emph on
5266 a
5267 \emph default
5268 rray
5269 \begin_inset LatexCommand index
5270 name "FPGA (field programmable gate array)"
5271
5272 \end_inset
5273
5274
5275 \begin_inset Quotes srd
5276 \end_inset
5277
5278  or 
5279 \begin_inset LatexCommand url
5280 target "http://sf.net/projects/fpgac"
5281
5282 \end_inset
5283
5284
5285 \begin_inset LatexCommand index
5286 name "FpgaC ((subset of) C to FPGA compiler)"
5287
5288 \end_inset
5289
5290  
5291 \begin_inset Quotes sld
5292 \end_inset
5293
5294 have you ever heard of an open source compiler that compiles a subset of
5295  C for an FPGA?
5296 \begin_inset Quotes srd
5297 \end_inset
5298
5299  we expect you to have a quick look there and come back.
5300  If you read this you are on the right track.
5301 \end_layout
5302
5303 \begin_layout Itemize
5304 Some sections attribute more space to problems, restrictions and warnings
5305  than to the solution.
5306 \end_layout
5307
5308 \begin_layout Itemize
5309 The installation section and the section about the debugger is intimidating.
5310 \end_layout
5311
5312 \begin_layout Itemize
5313 There are still lots of typos and there are more different writing styles
5314  than pictures.
5315 \end_layout
5316
5317 \begin_layout Section
5318 Testing the SDCC Compiler
5319 \begin_inset LatexCommand label
5320 name "sec:Testing-the-SDCC"
5321
5322 \end_inset
5323
5324
5325 \end_layout
5326
5327 \begin_layout Standard
5328 The first thing you should do after installing your SDCC compiler is to
5329  see if it runs.
5330  Type 
5331 \family sans
5332 \series bold
5333 "sdcc -
5334 \begin_inset ERT
5335 status collapsed
5336
5337 \begin_layout Standard
5338
5339
5340 \backslash
5341 /
5342 \end_layout
5343
5344 \end_inset
5345
5346 -version"
5347 \begin_inset LatexCommand index
5348 name "version"
5349
5350 \end_inset
5351
5352
5353 \family default
5354 \series default
5355  at the prompt, and the program should run and output its version like:
5356  
5357 \newline
5358
5359 \family typewriter
5360 SDCC : mcs51/z80/avr/ds390/pic16/pic14/ds400/hc08 2.5.6 #4169 (May 8 2006)
5361  (UNIX)
5362 \end_layout
5363
5364 \begin_layout Standard
5365 If it doesn't run, or gives a message about not finding sdcc program, then
5366  you need to check over your installation.
5367  Make sure that the sdcc bin directory is in your executable search path
5368  defined by the PATH environment setting (
5369 \series medium
5370 see
5371 \series default
5372  section 
5373 \begin_inset LatexCommand ref
5374 reference "sub:Install-Trouble-shooting"
5375
5376 \end_inset
5377
5378 \InsetSpace ~
5379
5380 \series medium
5381 Install trouble-shooting for suggestions
5382 \series default
5383 ).
5384  Make sure that the sdcc program is in the bin folder, if not perhaps something
5385  did not install correctly.
5386 \newline
5387
5388 \newline
5389
5390 \series medium
5391 SDCC
5392 \series default
5393  is commonly installed as described in section 
5394 \begin_inset Quotes sld
5395 \end_inset
5396
5397 Install and search paths
5398 \begin_inset Quotes srd
5399 \end_inset
5400
5401 .
5402 \newline
5403
5404 \newline
5405
5406 \series medium
5407 Make sure the compiler works on a very simple example.
5408  Type in the following test.c program using your favorite
5409 \series default
5410  ASCII 
5411 \series medium
5412 editor:
5413 \end_layout
5414
5415 \begin_layout Verse
5416
5417 \family typewriter
5418 char test;
5419 \newline
5420
5421 \newline
5422 void main(void) {
5423 \newline
5424 \InsetSpace ~
5425 \InsetSpace ~
5426 \InsetSpace ~
5427 \InsetSpace ~
5428 test=0;
5429 \newline
5430 }
5431 \end_layout
5432
5433 \begin_layout Standard
5434
5435 \series medium
5436 Compile this using the following command:
5437 \series default
5438  
5439 \family sans
5440 \series bold
5441 "sdcc -c test.c".
5442
5443 \family default
5444 \series default
5445  
5446 \series medium
5447 If all goes well, the compiler will generate a test.asm and test.rel file.
5448  Congratulations, you've just compiled your first program with SDCC.
5449  We used the -c option to tell SDCC not to link the generated code, just
5450  to keep things simple for this step.
5451 \series default
5452
5453 \newline
5454
5455 \newline
5456
5457 \series medium
5458 The next step is to try it with the linker.
5459  Type in
5460 \series default
5461  
5462 \family sans
5463 \series bold
5464 "sdcc test.c
5465 \family default
5466 \series default
5467 "
5468 \series medium
5469 .
5470  If all goes well the compiler will link with the libraries and produce
5471  a test.ihx output file.
5472  If this step fails
5473 \series default
5474  
5475 \series medium
5476 (no test.ihx, and the linker generates warnings), then the problem is most
5477  likely that
5478 \series default
5479  SDCC 
5480 \series medium
5481 cannot find the
5482 \series default
5483  /
5484 \series medium
5485 usr/local/share/sdcc/lib directory
5486 \series default
5487  
5488 \series medium
5489 (see
5490 \series default
5491  section 
5492 \begin_inset LatexCommand ref
5493 reference "sub:Install-Trouble-shooting"
5494
5495 \end_inset
5496
5497 \InsetSpace ~
5498
5499 \series medium
5500 Install trouble-shooting for suggestions).
5501 \series default
5502
5503 \newline
5504
5505 \newline
5506
5507 \series medium
5508 The final test is to ensure
5509 \series default
5510  SDCC 
5511 \series medium
5512 can use the
5513 \series default
5514  standard 
5515 \series medium
5516 header files and libraries.
5517  Edit test.c and change it to the following:
5518 \end_layout
5519
5520 \begin_layout Verse
5521
5522 \family typewriter
5523 #include <string.h>
5524 \newline
5525
5526 \newline
5527 char str1[10];
5528 \newline
5529
5530 \newline
5531 void main(void) {
5532 \newline
5533 \InsetSpace ~
5534 \InsetSpace ~
5535 strcpy(str1, "testing");
5536 \newline
5537 }
5538 \end_layout
5539
5540 \begin_layout Standard
5541
5542 \series medium
5543 Compile this by typing
5544 \series default
5545  
5546 \family sans
5547 \series bold
5548 "sdcc test.c"
5549 \family default
5550 \series medium
5551 .
5552  This should generate a test.ihx output file, and it should give no warnings
5553  such as not finding the string.h file.
5554  If it cannot find the string.h file, then the problem is that
5555 \series default
5556  SDCC 
5557 \series medium
5558 cannot find the /usr/local/share/sdcc/include directory
5559 \series default
5560  
5561 \series medium
5562 (see the
5563 \series default
5564  section 
5565 \begin_inset LatexCommand ref
5566 reference "sub:Install-Trouble-shooting"
5567
5568 \end_inset
5569
5570 \InsetSpace ~
5571
5572 \series medium
5573 Install trouble-shooting section for suggestions).
5574
5575 \series default
5576  Use option 
5577 \series bold
5578 -
5579 \begin_inset ERT
5580 status collapsed
5581
5582 \begin_layout Standard
5583
5584
5585 \backslash
5586 /
5587 \end_layout
5588
5589 \end_inset
5590
5591 -print-search-dirs
5592 \series default
5593
5594 \begin_inset LatexCommand index
5595 name "-\\/-print-search-dirs"
5596
5597 \end_inset
5598
5599  to find exactly where SDCC is looking for the include and lib files.
5600 \end_layout
5601
5602 \begin_layout Section
5603 Install Trouble-shooting
5604 \begin_inset LatexCommand label
5605 name "sub:Install-Trouble-shooting"
5606
5607 \end_inset
5608
5609
5610 \begin_inset LatexCommand index
5611 name "Install trouble-shooting"
5612
5613 \end_inset
5614
5615
5616 \end_layout
5617
5618 \begin_layout Subsection
5619 If SDCC does not build correctly
5620 \end_layout
5621
5622 \begin_layout Standard
5623 A thing to try is starting from scratch by unpacking the .tgz source package
5624  again in an empty directory.
5625  Configure it like:
5626 \newline
5627
5628 \newline
5629
5630 \family sans
5631 \series bold
5632 ./configure 2>&1 | tee configure.log
5633 \family default
5634 \series default
5635
5636 \newline
5637
5638 \newline
5639 and build it like:
5640 \newline
5641
5642 \newline
5643
5644 \family sans
5645 \series bold
5646 make 2>&1 | tee make.log
5647 \family default
5648 \series default
5649
5650 \newline
5651
5652 \newline
5653 If anything goes wrong, you can review the log files to locate the problem.
5654  Or a relevant part of this can be attached to an email that could be helpful
5655  when requesting help from the mailing list.
5656 \end_layout
5657
5658 \begin_layout Subsection
5659 What the 
5660 \begin_inset Quotes sld
5661 \end_inset
5662
5663 ./configure
5664 \begin_inset Quotes srd
5665 \end_inset
5666
5667  does
5668 \end_layout
5669
5670 \begin_layout Standard
5671 The 
5672 \begin_inset Quotes sld
5673 \end_inset
5674
5675 ./configure
5676 \begin_inset Quotes srd
5677 \end_inset
5678
5679  command is a script that analyzes your system and performs some configuration
5680  to ensure the source package compiles on your system.
5681  It will take a few minutes to run, and will compile a few tests to determine
5682  what compiler features are installed.
5683 \end_layout
5684
5685 \begin_layout Subsection
5686 What the 
5687 \begin_inset Quotes sld
5688 \end_inset
5689
5690 make
5691 \begin_inset Quotes srd
5692 \end_inset
5693
5694  does
5695 \end_layout
5696
5697 \begin_layout Standard
5698 This runs the GNU make tool, which automatically compiles all the source
5699  packages into the final installed binary executables.
5700 \end_layout
5701
5702 \begin_layout Subsection
5703 What the 
5704 \begin_inset Quotes sld
5705 \end_inset
5706
5707 make install
5708 \begin_inset Quotes erd
5709 \end_inset
5710
5711  command does.
5712 \end_layout
5713
5714 \begin_layout Standard
5715 This will install the compiler, other executables libraries and include
5716  files into the appropriate directories.
5717  See sections 
5718 \begin_inset LatexCommand ref
5719 reference "sub:Install-paths"
5720
5721 \end_inset
5722
5723 ,\InsetSpace ~
5724
5725 \begin_inset LatexCommand ref
5726 reference "sub:Search-Paths"
5727
5728 \end_inset
5729
5730 \InsetSpace ~
5731 about install and search paths.
5732 \newline
5733 On most systems you will need super-user privilege
5734 s to do this.
5735 \end_layout
5736
5737 \begin_layout Section
5738 Components of SDCC
5739 \end_layout
5740
5741 \begin_layout Standard
5742 SDCC is not just a compiler, but a collection of tools by various developers.
5743  These include linkers, assemblers, simulators and other components.
5744  Here is a summary of some of the components.
5745  Note that the included simulator and assembler have separate documentation
5746  which you can find in the source package in their respective directories.
5747  As SDCC grows to include support for other processors, other packages from
5748  various developers are included and may have their own sets of documentation.
5749 \newline
5750
5751 \newline
5752 You
5753  might want to look at the files which are installed in <installdir>.
5754  At the time of this writing, we find the following programs for gcc-builds:
5755 \newline
5756
5757  
5758 \newline
5759 In <installdir>/bin:
5760 \end_layout
5761
5762 \begin_layout Itemize
5763 sdcc - The compiler.
5764 \end_layout
5765
5766 \begin_layout Itemize
5767 sdcpp - The C preprocessor.
5768 \end_layout
5769
5770 \begin_layout Itemize
5771 asx8051 - The assembler for 8051 type processors.
5772 \end_layout
5773
5774 \begin_layout Itemize
5775 as-z80
5776 \series bold
5777 ,
5778 \series default
5779  as-gbz80 - The Z80 and GameBoy Z80 assemblers.
5780 \end_layout
5781
5782 \begin_layout Itemize
5783 aslink -The linker for 8051 type processors.
5784 \end_layout
5785
5786 \begin_layout Itemize
5787 link-z80
5788 \series bold
5789 ,
5790 \series default
5791  link-gbz80 - The Z80 and GameBoy Z80 linkers.
5792 \end_layout
5793
5794 \begin_layout Itemize
5795 s51 - The ucSim 8051 simulator.
5796 \end_layout
5797
5798 \begin_layout Itemize
5799 sdcdb - The source debugger.
5800 \end_layout
5801
5802 \begin_layout Itemize
5803 packihx - A tool to pack (compress) Intel hex files.
5804 \end_layout
5805
5806 \begin_layout Standard
5807 In <installdir>/share/sdcc/include
5808 \end_layout
5809
5810 \begin_layout Itemize
5811 the include files
5812 \end_layout
5813
5814 \begin_layout Standard
5815 In <installdir>/share/sdcc/lib
5816 \end_layout
5817
5818 \begin_layout Itemize
5819 the subdirs src and small, large, z80, gbz80 and ds390 with the precompiled
5820  relocatables.
5821 \end_layout
5822
5823 \begin_layout Standard
5824 In <installdir>/share/sdcc/doc
5825 \end_layout
5826
5827 \begin_layout Itemize
5828 the documentation
5829 \end_layout
5830
5831 \begin_layout Standard
5832 As development for other processors proceeds, this list will expand to include
5833  executables to support processors like AVR, PIC, etc.
5834 \end_layout
5835
5836 \begin_layout Subsection
5837 sdcc - The Compiler
5838 \end_layout
5839
5840 \begin_layout Standard
5841 This is the actual compiler, it in turn uses the c-preprocessor and invokes
5842  the assembler and linkage editor.
5843 \end_layout
5844
5845 \begin_layout Subsection
5846 sdcpp - The C-Preprocessor
5847 \end_layout
5848
5849 \begin_layout Standard
5850 The preprocessor
5851 \begin_inset LatexCommand index
5852 name "sdcpp (preprocessor)"
5853
5854 \end_inset
5855
5856  is a modified version of the GNU cpp
5857 \begin_inset LatexCommand index
5858 name "cpp|see{sdcpp}"
5859
5860 \end_inset
5861
5862  preprocessor 
5863 \begin_inset LatexCommand url
5864 target "http://gcc.gnu.org/"
5865
5866 \end_inset
5867
5868 .
5869  The C preprocessor is used to pull in #include sources, process #ifdef
5870  statements, #defines and so on.
5871 \end_layout
5872
5873 \begin_layout Subsection
5874 as
5875 \emph on
5876 xxxx
5877 \emph default
5878 , aslink, link-
5879 \emph on
5880 xxx
5881 \emph default
5882  - The Assemblers and Linkage Editors
5883 \end_layout
5884
5885 \begin_layout Standard
5886 This is retargettable assembler & linkage editor, it was developed by Alan
5887  Baldwin.
5888  John Hartman created the version for 8051, and I (Sandeep) have made some
5889  enhancements and bug fixes for it to work properly with SDCC.
5890 \end_layout
5891
5892 \begin_layout Subsection
5893 s51 - The Simulator
5894 \end_layout
5895
5896 \begin_layout Standard
5897 S51
5898 \begin_inset LatexCommand index
5899 name "s51"
5900
5901 \end_inset
5902
5903  is a free open source simulator developed by Daniel Drotos.
5904  The simulator is built as part of the build process.
5905  For more information visit Daniel's web site at: 
5906 \begin_inset LatexCommand url
5907 target "http://mazsola.iit.uni-miskolc.hu/~drdani/embedded/s51"
5908
5909 \end_inset
5910
5911 .
5912  It currently supports the core mcs51, the Dallas DS80C390 and the Phillips
5913  XA51 family.
5914 \end_layout
5915
5916 \begin_layout Subsection
5917 sdcdb - Source Level Debugger
5918 \end_layout
5919
5920 \begin_layout Standard
5921 SDCDB
5922 \begin_inset LatexCommand index
5923 name "SDCDB (debugger)"
5924
5925 \end_inset
5926
5927  is the companion source level debugger.
5928  More about SDCDB in section 
5929 \begin_inset LatexCommand ref
5930 reference "cha:Debugging-with-SDCDB"
5931
5932 \end_inset
5933
5934 .
5935  The current version of the debugger uses Daniel's Simulator S51
5936 \begin_inset LatexCommand index
5937 name "s51"
5938
5939 \end_inset
5940
5941 , but can be easily changed to use other simulators.
5942 \end_layout
5943
5944 \begin_layout Chapter
5945 Using SDCC
5946 \end_layout
5947
5948 \begin_layout Section
5949 Compiling
5950 \end_layout
5951
5952 \begin_layout Subsection
5953 Single Source File Projects
5954 \end_layout
5955
5956 \begin_layout Standard
5957 For single source file 8051 projects the process is very simple.
5958  Compile your programs with the following command 
5959 \family sans
5960 \series bold
5961 "sdcc sourcefile.c".
5962
5963 \family default
5964 \series default
5965  This will compile, assemble and link your source file.
5966  Output files are as follows:
5967 \end_layout
5968
5969 \begin_layout Itemize
5970 sourcefile.asm
5971 \begin_inset LatexCommand index
5972 name "<file>.asm"
5973
5974 \end_inset
5975
5976  - Assembler source
5977 \begin_inset LatexCommand index
5978 name "Assembler source"
5979
5980 \end_inset
5981
5982  file created by the compiler
5983 \end_layout
5984
5985 \begin_layout Itemize
5986 sourcefile.lst
5987 \begin_inset LatexCommand index
5988 name "<file>.lst"
5989
5990 \end_inset
5991
5992  - Assembler listing
5993 \begin_inset LatexCommand index
5994 name "Assembler listing"
5995
5996 \end_inset
5997
5998  file created by the Assembler
5999 \end_layout
6000
6001 \begin_layout Itemize
6002 sourcefile.rst
6003 \begin_inset LatexCommand index
6004 name "<file>.rst"
6005
6006 \end_inset
6007
6008  - Assembler listing
6009 \begin_inset LatexCommand index
6010 name "Assembler listing"
6011
6012 \end_inset
6013
6014  file updated with linkedit information, created by linkage editor
6015 \end_layout
6016
6017 \begin_layout Itemize
6018 sourcefile.sym
6019 \begin_inset LatexCommand index
6020 name "<file>.sym"
6021
6022 \end_inset
6023
6024  - symbol listing
6025 \begin_inset LatexCommand index
6026 name "Symbol listing"
6027
6028 \end_inset
6029
6030  for the sourcefile, created by the assembler
6031 \end_layout
6032
6033 \begin_layout Itemize
6034 sourcefile.rel
6035 \begin_inset LatexCommand index
6036 name "<file>.rel"
6037
6038 \end_inset
6039
6040  or sourcefile.o
6041 \begin_inset LatexCommand index
6042 name "<file>.o"
6043
6044 \end_inset
6045
6046  - Object file
6047 \begin_inset LatexCommand index
6048 name "Object file"
6049
6050 \end_inset
6051
6052  created by the assembler, input to Linkage editor
6053 \end_layout
6054
6055 \begin_layout Itemize
6056 sourcefile.map
6057 \begin_inset LatexCommand index
6058 name "<file>.map"
6059
6060 \end_inset
6061
6062  - The memory map
6063 \begin_inset LatexCommand index
6064 name "Memory map"
6065
6066 \end_inset
6067
6068  for the load module, created by the Linker
6069 \end_layout
6070
6071 \begin_layout Itemize
6072 sourcefile.mem
6073 \begin_inset LatexCommand index
6074 name "<file>.mem"
6075
6076 \end_inset
6077
6078  - A file with a summary of the memory usage
6079 \end_layout
6080
6081 \begin_layout Itemize
6082 sourcefile.ihx
6083 \begin_inset LatexCommand index
6084 name "<file>.ihx"
6085
6086 \end_inset
6087
6088  - The load module in Intel hex format
6089 \begin_inset LatexCommand index
6090 name "Intel hex format"
6091
6092 \end_inset
6093
6094  (you can select the Motorola S19 format
6095 \begin_inset LatexCommand index
6096 name "Motorola S19 format"
6097
6098 \end_inset
6099
6100  with -
6101 \begin_inset ERT
6102 status collapsed
6103
6104 \begin_layout Standard
6105
6106
6107 \backslash
6108 /
6109 \end_layout
6110
6111 \end_inset
6112
6113 -out-fmt-s19
6114 \begin_inset LatexCommand index
6115 name "-\\/-out-fmt-s19"
6116
6117 \end_inset
6118
6119 .
6120  If you need another format you might want to use 
6121 \family sans
6122 \shape italic
6123 objdump
6124 \family default
6125 \shape default
6126
6127 \begin_inset LatexCommand index
6128 name "objdump (tool)"
6129
6130 \end_inset
6131
6132  or 
6133 \family sans
6134 \shape italic
6135 srecord
6136 \family default
6137 \shape default
6138
6139 \begin_inset LatexCommand index
6140 name "srecord (bin, hex, ... tool)"
6141
6142 \end_inset
6143
6144
6145 \begin_inset Note Note
6146 status collapsed
6147
6148 \begin_layout Standard
6149 hyperlinks needed
6150 \end_layout
6151
6152 \end_inset
6153
6154  - see also section 
6155 \begin_inset LatexCommand vref
6156 reference "sub:Postprocessing-the-Intel"
6157
6158 \end_inset
6159
6160 ).
6161  Both formats are documented in the documentation of srecord
6162 \begin_inset LatexCommand index
6163 name "srecord (bin, hex, ... tool)"
6164
6165 \end_inset
6166
6167
6168 \end_layout
6169
6170 \begin_layout Itemize
6171 sourcefile.adb
6172 \begin_inset LatexCommand index
6173 name "<file>.adb"
6174
6175 \end_inset
6176
6177  - An intermediate file containing debug information needed to create the
6178  .cdb file (with -
6179 \begin_inset ERT
6180 status collapsed
6181
6182 \begin_layout Standard
6183
6184
6185 \backslash
6186 /
6187 \end_layout
6188
6189 \end_inset
6190
6191 -debug
6192 \begin_inset LatexCommand index
6193 name "-\\/-debug"
6194
6195 \end_inset
6196
6197
6198 \end_layout
6199
6200 \begin_layout Itemize
6201 sourcefile.cdb
6202 \begin_inset LatexCommand index
6203 name "<file>.cdb"
6204
6205 \end_inset
6206
6207  - An optional file (with -
6208 \begin_inset ERT
6209 status collapsed
6210
6211 \begin_layout Standard
6212
6213
6214 \backslash
6215 /
6216 \end_layout
6217
6218 \end_inset
6219
6220 -debug) containing debug information.
6221  The format is documented in cdbfileformat.pdf
6222 \end_layout
6223
6224 \begin_layout Itemize
6225 sourcefile.
6226  - (no extension)
6227 \begin_inset LatexCommand index
6228 name "<file> (no extension)"
6229
6230 \end_inset
6231
6232  An optional AOMF or AOMF51
6233 \begin_inset LatexCommand index
6234 name "AOMF, AOMF51"
6235
6236 \end_inset
6237
6238  
6239 \begin_inset LatexCommand label
6240 name "OMF file"
6241
6242 \end_inset
6243
6244 file containing debug information (generated with option -
6245 \begin_inset ERT
6246 status collapsed
6247
6248 \begin_layout Standard
6249
6250
6251 \backslash
6252 /
6253 \end_layout
6254
6255 \end_inset
6256
6257 -debug).
6258  The (Intel) 
6259 \emph on
6260 a
6261 \emph default
6262 bsolute 
6263 \emph on
6264 o
6265 \emph default
6266 bject 
6267 \emph on
6268 m
6269 \emph default
6270 odule 
6271 \emph on
6272 f
6273 \emph default
6274 ormat is a subformat of the OMF51 format and is commonly used by third party
6275  tools (debuggers
6276 \begin_inset LatexCommand index
6277 name "Debugger"
6278
6279 \end_inset
6280
6281 , simulators, emulators).
6282 \end_layout
6283
6284 \begin_layout Itemize
6285 sourcefile.dump*
6286 \begin_inset LatexCommand index
6287 name "<file>.dump*"
6288
6289 \end_inset
6290
6291  - Dump file to debug the compiler it self (generated with option -
6292 \begin_inset ERT
6293 status collapsed
6294
6295 \begin_layout Standard
6296
6297
6298 \backslash
6299 /
6300 \end_layout
6301
6302 \end_inset
6303
6304 -dumpall) (see section 
6305 \begin_inset LatexCommand ref
6306 reference "sub:Intermediate-Dump-Options"
6307
6308 \end_inset
6309
6310 \InsetSpace ~
6311  and section 
6312 \begin_inset LatexCommand ref
6313 reference "sub:The-anatomy-of"
6314
6315 \end_inset
6316
6317 \InsetSpace ~
6318
6319 \begin_inset Quotes sld
6320 \end_inset
6321
6322 Anatomy of the compiler
6323 \begin_inset Quotes srd
6324 \end_inset
6325
6326 ).
6327 \end_layout
6328
6329 \begin_layout Subsection
6330 Postprocessing the Intel Hex
6331 \begin_inset LatexCommand index
6332 name "Intel hex format"
6333
6334 \end_inset
6335
6336  file
6337 \begin_inset LatexCommand label
6338 name "sub:Postprocessing-the-Intel"
6339
6340 \end_inset
6341
6342
6343 \end_layout
6344
6345 \begin_layout Standard
6346 In most cases this won't be needed but the Intel Hex file
6347 \begin_inset LatexCommand index
6348 name "<file>.ihx"
6349
6350 \end_inset
6351
6352  which is generated by SDCC might include lines of varying length and the
6353  addresses within the file are not guaranteed to be strictly ascending.
6354  If your toolchain or a bootloader does not like this you can use the tool
6355  
6356 \family typewriter
6357 packihx
6358 \family default
6359
6360 \begin_inset LatexCommand index
6361 name "packihx (tool)"
6362
6363 \end_inset
6364
6365  which is part of the SDCC distribution: 
6366 \newline
6367
6368 \newline
6369  
6370 \family sans
6371 \series bold
6372 packihx sourcefile.ihx >sourcefile.hex
6373 \family default
6374 \series default
6375
6376 \newline
6377
6378 \newline
6379 The separately available 
6380 \emph on
6381 srecord
6382 \emph default
6383
6384 \begin_inset LatexCommand index
6385 name "srecord (bin, hex, ... tool)"
6386
6387 \end_inset
6388
6389  package additionally allows to set undefined locations to a predefined
6390  value, to insert checksums
6391 \begin_inset LatexCommand index
6392 name "checksum"
6393
6394 \end_inset
6395
6396  of various flavours (crc, add, xor) and to perform other manipulations
6397  (convert, split, crop, offset, ...).
6398  
6399 \newline
6400
6401 \newline
6402
6403 \family sans
6404 \series bold
6405 srec_cat\InsetSpace ~
6406 \InsetSpace ~
6407 sourcefile.ihx -intel\InsetSpace ~
6408 \InsetSpace ~
6409 -o sourcefile.hex -intel
6410 \newline
6411
6412 \newline
6413
6414 \family default
6415 \series default
6416 An example for a more complex command line
6417 \begin_inset Foot
6418 status open
6419
6420 \begin_layout Standard
6421 the command backfills
6422 \begin_inset LatexCommand index
6423 name "backfill unused memory"
6424
6425 \end_inset
6426
6427  unused memory with 0x12 and the overall 16 bit sum of the complete 64 kByte
6428  block is zero.
6429  If the program counter on an mcs51 runs wild the backfill pattern 0x12
6430  will be interpreted as an 
6431 \family typewriter
6432 lcall
6433 \family default
6434  to address 
6435 \family typewriter
6436 0x1212
6437 \family default
6438  (where an emergency routine could sit).
6439 \end_layout
6440
6441 \end_inset
6442
6443  could look like:
6444 \newline
6445
6446 \newline
6447
6448 \family sans
6449 \series bold
6450 \size footnotesize
6451 srec_cat\InsetSpace ~
6452 sourcefile.ihx -intel\InsetSpace ~
6453 \InsetSpace ~
6454 -fill 0x12 0x0000 0xfffe\InsetSpace ~
6455 -little-endian-checksum-nega
6456 tive 0xfffe 0x02 0x02\InsetSpace ~
6457 \InsetSpace ~
6458 -o sourcefile.hex -intel
6459 \size default
6460
6461 \newline
6462
6463 \newline
6464
6465 \family default
6466 \series default
6467 The srecord package is available at 
6468 \begin_inset LatexCommand url
6469 target "http://sf.net/projects/srecord"
6470
6471 \end_inset
6472
6473  .
6474 \end_layout
6475
6476 \begin_layout Subsection
6477 Projects with Multiple Source Files
6478 \end_layout
6479
6480 \begin_layout Standard
6481 SDCC can compile only ONE file at a time.
6482  Let us for example assume that you have a project containing the following
6483  files:
6484 \newline
6485
6486 \newline
6487 foo1.c (contains some functions)
6488 \newline
6489 foo2.c (contains some more functions)
6490 \newline
6491 foomai
6492 n.c (contains more functions and the function main)
6493 \newline
6494
6495 \size footnotesize
6496
6497 \newline
6498
6499 \size default
6500 The first two files will need to be compiled separately with the commands:
6501 \size footnotesize
6502  
6503 \size default
6504
6505 \newline
6506
6507 \newline
6508
6509 \family sans
6510 \series bold
6511 sdcc\InsetSpace ~
6512 -c\InsetSpace ~
6513 foo1.c
6514 \family default
6515 \series default
6516 \size footnotesize
6517
6518 \newline
6519
6520 \family sans
6521 \series bold
6522 \size default
6523 sdcc\InsetSpace ~
6524 -c\InsetSpace ~
6525 foo2.c
6526 \family default
6527 \series default
6528
6529 \newline
6530
6531 \newline
6532 Then compile the source file containing the 
6533 \emph on
6534 main()
6535 \emph default
6536  function and link
6537 \begin_inset LatexCommand index
6538 name "Linker"
6539
6540 \end_inset
6541
6542  the files together with the following command: 
6543 \newline
6544
6545 \newline
6546
6547 \family sans
6548 \series bold
6549 sdcc\InsetSpace ~
6550 foomain.c\InsetSpace ~
6551 foo1.rel\InsetSpace ~
6552 foo2.rel
6553 \family default
6554 \series default
6555
6556 \begin_inset LatexCommand index
6557 name "<file>.rel"
6558
6559 \end_inset
6560
6561
6562 \newline
6563
6564 \newline
6565 Alternatively, 
6566 \emph on
6567 foomain.c
6568 \emph default
6569  can be separately compiled as well: 
6570 \family sans
6571 \series bold
6572
6573 \newline
6574
6575 \newline
6576 sdcc\InsetSpace ~
6577 -c\InsetSpace ~
6578 foomain.c
6579 \newline
6580 sdcc foomain.rel foo1.rel foo2.rel
6581 \newline
6582
6583 \newline
6584
6585 \family default
6586 \series default
6587 The file containing the 
6588 \emph on
6589 main()
6590 \emph default
6591  function 
6592 \noun on
6593 must
6594 \noun default
6595  be the 
6596 \noun on
6597 first
6598 \noun default
6599  file specified in the command line, since the linkage editor processes
6600  file in the order they are presented to it.
6601  The linker is invoked from SDCC using a script file with extension .lnk
6602 \begin_inset LatexCommand index
6603 name "<file>.lnk"
6604
6605 \end_inset
6606
6607 .
6608  You can view this file to troubleshoot linking problems such as those arising
6609  from missing libraries.
6610 \end_layout
6611
6612 \begin_layout Subsection
6613 Projects with Additional Libraries
6614 \begin_inset LatexCommand index
6615 name "Libraries"
6616
6617 \end_inset
6618
6619
6620 \end_layout
6621
6622 \begin_layout Standard
6623 Some reusable routines may be compiled into a library, see the documentation
6624  for the assembler and linkage editor (which are in <installdir>/share/sdcc/doc)
6625  for how to create a 
6626 \emph on
6627 .lib
6628 \begin_inset LatexCommand index
6629 name "<file>.lib"
6630
6631 \end_inset
6632
6633
6634 \emph default
6635  library file.
6636  Libraries created in this manner can be included in the command line.
6637  Make sure you include the -L <library-path> option to tell the linker where
6638  to look for these files if they are not in the current directory.
6639  Here is an example, assuming you have the source file 
6640 \emph on
6641 foomain.c
6642 \emph default
6643  and a library 
6644 \emph on
6645 foolib.lib
6646 \emph default
6647  in the directory 
6648 \emph on
6649 mylib
6650 \emph default
6651  (if that is not the same as your current project):
6652 \newline
6653
6654 \newline
6655
6656 \family sans
6657 \series bold
6658 sdcc foomain.c foolib.lib -L mylib
6659 \newline
6660
6661 \newline
6662
6663 \family default
6664 \series default
6665 Note here that 
6666 \emph on
6667 mylib
6668 \emph default
6669  must be an absolute path name.
6670 \newline
6671
6672 \newline
6673 The most efficient way to use libraries is
6674  to keep separate modules in separate source files.
6675  The lib file now should name all the modules.rel
6676 \begin_inset LatexCommand index
6677 name "<file>.rel"
6678
6679 \end_inset
6680
6681  files.
6682  For an example see the standard library file 
6683 \emph on
6684 libsdcc.lib
6685 \emph default
6686  in the directory <installdir>/share/lib/small.
6687 \end_layout
6688
6689 \begin_layout Subsection
6690 Using sdcclib to Create and Manage Libraries
6691 \begin_inset LatexCommand index
6692 name "sdcclib"
6693
6694 \end_inset
6695
6696
6697 \end_layout
6698
6699 \begin_layout Standard
6700 Alternatively, instead of having a .rel file for each entry on the library
6701  file as described in the preceding section, sdcclib can be used to embed
6702  all the modules belonging to such library in the library file itself.
6703  This results in a larger library file, but it greatly reduces the number
6704  of disk files accessed by the linker.
6705   Additionally, the packed library file contains an index of all include
6706  modules and symbols that significantly speeds up the linking process.
6707  To display a list of options supported by sdcclib type:
6708 \newline
6709
6710 \end_layout
6711
6712 \begin_layout Standard
6713
6714 \family sans
6715 \series bold
6716 sdcclib -?
6717 \begin_inset LatexCommand index
6718 name "sdcclib"
6719
6720 \end_inset
6721
6722
6723 \newline
6724
6725 \newline
6726
6727 \family default
6728 \series default
6729 To create a new library file, start by compiling all the required modules.
6730  For example:
6731 \newline
6732
6733 \end_layout
6734
6735 \begin_layout Standard
6736
6737 \family sans
6738 \series bold
6739 sdcc -c _divsint.c
6740 \end_layout
6741
6742 \begin_layout Standard
6743
6744 \family sans
6745 \series bold
6746 sdcc -c _divuint.c
6747 \end_layout
6748
6749 \begin_layout Standard
6750
6751 \family sans
6752 \series bold
6753 sdcc -c _modsint.c
6754 \end_layout
6755
6756 \begin_layout Standard
6757
6758 \family sans
6759 \series bold
6760 sdcc -c _moduint.c
6761 \end_layout
6762
6763 \begin_layout Standard
6764
6765 \family sans
6766 \series bold
6767 sdcc -c _mulint.c
6768 \newline
6769
6770 \end_layout
6771
6772 \begin_layout Standard
6773 This will create files _divsint.rel, _divuint.rel, _modsint.rel, _moduint.rel,
6774  and _mulint.rel.
6775  The next step is to add the .rel files to the library file:
6776 \newline
6777
6778 \end_layout
6779
6780 \begin_layout Standard
6781
6782 \family sans
6783 \series bold
6784 sdcclib libint.lib _divsint.rel
6785 \family default
6786
6787 \begin_inset LatexCommand index
6788 name "sdcclib"
6789
6790 \end_inset
6791
6792
6793 \end_layout
6794
6795 \begin_layout Standard
6796
6797 \family sans
6798 \series bold
6799 sdcclib libint.lib _divuint.rel
6800 \end_layout
6801
6802 \begin_layout Standard
6803
6804 \family sans
6805 \series bold
6806 sdcclib libint.lib _modsint.rel
6807 \end_layout
6808
6809 \begin_layout Standard
6810
6811 \family sans
6812 \series bold
6813 sdcclib libint.lib _moduint.rel
6814 \end_layout
6815
6816 \begin_layout Standard
6817
6818 \family sans
6819 \series bold
6820 sdcclib libint.lib _mulint.rel
6821 \family default
6822 \series default
6823
6824 \newline
6825
6826 \end_layout
6827
6828 \begin_layout Standard
6829 Or, if you preffer:
6830 \family sans
6831 \series bold
6832
6833 \newline
6834
6835 \end_layout
6836
6837 \begin_layout Standard
6838
6839 \family sans
6840 \series bold
6841 sdcclib libint.lib _divsint.rel _divuint.rel _modsint.rel _moduint.rel _mulint.rel
6842 \family default
6843 \series default
6844
6845 \newline
6846
6847 \end_layout
6848
6849 \begin_layout Standard
6850 If the file already exists in the library, it will be replaced.
6851  If a list of .rel files is available, you can tell sdcclib to add those
6852  files to a library.
6853  For example, if the file 'myliblist.txt' contains
6854 \family sans
6855 \series bold
6856
6857 \newline
6858
6859 \end_layout
6860
6861 \begin_layout Standard
6862
6863 \family sans
6864 \series bold
6865 _divsint.rel
6866 \end_layout
6867
6868 \begin_layout Standard
6869
6870 \family sans
6871 \series bold
6872 _divuint.rel
6873 \end_layout
6874
6875 \begin_layout Standard
6876
6877 \family sans
6878 \series bold
6879 _modsint.rel
6880 \end_layout
6881
6882 \begin_layout Standard
6883
6884 \family sans
6885 \series bold
6886 _moduint.rel
6887 \end_layout
6888
6889 \begin_layout Standard
6890
6891 \family sans
6892 \series bold
6893 _mulint.rel
6894 \family default
6895 \series default
6896
6897 \newline
6898
6899 \end_layout
6900
6901 \begin_layout Standard
6902 Use
6903 \family sans
6904 \series bold
6905
6906 \newline
6907
6908 \end_layout
6909
6910 \begin_layout Standard
6911
6912 \family sans
6913 \series bold
6914 sdcclib -l libint.lib myliblist.txt
6915 \family default
6916 \series default
6917
6918 \newline
6919
6920 \end_layout
6921
6922 \begin_layout Standard
6923 Additionally, you can instruct sdcclib to compiles the files before adding
6924  them to the library.
6925  This is achieved using the environment variables SDCCLIB_CC and/or SDCCLIB_AS.
6926  For example:
6927 \family sans
6928 \series bold
6929
6930 \newline
6931
6932 \end_layout
6933
6934 \begin_layout Standard
6935
6936 \family sans
6937 \series bold
6938 set SDCCLIB_CC=sdcc -c
6939 \end_layout
6940
6941 \begin_layout Standard
6942
6943 \family sans
6944 \series bold
6945 sdcclib -l libint.lib myliblist.txt
6946 \family default
6947 \series default
6948
6949 \newline
6950
6951 \end_layout
6952
6953 \begin_layout Standard
6954 To see what modules and symbols are included in the library, options -s
6955  and -m are available.
6956  For example:
6957 \newline
6958
6959 \newline
6960
6961 \family sans
6962 \series bold
6963 sdcclib -s libint.lib
6964 \family default
6965
6966 \begin_inset LatexCommand index
6967 name "sdcclib"
6968
6969 \end_inset
6970
6971
6972 \newline
6973
6974 \family typewriter
6975 \series default
6976 _divsint.rel:
6977 \end_layout
6978
6979 \begin_layout Standard
6980
6981 \family typewriter
6982 __divsint_a_1_1
6983 \end_layout
6984
6985 \begin_layout Standard
6986
6987 \family typewriter
6988 __divsint_PARM_2
6989 \end_layout
6990
6991 \begin_layout Standard
6992
6993 \family typewriter
6994 __divsint
6995 \newline
6996 _divuint.rel:
6997 \end_layout
6998
6999 \begin_layout Standard
7000
7001 \family typewriter
7002 __divuint_a_1_1
7003 \end_layout
7004
7005 \begin_layout Standard
7006
7007 \family typewriter
7008 __divuint_PARM_2
7009 \end_layout
7010
7011 \begin_layout Standard
7012
7013 \family typewriter
7014 __divuint_reste_1_1
7015 \end_layout
7016
7017 \begin_layout Standard
7018
7019 \family typewriter
7020 __divuint_count_1_1
7021 \end_layout
7022
7023 \begin_layout Standard
7024
7025 \family typewriter
7026 __divuint
7027 \newline
7028 _modsint.rel:
7029 \end_layout
7030
7031 \begin_layout Standard
7032
7033 \family typewriter
7034 __modsint_a_1_1
7035 \end_layout
7036
7037 \begin_layout Standard
7038
7039 \family typewriter
7040 __modsint_PARM_2
7041 \end_layout
7042
7043 \begin_layout Standard
7044
7045 \family typewriter
7046 __modsint
7047 \newline
7048 _moduint.rel:
7049 \end_layout
7050
7051 \begin_layout Standard
7052
7053 \family typewriter
7054 __moduint_a_1_1
7055 \end_layout
7056
7057 \begin_layout Standard
7058
7059 \family typewriter
7060 __moduint_PARM_2
7061 \end_layout
7062
7063 \begin_layout Standard
7064
7065 \family typewriter
7066 __moduint_count_1_1
7067 \end_layout
7068
7069 \begin_layout Standard
7070
7071 \family typewriter
7072 __moduint
7073 \newline
7074 _mulint.rel:
7075 \end_layout
7076
7077 \begin_layout Standard
7078
7079 \family typewriter
7080 __mulint_PARM_2
7081 \end_layout
7082
7083 \begin_layout Standard
7084
7085 \family typewriter
7086 __mulint
7087 \family default
7088 \series bold
7089
7090 \newline
7091
7092 \end_layout
7093
7094 \begin_layout Standard
7095 If the source files are compiled using -
7096 \begin_inset ERT
7097 status collapsed
7098
7099 \begin_layout Standard
7100
7101
7102 \backslash
7103 /
7104 \end_layout
7105
7106 \end_inset
7107
7108 -debug
7109 \begin_inset LatexCommand index
7110 name "-\\/-debug"
7111
7112 \end_inset
7113
7114 , the corresponding debug information file .adb will be include in the library
7115  file as well.
7116  The library files created with sdcclib are plain text files, so they can
7117  be viewed with a text editor.
7118  It is not recommended to modify a library file created with sdcclib using
7119  a text editor, as there are file indexes numbers located across the file
7120  used by the linker to quickly locate the required module to link.
7121  Once a .rel file (as well as a .adb file) is added to a library using sdcclib,
7122  it can be safely deleted, since all the information required for linking
7123  is embedded in the library file itself.
7124  Library files created using sdcclib are used as described in the preceding
7125  sections.
7126 \end_layout
7127
7128 \begin_layout Subsection
7129 Using ar to Create and Manage Libraries
7130 \begin_inset LatexCommand index
7131 name "ar"
7132
7133 \end_inset
7134
7135
7136 \end_layout
7137
7138 \begin_layout Standard
7139 Support for ar format libraries was introduced in sdcc 2.9.0.
7140  Ar is a standard archive managing utility on unices (Linux, Mac OS X, several
7141  unix flavors) so it is not included in the sdcc package.
7142 \series bold
7143
7144 \newline
7145
7146 \newline
7147
7148 \series default
7149 For Windows platform you can find ar utility in GNU binutils package included
7150  in several projects: Cygwin at 
7151 \begin_inset LatexCommand url
7152 target "http://www.cygwin.com/"
7153
7154 \end_inset
7155
7156 , MinGW at 
7157 \begin_inset LatexCommand url
7158 target "http://www.mingw.org/"
7159
7160 \end_inset
7161
7162 .
7163 \series bold
7164
7165 \newline
7166
7167 \newline
7168
7169 \series default
7170 Both the GNU and BSD ar format variants are suppurated by asxxxx linkers.
7171  Ar doesn't understand the asxxxx object file format, so there is a special
7172  version of ranlib distributed with sdcc, called asranlib, which produces
7173  the ar symbol lookup table.
7174 \series bold
7175
7176 \newline
7177
7178 \newline
7179
7180 \series default
7181 To create a library containing asxxxx object files, you should use the following
7182  sequence:
7183 \series bold
7184
7185 \newline
7186
7187 \end_layout
7188
7189 \begin_layout Standard
7190
7191 \family sans
7192 \series bold
7193 ar -Sq <library name>.lib <list of .rel files>
7194 \end_layout
7195
7196 \begin_layout Standard
7197
7198 \family sans
7199 \series bold
7200 asranlib <library name>.lib
7201 \end_layout
7202
7203 \begin_layout Standard
7204 \begin_inset VSpace bigskip
7205 \end_inset
7206
7207
7208 \end_layout
7209
7210 \begin_layout Section
7211 Command Line Options
7212 \begin_inset LatexCommand index
7213 name "Command Line Options"
7214
7215 \end_inset
7216
7217
7218 \begin_inset LatexCommand label
7219 name "sec:Command-Line-Options"
7220
7221 \end_inset
7222
7223
7224 \end_layout
7225
7226 \begin_layout Subsection
7227 Processor Selection Options
7228 \begin_inset LatexCommand index
7229 name "Options processor selection"
7230
7231 \end_inset
7232
7233
7234 \begin_inset LatexCommand index
7235 name "Processor selection options"
7236
7237 \end_inset
7238
7239
7240 \end_layout
7241
7242 \begin_layout List
7243 \labelwidthstring 00.00.0000
7244
7245 \series bold
7246 -mmcs51
7247 \begin_inset LatexCommand index
7248 name "-mmcs51"
7249
7250 \end_inset
7251
7252
7253 \series default
7254  Generate code for the Intel MCS51
7255 \begin_inset LatexCommand index
7256 name "MCS51"
7257
7258 \end_inset
7259
7260  family of processors.
7261  This is the default processor target.
7262 \end_layout
7263
7264 \begin_layout List
7265 \labelwidthstring 00.00.0000
7266
7267 \series bold
7268 -mds390
7269 \begin_inset LatexCommand index
7270 name "-mds390"
7271
7272 \end_inset
7273
7274
7275 \series default
7276  Generate code for the Dallas DS80C390
7277 \begin_inset LatexCommand index
7278 name "DS80C390"
7279
7280 \end_inset
7281
7282  processor.
7283 \end_layout
7284
7285 \begin_layout List
7286 \labelwidthstring 00.00.0000
7287
7288 \series bold
7289 -mds400
7290 \begin_inset LatexCommand index
7291 name "-mds400"
7292
7293 \end_inset
7294
7295
7296 \series default
7297  Generate code for the Dallas DS80C400
7298 \begin_inset LatexCommand index
7299 name "DS80C400"
7300
7301 \end_inset
7302
7303  processor.
7304 \end_layout
7305
7306 \begin_layout List
7307 \labelwidthstring 00.00.0000
7308
7309 \series bold
7310 -mhc08
7311 \begin_inset LatexCommand index
7312 name "-mhc08"
7313
7314 \end_inset
7315
7316
7317 \series default
7318  Generate code for the Freescale/Motorola HC08
7319 \begin_inset LatexCommand index
7320 name "HC08"
7321
7322 \end_inset
7323
7324  family of processors.
7325 \end_layout
7326
7327 \begin_layout List
7328 \labelwidthstring 00.00.0000
7329
7330 \series bold
7331 -mz80
7332 \begin_inset LatexCommand index
7333 name "-mz80"
7334
7335 \end_inset
7336
7337
7338 \series default
7339  Generate code for the Zilog Z80
7340 \begin_inset LatexCommand index
7341 name "Z80"
7342
7343 \end_inset
7344
7345  family of processors.
7346 \end_layout
7347
7348 \begin_layout List
7349 \labelwidthstring 00.00.0000
7350
7351 \series bold
7352 -mgbz80
7353 \begin_inset LatexCommand index
7354 name "-mgbz80"
7355
7356 \end_inset
7357
7358
7359 \series default
7360  Generate code for the GameBoy Z80
7361 \begin_inset LatexCommand index
7362 name "gbz80 (GameBoy Z80)"
7363
7364 \end_inset
7365
7366  processor (Not actively maintained).
7367 \end_layout
7368
7369 \begin_layout List
7370 \labelwidthstring 00.00.0000
7371
7372 \series bold
7373 -mavr
7374 \begin_inset LatexCommand index
7375 name "-mavr"
7376
7377 \end_inset
7378
7379
7380 \series default
7381  Generate code for the Atmel AVR
7382 \begin_inset LatexCommand index
7383 name "AVR"
7384
7385 \end_inset
7386
7387  processor (Not maintained, not complete).
7388  AVR users should probably have a look at winavr 
7389 \begin_inset LatexCommand url
7390 target "http://sourceforge.net/projects/winavr"
7391
7392 \end_inset
7393
7394  or 
7395 \begin_inset LatexCommand url
7396 target "http://www.avrfreaks.net/index.php?name=PNphpBB2&file=index"
7397
7398 \end_inset
7399
7400 , which is based on AVR-port of the gcc compiler.
7401 \end_layout
7402
7403 \begin_layout Standard
7404 \begin_inset Note Note
7405 status collapsed
7406
7407 \begin_layout Standard
7408 I think it is fair to direct users there for now.
7409  Open source is also about avoiding unnecessary work .
7410  But I didn't find the 'official' link.
7411 \end_layout
7412
7413 \end_inset
7414
7415
7416 \end_layout
7417
7418 \begin_layout List
7419 \labelwidthstring 00.00.0000
7420
7421 \series bold
7422 -mpic14
7423 \begin_inset LatexCommand index
7424 name "-mpic14"
7425
7426 \end_inset
7427
7428
7429 \series default
7430  Generate code for the Microchip PIC 14
7431 \begin_inset LatexCommand index
7432 name "PIC14"
7433
7434 \end_inset
7435
7436 -bit processors (p16f84 and variants.
7437  In development, not complete).
7438 \end_layout
7439
7440 \begin_layout Standard
7441 \begin_inset Note Note
7442 status collapsed
7443
7444 \begin_layout Standard
7445 p16f627 p16f628 p16f84 p16f873 p16f877?
7446 \end_layout
7447
7448 \end_inset
7449
7450
7451 \end_layout
7452
7453 \begin_layout List
7454 \labelwidthstring 00.00.0000
7455
7456 \series bold
7457 -mpic16
7458 \begin_inset LatexCommand index
7459 name "-mpic16"
7460
7461 \end_inset
7462
7463
7464 \series default
7465  Generate code for the Microchip PIC 16
7466 \begin_inset LatexCommand index
7467 name "PIC16"
7468
7469 \end_inset
7470
7471 -bit processors (p18f452 and variants.
7472  In development, not complete).
7473 \end_layout
7474
7475 \begin_layout List
7476 \labelwidthstring 00.00.0000
7477
7478 \series bold
7479 -mtlcs900h
7480 \series default
7481  Generate code for the Toshiba TLCS-900H
7482 \begin_inset LatexCommand index
7483 name "TLCS-900H"
7484
7485 \end_inset
7486
7487  processor (Not maintained, not complete).
7488 \end_layout
7489
7490 \begin_layout List
7491 \labelwidthstring 00.00.0000
7492
7493 \series bold
7494 -mxa51
7495 \begin_inset LatexCommand index
7496 name "-mxa51"
7497
7498 \end_inset
7499
7500
7501 \series default
7502  Generate code for the Phillips XA51
7503 \begin_inset LatexCommand index
7504 name "XA51"
7505
7506 \end_inset
7507
7508  processor (Not maintained, not complete).
7509 \end_layout
7510
7511 \begin_layout Standard
7512 \begin_inset VSpace bigskip
7513 \end_inset
7514
7515
7516 \end_layout
7517
7518 \begin_layout Subsection
7519 Preprocessor Options
7520 \begin_inset LatexCommand index
7521 name "Options preprocessor"
7522
7523 \end_inset
7524
7525
7526 \begin_inset LatexCommand index
7527 name "Preprocessor options"
7528
7529 \end_inset
7530
7531
7532 \begin_inset LatexCommand index
7533 name "sdcpp (preprocessor)"
7534
7535 \end_inset
7536
7537
7538 \end_layout
7539
7540 \begin_layout List
7541 \labelwidthstring 00.00.0000
7542
7543 \series bold
7544 -I<path>
7545 \begin_inset LatexCommand index
7546 name "-I<path>"
7547
7548 \end_inset
7549
7550
7551 \series default
7552  The additional location where the preprocessor will look for <..h> or 
7553 \begin_inset Quotes eld
7554 \end_inset
7555
7556 ..h
7557 \begin_inset Quotes erd
7558 \end_inset
7559
7560  files.
7561 \end_layout
7562
7563 \begin_layout List
7564 \labelwidthstring 00.00.0000
7565
7566 \series bold
7567 -D<macro[=value]>
7568 \begin_inset LatexCommand index
7569 name "-D<macro[=value]>"
7570
7571 \end_inset
7572
7573
7574 \series default
7575  Command line definition of macros.
7576  Passed to the preprocessor.
7577 \end_layout
7578
7579 \begin_layout List
7580 \labelwidthstring 00.00.0000
7581
7582 \series bold
7583 -M
7584 \begin_inset LatexCommand index
7585 name "-M"
7586
7587 \end_inset
7588
7589
7590 \series default
7591  Tell the preprocessor to output a rule suitable for make describing the
7592  dependencies of each object file.
7593  For each source file, the preprocessor outputs one make-rule whose target
7594  is the object file name for that source file and whose dependencies are
7595  all the files `#include'd in it.
7596  This rule may be a single line or may be continued with `
7597 \backslash
7598 '-newline if it is long.
7599  The list of rules is printed on standard output instead of the preprocessed
7600  C program.
7601  `-M' implies `-E
7602 \begin_inset LatexCommand index
7603 name "-E"
7604
7605 \end_inset
7606
7607 '.
7608 \end_layout
7609
7610 \begin_layout List
7611 \labelwidthstring 00.00.0000
7612
7613 \series bold
7614 -C
7615 \begin_inset LatexCommand index
7616 name "-C"
7617
7618 \end_inset
7619
7620
7621 \series default
7622  Tell the preprocessor not to discard comments.
7623  Used with the `-E' option.
7624 \end_layout
7625
7626 \begin_layout List
7627 \labelwidthstring 00.00.0000
7628
7629 \series bold
7630 -MM
7631 \begin_inset LatexCommand index
7632 name "-MM"
7633
7634 \end_inset
7635
7636
7637 \series default
7638 \size large
7639  
7640 \size default
7641 Like `-M' but the output mentions only the user header files included with
7642  `#include 
7643 \begin_inset Quotes eld
7644 \end_inset
7645
7646 file"'.
7647  System header files included with `#include <file>' are omitted.
7648 \end_layout
7649
7650 \begin_layout List
7651 \labelwidthstring 00.00.0000
7652
7653 \series bold
7654 -Aquestion(answer)
7655 \begin_inset LatexCommand index
7656 name "-Aquestion(answer)"
7657
7658 \end_inset
7659
7660
7661 \series default
7662  Assert the answer answer for question, in case it is tested with a preprocessor
7663  conditional such as `#if #question(answer)'.
7664  `-A-' disables the standard assertions that normally describe the target
7665  machine.
7666 \end_layout
7667
7668 \begin_layout List
7669 \labelwidthstring 00.00.0000
7670
7671 \series bold
7672 -Umacro
7673 \begin_inset LatexCommand index
7674 name "-Umacro"
7675
7676 \end_inset
7677
7678
7679 \series default
7680  Undefine macro macro.
7681  `-U' options are evaluated after all `-D' options, but before any `-include'
7682  and `-imacros' options.
7683 \end_layout
7684
7685 \begin_layout List
7686 \labelwidthstring 00.00.0000
7687
7688 \series bold
7689 -dM
7690 \begin_inset LatexCommand index
7691 name "-dM"
7692
7693 \end_inset
7694
7695
7696 \series default
7697  Tell the preprocessor to output only a list of the macro definitions that
7698  are in effect at the end of preprocessing.
7699  Used with the `-E' option.
7700 \end_layout
7701
7702 \begin_layout List
7703 \labelwidthstring 00.00.0000
7704
7705 \series bold
7706 -dD
7707 \begin_inset LatexCommand index
7708 name "-dD"
7709
7710 \end_inset
7711
7712
7713 \series default
7714  Tell the preprocessor to pass all macro definitions into the output, in
7715  their proper sequence in the rest of the output.
7716 \end_layout
7717
7718 \begin_layout List
7719 \labelwidthstring 00.00.0000
7720
7721 \series bold
7722 -dN
7723 \begin_inset LatexCommand index
7724 name "-dN"
7725
7726 \end_inset
7727
7728
7729 \series default
7730 \size large
7731  
7732 \size default
7733 Like `-dD' except that the macro arguments and contents are omitted.
7734  Only `#define name' is included in the output.
7735 \end_layout
7736
7737 \begin_layout List
7738 \labelwidthstring 00.00.0000
7739
7740 \series bold
7741 -pedantic-parse-number
7742 \begin_inset LatexCommand index
7743 name "pedantic"
7744
7745 \end_inset
7746
7747
7748 \begin_inset LatexCommand index
7749 name "-pedantic-parse-number"
7750
7751 \end_inset
7752
7753
7754 \size large
7755 \bar under
7756
7757 \begin_inset LatexCommand label
7758 name "lyx:-pedantic-parse-number"
7759
7760 \end_inset
7761
7762
7763 \series default
7764 \bar default
7765  
7766 \size default
7767 Pedantic parse numbers so that situations like 0xfe-LO_B(3) are parsed properly
7768  and the macro LO_B(3) gets expanded.
7769  See also #pragma pedantic_parse_number 
7770 \begin_inset LatexCommand vpageref
7771 reference "ite:pedantic_parse_number"
7772
7773 \end_inset
7774
7775  in section
7776 \begin_inset LatexCommand ref
7777 reference "sec:Pragmas"
7778
7779 \end_inset
7780
7781  
7782 \emph on
7783 Note: this functionality is not in conformance with C99 standard!
7784 \end_layout
7785
7786 \begin_layout List
7787 \labelwidthstring 00.00.0000
7788
7789 \series bold
7790 -Wp\InsetSpace ~
7791 preprocessorOption[,preprocessorOption]
7792 \series default
7793
7794 \begin_inset LatexCommand index
7795 name "-Wp preprocessorOption[,preprocessorOption]"
7796
7797 \end_inset
7798
7799 ...
7800  Pass the preprocessorOption to the preprocessor 
7801 \family typewriter
7802 sdcpp
7803 \family default
7804
7805 \begin_inset LatexCommand index
7806 name "sdcpp (preprocessor)"
7807
7808 \end_inset
7809
7810 .
7811  SDCC uses an adapted version of the GNU Compiler Collection
7812 \begin_inset LatexCommand index
7813 name "gcc (GNU Compiler Collection)"
7814
7815 \end_inset
7816
7817  preprocessor 
7818 \emph on
7819 cpp
7820 \emph default
7821  (
7822 \emph on
7823 gcc
7824 \emph default
7825  
7826 \begin_inset LatexCommand url
7827 target "http://gcc.gnu.org/"
7828
7829 \end_inset
7830
7831 ).
7832  If you need more dedicated options please refer to the GCC\InsetSpace ~
7833 CPP\InsetSpace ~
7834 Manual at
7835  
7836 \begin_inset LatexCommand htmlurl
7837 target "http://www.gnu.org/software/gcc/onlinedocs/"
7838
7839 \end_inset
7840
7841 .
7842 \end_layout
7843
7844 \begin_layout Standard
7845 \begin_inset VSpace bigskip
7846 \end_inset
7847
7848
7849 \end_layout
7850
7851 \begin_layout Subsection
7852 Linker Options
7853 \begin_inset LatexCommand index
7854 name "Options linker"
7855
7856 \end_inset
7857
7858
7859 \begin_inset LatexCommand index
7860 name "Linker options"
7861
7862 \end_inset
7863
7864
7865 \end_layout
7866
7867 \begin_layout List
7868 \labelwidthstring 00.00.0000
7869
7870 \series bold
7871 -L\InsetSpace ~
7872 -
7873 \series default
7874
7875 \begin_inset ERT
7876 status collapsed
7877
7878 \begin_layout Standard
7879
7880
7881 \backslash
7882 /
7883 \end_layout
7884
7885 \end_inset
7886
7887
7888 \series bold
7889 -lib-path
7890 \begin_inset LatexCommand index
7891 name "-\\/-lib-path <path>"
7892
7893 \end_inset
7894
7895
7896 \begin_inset LatexCommand index
7897 name "-L <path>"
7898
7899 \end_inset
7900
7901
7902 \series default
7903 \InsetSpace ~
7904 <absolute path to additional libraries> This option is passed to the linkage
7905  editor's additional libraries
7906 \begin_inset LatexCommand index
7907 name "Libraries"
7908
7909 \end_inset
7910
7911  search path.
7912  The path name must be absolute.
7913  Additional library files may be specified in the command line.
7914  See section Compiling programs for more details.
7915 \end_layout
7916
7917 \begin_layout List
7918 \labelwidthstring 00.00.0000
7919
7920 \series bold
7921 -
7922 \begin_inset ERT
7923 status collapsed
7924
7925 \begin_layout Standard
7926
7927
7928 \backslash
7929 /
7930 \end_layout
7931
7932 \end_inset
7933
7934 -xram-loc
7935 \series default
7936
7937 \begin_inset LatexCommand index
7938 name "-\\/-xram-loc <Value>"
7939
7940 \end_inset
7941
7942 \InsetSpace ~
7943 <Value> The start location of the external ram
7944 \begin_inset LatexCommand index
7945 name "xdata (mcs51, ds390 storage class)"
7946
7947 \end_inset
7948
7949 , default value is 0.
7950  The value entered can be in Hexadecimal or Decimal format, e.g.: -
7951 \begin_inset ERT
7952 status collapsed
7953
7954 \begin_layout Standard
7955
7956
7957 \backslash
7958 /
7959 \end_layout
7960
7961 \end_inset
7962
7963 -xram-loc 0x8000 or -
7964 \begin_inset ERT
7965 status collapsed
7966
7967 \begin_layout Standard
7968
7969
7970 \backslash
7971 /
7972 \end_layout
7973
7974 \end_inset
7975
7976 -xram-loc 32768.
7977 \end_layout
7978
7979 \begin_layout List
7980 \labelwidthstring 00.00.0000
7981
7982 \series bold
7983 -
7984 \begin_inset ERT
7985 status collapsed
7986
7987 \begin_layout Standard
7988
7989
7990 \backslash
7991 /
7992 \end_layout
7993
7994 \end_inset
7995
7996 -code-loc
7997 \series default
7998
7999 \begin_inset LatexCommand index
8000 name "-\\/-code-loc <Value>"
8001
8002 \end_inset
8003
8004 \InsetSpace ~
8005 <Value> The start location of the code
8006 \begin_inset LatexCommand index
8007 name "code"
8008
8009 \end_inset
8010
8011  segment, default value 0.
8012  Note when this option is used the interrupt vector table
8013 \begin_inset LatexCommand index
8014 name "interrupt vector table"
8015
8016 \end_inset
8017
8018  is also relocated to the given address.
8019  The value entered can be in Hexadecimal or Decimal format, e.g.: -
8020 \begin_inset ERT
8021 status collapsed
8022
8023 \begin_layout Standard
8024
8025
8026 \backslash
8027 /
8028 \end_layout
8029
8030 \end_inset
8031
8032 -code-loc 0x8000 or -
8033 \begin_inset ERT
8034 status collapsed
8035
8036 \begin_layout Standard
8037
8038
8039 \backslash
8040 /
8041 \end_layout
8042
8043 \end_inset
8044
8045 -code-loc 32768.
8046 \end_layout
8047
8048 \begin_layout List
8049 \labelwidthstring 00.00.0000
8050
8051 \series bold
8052 -
8053 \begin_inset ERT
8054 status collapsed
8055
8056 \begin_layout Standard
8057
8058
8059 \backslash
8060 /
8061 \end_layout
8062
8063 \end_inset
8064
8065 -stack-loc
8066 \series default
8067
8068 \begin_inset LatexCommand index
8069 name "-\\/-stack-loc <Value>"
8070
8071 \end_inset
8072
8073 \InsetSpace ~
8074 <Value> By default the stack
8075 \begin_inset LatexCommand index
8076 name "stack"
8077
8078 \end_inset
8079
8080  is placed after the data segment.
8081  Using this option the stack can be placed anywhere in the internal memory
8082  space of the 8051.
8083  The value entered can be in Hexadecimal or Decimal format, e.g.
8084  -
8085 \begin_inset ERT
8086 status collapsed
8087
8088 \begin_layout Standard
8089
8090
8091 \backslash
8092 /
8093 \end_layout
8094
8095 \end_inset
8096
8097 -stack-loc 0x20 or -
8098 \begin_inset ERT
8099 status collapsed
8100
8101 \begin_layout Standard
8102
8103
8104 \backslash
8105 /
8106 \end_layout
8107
8108 \end_inset
8109
8110 -stack-loc 32.
8111  Since the sp register is incremented before a push or call, the initial
8112  sp will be set to one byte prior the provided value.
8113  The provided value should not overlap any other memory areas such as used
8114  register banks or the data segment and with enough space for the current
8115  application.
8116  The 
8117 \series bold
8118 -
8119 \begin_inset ERT
8120 status collapsed
8121
8122 \begin_layout Standard
8123
8124
8125 \backslash
8126 /
8127 \end_layout
8128
8129 \end_inset
8130
8131 -pack-iram
8132 \series default
8133 \InsetSpace ~
8134
8135 \begin_inset LatexCommand index
8136 name "-\\/-pack-iram"
8137
8138 \end_inset
8139
8140  option (which is now a default setting) will override this setting, so
8141  you should also specify the 
8142 \series bold
8143 -
8144 \begin_inset ERT
8145 status collapsed
8146
8147 \begin_layout Standard
8148
8149
8150 \backslash
8151 /
8152 \end_layout
8153
8154 \end_inset
8155
8156 -no-pack-iram
8157 \series default
8158 \InsetSpace ~
8159
8160 \begin_inset LatexCommand index
8161 name "-\\/-no-pack-iram"
8162
8163 \end_inset
8164
8165  option if you need to manually place the stack.
8166 \end_layout
8167
8168 \begin_layout List
8169 \labelwidthstring 00.00.0000
8170
8171 \series bold
8172 -
8173 \begin_inset ERT
8174 status collapsed
8175
8176 \begin_layout Standard
8177
8178
8179 \backslash
8180 /
8181 \end_layout
8182
8183 \end_inset
8184
8185 -xstack-loc
8186 \series default
8187
8188 \begin_inset LatexCommand index
8189 name "-\\/-xstack-loc <Value>"
8190
8191 \end_inset
8192
8193 \InsetSpace ~
8194 <Value> By default the external stack
8195 \begin_inset LatexCommand index
8196 name "xstack"
8197
8198 \end_inset
8199
8200  is placed after the pdata
8201 \begin_inset LatexCommand index
8202 name "pdata (mcs51, ds390 storage class)"
8203
8204 \end_inset
8205
8206  segment.
8207  Using this option the xstack can be placed anywhere in the external memory
8208  space of the 8051.
8209  The value entered can be in Hexadecimal or Decimal format, e.g.
8210  -
8211 \begin_inset ERT
8212 status collapsed
8213
8214 \begin_layout Standard
8215
8216
8217 \backslash
8218 /
8219 \end_layout
8220
8221 \end_inset
8222
8223 -xstack-loc 0x8000 or -
8224 \begin_inset ERT
8225 status collapsed
8226
8227 \begin_layout Standard
8228
8229
8230 \backslash
8231 /
8232 \end_layout
8233
8234 \end_inset
8235
8236 -stack-loc 32768.
8237  The provided value should not overlap any other memory areas such as the
8238  pdata or xdata segment and with enough space for the current application.
8239 \end_layout
8240
8241 \begin_layout List
8242 \labelwidthstring 00.00.0000
8243
8244 \series bold
8245 -
8246 \begin_inset ERT
8247 status collapsed
8248
8249 \begin_layout Standard
8250
8251
8252 \backslash
8253 /
8254 \end_layout
8255
8256 \end_inset
8257
8258 -data-loc
8259 \series default
8260
8261 \begin_inset LatexCommand index
8262 name "-\\/-data-loc <Value>"
8263
8264 \end_inset
8265
8266 \InsetSpace ~
8267 <Value> The start location of the internal ram data
8268 \begin_inset LatexCommand index
8269 name "data (mcs51, ds390 storage class)"
8270
8271 \end_inset
8272
8273  segment.
8274  The value entered can be in Hexadecimal or Decimal format, eg.
8275  -
8276 \begin_inset ERT
8277 status collapsed
8278
8279 \begin_layout Standard
8280
8281
8282 \backslash
8283 /
8284 \end_layout
8285
8286 \end_inset
8287
8288 -data-loc 0x20 or -
8289 \begin_inset ERT
8290 status collapsed
8291
8292 \begin_layout Standard
8293
8294
8295 \backslash
8296 /
8297 \end_layout
8298
8299 \end_inset
8300
8301 -data-loc 32.
8302  (By default, the start location of the internal ram data segment  is set
8303  as low as possible in memory, taking into account the used register banks
8304  and the bit segment at address 0x20.
8305  For example if register banks 0 and 1 are used without bit variables, the
8306  data segment will be set, if -
8307 \begin_inset ERT
8308 status collapsed
8309
8310 \begin_layout Standard
8311
8312
8313 \backslash
8314 /
8315 \end_layout
8316
8317 \end_inset
8318
8319 -data-loc is not used, to location 0x10.)
8320 \end_layout
8321
8322 \begin_layout List
8323 \labelwidthstring 00.00.0000
8324
8325 \series bold
8326 -
8327 \begin_inset ERT
8328 status collapsed
8329
8330 \begin_layout Standard
8331
8332
8333 \backslash
8334 /
8335 \end_layout
8336
8337 \end_inset
8338
8339 -idata-loc
8340 \series default
8341
8342 \begin_inset LatexCommand index
8343 name "-\\/-idata-loc <Value>"
8344
8345 \end_inset
8346
8347 \InsetSpace ~
8348 <Value> The start location of the indirectly addressable internal ram
8349 \begin_inset LatexCommand index
8350 name "idata (mcs51, ds390 storage class)"
8351
8352 \end_inset
8353
8354  of the 8051, default value is 0x80.
8355  The value entered can be in Hexadecimal or Decimal format, eg.
8356  -
8357 \begin_inset ERT
8358 status collapsed
8359
8360 \begin_layout Standard
8361
8362
8363 \backslash
8364 /
8365 \end_layout
8366
8367 \end_inset
8368
8369 -idata-loc 0x88 or -
8370 \begin_inset ERT
8371 status collapsed
8372
8373 \begin_layout Standard
8374
8375
8376 \backslash
8377 /
8378 \end_layout
8379
8380 \end_inset
8381
8382 -idata-loc 136.
8383 \end_layout
8384
8385 \begin_layout List
8386 \labelwidthstring 00.00.0000
8387
8388 \series bold
8389 -
8390 \begin_inset ERT
8391 status collapsed
8392
8393 \begin_layout Standard
8394
8395
8396 \backslash
8397 /
8398 \end_layout
8399
8400 \end_inset
8401
8402 -bit-loc
8403 \series default
8404 \InsetSpace ~
8405 <Value> The start location of the bit
8406 \begin_inset LatexCommand index
8407 name "bit"
8408
8409 \end_inset
8410
8411  addressable internal ram of the 8051.
8412  This is 
8413 \emph on
8414 not
8415 \emph default
8416  implemented yet.
8417  Instead an option can be passed directly to the linker: -Wl\InsetSpace ~
8418 -bBSEG=<Value>.
8419 \end_layout
8420
8421 \begin_layout List
8422 \labelwidthstring 00.00.0000
8423
8424 \series bold
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 -out-fmt-ihx
8439 \begin_inset LatexCommand index
8440 name "-\\/-out-fmt-ihx"
8441
8442 \end_inset
8443
8444  
8445 \series default
8446 The linker output (final object code) is in Intel Hex format.
8447 \begin_inset LatexCommand index
8448 name "Intel hex format"
8449
8450 \end_inset
8451
8452  This is the default option.
8453  The format itself is documented in the documentation of srecord
8454 \begin_inset LatexCommand index
8455 name "srecord (bin, hex, ... tool)"
8456
8457 \end_inset
8458
8459 .
8460 \end_layout
8461
8462 \begin_layout List
8463 \labelwidthstring 00.00.0000
8464
8465 \series bold
8466 -
8467 \begin_inset ERT
8468 status collapsed
8469
8470 \begin_layout Standard
8471
8472
8473 \backslash
8474 /
8475 \end_layout
8476
8477 \end_inset
8478
8479 -out-fmt-s19
8480 \begin_inset LatexCommand index
8481 name "-\\/-out-fmt-s19"
8482
8483 \end_inset
8484
8485  
8486 \series default
8487 The linker output (final object code) is in Motorola S19 format
8488 \begin_inset LatexCommand index
8489 name "Motorola S19 format"
8490
8491 \end_inset
8492
8493 .
8494  The format itself is documented in the documentation of srecord.
8495 \end_layout
8496
8497 \begin_layout List
8498 \labelwidthstring 00.00.0000
8499
8500 \series bold
8501 -
8502 \begin_inset ERT
8503 status collapsed
8504
8505 \begin_layout Standard
8506
8507
8508 \backslash
8509 /
8510 \end_layout
8511
8512 \end_inset
8513
8514 -out-fmt-elf
8515 \begin_inset LatexCommand index
8516 name "-\\/-out-fmt-s19"
8517
8518 \end_inset
8519
8520
8521 \begin_inset LatexCommand index
8522 name "HC08!Options!-\\/-out-fmt-elf"
8523
8524 \end_inset
8525
8526  
8527 \series default
8528 The linker output (final object code) is in ELF format
8529 \begin_inset LatexCommand index
8530 name "ELF format"
8531
8532 \end_inset
8533
8534 .
8535  (Currently only supported for the HC08
8536 \begin_inset LatexCommand index
8537 name "HC08"
8538
8539 \end_inset
8540
8541  processors)
8542 \end_layout
8543
8544 \begin_layout List
8545 \labelwidthstring 00.00.0000
8546
8547 \series bold
8548 -Wl\InsetSpace ~
8549 linkOption[,linkOption]
8550 \series default
8551
8552 \begin_inset LatexCommand index
8553 name "-Wl linkOption[,linkOption]"
8554
8555 \end_inset
8556
8557
8558 \begin_inset LatexCommand label
8559 name "lyx:-Wl option"
8560
8561 \end_inset
8562
8563 ...
8564  Pass the linkOption to the linker.
8565  If a bootloader is used an option like 
8566 \begin_inset Quotes sld
8567 \end_inset
8568
8569 -Wl\InsetSpace ~
8570 -bCSEG=0x1000
8571 \begin_inset Quotes srd
8572 \end_inset
8573
8574  would be typical to set the start of the code segment.
8575  Either use the double quotes around this option or use no space (e.g.
8576  -Wl-bCSEG=0x1000).
8577  See also #pragma constseg and #pragma codeseg in section 
8578 \begin_inset LatexCommand ref
8579 reference "sec:Pragmas"
8580
8581 \end_inset
8582
8583  .
8584  File sdcc/as/doc/asxhtm.html has more on linker options.
8585 \end_layout
8586
8587 \begin_layout Standard
8588 \begin_inset VSpace bigskip
8589 \end_inset
8590
8591
8592 \end_layout
8593
8594 \begin_layout Subsection
8595 MCS51 Options
8596 \begin_inset LatexCommand index
8597 name "Options MCS51"
8598
8599 \end_inset
8600
8601
8602 \begin_inset LatexCommand index
8603 name "MCS51 options"
8604
8605 \end_inset
8606
8607
8608 \end_layout
8609
8610 \begin_layout List
8611 \labelwidthstring 00.00.0000
8612
8613 \series bold
8614 -
8615 \begin_inset ERT
8616 status collapsed
8617
8618 \begin_layout Standard
8619
8620
8621 \backslash
8622 /
8623 \end_layout
8624
8625 \end_inset
8626
8627 -model-small
8628 \begin_inset LatexCommand index
8629 name "-\\/-model-small"
8630
8631 \end_inset
8632
8633
8634 \series default
8635 \size large
8636  
8637 \size default
8638 Generate code for Small Model programs, see section Memory Models for more
8639  details.
8640  This is the default model.
8641 \end_layout
8642
8643 \begin_layout List
8644 \labelwidthstring 00.00.0000
8645
8646 \series bold
8647 -
8648 \begin_inset ERT
8649 status collapsed
8650
8651 \begin_layout Standard
8652
8653
8654 \backslash
8655 /
8656 \end_layout
8657
8658 \end_inset
8659
8660 -model-medium
8661 \begin_inset LatexCommand index
8662 name "-\\/-model-medium"
8663
8664 \end_inset
8665
8666
8667 \series default
8668  Generate code for Medium model programs, see section Memory Models for
8669  more details.
8670  If this option is used all source files in the project have to be compiled
8671  with this option.
8672  It must also be used when invoking the linker.
8673 \end_layout
8674
8675 \begin_layout List
8676 \labelwidthstring 00.00.0000
8677
8678 \series bold
8679 -
8680 \begin_inset ERT
8681 status collapsed
8682
8683 \begin_layout Standard
8684
8685
8686 \backslash
8687 /
8688 \end_layout
8689
8690 \end_inset
8691
8692 -model-large
8693 \begin_inset LatexCommand index
8694 name "-\\/-model-large"
8695
8696 \end_inset
8697
8698
8699 \series default
8700  Generate code for Large model programs, see section Memory Models for more
8701  details.
8702  If this option is used all source files in the project have to be compiled
8703  with this option.
8704  It must also be used when invoking the linker.
8705 \end_layout
8706
8707 \begin_layout List
8708 \labelwidthstring 00.00.0000
8709
8710 \series bold
8711 -
8712 \begin_inset ERT
8713 status collapsed
8714
8715 \begin_layout Standard
8716
8717
8718 \backslash
8719 /
8720 \end_layout
8721
8722 \end_inset
8723
8724 -xstack
8725 \begin_inset LatexCommand index
8726 name "-\\/-xstack"
8727
8728 \end_inset
8729
8730
8731 \series default
8732  Uses a pseudo stack in the pdata
8733 \begin_inset LatexCommand index
8734 name "pdata (mcs51, ds390 storage class)"
8735
8736 \end_inset
8737
8738  area (usually the first 256 bytes in the external ram) for allocating variables
8739  and passing parameters.
8740  See section 
8741 \begin_inset LatexCommand ref
8742 reference "sub:External-Stack"
8743
8744 \end_inset
8745
8746 \InsetSpace ~
8747  External Stack for more details.
8748 \end_layout
8749
8750 \begin_layout List
8751 \labelwidthstring 00.00.0000
8752
8753 \series bold
8754 -
8755 \begin_inset ERT
8756 status collapsed
8757
8758 \begin_layout Standard
8759
8760
8761 \backslash
8762 /
8763 \end_layout
8764
8765 \end_inset
8766
8767 -iram-size
8768 \series default
8769 \InsetSpace ~
8770 <Value>
8771 \begin_inset LatexCommand index
8772 name "-\\/-iram-size <Value>"
8773
8774 \end_inset
8775
8776  Causes the linker to check if the internal ram usage is within limits of
8777  the given value.
8778 \end_layout
8779
8780 \begin_layout List
8781 \labelwidthstring 00.00.0000
8782
8783 \series bold
8784 -
8785 \begin_inset ERT
8786 status collapsed
8787
8788 \begin_layout Standard
8789
8790
8791 \backslash
8792 /
8793 \end_layout
8794
8795 \end_inset
8796
8797 -xram-size
8798 \series default
8799 \InsetSpace ~
8800 <Value>
8801 \begin_inset LatexCommand index
8802 name "-\\/-xram-size <Value>"
8803
8804 \end_inset
8805
8806  Causes the linker to check if the external ram usage is within limits of
8807  the given value.
8808 \end_layout
8809
8810 \begin_layout List
8811 \labelwidthstring 00.00.0000
8812
8813 \series bold
8814 -
8815 \begin_inset ERT
8816 status collapsed
8817
8818 \begin_layout Standard
8819
8820
8821 \backslash
8822 /
8823 \end_layout
8824
8825 \end_inset
8826
8827 -code-size
8828 \series default
8829 \InsetSpace ~
8830 <Value>
8831 \begin_inset LatexCommand index
8832 name "-\\/-code-size <Value>"
8833
8834 \end_inset
8835
8836  Causes the linker to check if the code memory usage is within limits of
8837  the given value.
8838 \end_layout
8839
8840 \begin_layout List
8841 \labelwidthstring 00.00.0000
8842
8843 \series bold
8844 -
8845 \begin_inset ERT
8846 status collapsed
8847
8848 \begin_layout Standard
8849
8850
8851 \backslash
8852 /
8853 \end_layout
8854
8855 \end_inset
8856
8857 -stack-size
8858 \series default
8859 \InsetSpace ~
8860 <Value>
8861 \begin_inset LatexCommand index
8862 name "-\\/-stack-size <Value>"
8863
8864 \end_inset
8865
8866  Causes the linker to check if there is at minimum <Value> bytes for stack.
8867 \end_layout
8868
8869 \begin_layout List
8870 \labelwidthstring 00.00.0000
8871
8872 \series bold
8873 -
8874 \begin_inset ERT
8875 status collapsed
8876
8877 \begin_layout Standard
8878
8879
8880 \backslash
8881 /
8882 \end_layout
8883
8884 \end_inset
8885
8886 -pack-iram
8887 \series default
8888 \InsetSpace ~
8889
8890 \begin_inset LatexCommand index
8891 name "-\\/-pack-iram"
8892
8893 \end_inset
8894
8895  Causes the linker to use unused register banks for data variables and pack
8896  data, idata and stack together.
8897  This is the default now.
8898 \end_layout
8899
8900 \begin_layout List
8901 \labelwidthstring 00.00.0000
8902
8903 \series bold
8904 -
8905 \begin_inset ERT
8906 status collapsed
8907
8908 \begin_layout Standard
8909
8910
8911 \backslash
8912 /
8913 \end_layout
8914
8915 \end_inset
8916
8917 -no-pack-iram
8918 \series default
8919 \InsetSpace ~
8920
8921 \begin_inset LatexCommand index
8922 name "-\\/-no-pack-iram"
8923
8924 \end_inset
8925
8926  Causes the linker to use old style for allocating memory areas.
8927 \end_layout
8928
8929 \begin_layout List
8930 \labelwidthstring 00.00.0000
8931
8932 \series bold
8933 -
8934 \begin_inset ERT
8935 status collapsed
8936
8937 \begin_layout Standard
8938
8939
8940 \backslash
8941 /
8942 \end_layout
8943
8944 \end_inset
8945
8946 -acall-ajmp
8947 \series default
8948 \InsetSpace ~
8949
8950 \begin_inset LatexCommand index
8951 name "-\\/-acall-ajmp"
8952
8953 \end_inset
8954
8955  Replaces the three byte instructions lcall/ljmp with the two byte instructions
8956  acall/ajmp.
8957  Only use this option if your code is in the same 2k block of memory.
8958  You may need to use this option for some 8051 derivatives which lack the
8959  lcall/ljmp instructions..
8960 \end_layout
8961
8962 \begin_layout Standard
8963 \begin_inset VSpace bigskip
8964 \end_inset
8965
8966
8967 \end_layout
8968
8969 \begin_layout Subsection
8970 DS390 / DS400 Options
8971 \begin_inset LatexCommand index
8972 name "Options DS390"
8973
8974 \end_inset
8975
8976
8977 \begin_inset LatexCommand index
8978 name "DS390"
8979
8980 \end_inset
8981
8982
8983 \end_layout
8984
8985 \begin_layout List
8986 \labelwidthstring 00.00.0000
8987
8988 \series bold
8989 -
8990 \begin_inset ERT
8991 status collapsed
8992
8993 \begin_layout Standard
8994
8995
8996 \backslash
8997 /
8998 \end_layout
8999
9000 \end_inset
9001
9002 -model-flat24
9003 \series default
9004
9005 \begin_inset LatexCommand index
9006 name "DS390!Options!-\\/-model-flat24"
9007
9008 \end_inset
9009
9010
9011 \size large
9012  
9013 \size default
9014 Generate 24-bit flat mode code.
9015  This is the one and only that the ds390 code generator supports right now
9016  and is default when using 
9017 \emph on
9018 -mds390
9019 \emph default
9020 .
9021  See section Memory Models for more details.
9022 \end_layout
9023
9024 \begin_layout List
9025 \labelwidthstring 00.00.0000
9026
9027 \series bold
9028 -
9029 \begin_inset ERT
9030 status collapsed
9031
9032 \begin_layout Standard
9033
9034
9035 \backslash
9036 /
9037 \end_layout
9038
9039 \end_inset
9040
9041 -protect-sp-update
9042 \begin_inset LatexCommand index
9043 name "DS390!Options!-\\/-protect-sp-update"
9044
9045 \end_inset
9046
9047
9048 \series default
9049  disable interrupts during ESP:SP updates.
9050 \end_layout
9051
9052 \begin_layout List
9053 \labelwidthstring 00.00.0000
9054
9055 \series bold
9056 -
9057 \begin_inset ERT
9058 status collapsed
9059
9060 \begin_layout Standard
9061
9062
9063 \backslash
9064 /
9065 \end_layout
9066
9067 \end_inset
9068
9069 -stack-10bit
9070 \series default
9071
9072 \begin_inset LatexCommand index
9073 name "DS390!Options!-\\/-stack-10bit"
9074
9075 \end_inset
9076
9077  Generate code for the 10 bit stack mode of the Dallas DS80C390 part.
9078  This is the one and only that the ds390 code generator supports right now
9079  and is default when using 
9080 \emph on
9081 -mds390
9082 \emph default
9083 .
9084  In this mode, the stack is located in the lower 1K of the internal RAM,
9085  which is mapped to 0x400000.
9086  Note that the support is incomplete, since it still uses a single byte
9087  as the stack pointer.
9088  This means that only the lower 256 bytes of the potential 1K stack space
9089  will actually be used.
9090  However, this does allow you to reclaim the precious 256 bytes of low RAM
9091  for use for the DATA and IDATA segments.
9092  The compiler will not generate any code to put the processor into 10 bit
9093  stack mode.
9094  It is important to ensure that the processor is in this mode before calling
9095  any re-entrant functions compiled with this option.
9096  In principle, this should work with the 
9097 \emph on
9098 -
9099 \begin_inset ERT
9100 status collapsed
9101
9102 \begin_layout Standard
9103
9104
9105 \backslash
9106 /
9107 \end_layout
9108
9109 \end_inset
9110
9111 -stack-auto
9112 \begin_inset LatexCommand index
9113 name "-\\/-stack-auto"
9114
9115 \end_inset
9116
9117
9118 \emph default
9119  option, but that has not been tested.
9120  It is incompatible with the 
9121 \emph on
9122 -
9123 \begin_inset ERT
9124 status collapsed
9125
9126 \begin_layout Standard
9127
9128
9129 \backslash
9130 /
9131 \end_layout
9132
9133 \end_inset
9134
9135 -xstack
9136 \begin_inset LatexCommand index
9137 name "-\\/-xstack"
9138
9139 \end_inset
9140
9141
9142 \emph default
9143  option.
9144  It also only makes sense if the processor is in 24 bit contiguous addressing
9145  mode (see the 
9146 \emph on
9147 -
9148 \begin_inset ERT
9149 status collapsed
9150
9151 \begin_layout Standard
9152
9153
9154 \backslash
9155 /
9156 \end_layout
9157
9158 \end_inset
9159
9160 -model-flat24 option
9161 \emph default
9162 ).
9163 \series bold
9164
9165 \begin_inset Note Note
9166 status collapsed
9167
9168 \begin_layout List
9169 \labelwidthstring 00.00.0000
9170
9171 \series bold
9172 -
9173 \begin_inset ERT
9174 status open
9175
9176 \begin_layout Standard
9177
9178
9179 \backslash
9180 /
9181 \end_layout
9182
9183 \end_inset
9184
9185 -stack-8-bit - switches off the 10-bit mode
9186 \end_layout
9187
9188 \end_inset
9189
9190
9191 \end_layout
9192
9193 \begin_layout List
9194 \labelwidthstring 00.00.0000
9195
9196 \series bold
9197 -
9198 \begin_inset ERT
9199 status collapsed
9200
9201 \begin_layout Standard
9202
9203
9204 \backslash
9205 /
9206 \end_layout
9207
9208 \end_inset
9209
9210 -stack-probe
9211 \begin_inset LatexCommand index
9212 name "DS390!Options!-\\/-stack-probe"
9213
9214 \end_inset
9215
9216
9217 \series default
9218  insert call to function __stack_probe at each function prologue.
9219 \end_layout
9220
9221 \begin_layout List
9222 \labelwidthstring 00.00.0000
9223
9224 \series bold
9225 -
9226 \begin_inset ERT
9227 status open
9228
9229 \begin_layout Standard
9230
9231
9232 \backslash
9233 /
9234 \end_layout
9235
9236 \end_inset
9237
9238 -tini-libid
9239 \begin_inset LatexCommand index
9240 name "DS390!Options!-\\/-tini-libid"
9241
9242 \end_inset
9243
9244
9245 \series default
9246  <nnnn> LibraryID used in -mTININative.
9247  
9248 \end_layout
9249
9250 \begin_layout List
9251 \labelwidthstring 00.00.0000
9252
9253 \series bold
9254 -
9255 \begin_inset ERT
9256 status collapsed
9257
9258 \begin_layout Standard
9259
9260
9261 \backslash
9262 /
9263 \end_layout
9264
9265 \end_inset
9266
9267 -use-accelerator
9268 \begin_inset LatexCommand index
9269 name "DS390!Options!-\\/-use-accelerator"
9270
9271 \end_inset
9272
9273
9274 \series default
9275  generate code for DS390 Arithmetic Accelerator.
9276  
9277 \end_layout
9278
9279 \begin_layout Standard
9280 \begin_inset VSpace bigskip
9281 \end_inset
9282
9283
9284 \end_layout
9285
9286 \begin_layout Subsection
9287 Z80 Options
9288 \begin_inset LatexCommand index
9289 name "Options Z80"
9290
9291 \end_inset
9292
9293
9294 \begin_inset LatexCommand index
9295 name "Z80"
9296
9297 \end_inset
9298
9299
9300 \end_layout
9301
9302 \begin_layout List
9303 \labelwidthstring 00.00.0000
9304
9305 \series bold
9306 -
9307 \begin_inset ERT
9308 status collapsed
9309
9310 \begin_layout Standard
9311
9312
9313 \backslash
9314 /
9315 \end_layout
9316
9317 \end_inset
9318
9319 -callee-saves-bc
9320 \series default
9321
9322 \begin_inset LatexCommand index
9323 name "Z80!Options!-\\/-callee-saves-bc"
9324
9325 \end_inset
9326
9327
9328 \size large
9329  
9330 \size default
9331 Force a called function to always save BC.
9332 \end_layout
9333
9334 \begin_layout List
9335 \labelwidthstring 00.00.0000
9336
9337 \series bold
9338 -
9339 \begin_inset ERT
9340 status collapsed
9341
9342 \begin_layout Standard
9343
9344
9345 \backslash
9346 /
9347 \end_layout
9348
9349 \end_inset
9350
9351 -no-std-crt0
9352 \series default
9353
9354 \begin_inset LatexCommand index
9355 name "Z80!Options!-\\/-no-std-crt0"
9356
9357 \end_inset
9358
9359  When linking, skip the standard crt0.o object file.
9360  You must provide your own crt0.o for your system when linking.
9361 \end_layout
9362
9363 \begin_layout List
9364 \labelwidthstring 00.00.0000
9365
9366 \series bold
9367 -
9368 \begin_inset ERT
9369 status collapsed
9370
9371 \begin_layout Standard
9372
9373
9374 \backslash
9375 /
9376 \end_layout
9377
9378 \end_inset
9379
9380 -portmode=
9381 \series default
9382 <Value>
9383 \begin_inset LatexCommand index
9384 name "Z80!Options!-\\/-portmode=<Value>"
9385
9386 \end_inset
9387
9388  Determinate PORT I/O mode (<Value> is z80 or z180).
9389 \end_layout
9390
9391 \begin_layout List
9392 \labelwidthstring 00.00.0000
9393
9394 \series bold
9395 -
9396 \begin_inset ERT
9397 status collapsed
9398
9399 \begin_layout Standard
9400
9401
9402 \backslash
9403 /
9404 \end_layout
9405
9406 \end_inset
9407
9408 -asm=
9409 \series default
9410 <Value>
9411 \begin_inset LatexCommand index
9412 name "Z80!Options!-\\/-asm=<Value>"
9413
9414 \end_inset
9415
9416  Define assembler name (<Value> is rgbds, asxxxx, isas or z80asm).
9417 \end_layout
9418
9419 \begin_layout List
9420 \labelwidthstring 00.00.0000
9421
9422 \series bold
9423 -
9424 \begin_inset ERT
9425 status collapsed
9426
9427 \begin_layout Standard
9428
9429
9430 \backslash
9431 /
9432 \end_layout
9433
9434 \end_inset
9435
9436 -codeseg
9437 \series default
9438 \InsetSpace ~
9439 <Value>
9440 \begin_inset LatexCommand index
9441 name "Z80!Options!-\\/-codeseg <Value>"
9442
9443 \end_inset
9444
9445  Use <Value> for the code segment name.
9446 \end_layout
9447
9448 \begin_layout List
9449 \labelwidthstring 00.00.0000
9450
9451 \series bold
9452 -
9453 \begin_inset ERT
9454 status collapsed
9455
9456 \begin_layout Standard
9457
9458
9459 \backslash
9460 /
9461 \end_layout
9462
9463 \end_inset
9464
9465 -constseg
9466 \series default
9467 \InsetSpace ~
9468 <Value>
9469 \begin_inset LatexCommand index
9470 name "Z80!Options!-\\/-constseg <Value>"
9471
9472 \end_inset
9473
9474  Use <Value> for the const segment name.
9475 \end_layout
9476
9477 \begin_layout List
9478 \labelwidthstring 00.00.0000
9479 \begin_inset VSpace bigskip
9480 \end_inset
9481
9482
9483 \end_layout
9484
9485 \begin_layout Subsection
9486 GBZ80 Options
9487 \begin_inset LatexCommand index
9488 name "Options GBZ80"
9489
9490 \end_inset
9491
9492
9493 \begin_inset LatexCommand index
9494 name "GBZ80"
9495
9496 \end_inset
9497
9498
9499 \end_layout
9500
9501 \begin_layout List
9502 \labelwidthstring 00.00.0000
9503
9504 \series bold
9505 -
9506 \begin_inset ERT
9507 status collapsed
9508
9509 \begin_layout Standard
9510
9511
9512 \backslash
9513 /
9514 \end_layout
9515
9516 \end_inset
9517
9518 -callee-saves-bc
9519 \series default
9520
9521 \begin_inset LatexCommand index
9522 name "GBZ80!Options!-\\/-callee-saves-bc"
9523
9524 \end_inset
9525
9526
9527 \size large
9528  
9529 \size default
9530 Force a called function to always save BC.
9531 \end_layout
9532
9533 \begin_layout List
9534 \labelwidthstring 00.00.0000
9535
9536 \series bold
9537 -
9538 \begin_inset ERT
9539 status collapsed
9540
9541 \begin_layout Standard
9542
9543
9544 \backslash
9545 /
9546 \end_layout
9547
9548 \end_inset
9549
9550 -no-std-crt0
9551 \series default
9552
9553 \begin_inset LatexCommand index
9554 name "Z80!Options!-\\/-no-std-crt0"
9555
9556 \end_inset
9557
9558  When linking, skip the standard crt0.o object file.
9559  You must provide your own crt0.o for your system when linking.
9560 \end_layout
9561
9562 \begin_layout List
9563 \labelwidthstring 00.00.0000
9564
9565 \series bold
9566 -bo
9567 \series default
9568 \InsetSpace ~
9569 <Num>
9570 \begin_inset LatexCommand index
9571 name "GBZ80!Options!-bo <Num>"
9572
9573 \end_inset
9574
9575  Use code bank <Num>.
9576 \end_layout
9577
9578 \begin_layout List
9579 \labelwidthstring 00.00.0000
9580
9581 \series bold
9582 -ba
9583 \series default
9584 \InsetSpace ~
9585 <Num>
9586 \begin_inset LatexCommand index
9587 name "GBZ80!Options!-ba <Num>"
9588
9589 \end_inset
9590
9591  Use data bank <Num>.
9592 \end_layout
9593
9594 \begin_layout List
9595 \labelwidthstring 00.00.0000
9596
9597 \series bold
9598 -
9599 \begin_inset ERT
9600 status collapsed
9601
9602 \begin_layout Standard
9603
9604
9605 \backslash
9606 /
9607 \end_layout
9608
9609 \end_inset
9610
9611 -codeseg
9612 \series default
9613 \InsetSpace ~
9614 <Value>
9615 \begin_inset LatexCommand index
9616 name "GBZ80!Options!-\\/-codeseg <Value>"
9617
9618 \end_inset
9619
9620  Use <Value> for the code segment name.
9621 \end_layout
9622
9623 \begin_layout List
9624 \labelwidthstring 00.00.0000
9625
9626 \series bold
9627 -
9628 \begin_inset ERT
9629 status collapsed
9630
9631 \begin_layout Standard
9632
9633
9634 \backslash
9635 /
9636 \end_layout
9637
9638 \end_inset
9639
9640 -constseg
9641 \series default
9642 \InsetSpace ~
9643 <Value>
9644 \begin_inset LatexCommand index
9645 name "GBZ80!Options!-\\/-constseg <Value>"
9646
9647 \end_inset
9648
9649  Use <Value> for the const segment name.
9650 \end_layout
9651
9652 \begin_layout Standard
9653 \begin_inset VSpace bigskip
9654 \end_inset
9655
9656
9657 \end_layout
9658
9659 \begin_layout Subsection
9660 Optimization Options
9661 \begin_inset LatexCommand index
9662 name "Options optimization"
9663
9664 \end_inset
9665
9666
9667 \begin_inset LatexCommand index
9668 name "Optimization options"
9669
9670 \end_inset
9671
9672
9673 \end_layout
9674
9675 \begin_layout List
9676 \labelwidthstring 00.00.0000
9677
9678 \series bold
9679 -
9680 \begin_inset ERT
9681 status collapsed
9682
9683 \begin_layout Standard
9684
9685
9686 \backslash
9687 /
9688 \end_layout
9689
9690 \end_inset
9691
9692 -nogcse
9693 \begin_inset LatexCommand index
9694 name "-\\/-nogcse"
9695
9696 \end_inset
9697
9698
9699 \series default
9700  Will not do global subexpression elimination, this option may be used when
9701  the compiler creates undesirably large stack/data spaces to store compiler
9702  temporaries (
9703 \emph on
9704 s
9705 \emph default
9706 pill 
9707 \emph on
9708 loc
9709 \emph default
9710 ations, sloc
9711 \begin_inset LatexCommand index
9712 name "sloc (spill location)"
9713
9714 \end_inset
9715
9716 ).
9717  A warning message will be generated when this happens and the compiler
9718  will indicate the number of extra bytes it allocated.
9719  It is recommended that this option NOT be used, #pragma\InsetSpace ~
9720 nogcse
9721 \begin_inset LatexCommand index
9722 name "\\#pragma nogcse"
9723
9724 \end_inset
9725
9726  can be used to turn off global subexpression elimination
9727 \begin_inset LatexCommand index
9728 name "Subexpression elimination"
9729
9730 \end_inset
9731
9732  for a given function only.
9733 \end_layout
9734
9735 \begin_layout List
9736 \labelwidthstring 00.00.0000
9737
9738 \series bold
9739 -
9740 \begin_inset ERT
9741 status collapsed
9742
9743 \begin_layout Standard
9744
9745
9746 \backslash
9747 /
9748 \end_layout
9749
9750 \end_inset
9751
9752 -noinvariant
9753 \begin_inset LatexCommand index
9754 name "-\\/-noinvariant"
9755
9756 \end_inset
9757
9758
9759 \series default
9760  Will not do loop invariant optimizations, this may be turned off for reasons
9761  explained for the previous option.
9762  For more details of loop optimizations performed see Loop Invariants in
9763  section 
9764 \begin_inset LatexCommand ref
9765 reference "sub:Loop-Optimizations"
9766
9767 \end_inset
9768
9769 .
9770  It is recommended that this option NOT be used, #pragma\InsetSpace ~
9771 noinvariant
9772 \begin_inset LatexCommand index
9773 name "\\#pragma noinvariant"
9774
9775 \end_inset
9776
9777  can be used to turn off invariant optimizations for a given function only.
9778 \end_layout
9779
9780 \begin_layout List
9781 \labelwidthstring 00.00.0000
9782
9783 \series bold
9784 -
9785 \begin_inset ERT
9786 status collapsed
9787
9788 \begin_layout Standard
9789
9790
9791 \backslash
9792 /
9793 \end_layout
9794
9795 \end_inset
9796
9797 -noinduction
9798 \begin_inset LatexCommand index
9799 name "-\\/-noinduction"
9800
9801 \end_inset
9802
9803
9804 \series default
9805  Will not do loop induction optimizations, see section strength reduction
9806  for more details.
9807  It is recommended that this option is NOT used, #pragma\InsetSpace ~
9808 noinduction
9809 \begin_inset LatexCommand index
9810 name "\\#pragma noinduction"
9811
9812 \end_inset
9813
9814  can be used to turn off induction optimizations for a given function only.
9815 \end_layout
9816
9817 \begin_layout List
9818 \labelwidthstring 00.00.0000
9819
9820 \series bold
9821 -
9822 \begin_inset ERT
9823 status collapsed
9824
9825 \begin_layout Standard
9826
9827
9828 \backslash
9829 /
9830 \end_layout
9831
9832 \end_inset
9833
9834 -nojtbound
9835 \begin_inset LatexCommand index
9836 name "-\\/-nojtbound"
9837
9838 \end_inset
9839
9840
9841 \size large
9842  
9843 \series default
9844 \size default
9845  Will not generate boundary condition check when switch statements
9846 \begin_inset LatexCommand index
9847 name "switch statement"
9848
9849 \end_inset
9850
9851  are implemented using jump-tables.
9852  See section 
9853 \begin_inset LatexCommand ref
9854 reference "sub:'switch'-Statements"
9855
9856 \end_inset
9857
9858 \InsetSpace ~
9859 Switch Statements for more details.
9860  It is recommended that this option is NOT used, #pragma\InsetSpace ~
9861 nojtbound
9862 \begin_inset LatexCommand index
9863 name "\\#pragma nojtbound"
9864
9865 \end_inset
9866
9867  can be used to turn off boundary checking for jump tables for a given function
9868  only.
9869 \end_layout
9870
9871 \begin_layout List
9872 \labelwidthstring 00.00.0000
9873
9874 \series bold
9875 -
9876 \begin_inset ERT
9877 status collapsed
9878
9879 \begin_layout Standard
9880
9881
9882 \backslash
9883 /
9884 \end_layout
9885
9886 \end_inset
9887
9888 -noloopreverse
9889 \begin_inset LatexCommand index
9890 name "-\\/-noloopreverse"
9891
9892 \end_inset
9893
9894
9895 \series default
9896 \size large
9897  
9898 \size default
9899 Will not do loop reversal 
9900 \begin_inset LatexCommand index
9901 name "Loop reversing"
9902
9903 \end_inset
9904
9905 optimization.
9906 \end_layout
9907
9908 \begin_layout List
9909 \labelwidthstring 00.00.0000
9910 -
9911 \begin_inset ERT
9912 status collapsed
9913
9914 \begin_layout Standard
9915
9916
9917 \backslash
9918 /
9919 \end_layout
9920
9921 \end_inset
9922
9923 -
9924 \series bold
9925 nolabelopt
9926 \series default
9927  
9928 \begin_inset LatexCommand index
9929 name "-\\/-nolabelopt "
9930
9931 \end_inset
9932
9933 Will not optimize labels (makes the dumpfiles more readable).
9934 \end_layout
9935
9936 \begin_layout List
9937 \labelwidthstring 00.00.0000
9938
9939 \series bold
9940 -
9941 \begin_inset ERT
9942 status collapsed
9943
9944 \begin_layout Standard
9945
9946
9947 \backslash
9948 /
9949 \end_layout
9950
9951 \end_inset
9952
9953 -no-xinit-opt
9954 \begin_inset LatexCommand index
9955 name "-\\/-no-xinit-opt"
9956
9957 \end_inset
9958
9959
9960 \series default
9961  Will not memcpy initialized data from code space into xdata space.
9962  This saves a few bytes in code space if you don't have initialized data
9963 \begin_inset LatexCommand index
9964 name "Variable initialization"
9965
9966 \end_inset
9967
9968 .
9969 \end_layout
9970
9971 \begin_layout List
9972 \labelwidthstring 00.00.0000
9973
9974 \series bold
9975 -
9976 \begin_inset ERT
9977 status collapsed
9978
9979 \begin_layout Standard
9980
9981
9982 \backslash
9983 /
9984 \end_layout
9985
9986 \end_inset
9987
9988 -nooverlay
9989 \begin_inset LatexCommand index
9990 name "-\\/-nooverlay"
9991
9992 \end_inset
9993
9994
9995 \series default
9996   The compiler will not overlay parameters and local variables of any function,
9997  see section Parameters and local variables for more details.
9998 \end_layout
9999
10000 \begin_layout List
10001 \labelwidthstring 00.00.0000
10002
10003 \series bold
10004 -
10005 \begin_inset ERT
10006 status collapsed
10007
10008 \begin_layout Standard
10009
10010
10011 \backslash
10012 /
10013 \end_layout
10014
10015 \end_inset
10016
10017 -no-peep
10018 \begin_inset LatexCommand index
10019 name "-\\/-no-peep"
10020
10021 \end_inset
10022
10023
10024 \series default
10025  Disable peep-hole optimization with built-in rules.
10026 \end_layout
10027
10028 \begin_layout List
10029 \labelwidthstring 00.00.0000
10030
10031 \series bold
10032 -
10033 \begin_inset ERT
10034 status collapsed
10035
10036 \begin_layout Standard
10037
10038
10039 \backslash
10040 /
10041 \end_layout
10042
10043 \end_inset
10044
10045 -peep-file
10046 \series default
10047
10048 \begin_inset LatexCommand index
10049 name "-\\/-peep-file"
10050
10051 \end_inset
10052
10053 \InsetSpace ~
10054 <filename> This option can be used to use additional rules to be used by
10055  the peep hole optimizer.
10056  See section 
10057 \begin_inset LatexCommand ref
10058 reference "sub:Peephole-Optimizer"
10059
10060 \end_inset
10061
10062 \InsetSpace ~
10063 Peep Hole optimizations for details on how to write these rules.
10064 \end_layout
10065
10066 \begin_layout List
10067 \labelwidthstring 00.00.0000
10068
10069 \series bold
10070 -
10071 \begin_inset ERT
10072 status collapsed
10073
10074 \begin_layout Standard
10075
10076
10077 \backslash
10078 /
10079 \end_layout
10080
10081 \end_inset
10082
10083 -peep-asm
10084 \begin_inset LatexCommand index
10085 name "-\\/-peep-asm"
10086
10087 \end_inset
10088
10089
10090 \series default
10091  Pass the inline assembler code through the peep hole optimizer.
10092  This can cause unexpected changes to inline assembler code, please go through
10093  the peephole optimizer
10094 \begin_inset LatexCommand index
10095 name "Peephole optimizer"
10096
10097 \end_inset
10098
10099  rules defined in the source file tree '<target>/peeph.def' before using
10100  this option.
10101 \end_layout
10102
10103 \begin_layout List
10104 \labelwidthstring 00.00.0000
10105
10106 \series bold
10107 -
10108 \begin_inset ERT
10109 status collapsed
10110
10111 \begin_layout Standard
10112
10113
10114 \backslash
10115 /
10116 \end_layout
10117
10118 \end_inset
10119
10120 -opt-code-speed
10121 \begin_inset LatexCommand index
10122 name "-\\/-opt-code-speed"
10123
10124 \end_inset
10125
10126
10127 \series default
10128  The compiler will optimize code generation towards fast code, possibly
10129  at the expense of code size.
10130 \end_layout
10131
10132 \begin_layout List
10133 \labelwidthstring 00.00.0000
10134
10135 \series bold
10136 -
10137 \begin_inset ERT
10138 status collapsed
10139
10140 \begin_layout Standard
10141
10142
10143 \backslash
10144 /
10145 \end_layout
10146
10147 \end_inset
10148
10149 -opt-code-size
10150 \begin_inset LatexCommand index
10151 name "-\\/-opt-code-size"
10152
10153 \end_inset
10154
10155
10156 \series default
10157  The compiler will optimize code generation towards compact code, possibly
10158  at the expense of code speed.
10159 \end_layout
10160
10161 \begin_layout Standard
10162 \begin_inset VSpace bigskip
10163 \end_inset
10164
10165
10166 \end_layout
10167
10168 \begin_layout Subsection
10169 Other Options
10170 \begin_inset LatexCommand index
10171 name "Options other"
10172
10173 \end_inset
10174
10175
10176 \end_layout
10177
10178 \begin_layout List
10179 \labelwidthstring 00.00.0000
10180
10181 \series bold
10182 -v\InsetSpace ~
10183 -
10184 \begin_inset ERT
10185 status collapsed
10186
10187 \begin_layout Standard
10188
10189
10190 \backslash
10191 /
10192 \end_layout
10193
10194 \end_inset
10195
10196 -version
10197 \begin_inset LatexCommand index
10198 name "-\\/-version"
10199
10200 \end_inset
10201
10202
10203 \begin_inset LatexCommand index
10204 name "-v"
10205
10206 \end_inset
10207
10208
10209 \series default
10210  displays the sdcc version.
10211 \end_layout
10212
10213 \begin_layout List
10214 \labelwidthstring 00.00.0000
10215
10216 \series bold
10217 -c\InsetSpace ~
10218 -
10219 \begin_inset ERT
10220 status collapsed
10221
10222 \begin_layout Standard
10223
10224
10225 \backslash
10226 /
10227 \end_layout
10228
10229 \end_inset
10230
10231 -compile-only
10232 \begin_inset LatexCommand index
10233 name "-\\/-compile-only"
10234
10235 \end_inset
10236
10237
10238 \begin_inset LatexCommand index
10239 name "-c"
10240
10241 \end_inset
10242
10243
10244 \series default
10245  will compile and assemble the source, but will not call the linkage editor.
10246 \end_layout
10247
10248 \begin_layout List
10249 \labelwidthstring 00.00.0000
10250
10251 \series bold
10252 -
10253 \series default
10254
10255 \begin_inset ERT
10256 status collapsed
10257
10258 \begin_layout Standard
10259
10260
10261 \backslash
10262 /
10263 \end_layout
10264
10265 \end_inset
10266
10267
10268 \series bold
10269 -c1mode
10270 \begin_inset LatexCommand index
10271 name "-\\/-c1mode"
10272
10273 \end_inset
10274
10275
10276 \series default
10277  reads the preprocessed source from standard input and compiles it.
10278  The file name for the assembler output must be specified using the -o option.
10279 \end_layout
10280
10281 \begin_layout List
10282 \labelwidthstring 00.00.0000
10283
10284 \series bold
10285 -E
10286 \begin_inset LatexCommand index
10287 name "-E"
10288
10289 \end_inset
10290
10291
10292 \series default
10293  Run only the C preprocessor.
10294  Preprocess all the C source files specified and output the results to standard
10295  output.
10296 \end_layout
10297
10298 \begin_layout List
10299 \labelwidthstring 00.00.0000
10300
10301 \series bold
10302 -o\InsetSpace ~
10303 <path/file>
10304 \begin_inset LatexCommand index
10305 name "-o <path/file>"
10306
10307 \end_inset
10308
10309
10310 \series default
10311  The output path where everything will be placed or the file name used for
10312  all generated output files.
10313  If the parameter is a path, it must have a trailing slash (or backslash
10314  for the Windows binaries) to be recognized as a path.
10315  Note for Windows users: if the path contains spaces, it should be surrounded
10316  by quotes.
10317  The trailing backslash should be doubled in order to prevent escaping the
10318  final quote, for example: 
10319 \emph on
10320 -o 
10321 \begin_inset Quotes sld
10322 \end_inset
10323
10324 F:
10325 \backslash
10326 Projects
10327 \backslash
10328 test3
10329 \backslash
10330 output 1
10331 \backslash
10332
10333 \backslash
10334
10335 \begin_inset Quotes srd
10336 \end_inset
10337
10338
10339 \emph default
10340  or put after the final quote, for example: 
10341 \emph on
10342 -o 
10343 \begin_inset Quotes sld
10344 \end_inset
10345
10346 F:
10347 \backslash
10348 Projects
10349 \backslash
10350 test3
10351 \backslash
10352 output 1
10353 \begin_inset Quotes srd
10354 \end_inset
10355
10356
10357 \backslash
10358
10359 \emph default
10360 .
10361  The path using slashes for directory delimiters can be used too, for example:
10362  
10363 \emph on
10364 -o 
10365 \begin_inset Quotes sld
10366 \end_inset
10367
10368 F:/Projects/test3/output 1/
10369 \begin_inset Quotes srd
10370 \end_inset
10371
10372
10373 \emph default
10374 .
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 -stack-auto
10395 \begin_inset LatexCommand index
10396 name "-\\/-stack-auto"
10397
10398 \end_inset
10399
10400
10401 \series default
10402 \size large
10403  
10404 \size default
10405 All functions in the source file will be compiled as 
10406 \emph on
10407 reentrant
10408 \emph default
10409
10410 \begin_inset LatexCommand index
10411 name "reentrant"
10412
10413 \end_inset
10414
10415 , i.e.
10416  the parameters and local variables will be allocated on the stack
10417 \begin_inset LatexCommand index
10418 name "stack"
10419
10420 \end_inset
10421
10422 .
10423  See section 
10424 \begin_inset LatexCommand ref
10425 reference "sec:Parameters-and-Local-Variables"
10426
10427 \end_inset
10428
10429  Parameters and Local Variables for more details.
10430  If this option is used all source files in the project should be compiled
10431  with this option.
10432  It automatically implies -
10433 \series bold
10434
10435 \begin_inset ERT
10436 status open
10437
10438 \begin_layout Standard
10439
10440
10441 \backslash
10442 /
10443 \end_layout
10444
10445 \end_inset
10446
10447
10448 \series default
10449 -int-long-reent and -
10450 \series bold
10451
10452 \begin_inset ERT
10453 status open
10454
10455 \begin_layout Standard
10456
10457
10458 \backslash
10459 /
10460 \end_layout
10461
10462 \end_inset
10463
10464
10465 \series default
10466 -float-reent.
10467  
10468 \end_layout
10469
10470 \begin_layout List
10471 \labelwidthstring 00.00.0000
10472
10473 \series bold
10474 -
10475 \begin_inset ERT
10476 status collapsed
10477
10478 \begin_layout Standard
10479
10480
10481 \backslash
10482 /
10483 \end_layout
10484
10485 \end_inset
10486
10487 -callee-saves
10488 \begin_inset LatexCommand index
10489 name "-\\/-callee-saves"
10490
10491 \end_inset
10492
10493  
10494 \begin_inset LatexCommand label
10495 name "lyx:--callee-saves-function1[,function2][,function3]..."
10496
10497 \end_inset
10498
10499 function1[,function2][,function3]....
10500
10501 \series default
10502  The compiler by default uses a caller saves convention for register saving
10503  across function calls, however this can cause unnecessary register pushing
10504  and popping when calling small functions from larger functions.
10505  This option can be used to switch the register saving convention for the
10506  function names specified.
10507  The compiler will not save registers when calling these functions, no extra
10508  code will be generated at the entry and exit (function prologue
10509 \series bold
10510
10511 \begin_inset LatexCommand index
10512 name "function prologue"
10513
10514 \end_inset
10515
10516
10517 \series default
10518  and epilogue
10519 \series bold
10520
10521 \begin_inset LatexCommand index
10522 name "function epilogue"
10523
10524 \end_inset
10525
10526
10527 \series default
10528 ) for these functions to save and restore the registers used by these functions,
10529  this can SUBSTANTIALLY reduce code and improve run time performance of
10530  the generated code.
10531  In the future the compiler (with inter procedural analysis) will be able
10532  to determine the appropriate scheme to use for each function call.
10533  DO NOT use this option for built-in functions such as _mulint..., if this
10534  option is used for a library function the appropriate library function
10535  needs to be recompiled with the same option.
10536  If the project consists of multiple source files then all the source file
10537  should be compiled with the same -
10538 \begin_inset ERT
10539 status collapsed
10540
10541 \begin_layout Standard
10542
10543
10544 \backslash
10545 /
10546 \end_layout
10547
10548 \end_inset
10549
10550 -callee-saves option string.
10551  Also see #pragma\InsetSpace ~
10552 callee_saves 
10553 \begin_inset LatexCommand index
10554 name "\\#pragma callee\\_saves"
10555
10556 \end_inset
10557
10558  
10559 \begin_inset LatexCommand vpageref
10560 reference "ite:callee_saves-function1[,function2[,function3...]]--"
10561
10562 \end_inset
10563
10564 .
10565 \end_layout
10566
10567 \begin_layout List
10568 \labelwidthstring 00.00.0000
10569
10570 \series bold
10571 -
10572 \begin_inset ERT
10573 status collapsed
10574
10575 \begin_layout Standard
10576
10577
10578 \backslash
10579 /
10580 \end_layout
10581
10582 \end_inset
10583
10584 -all-callee-saves
10585 \begin_inset LatexCommand index
10586 name "-\\/-all-callee-saves"
10587
10588 \end_inset
10589
10590
10591 \series default
10592  Function of -
10593 \begin_inset ERT
10594 status collapsed
10595
10596 \begin_layout Standard
10597
10598
10599 \backslash
10600 /
10601 \end_layout
10602
10603 \end_inset
10604
10605 -callee-saves will be applied to all functions by default.
10606 \end_layout
10607
10608 \begin_layout List
10609 \labelwidthstring 00.00.0000
10610
10611 \series bold
10612 -
10613 \begin_inset ERT
10614 status collapsed
10615
10616 \begin_layout Standard
10617
10618
10619 \backslash
10620 /
10621 \end_layout
10622
10623 \end_inset
10624
10625 -debug
10626 \begin_inset LatexCommand index
10627 name "-\\/-debug"
10628
10629 \end_inset
10630
10631  
10632 \series default
10633 When this option is used the compiler will generate debug information.
10634  The debug information collected in a file with .cdb extension can be used
10635  with the SDCDB.
10636  For more information see documentation for SDCDB.
10637  Another file with no extension contains debug information in AOMF or AOMF51
10638 \begin_inset LatexCommand index
10639 name "AOMF, AOMF51"
10640
10641 \end_inset
10642
10643  format which is commonly used by third party tools.
10644 \end_layout
10645
10646 \begin_layout List
10647 \labelwidthstring 00.00.0000
10648
10649 \series bold
10650 -S
10651 \begin_inset LatexCommand index
10652 name "-S"
10653
10654 \end_inset
10655
10656
10657 \series default
10658 \size large
10659  
10660 \size default
10661 Stop after the stage of compilation proper; do not assemble.
10662  The output is an assembler code file for the input file specified.
10663 \end_layout
10664
10665 \begin_layout List
10666 \labelwidthstring 00.00.0000
10667
10668 \series bold
10669 -
10670 \begin_inset ERT
10671 status collapsed
10672
10673 \begin_layout Standard
10674
10675
10676 \backslash
10677 /
10678 \end_layout
10679
10680 \end_inset
10681
10682 -int-long-reent
10683 \begin_inset LatexCommand index
10684 name "-\\/-int-long-reent"
10685
10686 \end_inset
10687
10688
10689 \series default
10690  Integer (16 bit) and long (32 bit) libraries have been compiled as reentrant.
10691  Note by default these libraries are compiled as non-reentrant.
10692  See section Installation for more details.
10693 \end_layout
10694
10695 \begin_layout List
10696 \labelwidthstring 00.00.0000
10697
10698 \series bold
10699 -
10700 \begin_inset ERT
10701 status collapsed
10702
10703 \begin_layout Standard
10704
10705
10706 \backslash
10707 /
10708 \end_layout
10709
10710 \end_inset
10711
10712 -cyclomatic
10713 \begin_inset LatexCommand index
10714 name "-\\/-cyclomatic"
10715
10716 \end_inset
10717
10718  
10719 \series default
10720 This option will cause the compiler to generate an information message for
10721  each function in the source file.
10722  The message contains some 
10723 \emph on
10724 important
10725 \emph default
10726  information about the function.
10727  The number of edges and nodes the compiler detected in the control flow
10728  graph of the function, and most importantly the 
10729 \emph on
10730 cyclomatic complexity
10731 \begin_inset LatexCommand index
10732 name "Cyclomatic complexity"
10733
10734 \end_inset
10735
10736
10737 \emph default
10738  see section on Cyclomatic Complexity for more details.
10739 \end_layout
10740
10741 \begin_layout List
10742 \labelwidthstring 00.00.0000
10743
10744 \series bold
10745 -
10746 \begin_inset ERT
10747 status collapsed
10748
10749 \begin_layout Standard
10750
10751
10752 \backslash
10753 /
10754 \end_layout
10755
10756 \end_inset
10757
10758 -float-reent
10759 \begin_inset LatexCommand index
10760 name "-\\/-float-reent"
10761
10762 \end_inset
10763
10764
10765 \series default
10766  Floating point library is compiled as reentrant
10767 \begin_inset LatexCommand index
10768 name "reentrant"
10769
10770 \end_inset
10771
10772 .
10773  See section Installation for more details.
10774 \end_layout
10775
10776 \begin_layout List
10777 \labelwidthstring 00.00.0000
10778
10779 \series bold
10780 -
10781 \begin_inset ERT
10782 status collapsed
10783
10784 \begin_layout Standard
10785
10786
10787 \backslash
10788 /
10789 \end_layout
10790
10791 \end_inset
10792
10793 -funsigned-char
10794 \begin_inset LatexCommand index
10795 name "-\\/-funsigned-char"
10796
10797 \end_inset
10798
10799
10800 \series default
10801  The default signedness for every type is 
10802 \family typewriter
10803 signed
10804 \family default
10805 .
10806  In some embedded environments the default signedness of 
10807 \family typewriter
10808 char
10809 \family default
10810  is 
10811 \family typewriter
10812 unsigned
10813 \family default
10814 .
10815  To set the signess for characters to unsigned, use the option -
10816 \series bold
10817
10818 \begin_inset ERT
10819 status open
10820
10821 \begin_layout Standard
10822
10823
10824 \backslash
10825 /
10826 \end_layout
10827
10828 \end_inset
10829
10830
10831 \series default
10832 -funsigned-char.
10833  If this option is set and no signedness keyword (unsigned/signed) is given,
10834  a char will be signed.
10835  All other types are unaffected.
10836 \end_layout
10837
10838 \begin_layout List
10839 \labelwidthstring 00.00.0000
10840
10841 \series bold
10842 -
10843 \begin_inset ERT
10844 status collapsed
10845
10846 \begin_layout Standard
10847
10848
10849 \backslash
10850 /
10851 \end_layout
10852
10853 \end_inset
10854
10855 -main-return
10856 \begin_inset LatexCommand index
10857 name "-\\/-main-return"
10858
10859 \end_inset
10860
10861
10862 \series default
10863  This option can be used if the code generated is called by a monitor program
10864  or if the main routine includes an endless loop.
10865  This option results in slightly smaller code and saves two bytes of stack
10866  space.
10867  The return from the 'main'
10868 \begin_inset LatexCommand index
10869 name "main return"
10870
10871 \end_inset
10872
10873  function will return to the function calling main.
10874  The default setting is to lock up i.e.
10875  generate a '
10876 \family typewriter
10877 sjmp .
10878 \family default
10879 '.
10880 \end_layout
10881
10882 \begin_layout List
10883 \labelwidthstring 00.00.0000
10884
10885 \series bold
10886 -
10887 \begin_inset ERT
10888 status collapsed
10889
10890 \begin_layout Standard
10891
10892
10893 \backslash
10894 /
10895 \end_layout
10896
10897 \end_inset
10898
10899 -nostdinc
10900 \begin_inset LatexCommand index
10901 name "-\\/-nostdinc"
10902
10903 \end_inset
10904
10905
10906 \series default
10907  This will prevent the compiler from passing on the default include path
10908  to the preprocessor.
10909 \end_layout
10910
10911 \begin_layout List
10912 \labelwidthstring 00.00.0000
10913
10914 \series bold
10915 -
10916 \begin_inset ERT
10917 status collapsed
10918
10919 \begin_layout Standard
10920
10921
10922 \backslash
10923 /
10924 \end_layout
10925
10926 \end_inset
10927
10928 -nostdlib
10929 \begin_inset LatexCommand index
10930 name "-\\/-nostdlib"
10931
10932 \end_inset
10933
10934
10935 \series default
10936  This will prevent the compiler from passing on the default library
10937 \begin_inset LatexCommand index
10938 name "Libraries"
10939
10940 \end_inset
10941
10942  path to the linker.
10943 \end_layout
10944
10945 \begin_layout List
10946 \labelwidthstring 00.00.0000
10947
10948 \series bold
10949 -
10950 \begin_inset ERT
10951 status collapsed
10952
10953 \begin_layout Standard
10954
10955
10956 \backslash
10957 /
10958 \end_layout
10959
10960 \end_inset
10961
10962 -verbose
10963 \begin_inset LatexCommand index
10964 name "-\\/-verbose"
10965
10966 \end_inset
10967
10968
10969 \series default
10970  Shows the various actions the compiler is performing.
10971 \end_layout
10972
10973 \begin_layout List
10974 \labelwidthstring 00.00.0000
10975
10976 \series bold
10977 -V
10978 \begin_inset LatexCommand index
10979 name "-V"
10980
10981 \end_inset
10982
10983
10984 \series default
10985  Shows the actual commands the compiler is executing.
10986 \end_layout
10987
10988 \begin_layout List
10989 \labelwidthstring 00.00.0000
10990
10991 \series bold
10992 -
10993 \begin_inset ERT
10994 status collapsed
10995
10996 \begin_layout Standard
10997
10998
10999 \backslash
11000 /
11001 \end_layout
11002
11003 \end_inset
11004
11005 -no-c-code-in-asm
11006 \begin_inset LatexCommand index
11007 name "-\\/-no-c-code-in-asm"
11008
11009 \end_inset
11010
11011
11012 \series default
11013  Hides your ugly and inefficient c-code from the asm file, so you can always
11014  blame the compiler :)
11015 \end_layout
11016
11017 \begin_layout List
11018 \labelwidthstring 00.00.0000
11019
11020 \series bold
11021 -
11022 \begin_inset ERT
11023 status collapsed
11024
11025 \begin_layout Standard
11026
11027
11028 \backslash
11029 /
11030 \end_layout
11031
11032 \end_inset
11033
11034 -fverbose-asm
11035 \begin_inset LatexCommand index
11036 name "-\\/-no-gen-comments"
11037
11038 \end_inset
11039
11040
11041 \series default
11042  Include code generator and peep-hole comments in the generated asm files.
11043 \end_layout
11044
11045 \begin_layout List
11046 \labelwidthstring 00.00.0000
11047
11048 \series bold
11049 -
11050 \begin_inset ERT
11051 status collapsed
11052
11053 \begin_layout Standard
11054
11055
11056 \backslash
11057 /
11058 \end_layout
11059
11060 \end_inset
11061
11062 -no-peep-comments
11063 \begin_inset LatexCommand index
11064 name "-\\/-no-peep-comments"
11065
11066 \end_inset
11067
11068
11069 \series default
11070  Don't include peep-hole comments in the generated asm files even if -
11071 \series bold
11072
11073 \begin_inset ERT
11074 status open
11075
11076 \begin_layout Standard
11077
11078
11079 \backslash
11080 /
11081 \end_layout
11082
11083 \end_inset
11084
11085
11086 \series default
11087 -fverbose-asm option is specified.
11088 \end_layout
11089
11090 \begin_layout List
11091 \labelwidthstring 00.00.0000
11092
11093 \series bold
11094 -
11095 \begin_inset ERT
11096 status collapsed
11097
11098 \begin_layout Standard
11099
11100
11101 \backslash
11102 /
11103 \end_layout
11104
11105 \end_inset
11106
11107 -i-code-in-asm
11108 \begin_inset LatexCommand index
11109 name "-\\/-i-code-in-asm"
11110
11111 \end_inset
11112
11113
11114 \series default
11115  Include i-codes in the asm file.
11116  Sounds like noise but is most helpful for debugging the compiler itself.
11117 \end_layout
11118
11119 \begin_layout List
11120 \labelwidthstring 00.00.0000
11121
11122 \series bold
11123 -
11124 \begin_inset ERT
11125 status collapsed
11126
11127 \begin_layout Standard
11128
11129
11130 \backslash
11131 /
11132 \end_layout
11133
11134 \end_inset
11135
11136 -less-pedantic
11137 \begin_inset LatexCommand index
11138 name "pedantic"
11139
11140 \end_inset
11141
11142
11143 \begin_inset LatexCommand index
11144 name "-\\/-less-pedantic"
11145
11146 \end_inset
11147
11148
11149 \series default
11150
11151 \begin_inset LatexCommand label
11152 name "lyx:--less-pedantic"
11153
11154 \end_inset
11155
11156  Disable some of the more pedantic warnings
11157 \begin_inset LatexCommand index
11158 name "Warnings"
11159
11160 \end_inset
11161
11162 .
11163  For more details, see the less_pedantic pragma 
11164 \begin_inset LatexCommand vpageref
11165 reference "ite:less_pedantic"
11166
11167 \end_inset
11168
11169 .
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 -disable-warning\InsetSpace ~
11190 <nnnn>
11191 \begin_inset LatexCommand index
11192 name "-\\/-disable-warning"
11193
11194 \end_inset
11195
11196
11197 \series default
11198  Disable specific warning with number <nnnn>.
11199 \end_layout
11200
11201 \begin_layout List
11202 \labelwidthstring 00.00.0000
11203
11204 \series bold
11205 -
11206 \begin_inset ERT
11207 status collapsed
11208
11209 \begin_layout Standard
11210
11211
11212 \backslash
11213 /
11214 \end_layout
11215
11216 \end_inset
11217
11218 -Werror
11219 \begin_inset LatexCommand index
11220 name "-\\/-Werror"
11221
11222 \end_inset
11223
11224
11225 \series default
11226  Treat all warnings as errors.
11227 \end_layout
11228
11229 \begin_layout List
11230 \labelwidthstring 00.00.0000
11231
11232 \series bold
11233 -
11234 \begin_inset ERT
11235 status collapsed
11236
11237 \begin_layout Standard
11238
11239
11240 \backslash
11241 /
11242 \end_layout
11243
11244 \end_inset
11245
11246 -print-search-dirs
11247 \begin_inset LatexCommand index
11248 name "-\\/-print-search-dirs"
11249
11250 \end_inset
11251
11252
11253 \series default
11254  Display the directories in the compiler's search path
11255 \end_layout
11256
11257 \begin_layout List
11258 \labelwidthstring 00.00.0000
11259
11260 \series bold
11261 -
11262 \begin_inset ERT
11263 status collapsed
11264
11265 \begin_layout Standard
11266
11267
11268 \backslash
11269 /
11270 \end_layout
11271
11272 \end_inset
11273
11274 -vc
11275 \begin_inset LatexCommand index
11276 name "-\\/-vc"
11277
11278 \end_inset
11279
11280
11281 \series default
11282  Display errors and warnings using MSVC style, so you can use SDCC with
11283  the visual studio IDE
11284 \begin_inset LatexCommand index
11285 name "IDE"
11286
11287 \end_inset
11288
11289 .
11290  With SDCC both offering a GCC-like (the default) and a MSVC-like
11291 \begin_inset LatexCommand index
11292 name "MSVC output style"
11293
11294 \end_inset
11295
11296  output style, integration into most programming editors should be straightforwa
11297 rd.
11298 \end_layout
11299
11300 \begin_layout List
11301 \labelwidthstring 00.00.0000
11302
11303 \series bold
11304 -
11305 \begin_inset ERT
11306 status collapsed
11307
11308 \begin_layout Standard
11309
11310
11311 \backslash
11312 /
11313 \end_layout
11314
11315 \end_inset
11316
11317 -use-stdout
11318 \begin_inset LatexCommand index
11319 name "-\\/-use-stdout"
11320
11321 \end_inset
11322
11323
11324 \series default
11325  Send errors and warnings to stdout instead of stderr.
11326 \end_layout
11327
11328 \begin_layout List
11329 \labelwidthstring 00.00.0000
11330
11331 \series bold
11332 -Wa\InsetSpace ~
11333 asmOption[,asmOption]
11334 \series default
11335
11336 \begin_inset LatexCommand index
11337 name "-Wa asmOption[,asmOption]"
11338
11339 \end_inset
11340
11341 ...
11342  Pass the asmOption to the assembler
11343 \begin_inset LatexCommand index
11344 name "Options assembler"
11345
11346 \end_inset
11347
11348
11349 \begin_inset LatexCommand index
11350 name "Assembler options"
11351
11352 \end_inset
11353
11354 .
11355  See file sdcc/as/doc/asxhtm.html for assembler options.cd
11356 \end_layout
11357
11358 \begin_layout List
11359 \labelwidthstring 00.00.0000
11360
11361 \series bold
11362 -
11363 \begin_inset ERT
11364 status collapsed
11365
11366 \begin_layout Standard
11367
11368
11369 \backslash
11370 /
11371 \end_layout
11372
11373 \end_inset
11374
11375 -std-sdcc89
11376 \begin_inset LatexCommand index
11377 name "-\\/-std-sdcc89"
11378
11379 \end_inset
11380
11381
11382 \series default
11383  Generally follow the C89 standard, but allow SDCC features that conflict
11384  with the standard (default).
11385 \end_layout
11386
11387 \begin_layout List
11388 \labelwidthstring 00.00.0000
11389
11390 \series bold
11391 -
11392 \begin_inset ERT
11393 status collapsed
11394
11395 \begin_layout Standard
11396
11397
11398 \backslash
11399 /
11400 \end_layout
11401
11402 \end_inset
11403
11404 -std-c89
11405 \begin_inset LatexCommand index
11406 name "-\\/-std-c89"
11407
11408 \end_inset
11409
11410
11411 \series default
11412  Follow the C89 standard and disable SDCC features that conflict with the
11413  standard.
11414 \end_layout
11415
11416 \begin_layout List
11417 \labelwidthstring 00.00.0000
11418
11419 \series bold
11420 -
11421 \begin_inset ERT
11422 status collapsed
11423
11424 \begin_layout Standard
11425
11426
11427 \backslash
11428 /
11429 \end_layout
11430
11431 \end_inset
11432
11433 -std-sdcc99
11434 \begin_inset LatexCommand index
11435 name "-\\/-std-sdcc99"
11436
11437 \end_inset
11438
11439
11440 \series default
11441  Generally follow the C99 standard, but allow SDCC features that conflict
11442  with the standard (incomplete support).
11443 \end_layout
11444
11445 \begin_layout List
11446 \labelwidthstring 00.00.0000
11447
11448 \series bold
11449 -
11450 \begin_inset ERT
11451 status collapsed
11452
11453 \begin_layout Standard
11454
11455
11456 \backslash
11457 /
11458 \end_layout
11459
11460 \end_inset
11461
11462 -std-c99
11463 \begin_inset LatexCommand index
11464 name "-\\/-std-sdcc99"
11465
11466 \end_inset
11467
11468
11469 \series default
11470  Follow the C99 standard and disable SDCC features that conflict with the
11471  standard (incomplete support).
11472 \end_layout
11473
11474 \begin_layout List
11475 \labelwidthstring 00.00.0000
11476
11477 \series bold
11478 -
11479 \begin_inset ERT
11480 status collapsed
11481
11482 \begin_layout Standard
11483
11484
11485 \backslash
11486 /
11487 \end_layout
11488
11489 \end_inset
11490
11491 -codeseg
11492 \series default
11493
11494 \begin_inset LatexCommand index
11495 name "-\\/-codeseg <Value>"
11496
11497 \end_inset
11498
11499
11500 \begin_inset LatexCommand label
11501 name "lyx:-codeseg"
11502
11503 \end_inset
11504
11505 \InsetSpace ~
11506 <Name> The name to be used for the code
11507 \begin_inset LatexCommand index
11508 name "code"
11509
11510 \end_inset
11511
11512  segment, default CSEG.
11513  This is useful if you need to tell the compiler to put the code in a special
11514  segment so you can later on tell the linker to put this segment in a special
11515  place in memory.
11516  Can be used for instance when using bank switching to put the code in a
11517  bank.
11518 \end_layout
11519
11520 \begin_layout List
11521 \labelwidthstring 00.00.0000
11522
11523 \series bold
11524 -
11525 \begin_inset ERT
11526 status collapsed
11527
11528 \begin_layout Standard
11529
11530
11531 \backslash
11532 /
11533 \end_layout
11534
11535 \end_inset
11536
11537 -constseg
11538 \series default
11539
11540 \begin_inset LatexCommand index
11541 name "-\\/-constseg <Value>"
11542
11543 \end_inset
11544
11545 \InsetSpace ~
11546 <Name> The name to be used for the const
11547 \begin_inset LatexCommand index
11548 name "const"
11549
11550 \end_inset
11551
11552  segment, default CONST.
11553  This is useful if you need to tell the compiler to put the const data in
11554  a special segment so you can later on tell the linker to put this segment
11555  in a special place in memory.
11556  Can be used for instance when using bank switching to put the const data
11557  in a bank.
11558 \end_layout
11559
11560 \begin_layout List
11561 \labelwidthstring 00.00.0000
11562
11563 \series bold
11564 -
11565 \begin_inset ERT
11566 status collapsed
11567
11568 \begin_layout Standard
11569
11570
11571 \backslash
11572 /
11573 \end_layout
11574
11575 \end_inset
11576
11577 -fdollars-in-identifiers
11578 \begin_inset LatexCommand index
11579 name "-\\/-fdollars-in-identifiers"
11580
11581 \end_inset
11582
11583
11584 \series default
11585  Permit '$' as an identifier character.
11586 \end_layout
11587
11588 \begin_layout List
11589 \labelwidthstring 00.00.0000
11590
11591 \series bold
11592 -
11593 \begin_inset ERT
11594 status collapsed
11595
11596 \begin_layout Standard
11597
11598
11599 \backslash
11600 /
11601 \end_layout
11602
11603 \end_inset
11604
11605 -more-pedantic
11606 \series default
11607
11608 \begin_inset LatexCommand index
11609 name "-\\/-more-pedantic"
11610
11611 \end_inset
11612
11613
11614 \begin_inset LatexCommand index
11615 name "pedantic"
11616
11617 \end_inset
11618
11619  Actually this is 
11620 \series bold
11621 \emph on
11622 not
11623 \series default
11624 \emph default
11625  a SDCC compiler option but if you want 
11626 \emph on
11627 more
11628 \emph default
11629  warnings you can use a separate tool dedicated to syntax checking like
11630  splint
11631 \begin_inset LatexCommand label
11632 name "lyx:more-pedantic-SPLINT"
11633
11634 \end_inset
11635
11636
11637 \begin_inset LatexCommand index
11638 name "lint (syntax checking tool)"
11639
11640 \end_inset
11641
11642  
11643 \begin_inset LatexCommand url
11644 target "http://www.splint.org"
11645
11646 \end_inset
11647
11648 .
11649  To make your source files parseable by splint you will have to include
11650  
11651 \family sans
11652 lint.h
11653 \family default
11654
11655 \begin_inset LatexCommand index
11656 name "splint (syntax checking tool)"
11657
11658 \end_inset
11659
11660  in your source file and add brackets around extended keywords (like 
11661 \family sans
11662
11663 \begin_inset Quotes sld
11664 \end_inset
11665
11666 __at\InsetSpace ~
11667
11668 \series bold
11669 (
11670 \series default
11671 0xab
11672 \series bold
11673 )
11674 \series default
11675
11676 \begin_inset Quotes srd
11677 \end_inset
11678
11679
11680 \family default
11681  and 
11682 \family sans
11683
11684 \begin_inset Quotes sld
11685 \end_inset
11686
11687 __interrupt\InsetSpace ~
11688 (2)
11689 \begin_inset Quotes srd
11690 \end_inset
11691
11692
11693 \family default
11694 ).
11695  
11696 \newline
11697 Splint has an excellent on line manual at 
11698 \begin_inset LatexCommand url
11699 target "http://www.splint.org/manual/"
11700
11701 \end_inset
11702
11703  and it's capabilities go beyond pure syntax checking.
11704  You'll need to tell splint the location of SDCC's include files so a typical
11705  command line could look like this: 
11706 \newline
11707
11708 \family sans
11709 splint\InsetSpace ~
11710 -I\InsetSpace ~
11711 /usr/local/share/sdcc/include/mcs51/\InsetSpace ~
11712 \InsetSpace ~
11713 myprogram.c
11714 \end_layout
11715
11716 \begin_layout List
11717 \labelwidthstring 00.00.0000
11718
11719 \series bold
11720 -
11721 \begin_inset ERT
11722 status collapsed
11723
11724 \begin_layout Standard
11725
11726
11727 \backslash
11728 /
11729 \end_layout
11730
11731 \end_inset
11732
11733 -short-is-8bits
11734 \series default
11735
11736 \begin_inset LatexCommand index
11737 name "-\\/-short-is-8bits"
11738
11739 \end_inset
11740
11741
11742 \begin_inset LatexCommand label
11743 name "lyx:--short-is-8bits"
11744
11745 \end_inset
11746
11747  Treat short as 8-bit (for backward compatibility with older versions of
11748  compiler - see section 
11749 \begin_inset LatexCommand ref
11750 reference "sec:Compatibility-with-previous"
11751
11752 \end_inset
11753
11754 )
11755 \end_layout
11756
11757 \begin_layout Standard
11758 \begin_inset VSpace bigskip
11759 \end_inset
11760
11761
11762 \end_layout
11763
11764 \begin_layout Subsection
11765 Intermediate Dump Options
11766 \begin_inset LatexCommand label
11767 name "sub:Intermediate-Dump-Options"
11768
11769 \end_inset
11770
11771
11772 \begin_inset LatexCommand index
11773 name "Options intermediate dump"
11774
11775 \end_inset
11776
11777
11778 \begin_inset LatexCommand index
11779 name "Intermediate dump options"
11780
11781 \end_inset
11782
11783
11784 \end_layout
11785
11786 \begin_layout Standard
11787 The following options are provided for the purpose of retargetting and debugging
11788  the compiler.
11789  They provide a means to dump the intermediate code (iCode
11790 \begin_inset LatexCommand index
11791 name "iCode"
11792
11793 \end_inset
11794
11795 ) generated by the compiler in human readable form at various stages of
11796  the compilation process.
11797  More on iCodes see chapter 
11798 \begin_inset LatexCommand ref
11799 reference "sub:The-anatomy-of"
11800
11801 \end_inset
11802
11803  
11804 \begin_inset Quotes srd
11805 \end_inset
11806
11807 The anatomy of the compiler
11808 \begin_inset Quotes srd
11809 \end_inset
11810
11811 .
11812 \end_layout
11813
11814 \begin_layout List
11815 \labelwidthstring 00.00.0000
11816
11817 \series bold
11818 -
11819 \begin_inset ERT
11820 status collapsed
11821
11822 \begin_layout Standard
11823
11824
11825 \backslash
11826 /
11827 \end_layout
11828
11829 \end_inset
11830
11831 -dumpraw
11832 \begin_inset LatexCommand index
11833 name "-\\/-dumpraw"
11834
11835 \end_inset
11836
11837
11838 \series default
11839  This option will cause the compiler to dump the intermediate code into
11840  a file of named 
11841 \emph on
11842 <source filename>.dumpraw
11843 \emph default
11844  just after the intermediate code has been generated for a function, i.e.
11845  before any optimizations are done.
11846  The basic blocks
11847 \begin_inset LatexCommand index
11848 name "Basic blocks"
11849
11850 \end_inset
11851
11852  at this stage ordered in the depth first number, so they may not be in
11853  sequence of execution.
11854 \end_layout
11855
11856 \begin_layout List
11857 \labelwidthstring 00.00.0000
11858
11859 \series bold
11860 -
11861 \begin_inset ERT
11862 status collapsed
11863
11864 \begin_layout Standard
11865
11866
11867 \backslash
11868 /
11869 \end_layout
11870
11871 \end_inset
11872
11873 -dumpgcse
11874 \begin_inset LatexCommand index
11875 name "-\\/-dumpgcse"
11876
11877 \end_inset
11878
11879
11880 \series default
11881  Will create a dump of iCodes, after global subexpression elimination
11882 \begin_inset LatexCommand index
11883 name "Global subexpression elimination"
11884
11885 \end_inset
11886
11887 , into a file named 
11888 \emph on
11889 <source filename>.dumpgcse.
11890 \end_layout
11891
11892 \begin_layout List
11893 \labelwidthstring 00.00.0000
11894
11895 \series bold
11896 -
11897 \begin_inset ERT
11898 status collapsed
11899
11900 \begin_layout Standard
11901
11902
11903 \backslash
11904 /
11905 \end_layout
11906
11907 \end_inset
11908
11909 -dumpdeadcode
11910 \begin_inset LatexCommand index
11911 name "-\\/-dumpdeadcode"
11912
11913 \end_inset
11914
11915
11916 \series default
11917  Will create a dump of iCodes, after deadcode elimination
11918 \begin_inset LatexCommand index
11919 name "Dead-code elimination"
11920
11921 \end_inset
11922
11923 , into a file named 
11924 \emph on
11925 <source filename>.dumpdeadcode.
11926 \end_layout
11927
11928 \begin_layout List
11929 \labelwidthstring 00.00.0000
11930
11931 \series bold
11932 -
11933 \begin_inset ERT
11934 status collapsed
11935
11936 \begin_layout Standard
11937
11938
11939 \backslash
11940 /
11941 \end_layout
11942
11943 \end_inset
11944
11945 -dumploop
11946 \begin_inset LatexCommand index
11947 name "-\\/-dumploop"
11948
11949 \end_inset
11950
11951
11952 \series default
11953 \size large
11954  
11955 \size default
11956 Will create a dump of iCodes, after loop optimizations
11957 \begin_inset LatexCommand index
11958 name "Loop optimization"
11959
11960 \end_inset
11961
11962 , into a file named 
11963 \emph on
11964 <source filename>.dumploop.
11965 \end_layout
11966
11967 \begin_layout List
11968 \labelwidthstring 00.00.0000
11969
11970 \series bold
11971 -
11972 \begin_inset ERT
11973 status collapsed
11974
11975 \begin_layout Standard
11976
11977
11978 \backslash
11979 /
11980 \end_layout
11981
11982 \end_inset
11983
11984 -dumprange
11985 \begin_inset LatexCommand index
11986 name "-\\/-dumprange"
11987
11988 \end_inset
11989
11990
11991 \series default
11992 \size large
11993  
11994 \size default
11995 Will create a dump of iCodes, after live range analysis
11996 \begin_inset LatexCommand index
11997 name "Live range analysis"
11998
11999 \end_inset
12000
12001 , into a file named 
12002 \emph on
12003 <source filename>.dumprange.
12004 \end_layout
12005
12006 \begin_layout List
12007 \labelwidthstring 00.00.0000
12008
12009 \series bold
12010 -
12011 \begin_inset ERT
12012 status collapsed
12013
12014 \begin_layout Standard
12015
12016
12017 \backslash
12018 /
12019 \end_layout
12020
12021 \end_inset
12022
12023 -dumlrange
12024 \begin_inset LatexCommand index
12025 name "-\\/-dumlrange"
12026
12027 \end_inset
12028
12029
12030 \series default
12031  Will dump the life ranges
12032 \begin_inset LatexCommand index
12033 name "Live range analysis"
12034
12035 \end_inset
12036
12037  for all symbols.
12038 \end_layout
12039
12040 \begin_layout List
12041 \labelwidthstring 00.00.0000
12042
12043 \series bold
12044 -
12045 \begin_inset ERT
12046 status collapsed
12047
12048 \begin_layout Standard
12049
12050
12051 \backslash
12052 /
12053 \end_layout
12054
12055 \end_inset
12056
12057 -dumpregassign
12058 \begin_inset LatexCommand index
12059 name "-\\/-dumpregassign"
12060
12061 \end_inset
12062
12063  
12064 \series default
12065 Will create a dump of iCodes, after register assignment
12066 \begin_inset LatexCommand index
12067 name "Register assignment"
12068
12069 \end_inset
12070
12071 , into a file named 
12072 \emph on
12073 <source filename>.dumprassgn.
12074 \end_layout
12075
12076 \begin_layout List
12077 \labelwidthstring 00.00.0000
12078
12079 \series bold
12080 -
12081 \begin_inset ERT
12082 status collapsed
12083
12084 \begin_layout Standard
12085
12086
12087 \backslash
12088 /
12089 \end_layout
12090
12091 \end_inset
12092
12093 -dumplrange
12094 \begin_inset LatexCommand index
12095 name "-\\/-dumplrange"
12096
12097 \end_inset
12098
12099
12100 \series default
12101  Will create a dump of the live ranges of iTemp's
12102 \end_layout
12103
12104 \begin_layout List
12105 \labelwidthstring 00.00.0000
12106
12107 \series bold
12108 -
12109 \begin_inset ERT
12110 status collapsed
12111
12112 \begin_layout Standard
12113
12114
12115 \backslash
12116 /
12117 \end_layout
12118
12119 \end_inset
12120
12121 -dumpall
12122 \begin_inset LatexCommand index
12123 name "-\\/-dumpall"
12124
12125 \end_inset
12126
12127
12128 \size large
12129  
12130 \series default
12131 \size default
12132 Will cause all the above mentioned dumps to be created.
12133 \end_layout
12134
12135 \begin_layout Standard
12136 \begin_inset VSpace bigskip
12137 \end_inset
12138
12139
12140 \end_layout
12141
12142 \begin_layout Subsection
12143 Redirecting output on Windows Shells
12144 \end_layout
12145
12146 \begin_layout Standard
12147 By default SDCC writes its error messages to 
12148 \begin_inset Quotes sld
12149 \end_inset
12150
12151 standard error
12152 \begin_inset Quotes srd
12153 \end_inset
12154
12155 .
12156  To force all messages to 
12157 \begin_inset Quotes sld
12158 \end_inset
12159
12160 standard output
12161 \begin_inset Quotes srd
12162 \end_inset
12163
12164  use 
12165 \series bold
12166 -
12167 \series default
12168 \emph on
12169
12170 \begin_inset ERT
12171 status collapsed
12172
12173 \begin_layout Standard
12174
12175
12176 \backslash
12177 /
12178 \end_layout
12179
12180 \end_inset
12181
12182
12183 \series bold
12184 \emph default
12185 -
12186 \series default
12187 use-stdout
12188 \begin_inset LatexCommand index
12189 name "-\\/-use-stdout"
12190
12191 \end_inset
12192
12193 .
12194  Additionally, if you happen to have visual studio installed in your windows
12195  machine, you can use it to compile your sources using a custom build and
12196  the SDCC -
12197 \emph on
12198
12199 \begin_inset ERT
12200 status collapsed
12201
12202 \begin_layout Standard
12203
12204
12205 \backslash
12206 /
12207 \end_layout
12208
12209 \end_inset
12210
12211
12212 \emph default
12213 -vc
12214 \begin_inset LatexCommand index
12215 name "-\\/-vc"
12216
12217 \end_inset
12218
12219  option.
12220  Something like this should work:
12221 \newline
12222
12223 \newline
12224
12225 \series bold
12226 c:
12227 \backslash
12228 sdcc
12229 \backslash
12230 bin
12231 \backslash
12232 sdcc.exe -
12233 \series default
12234 \emph on
12235
12236 \begin_inset ERT
12237 status collapsed
12238
12239 \begin_layout Standard
12240
12241
12242 \backslash
12243 /
12244 \end_layout
12245
12246 \end_inset
12247
12248
12249 \series bold
12250 \emph default
12251 -vc -
12252 \series default
12253 \emph on
12254
12255 \begin_inset ERT
12256 status collapsed
12257
12258 \begin_layout Standard
12259
12260
12261 \backslash
12262 /
12263 \end_layout
12264
12265 \end_inset
12266
12267
12268 \series bold
12269 \emph default
12270 -model-large -c $(InputPath)
12271 \series default
12272
12273 \begin_inset VSpace bigskip
12274 \end_inset
12275
12276
12277 \end_layout
12278
12279 \begin_layout Section
12280 Environment variables
12281 \begin_inset LatexCommand index
12282 name "Environment variables"
12283
12284 \end_inset
12285
12286
12287 \end_layout
12288
12289 \begin_layout Standard
12290 SDCC recognizes the following environment variables:
12291 \end_layout
12292
12293 \begin_layout List
12294 \labelwidthstring 00.00.0000
12295
12296 \series bold
12297 SDCC_LEAVE_SIGNALS
12298 \begin_inset LatexCommand index
12299 name "SDCC\\_LEAVE\\_SIGNALS"
12300
12301 \end_inset
12302
12303
12304 \series default
12305  SDCC installs a signal handler
12306 \begin_inset LatexCommand index
12307 name "signal handler"
12308
12309 \end_inset
12310
12311  to be able to delete temporary files after an user break (^C) or an exception.
12312  If this environment variable is set, SDCC won't install the signal handler
12313  in order to be able to debug SDCC.
12314 \end_layout
12315
12316 \begin_layout List
12317 \labelwidthstring 00.00.0000
12318
12319 \series bold
12320 TMP,\InsetSpace ~
12321 TEMP,\InsetSpace ~
12322 TMPDIR
12323 \begin_inset LatexCommand index
12324 name "TMP, TEMP, TMPDIR"
12325
12326 \end_inset
12327
12328
12329 \series default
12330  Path, where temporary files will be created.
12331  The order of the variables is the search order.
12332  In a standard *nix environment these variables are not set, and there's
12333  no need to set them.
12334  On Windows it's recommended to set one of them.
12335 \end_layout
12336
12337 \begin_layout List
12338 \labelwidthstring 00.00.0000
12339
12340 \series bold
12341 SDCC_HOME
12342 \begin_inset LatexCommand index
12343 name "SDCC\\_HOME"
12344
12345 \end_inset
12346
12347
12348 \series default
12349  Path, see section 
12350 \begin_inset LatexCommand ref
12351 reference "sub:Install-paths"
12352
12353 \end_inset
12354
12355 \InsetSpace ~
12356
12357 \begin_inset Quotes sld
12358 \end_inset
12359
12360  Install Paths
12361 \begin_inset Quotes srd
12362 \end_inset
12363
12364 .
12365 \end_layout
12366
12367 \begin_layout List
12368 \labelwidthstring 00.00.0000
12369
12370 \series bold
12371 SDCC_INCLUDE
12372 \begin_inset LatexCommand index
12373 name "SDCC\\_INCLUDE"
12374
12375 \end_inset
12376
12377
12378 \series default
12379  Path, see section 
12380 \begin_inset LatexCommand ref
12381 reference "sub:Search-Paths"
12382
12383 \end_inset
12384
12385 \InsetSpace ~
12386
12387 \begin_inset Quotes sld
12388 \end_inset
12389
12390 Search Paths
12391 \begin_inset Quotes srd
12392 \end_inset
12393
12394 .
12395 \end_layout
12396
12397 \begin_layout List
12398 \labelwidthstring 00.00.0000
12399
12400 \series bold
12401 SDCC_LIB
12402 \begin_inset LatexCommand index
12403 name "SDCC\\_LIB"
12404
12405 \end_inset
12406
12407
12408 \series default
12409  Path, see section 
12410 \begin_inset LatexCommand ref
12411 reference "sub:Search-Paths"
12412
12413 \end_inset
12414
12415 \InsetSpace ~
12416
12417 \begin_inset Quotes sld
12418 \end_inset
12419
12420 Search Paths
12421 \begin_inset Quotes srd
12422 \end_inset
12423
12424 ..
12425 \end_layout
12426
12427 \begin_layout Standard
12428 There are some more environment variables recognized by SDCC, but these
12429  are solely used for debugging purposes.
12430  They can change or disappear very quickly, and will never be documented.
12431 \begin_inset VSpace bigskip
12432 \end_inset
12433
12434
12435 \end_layout
12436
12437 \begin_layout Section
12438 Storage Class Language Extensions
12439 \end_layout
12440
12441 \begin_layout Subsection
12442 MCS51/DS390 Storage Class
12443 \begin_inset LatexCommand index
12444 name "Storage class"
12445
12446 \end_inset
12447
12448  Language Extensions
12449 \end_layout
12450
12451 \begin_layout Standard
12452 In addition to the ANSI storage classes SDCC allows the following MCS51
12453  specific storage classes:
12454 \end_layout
12455
12456 \begin_layout Subsubsection
12457 data
12458 \begin_inset LatexCommand index
12459 name "data (mcs51, ds390 storage class)"
12460
12461 \end_inset
12462
12463
12464 \begin_inset LatexCommand index
12465 name "\\_\\_data (mcs51, ds390 storage class)"
12466
12467 \end_inset
12468
12469  / near
12470 \begin_inset LatexCommand index
12471 name "near (storage class)"
12472
12473 \end_inset
12474
12475
12476 \begin_inset LatexCommand index
12477 name "\\_\\_near (storage class)"
12478
12479 \end_inset
12480
12481
12482 \end_layout
12483
12484 \begin_layout Standard
12485 This is the 
12486 \series bold
12487 default
12488 \series default
12489  storage class for the Small Memory model (
12490 \emph on
12491 data
12492 \emph default
12493  and 
12494 \emph on
12495 near
12496 \emph default
12497  or the more ANSI-C compliant forms 
12498 \emph on
12499 __data
12500 \emph default
12501  and 
12502 \emph on
12503 __near
12504 \emph default
12505  can be used synonymously).
12506  Variables declared with this storage class will be allocated in the directly
12507  addressable portion of the internal RAM of a 8051, e.g.:
12508 \end_layout
12509
12510 \begin_layout Verse
12511
12512 \family typewriter
12513 __data unsigned char test_data;
12514 \end_layout
12515
12516 \begin_layout Standard
12517 Writing 0x01 to this variable generates the assembly code:
12518 \end_layout
12519
12520 \begin_layout Verse
12521
12522 \family typewriter
12523 75*00 01\InsetSpace ~
12524 \InsetSpace ~
12525 \InsetSpace ~
12526 mov\InsetSpace ~
12527 \InsetSpace ~
12528 _test_data,#0x01
12529 \end_layout
12530
12531 \begin_layout Subsubsection
12532 xdata
12533 \begin_inset LatexCommand index
12534 name "xdata (mcs51, ds390 storage class)"
12535
12536 \end_inset
12537
12538
12539 \begin_inset LatexCommand index
12540 name "\\_\\_xdata (mcs51, ds390 storage class)"
12541
12542 \end_inset
12543
12544  / far
12545 \begin_inset LatexCommand index
12546 name "far (storage class)"
12547
12548 \end_inset
12549
12550
12551 \begin_inset LatexCommand index
12552 name "\\_\\_far (storage class)"
12553
12554 \end_inset
12555
12556
12557 \end_layout
12558
12559 \begin_layout Standard
12560 Variables declared with this storage class will be placed in the external
12561  RAM.
12562  This is the 
12563 \series bold
12564 default
12565 \series default
12566  storage class for the Large Memory model, e.g.:
12567 \end_layout
12568
12569 \begin_layout Verse
12570
12571 \family typewriter
12572 __xdata unsigned char test_xdata;
12573 \end_layout
12574
12575 \begin_layout Standard
12576 Writing 0x01 to this variable generates the assembly code:
12577 \end_layout
12578
12579 \begin_layout Verse
12580
12581 \family typewriter
12582 90s00r00\InsetSpace ~
12583 \InsetSpace ~
12584 \InsetSpace ~
12585 mov\InsetSpace ~
12586 \InsetSpace ~
12587 dptr,#_test_xdata 
12588 \newline
12589 74\InsetSpace ~
12590 01\InsetSpace ~
12591 \InsetSpace ~
12592 \InsetSpace ~
12593 \InsetSpace ~
12594 \InsetSpace ~
12595 \InsetSpace ~
12596 mov\InsetSpace ~
12597 \InsetSpace ~
12598 a,#0x01 
12599 \newline
12600 F0\InsetSpace ~
12601 \InsetSpace ~
12602 \InsetSpace ~
12603 \InsetSpace ~
12604 \InsetSpace ~
12605 \InsetSpace ~
12606 \InsetSpace ~
12607 \InsetSpace ~
12608 \InsetSpace ~
12609 movx\InsetSpace ~
12610 @dptr,a 
12611 \end_layout
12612
12613 \begin_layout Subsubsection
12614 idata
12615 \begin_inset LatexCommand index
12616 name "idata (mcs51, ds390 storage class)"
12617
12618 \end_inset
12619
12620
12621 \begin_inset LatexCommand index
12622 name "\\_\\_idata (mcs51, ds390 storage class)"
12623
12624 \end_inset
12625
12626
12627 \end_layout
12628
12629 \begin_layout Standard
12630 Variables declared with this storage class will be allocated into the indirectly
12631  addressable portion of the internal ram of a 8051, e.g.:
12632 \end_layout
12633
12634 \begin_layout Verse
12635
12636 \family typewriter
12637 __idata unsigned char test_idata;
12638 \end_layout
12639
12640 \begin_layout Standard
12641 Writing 0x01 to this variable generates the assembly code:
12642 \end_layout
12643
12644 \begin_layout Verse
12645
12646 \family typewriter
12647 78r00\InsetSpace ~
12648 \InsetSpace ~
12649 \InsetSpace ~
12650 \InsetSpace ~
12651 \InsetSpace ~
12652 \InsetSpace ~
12653 \InsetSpace ~
12654 mov\InsetSpace ~
12655 \InsetSpace ~
12656 r0,#_test_idata
12657 \newline
12658 76\InsetSpace ~
12659 01\InsetSpace ~
12660 \InsetSpace ~
12661 \InsetSpace ~
12662 \InsetSpace ~
12663 \InsetSpace ~
12664 \InsetSpace ~
12665 \InsetSpace ~
12666 mov\InsetSpace ~
12667 \InsetSpace ~
12668 @r0,#0x01
12669 \end_layout
12670
12671 \begin_layout Standard
12672 Please note, the first 128 byte of idata physically access the same RAM
12673  as the data memory.
12674  The original 8051 had 128 byte idata memory, nowadays most devices have
12675  256 byte idata memory.
12676  The stack
12677 \begin_inset LatexCommand index
12678 name "stack"
12679
12680 \end_inset
12681
12682  is located in idata memory.
12683 \end_layout
12684
12685 \begin_layout Subsubsection
12686 pdata
12687 \begin_inset LatexCommand index
12688 name "pdata (mcs51, ds390 storage class)"
12689
12690 \end_inset
12691
12692
12693 \begin_inset LatexCommand index
12694 name "\\_\\_pdata (mcs51, ds390 storage class)"
12695
12696 \end_inset
12697
12698
12699 \end_layout
12700
12701 \begin_layout Standard
12702 Paged xdata access is just as straightforward as using the other addressing
12703  modes of a 8051.
12704  It is typically located at the start of xdata and has a maximum size of
12705  256 bytes.
12706  The following example writes 0x01 to the pdata variable.
12707  Please note, pdata access physically accesses xdata memory.
12708  The high byte of the address is determined by port P2 
12709 \begin_inset LatexCommand index
12710 name "P2 (mcs51 sfr)"
12711
12712 \end_inset
12713
12714 (or in case of some 8051 variants by a separate Special Function Register,
12715  see section 
12716 \begin_inset LatexCommand ref
12717 reference "sub:MCS51-variants"
12718
12719 \end_inset
12720
12721 ).
12722  This is the 
12723 \series bold
12724 default
12725 \series default
12726  storage class for the Medium Memory model, e.g.:
12727 \end_layout
12728
12729 \begin_layout Verse
12730
12731 \family typewriter
12732 __pdata unsigned char test_pdata;
12733 \end_layout
12734
12735 \begin_layout Standard
12736 Writing 0x01 to this variable generates the assembly code:
12737 \end_layout
12738
12739 \begin_layout Verse
12740
12741 \family typewriter
12742 78r00\InsetSpace ~
12743 \InsetSpace ~
12744 \InsetSpace ~
12745 \InsetSpace ~
12746 \InsetSpace ~
12747 \InsetSpace ~
12748 mov r0,#_test_pdata
12749 \newline
12750 74 01\InsetSpace ~
12751 \InsetSpace ~
12752 \InsetSpace ~
12753 \InsetSpace ~
12754 \InsetSpace ~
12755 \InsetSpace ~
12756 mov a,#0x01 
12757 \newline
12758 F2\InsetSpace ~
12759 \InsetSpace ~
12760 \InsetSpace ~
12761 \InsetSpace ~
12762 \InsetSpace ~
12763 \InsetSpace ~
12764 \InsetSpace ~
12765 \InsetSpace ~
12766 \InsetSpace ~
12767 movx @r0,a
12768 \end_layout
12769
12770 \begin_layout Standard
12771 If the -
12772 \begin_inset ERT
12773 status collapsed
12774
12775 \begin_layout Standard
12776
12777
12778 \backslash
12779 /
12780 \end_layout
12781
12782 \end_inset
12783
12784 -xstack
12785 \begin_inset LatexCommand index
12786 name "-\\/-xstack"
12787
12788 \end_inset
12789
12790  option is used the pdata memory area is followed by the xstack memory area
12791  and the sum of their sizes is limited to 256 bytes.
12792 \end_layout
12793
12794 \begin_layout Subsubsection
12795 code
12796 \begin_inset LatexCommand index
12797 name "code"
12798
12799 \end_inset
12800
12801
12802 \begin_inset LatexCommand index
12803 name "\\_\\_code"
12804
12805 \end_inset
12806
12807
12808 \end_layout
12809
12810 \begin_layout Standard
12811 'Variables' declared with this storage class will be placed in the code
12812  memory:
12813 \end_layout
12814
12815 \begin_layout Verse
12816
12817 \family typewriter
12818 __code unsigned char test_code;
12819 \end_layout
12820
12821 \begin_layout Standard
12822 Read access to this variable generates the assembly code:
12823 \end_layout
12824
12825 \begin_layout Verse
12826
12827 \family typewriter
12828 90s00r6F\InsetSpace ~
12829 \InsetSpace ~
12830 \InsetSpace ~
12831 mov dptr,#_test_code
12832 \newline
12833 E4\InsetSpace ~
12834 \InsetSpace ~
12835 \InsetSpace ~
12836 \InsetSpace ~
12837 \InsetSpace ~
12838 \InsetSpace ~
12839 \InsetSpace ~
12840 \InsetSpace ~
12841 \InsetSpace ~
12842 clr a
12843 \newline
12844 93\InsetSpace ~
12845 \InsetSpace ~
12846 \InsetSpace ~
12847 \InsetSpace ~
12848 \InsetSpace ~
12849 \InsetSpace ~
12850 \InsetSpace ~
12851 \InsetSpace ~
12852 \InsetSpace ~
12853 movc a,@a+dptr 
12854 \end_layout
12855
12856 \begin_layout Standard
12857
12858 \family typewriter
12859 char
12860 \family default
12861  indexed arrays of characters in code memory can be accessed efficiently:
12862 \end_layout
12863
12864 \begin_layout Verse
12865
12866 \family typewriter
12867 __code char test_array[] = {'c','h','e','a','p'}; 
12868 \end_layout
12869
12870 \begin_layout Standard
12871 Read access to this array using an 8-bit unsigned index generates the assembly
12872  code:
12873 \end_layout
12874
12875 \begin_layout Verse
12876
12877 \family typewriter
12878 E5*00\InsetSpace ~
12879 \InsetSpace ~
12880 \InsetSpace ~
12881 \InsetSpace ~
12882 \InsetSpace ~
12883 \InsetSpace ~
12884 mov a,_index 
12885 \end_layout
12886
12887 \begin_layout Verse
12888
12889 \family typewriter
12890 90s00r41\InsetSpace ~
12891 \InsetSpace ~
12892 \InsetSpace ~
12893 mov dptr,#_test_array
12894 \end_layout
12895
12896 \begin_layout Verse
12897
12898 \family typewriter
12899 93\InsetSpace ~
12900 \InsetSpace ~
12901 \InsetSpace ~
12902 \InsetSpace ~
12903 \InsetSpace ~
12904 \InsetSpace ~
12905 \InsetSpace ~
12906 \InsetSpace ~
12907 \InsetSpace ~
12908 movc a,@a+dptr 
12909 \end_layout
12910
12911 \begin_layout Subsubsection
12912 bit
12913 \begin_inset LatexCommand index
12914 name "bit"
12915
12916 \end_inset
12917
12918
12919 \begin_inset LatexCommand index
12920 name "\\_\\_bit"
12921
12922 \end_inset
12923
12924
12925 \end_layout
12926
12927 \begin_layout Standard
12928 This is a data-type and a storage class specifier.
12929  When a variable is declared as a bit, it is allocated into the bit addressable
12930  memory of 8051, e.g.:
12931 \end_layout
12932
12933 \begin_layout Verse
12934
12935 \family typewriter
12936 __bit test_bit;
12937 \end_layout
12938
12939 \begin_layout Standard
12940 Writing 1 to this variable generates the assembly code:
12941 \end_layout
12942
12943 \begin_layout Verse
12944
12945 \family typewriter
12946 D2*00\InsetSpace ~
12947 \InsetSpace ~
12948 \InsetSpace ~
12949 \InsetSpace ~
12950 \InsetSpace ~
12951 \InsetSpace ~
12952 \InsetSpace ~
12953 setb\InsetSpace ~
12954 _test_bit
12955 \end_layout
12956
12957 \begin_layout Standard
12958 The bit addressable memory consists of 128 bits which are located from 0x20
12959  to 0x2f in data memory.
12960  
12961 \newline
12962 Apart from this 8051 specific storage class most architectures support
12963  ANSI-C bitfields
12964 \begin_inset LatexCommand index
12965 name "bitfields"
12966
12967 \end_inset
12968
12969
12970 \begin_inset Foot
12971 status open
12972
12973 \begin_layout Standard
12974 Not really meant as examples, but nevertheless showing what bitfields are
12975  about: device/include/mc68hc908qy.h and support/regression/tests/bitfields.c
12976 \end_layout
12977
12978 \end_inset
12979
12980 .
12981  In accordance with ISO/IEC 9899 bits and bitfields without an explicit
12982  signed modifier are implemented as unsigned.
12983 \end_layout
12984
12985 \begin_layout Subsubsection
12986 sfr
12987 \begin_inset LatexCommand index
12988 name "sfr"
12989
12990 \end_inset
12991
12992
12993 \begin_inset LatexCommand index
12994 name "\\_\\_sfr"
12995
12996 \end_inset
12997
12998  / sfr16
12999 \begin_inset LatexCommand index
13000 name "sfr16"
13001
13002 \end_inset
13003
13004
13005 \begin_inset LatexCommand index
13006 name "\\_\\_sfr16"
13007
13008 \end_inset
13009
13010  / sfr32
13011 \begin_inset LatexCommand index
13012 name "sfr32"
13013
13014 \end_inset
13015
13016
13017 \begin_inset LatexCommand index
13018 name "\\_\\_sfr32"
13019
13020 \end_inset
13021
13022  / sbit
13023 \begin_inset LatexCommand index
13024 name "\\_\\_sbit"
13025
13026 \end_inset
13027
13028
13029 \begin_inset LatexCommand index
13030 name "sbit"
13031
13032 \end_inset
13033
13034
13035 \end_layout
13036
13037 \begin_layout Standard
13038 Like the bit keyword, 
13039 \emph on
13040 sfr / sfr16 / sfr32 / sbit
13041 \emph default
13042  signify both a data-type and storage class, they are used to describe the
13043  
13044 \emph on
13045 s
13046 \emph default
13047 pecial 
13048 \emph on
13049 f
13050 \emph default
13051 unction 
13052 \emph on
13053 r
13054 \emph default
13055 egisters and 
13056 \emph on
13057 s
13058 \emph default
13059 pecial 
13060 \emph on
13061 bit
13062 \emph default
13063  variables of a 8051, eg:
13064 \end_layout
13065
13066 \begin_layout Verse
13067
13068 \family typewriter
13069 __sfr __at
13070 \begin_inset LatexCommand index
13071 name "at"
13072
13073 \end_inset
13074
13075
13076 \begin_inset LatexCommand index
13077 name "\\_\\_at"
13078
13079 \end_inset
13080
13081  (0x80) P0;\InsetSpace ~
13082  /* special function register P0 at location 0x80 */
13083 \newline
13084
13085 \newline
13086 /* 16 bit
13087  special function register combination for timer 0
13088 \newline
13089 \InsetSpace ~
13090 \InsetSpace ~
13091  with the high byte at
13092  location 0x8C and the low byte at location 0x8A */
13093 \newline
13094 __sfr16 __at (0x8C8A)
13095  TMR0;
13096 \newline
13097
13098 \newline
13099 __sbit __at
13100 \begin_inset LatexCommand index
13101 name "at"
13102
13103 \end_inset
13104
13105
13106 \begin_inset LatexCommand index
13107 name "\\_\\_at"
13108
13109 \end_inset
13110
13111  (0xd7) CY;\InsetSpace ~
13112  /* CY (Carry Flag
13113 \begin_inset LatexCommand index
13114 name "Flags"
13115
13116 \end_inset
13117
13118
13119 \begin_inset LatexCommand index
13120 name "Carry flag"
13121
13122 \end_inset
13123
13124 ) */
13125 \end_layout
13126
13127 \begin_layout Standard
13128 Special function registers which are located on an address dividable by
13129  8 are bit-addressable, an 
13130 \emph on
13131 sbit
13132 \emph default
13133  addresses a specific bit within these sfr.
13134 \newline
13135 16 Bit and 32 bit special function
13136  register combinations which require a certain access order are better not
13137  declared using 
13138 \emph on
13139 sfr16
13140 \emph default
13141  or 
13142 \emph on
13143 sfr32.
13144
13145 \emph default
13146  Allthough SDCC usually accesses them Least Significant Byte (LSB) first,
13147  this is not guaranteed.
13148 \newline
13149
13150 \end_layout
13151
13152 \begin_layout Standard
13153 Please note, if you use a header file which was written for another compiler
13154  then the sfr / sfr16 / sfr32 / sbit Storage Class extensions will most
13155  likely be 
13156 \emph on
13157 not
13158 \emph default
13159  compatible.
13160  Specifically the syntax 
13161 \family typewriter
13162 \InsetSpace ~
13163 sfr P0 = 0x80;\InsetSpace ~
13164
13165 \family default
13166  is compiled 
13167 \emph on
13168 without warning
13169 \emph default
13170  by SDCC to an assignment of 0x80 to a variable called P0 
13171 \family typewriter
13172
13173 \begin_inset Marginal
13174 status collapsed
13175
13176 \begin_layout Standard
13177
13178 \series bold
13179 \InsetSpace ~
13180 !
13181 \end_layout
13182
13183 \end_inset
13184
13185 .
13186
13187 \family default
13188  
13189 \series bold
13190 Nevertheless it is possible to write header files
13191 \begin_inset LatexCommand index
13192 name "Header files"
13193
13194 \end_inset
13195
13196
13197 \begin_inset LatexCommand index
13198 name "Include files"
13199
13200 \end_inset
13201
13202  which can be shared among different compilers (see section 
13203 \begin_inset LatexCommand ref
13204 reference "sec:Porting-code-to-other-compilers"
13205
13206 \end_inset
13207
13208 ).
13209  
13210 \end_layout
13211
13212 \begin_layout Subsubsection
13213 Pointers
13214 \begin_inset LatexCommand index
13215 name "Pointer"
13216
13217 \end_inset
13218
13219  to MCS51/DS390 specific memory spaces
13220 \end_layout
13221
13222 \begin_layout Standard
13223 SDCC allows (via language extensions) pointers to explicitly point to any
13224  of the memory spaces
13225 \begin_inset LatexCommand index
13226 name "Memory model"
13227
13228 \end_inset
13229
13230  of the 8051.
13231  In addition to the explicit pointers, the compiler uses (by default) generic
13232  pointers which can be used to point to any of the memory spaces.
13233 \newline
13234
13235 \newline
13236 Pointer
13237  declaration examples:
13238 \end_layout
13239
13240 \begin_layout Verse
13241
13242 \family typewriter
13243 /* pointer physically in internal ram pointing to object in external ram
13244  */ 
13245 \newline
13246 __xdata unsigned char * __data p;
13247 \newline
13248
13249 \newline
13250 /* pointer physically in external ram
13251  pointing to object in internal ram */ 
13252 \newline
13253 __data unsigned char * __xdata p;
13254 \newline
13255
13256 \newline
13257 /*
13258  pointer physically in code rom pointing to data in xdata space */ 
13259 \newline
13260 __xdata
13261  unsigned char * __code p;
13262 \newline
13263
13264 \newline
13265 /* pointer physically in code space pointing to
13266  data in code space */ 
13267 \newline
13268 __code unsigned char * __code p;
13269 \newline
13270
13271 \newline
13272 /* generic pointer
13273  physically located in xdata space */
13274 \newline
13275 unsigned char * __xdata p;
13276 \newline
13277
13278 \newline
13279 /* generic
13280  pointer physically located in default memory space */
13281 \newline
13282 unsigned char * p;
13283 \newline
13284
13285 \newline
13286 /*
13287  the following is a function pointer
13288 \begin_inset LatexCommand index
13289 name "function pointer"
13290
13291 \end_inset
13292
13293  physically located in data space */
13294 \newline
13295 char (* __data fp)(void);
13296 \end_layout
13297
13298 \begin_layout Standard
13299 Well you get the idea.
13300  
13301 \newline
13302
13303 \newline
13304 All unqualified pointers are treated as 3-byte (4-byte for the ds390) 
13305 \emph on
13306 generic
13307 \emph default
13308  pointers.
13309  
13310 \size small
13311
13312 \newline
13313
13314 \newline
13315
13316 \size default
13317 The highest order byte of the 
13318 \emph on
13319 generic
13320 \emph default
13321  pointers contains the data space information.
13322  Assembler support routines are called whenever data is stored or retrieved
13323  using 
13324 \emph on
13325 generic
13326 \emph default
13327  pointers.
13328  These are useful for developing reusable library
13329 \begin_inset LatexCommand index
13330 name "Libraries"
13331
13332 \end_inset
13333
13334  routines.
13335  Explicitly specifying the pointer
13336 \begin_inset LatexCommand index
13337 name "pointer"
13338
13339 \end_inset
13340
13341  type will generate the most efficient code.
13342 \end_layout
13343
13344 \begin_layout Subsubsection
13345 Notes on MCS51 memory
13346 \begin_inset LatexCommand index
13347 name "MCS51 memory"
13348
13349 \end_inset
13350
13351  layout
13352 \end_layout
13353
13354 \begin_layout Standard
13355 The 8051 family of microcontrollers have a minimum of 128 bytes of internal
13356  RAM memory which is structured as follows:
13357 \newline
13358
13359 \newline
13360 - Bytes 00-1F - 32 bytes to hold
13361  up to 4 banks of the registers R0 to R7, 
13362 \newline
13363 - Bytes 20-2F - 16 bytes to hold
13364  128 bit
13365 \begin_inset LatexCommand index
13366 name "bit"
13367
13368 \end_inset
13369
13370  variables and, 
13371 \newline
13372 - Bytes 30-7F - 80 bytes for general purpose use.
13373 \newline
13374
13375 \end_layout
13376
13377 \begin_layout Standard
13378 Additionally some members of the MCS51 family may have up to 128 bytes of
13379  additional, indirectly addressable, internal RAM memory (
13380 \emph on
13381 idata
13382 \emph default
13383
13384 \begin_inset LatexCommand index
13385 name "idata (mcs51, ds390 storage class)"
13386
13387 \end_inset
13388
13389
13390 \begin_inset LatexCommand index
13391 name "\\_\\_idata (mcs51, ds390 storage class)"
13392
13393 \end_inset
13394
13395 ).
13396  Furthermore, some chips may have some built in external memory (
13397 \emph on
13398 xdata
13399 \emph default
13400
13401 \begin_inset LatexCommand index
13402 name "xdata (mcs51, ds390 storage class)"
13403
13404 \end_inset
13405
13406
13407 \begin_inset LatexCommand index
13408 name "\\_\\_xdata (mcs51, ds390 storage class)"
13409
13410 \end_inset
13411
13412 ) which should not be confused with the internal, directly addressable RAM
13413  memory (
13414 \emph on
13415 data
13416 \emph default
13417
13418 \begin_inset LatexCommand index
13419 name "data (mcs51, ds390 storage class)"
13420
13421 \end_inset
13422
13423
13424 \begin_inset LatexCommand index
13425 name "\\_\\_data (mcs51, ds390 storage class)"
13426
13427 \end_inset
13428
13429 ).
13430  Sometimes this built in 
13431 \emph on
13432 xdata
13433 \emph default
13434  memory has to be activated before using it (you can probably find this
13435  information on the datasheet of the microcontroller your are using, see
13436  also section 
13437 \begin_inset LatexCommand ref
13438 reference "sub:Startup-Code"
13439
13440 \end_inset
13441
13442 \InsetSpace ~
13443 Startup-Code).
13444 \end_layout
13445
13446 \begin_layout Standard
13447 Normally SDCC will only use the first bank
13448 \begin_inset LatexCommand index
13449 name "register bank (mcs51, ds390)"
13450
13451 \end_inset
13452
13453  of registers (register bank 0), but it is possible to specify that other
13454  banks of registers (keyword 
13455 \emph on
13456 using
13457 \emph default
13458  
13459 \emph on
13460
13461 \begin_inset LatexCommand index
13462 name "using (mcs51, ds390 register bank)"
13463
13464 \end_inset
13465
13466
13467 \begin_inset LatexCommand index
13468 name "\\_\\_using (mcs51, ds390 register bank)"
13469
13470 \end_inset
13471
13472
13473 \emph default
13474 ) should be used for example in interrupt
13475 \begin_inset LatexCommand index
13476 name "interrupt"
13477
13478 \end_inset
13479
13480
13481 \begin_inset LatexCommand index
13482 name "\\_\\_interrupt"
13483
13484 \end_inset
13485
13486  routines.
13487  By default, the compiler will place the stack after the last byte of allocated
13488  memory for variables.
13489  For example, if the first 2 banks of registers are used, and only four
13490  bytes are used for 
13491 \emph on
13492 data
13493 \emph default
13494  variables, it will position the base of the internal stack at address 20
13495  (0x14).
13496  This implies that as the stack
13497 \begin_inset LatexCommand index
13498 name "stack"
13499
13500 \end_inset
13501
13502  grows, it will use up the remaining register banks, and the 16 bytes used
13503  by the 128 bit variables, and 80 bytes for general purpose use.
13504  If any bit variables are used, the data variables will be placed in unused
13505  register banks and after the byte holding the last bit variable.
13506  For example, if register banks 0 and 1 are used, and there are 9 bit variables
13507  (two bytes used), 
13508 \emph on
13509 data
13510 \emph default
13511  variables will be placed starting from address 0x10 to 0x20 and continue
13512  at address 0x22.
13513  You can also use -
13514 \begin_inset ERT
13515 status collapsed
13516
13517 \begin_layout Standard
13518
13519
13520 \backslash
13521 /
13522 \end_layout
13523
13524 \end_inset
13525
13526 -data-loc
13527 \begin_inset LatexCommand index
13528 name "-\\/-data-loc <Value>"
13529
13530 \end_inset
13531
13532  to specify the start address of the 
13533 \emph on
13534 data
13535 \emph default
13536  and -
13537 \begin_inset ERT
13538 status collapsed
13539
13540 \begin_layout Standard
13541
13542
13543 \backslash
13544 /
13545 \end_layout
13546
13547 \end_inset
13548
13549 -iram-size
13550 \begin_inset LatexCommand index
13551 name "-\\/-iram-size <Value>"
13552
13553 \end_inset
13554
13555  to specify the size of the total internal RAM (
13556 \emph on
13557 data
13558 \emph default
13559 +
13560 \emph on
13561 idata
13562 \emph default
13563 ).
13564  
13565 \newline
13566
13567 \end_layout
13568
13569 \begin_layout Standard
13570 By default the 8051 linker will place the stack after the last byte of (i)data
13571  variables.
13572  Option -
13573 \begin_inset ERT
13574 status collapsed
13575
13576 \begin_layout Standard
13577
13578
13579 \backslash
13580 /
13581 \end_layout
13582
13583 \end_inset
13584
13585 -stack-loc
13586 \begin_inset LatexCommand index
13587 name "-\\/-stack-loc <Value>"
13588
13589 \end_inset
13590
13591  allows you to specify the start of the stack, i.e.
13592  you could start it after any data in the general purpose area.
13593  If your microcontroller has additional indirectly addressable internal
13594  RAM (
13595 \emph on
13596 idata
13597 \emph default
13598 ) you can place the stack on it.
13599  You may also need to use -
13600 \begin_inset ERT
13601 status collapsed
13602
13603 \begin_layout Standard
13604
13605
13606 \backslash
13607 /
13608 \end_layout
13609
13610 \end_inset
13611
13612 -xdata-loc
13613 \begin_inset LatexCommand index
13614 name "-\\/-xdata-loc<Value>"
13615
13616 \end_inset
13617
13618  to set the start address of the external RAM (
13619 \emph on
13620 xdata
13621 \emph default
13622 ) and -
13623 \begin_inset ERT
13624 status collapsed
13625
13626 \begin_layout Standard
13627
13628
13629 \backslash
13630 /
13631 \end_layout
13632
13633 \end_inset
13634
13635 -xram-size
13636 \begin_inset LatexCommand index
13637 name "-\\/-xram-size <Value>"
13638
13639 \end_inset
13640
13641  to specify its size.
13642  Same goes for the code memory, using -
13643 \begin_inset ERT
13644 status collapsed
13645
13646 \begin_layout Standard
13647
13648
13649 \backslash
13650 /
13651 \end_layout
13652
13653 \end_inset
13654
13655 -code-loc
13656 \begin_inset LatexCommand index
13657 name "-\\/-code-loc <Value>"
13658
13659 \end_inset
13660
13661  and -
13662 \begin_inset ERT
13663 status collapsed
13664
13665 \begin_layout Standard
13666
13667
13668 \backslash
13669 /
13670 \end_layout
13671
13672 \end_inset
13673
13674 -code-size
13675 \begin_inset LatexCommand index
13676 name "-\\/-code-size <Value>"
13677
13678 \end_inset
13679
13680 .
13681  If in doubt, don't specify any options and see if the resulting memory
13682  layout is appropriate, then you can adjust it.
13683 \end_layout
13684
13685 \begin_layout Standard
13686 The linker generates two files with memory allocation information.
13687  The first, with extension .map
13688 \begin_inset LatexCommand index
13689 name "<file>.map"
13690
13691 \end_inset
13692
13693  shows all the variables and segments.
13694  The second with extension .mem
13695 \begin_inset LatexCommand index
13696 name "<file>.mem"
13697
13698 \end_inset
13699
13700  shows the final memory layout.
13701  The linker will complain either if memory segments overlap, there is not
13702  enough memory, or there is not enough space for stack.
13703  If you get any linking warnings and/or errors related to stack or segments
13704  allocation, take a look at either the .map or .mem files to find out what
13705  the problem is.
13706  The .mem file may even suggest a solution to the problem.
13707 \begin_inset VSpace bigskip
13708 \end_inset
13709
13710
13711 \end_layout
13712
13713 \begin_layout Subsection
13714 Z80/Z180 Storage Class
13715 \begin_inset LatexCommand index
13716 name "Z80!Storage class"
13717
13718 \end_inset
13719
13720  Language Extensions
13721 \end_layout
13722
13723 \begin_layout Subsubsection
13724 sfr
13725 \begin_inset LatexCommand index
13726 name "sfr"
13727
13728 \end_inset
13729
13730
13731 \begin_inset LatexCommand index
13732 name "\\_\\_sfr"
13733
13734 \end_inset
13735
13736  (in/out to 8-bit addresses)
13737 \end_layout
13738
13739 \begin_layout Standard
13740 The Z80
13741 \begin_inset LatexCommand index
13742 name "Z80"
13743
13744 \end_inset
13745
13746  family has separate address spaces for memory and 
13747 \emph on
13748 i
13749 \emph default
13750 nput/
13751 \emph on
13752 o
13753 \emph default
13754 utput memory.
13755  I/O memory
13756 \begin_inset LatexCommand index
13757 name "I/O memory (Z80, Z180)"
13758
13759 \end_inset
13760
13761
13762 \begin_inset LatexCommand index
13763 name "Z80!I/O memory"
13764
13765 \end_inset
13766
13767
13768 \begin_inset LatexCommand index
13769 name "Z180!I/O memory"
13770
13771 \end_inset
13772
13773  is accessed with special instructions, e.g.:
13774 \end_layout
13775
13776 \begin_layout Verse
13777
13778 \family typewriter
13779 sfr at 0x78 IoPort;\InsetSpace ~
13780 \InsetSpace ~
13781 /* define a var in I/O space at 78h called IoPort */
13782  
13783 \end_layout
13784
13785 \begin_layout Standard
13786 Writing 0x01 to this variable generates the assembly code:
13787 \end_layout
13788
13789 \begin_layout Verse
13790
13791 \family typewriter
13792 3E 01\InsetSpace ~
13793 \InsetSpace ~
13794 \InsetSpace ~
13795 \InsetSpace ~
13796 \InsetSpace ~
13797 \InsetSpace ~
13798 ld a,#0x01
13799 \newline
13800 D3 78\InsetSpace ~
13801 \InsetSpace ~
13802 \InsetSpace ~
13803 \InsetSpace ~
13804 \InsetSpace ~
13805 \InsetSpace ~
13806 out (_IoPort),a 
13807 \end_layout
13808
13809 \begin_layout Subsubsection
13810 banked sfr
13811 \begin_inset LatexCommand index
13812 name "sfr"
13813
13814 \end_inset
13815
13816
13817 \begin_inset LatexCommand index
13818 name "\\_\\_sfr"
13819
13820 \end_inset
13821
13822  (in/out to 16-bit addresses)
13823 \end_layout
13824
13825 \begin_layout Standard
13826 The keyword 
13827 \emph on
13828 banked
13829 \emph default
13830  is used to support 16 bit addresses in I/O memory e.g.:
13831 \end_layout
13832
13833 \begin_layout Verse
13834
13835 \family typewriter
13836 sfr banked at
13837 \begin_inset LatexCommand index
13838 name "at"
13839
13840 \end_inset
13841
13842
13843 \begin_inset LatexCommand index
13844 name "\\_\\_at"
13845
13846 \end_inset
13847
13848  0x123 IoPort; 
13849 \end_layout
13850
13851 \begin_layout Standard
13852 Writing 0x01 to this variable generates the assembly code:
13853 \end_layout
13854
13855 \begin_layout Verse
13856
13857 \family typewriter
13858 01 23 01\InsetSpace ~
13859 \InsetSpace ~
13860 \InsetSpace ~
13861 ld bc,#_IoPort
13862 \newline
13863 3E 01\InsetSpace ~
13864 \InsetSpace ~
13865 \InsetSpace ~
13866 \InsetSpace ~
13867 \InsetSpace ~
13868 \InsetSpace ~
13869 ld a,#0x01 
13870 \newline
13871 ED 79\InsetSpace ~
13872 \InsetSpace ~
13873 \InsetSpace ~
13874 \InsetSpace ~
13875 \InsetSpace ~
13876 \InsetSpace ~
13877 out (c),a 
13878 \end_layout
13879
13880 \begin_layout Subsubsection
13881 sfr
13882 \begin_inset LatexCommand index
13883 name "sfr"
13884
13885 \end_inset
13886
13887
13888 \begin_inset LatexCommand index
13889 name "\\_\\_sfr"
13890
13891 \end_inset
13892
13893  (in0/out0 to 8 bit addresses on Z180
13894 \begin_inset LatexCommand index
13895 name "Z180"
13896
13897 \end_inset
13898
13899 /HD64180
13900 \begin_inset LatexCommand index
13901 name "HD64180 (see Z180)"
13902
13903 \end_inset
13904
13905 )
13906 \end_layout
13907
13908 \begin_layout Standard
13909 The compiler option -
13910 \begin_inset ERT
13911 status collapsed
13912
13913 \begin_layout Standard
13914
13915
13916 \backslash
13917 /
13918 \end_layout
13919
13920 \end_inset
13921
13922 -portmode
13923 \begin_inset LatexCommand index
13924 name "Z180!Options!-\\/-portmode"
13925
13926 \end_inset
13927
13928 =180 (80) and a compiler #pragma\InsetSpace ~
13929 portmode
13930 \begin_inset LatexCommand index
13931 name "Z180!Pragmas!\\#pragma portmode"
13932
13933 \end_inset
13934
13935  z180 (z80) is used to turn on (off) the Z180/HD64180 port addressing instructio
13936 ns 
13937 \family typewriter
13938 in0/out0
13939 \family default
13940  instead of 
13941 \family typewriter
13942 in/out
13943 \family default
13944 .
13945  If you include the file z180.h this will be set automatically.
13946 \begin_inset VSpace bigskip
13947 \end_inset
13948
13949
13950 \end_layout
13951
13952 \begin_layout Subsection
13953 HC08 Storage Class
13954 \begin_inset LatexCommand index
13955 name "HC08!Storage class"
13956
13957 \end_inset
13958
13959  Language Extensions
13960 \end_layout
13961
13962 \begin_layout Subsubsection
13963 data
13964 \begin_inset LatexCommand index
13965 name "data (hc08 storage class)"
13966
13967 \end_inset
13968
13969
13970 \begin_inset LatexCommand index
13971 name "\\_\\_data (hc08 storage class)"
13972
13973 \end_inset
13974
13975  
13976 \end_layout
13977
13978 \begin_layout Standard
13979 The data storage class declares a variable that resides in the first 256
13980  bytes of memory (the direct page).
13981  The HC08
13982 \begin_inset LatexCommand index
13983 name "HC08"
13984
13985 \end_inset
13986
13987  is most efficient at accessing variables (especially pointers) stored here.
13988 \end_layout
13989
13990 \begin_layout Subsubsection
13991 xdata
13992 \begin_inset LatexCommand index
13993 name "xdata (hc08 storage class)"
13994
13995 \end_inset
13996
13997
13998 \begin_inset LatexCommand index
13999 name "\\_\\_xdata (hc08 storage class)"
14000
14001 \end_inset
14002
14003  
14004 \end_layout
14005
14006 \begin_layout Standard
14007 The xdata storage class declares a variable that can reside anywhere in
14008  memory.
14009  This is the default if no storage class is specified.
14010  
14011 \begin_inset VSpace bigskip
14012 \end_inset
14013
14014
14015 \end_layout
14016
14017 \begin_layout Section
14018 Other SDCC language extensions
14019 \begin_inset LatexCommand index
14020 name "Other SDCC language extensions"
14021
14022 \end_inset
14023
14024
14025 \end_layout
14026
14027 \begin_layout Subsection
14028 Binary constants
14029 \end_layout
14030
14031 \begin_layout Standard
14032 SDCC supports the use of binary constants, such as 0b01100010.
14033  This feature is only enabled when the compiler is invoked using --std-sdccxx.
14034 \end_layout
14035
14036 \begin_layout Standard
14037 \begin_inset VSpace bigskip
14038 \end_inset
14039
14040
14041 \end_layout
14042
14043 \begin_layout Section
14044 Absolute Addressing
14045 \begin_inset LatexCommand index
14046 name "Absolute addressing"
14047
14048 \end_inset
14049
14050
14051 \end_layout
14052
14053 \begin_layout Standard
14054 Data items can be assigned an absolute address with the 
14055 \emph on
14056 at
14057 \begin_inset LatexCommand index
14058 name "at"
14059
14060 \end_inset
14061
14062
14063 \begin_inset LatexCommand index
14064 name "\\_\\_at"
14065
14066 \end_inset
14067
14068  <address>
14069 \emph default
14070  keyword, in addition to a storage class, e.g.:
14071 \end_layout
14072
14073 \begin_layout Verse
14074
14075 \family typewriter
14076 xdata
14077 \begin_inset LatexCommand index
14078 name "xdata (mcs51, ds390 storage class)"
14079
14080 \end_inset
14081
14082
14083 \begin_inset LatexCommand index
14084 name "\\_\\_xdata (mcs51, ds390 storage class)"
14085
14086 \end_inset
14087
14088  at
14089 \begin_inset LatexCommand index
14090 name "at"
14091
14092 \end_inset
14093
14094
14095 \begin_inset LatexCommand index
14096 name "\\_\\_at"
14097
14098 \end_inset
14099
14100  0x7ffe unsigned int chksum;
14101 \end_layout
14102
14103 \begin_layout Standard
14104 or, better conforming to ISO/IEC 9899 C:
14105 \end_layout
14106
14107 \begin_layout Verse
14108
14109 \family typewriter
14110 __xdata __at (0x7ffe) unsigned int chksum;
14111 \end_layout
14112
14113 \begin_layout Standard
14114 In the above example the variable chksum will be located at 0x7ffe and 0x7fff
14115  of the external ram.
14116  The compiler does 
14117 \emph on
14118 not
14119 \emph default
14120  reserve any space for variables declared in this way
14121 \begin_inset Marginal
14122 status collapsed
14123
14124 \begin_layout Standard
14125
14126 \series bold
14127 \InsetSpace ~
14128 !
14129 \end_layout
14130
14131 \end_inset
14132
14133  (they are implemented with an equate in the assembler).
14134  Thus it is left to the programmer to make sure there are no overlaps with
14135  other variables that are declared without the absolute address.
14136  The assembler listing file (.lst
14137 \begin_inset LatexCommand index
14138 name "<file>.lst"
14139
14140 \end_inset
14141
14142 ) and the linker output files (.rst
14143 \begin_inset LatexCommand index
14144 name "<file>.rst"
14145
14146 \end_inset
14147
14148 ) and (.map
14149 \begin_inset LatexCommand index
14150 name "<file>.map"
14151
14152 \end_inset
14153
14154 ) are good places to look for such overlaps.
14155 \end_layout
14156
14157 \begin_layout Standard
14158 If however you provide an initializer
14159 \begin_inset LatexCommand index
14160 name "Variable initialization"
14161
14162 \end_inset
14163
14164  actual memory allocation will take place and overlaps will be detected
14165  by the linker.
14166  E.g.:
14167 \end_layout
14168
14169 \begin_layout Verse
14170
14171 \family typewriter
14172 __code __at (0x7ff0) char Id[5] = 
14173 \begin_inset Quotes sld
14174 \end_inset
14175
14176 SDCC
14177 \begin_inset Quotes srd
14178 \end_inset
14179
14180 ;
14181 \end_layout
14182
14183 \begin_layout Standard
14184 In the above example the variable Id will be located from 0x7ff0 to 0x7ff4
14185  in code memory.
14186 \end_layout
14187
14188 \begin_layout Standard
14189 In case of memory mapped I/O devices the keyword 
14190 \emph on
14191 volatile
14192 \emph default
14193  has to be used to tell the compiler that accesses might not be removed:
14194 \end_layout
14195
14196 \begin_layout Verse
14197
14198 \family typewriter
14199 volatile
14200 \begin_inset LatexCommand index
14201 name "volatile"
14202
14203 \end_inset
14204
14205  __xdata
14206 \begin_inset LatexCommand index
14207 name "xdata (mcs51, ds390 storage class)"
14208
14209 \end_inset
14210
14211  __at
14212 \begin_inset LatexCommand index
14213 name "at"
14214
14215 \end_inset
14216
14217  (0x8000) unsigned char PORTA_8255;
14218 \end_layout
14219
14220 \begin_layout Standard
14221 For some architectures (mcs51) array accesses are more efficient if an (xdata/fa
14222 r) array
14223 \family typewriter
14224 \size footnotesize
14225
14226 \begin_inset LatexCommand index
14227 name "Aligned array"
14228
14229 \end_inset
14230
14231
14232 \family default
14233 \size default
14234  starts at a block (256 byte) boundary
14235 \begin_inset LatexCommand index
14236 name "block boundary"
14237
14238 \end_inset
14239
14240  (section 
14241 \begin_inset LatexCommand ref
14242 reference "sub:A-Step-by Assembler Introduction"
14243
14244 \end_inset
14245
14246  has an example).
14247 \newline
14248 Absolute addresses can be specified for variables in all
14249  storage classes, e.g.:
14250 \end_layout
14251
14252 \begin_layout Verse
14253
14254 \family typewriter
14255 __bit
14256 \begin_inset LatexCommand index
14257 name "bit"
14258
14259 \end_inset
14260
14261  __at
14262 \begin_inset LatexCommand index
14263 name "at"
14264
14265 \end_inset
14266
14267  (0x02) bvar;
14268 \end_layout
14269
14270 \begin_layout Standard
14271 The above example will allocate the variable at offset 0x02 in the bit-addressab
14272 le space.
14273  There is no real advantage to assigning absolute addresses to variables
14274  in this manner, unless you want strict control over all the variables allocated.
14275  One possible use would be to write hardware portable code.
14276  For example, if you have a routine that uses one or more of the microcontroller
14277  I/O pins, and such pins are different for two different hardwares, you
14278  can declare the I/O pins in your routine using:
14279 \end_layout
14280
14281 \begin_layout Verse
14282
14283 \family typewriter
14284 extern volatile
14285 \begin_inset LatexCommand index
14286 name "volatile"
14287
14288 \end_inset
14289
14290  __bit MOSI;\InsetSpace ~
14291 \InsetSpace ~
14292 \InsetSpace ~
14293 \InsetSpace ~
14294 /* master out, slave in */
14295 \newline
14296 extern volatile __bit MISO;\InsetSpace ~
14297 \InsetSpace ~
14298 \InsetSpace ~
14299 \InsetSpace ~
14300 /* master
14301  in, slave out */
14302 \newline
14303 extern volatile __bit MCLK;\InsetSpace ~
14304 \InsetSpace ~
14305 \InsetSpace ~
14306 \InsetSpace ~
14307 /* master clock */
14308 \newline
14309
14310 \newline
14311 /* Input and
14312  Output of a byte on a 3-wire serial bus.
14313 \newline
14314 \InsetSpace ~
14315 \InsetSpace ~
14316 \InsetSpace ~
14317 If needed adapt polarity of clock,
14318  polarity of data and bit order
14319 \newline
14320 \InsetSpace ~
14321 */
14322 \newline
14323 unsigned char spi_io(unsigned char out_byte)
14324  
14325 \newline
14326
14327 \newline
14328 \InsetSpace ~
14329 \InsetSpace ~
14330 \InsetSpace ~
14331 \InsetSpace ~
14332 unsigned char i=8;
14333 \newline
14334 \InsetSpace ~
14335 \InsetSpace ~
14336 \InsetSpace ~
14337 \InsetSpace ~
14338 do { 
14339 \newline
14340 \InsetSpace ~
14341 \InsetSpace ~
14342 \InsetSpace ~
14343 \InsetSpace ~
14344 \InsetSpace ~
14345 \InsetSpace ~
14346 \InsetSpace ~
14347 \InsetSpace ~
14348 MOSI = out_byte & 0x80; 
14349 \newline
14350 \InsetSpace ~
14351 \InsetSpace ~
14352 \InsetSpace ~
14353 \InsetSpace ~
14354 \InsetSpace ~
14355 \InsetSpace ~
14356 \InsetSpace ~
14357 \InsetSpace ~
14358 out_byte <<= 1;
14359 \newline
14360 \InsetSpace ~
14361 \InsetSpace ~
14362 \InsetSpace ~
14363 \InsetSpace ~
14364 \InsetSpace ~
14365 \InsetSpace ~
14366 \InsetSpace ~
14367 \InsetSpace ~
14368 MCLK =
14369  1; 
14370 \newline
14371 \InsetSpace ~
14372 \InsetSpace ~
14373 \InsetSpace ~
14374 \InsetSpace ~
14375 \InsetSpace ~
14376 \InsetSpace ~
14377 \InsetSpace ~
14378 \InsetSpace ~
14379 /* _asm nop _endasm; */\InsetSpace ~
14380 \InsetSpace ~
14381 \InsetSpace ~
14382 \InsetSpace ~
14383 \InsetSpace ~
14384 \InsetSpace ~
14385 \InsetSpace ~
14386 \InsetSpace ~
14387 /* for slow peripherals */
14388 \newline
14389 \InsetSpace ~
14390 \InsetSpace ~
14391 \InsetSpace ~
14392 \InsetSpace ~
14393 \InsetSpace ~
14394 \InsetSpace ~
14395 \InsetSpace ~
14396 \InsetSpace ~
14397 if(MISO) 
14398 \newline
14399 \InsetSpace ~
14400 \InsetSpace ~
14401 \InsetSpace ~
14402 \InsetSpace ~
14403 \InsetSpace ~
14404 \InsetSpace ~
14405 \InsetSpace ~
14406 \InsetSpace ~
14407 \InsetSpace ~
14408 \InsetSpace ~
14409 \InsetSpace ~
14410 \InsetSpace ~
14411 out_byte +=
14412  1; 
14413 \newline
14414 \InsetSpace ~
14415 \InsetSpace ~
14416 \InsetSpace ~
14417 \InsetSpace ~
14418 \InsetSpace ~
14419 \InsetSpace ~
14420 \InsetSpace ~
14421 \InsetSpace ~
14422 MCLK = 0; 
14423 \newline
14424 \InsetSpace ~
14425 \InsetSpace ~
14426 \InsetSpace ~
14427 \InsetSpace ~
14428 } while(--i);
14429 \newline
14430 \InsetSpace ~
14431 \InsetSpace ~
14432 \InsetSpace ~
14433 \InsetSpace ~
14434 return out_byte; 
14435 \newline
14436 }
14437 \end_layout
14438
14439 \begin_layout Standard
14440 Then, someplace in the code for the first hardware you would use
14441 \end_layout
14442
14443 \begin_layout Verse
14444
14445 \family typewriter
14446 __bit __at
14447 \begin_inset LatexCommand index
14448 name "at"
14449
14450 \end_inset
14451
14452
14453 \begin_inset LatexCommand index
14454 name "\\_\\_at"
14455
14456 \end_inset
14457
14458  (0x80) MOSI;\InsetSpace ~
14459 \InsetSpace ~
14460 \InsetSpace ~
14461 \InsetSpace ~
14462 /* I/O port 0, bit 0 */
14463 \newline
14464 __bit __at (0x81) MISO;\InsetSpace ~
14465 \InsetSpace ~
14466 \InsetSpace ~
14467 \InsetSpace ~
14468 /* I/O port 0,
14469  bit 1 */
14470 \newline
14471 __bit __at (0x82) MCLK;\InsetSpace ~
14472 \InsetSpace ~
14473 \InsetSpace ~
14474 \InsetSpace ~
14475 /* I/O port 0, bit 2 */
14476 \end_layout
14477
14478 \begin_layout Standard
14479 Similarly, for the second hardware you would use
14480 \end_layout
14481
14482 \begin_layout Verse
14483
14484 \family typewriter
14485 __bit __at (0x83) MOSI;\InsetSpace ~
14486 \InsetSpace ~
14487 \InsetSpace ~
14488 \InsetSpace ~
14489 /* I/O port 0, bit 3 */
14490 \newline
14491 __bit __at (0x91) MISO;\InsetSpace ~
14492 \InsetSpace ~
14493 \InsetSpace ~
14494 \InsetSpace ~
14495 /*
14496  I/O port 1, bit 1 */
14497 \newline
14498 __bit
14499 \begin_inset LatexCommand index
14500 name "bit"
14501
14502 \end_inset
14503
14504  __at (0x92) MCLK;\InsetSpace ~
14505 \InsetSpace ~
14506 \InsetSpace ~
14507 \InsetSpace ~
14508 /* I/O port 1, bit 2 */
14509 \end_layout
14510
14511 \begin_layout Standard
14512 and you can use the same hardware dependent routine without changes, as
14513  for example in a library.
14514  This is somehow similar to sbit, but only one absolute address has to be
14515  specified in the whole project.
14516 \begin_inset VSpace bigskip
14517 \end_inset
14518
14519
14520 \end_layout
14521
14522 \begin_layout Section
14523 Parameters
14524 \begin_inset LatexCommand index
14525 name "Parameters"
14526
14527 \end_inset
14528
14529
14530 \begin_inset LatexCommand index
14531 name "function parameter"
14532
14533 \end_inset
14534
14535  & Local Variables
14536 \begin_inset LatexCommand index
14537 name "local variables"
14538
14539 \end_inset
14540
14541
14542 \begin_inset LatexCommand label
14543 name "sec:Parameters-and-Local-Variables"
14544
14545 \end_inset
14546
14547
14548 \end_layout
14549
14550 \begin_layout Standard
14551 Automatic (local) variables and parameters to functions can either be placed
14552  on the stack or in data-space.
14553  The default action of the compiler is to place these variables in the internal
14554  RAM (for small model) or external RAM (for medium or large model).
14555  This in fact makes them similar to 
14556 \emph on
14557 static
14558 \begin_inset LatexCommand index
14559 name "static"
14560
14561 \end_inset
14562
14563
14564 \emph default
14565  so by default functions are non-reentrant
14566 \begin_inset LatexCommand index
14567 name "reentrant"
14568
14569 \end_inset
14570
14571 .
14572  
14573 \newline
14574
14575 \newline
14576 They can be placed on the stack
14577 \begin_inset LatexCommand index
14578 name "stack"
14579
14580 \end_inset
14581
14582  by using the 
14583 \emph on
14584 -
14585 \begin_inset ERT
14586 status collapsed
14587
14588 \begin_layout Standard
14589
14590
14591 \backslash
14592 /
14593 \end_layout
14594
14595 \end_inset
14596
14597 -stack-auto
14598 \begin_inset LatexCommand index
14599 name "-\\/-stack-auto"
14600
14601 \end_inset
14602
14603
14604 \emph default
14605  option, by using 
14606 \emph on
14607 #pragma\InsetSpace ~
14608 stackauto
14609 \emph default
14610
14611 \begin_inset LatexCommand index
14612 name "\\#pragma stackauto"
14613
14614 \end_inset
14615
14616  or by using the 
14617 \emph on
14618 reentrant
14619 \begin_inset LatexCommand index
14620 name "reentrant"
14621
14622 \end_inset
14623
14624
14625 \emph default
14626  keyword in the function declaration, e.g.:
14627 \end_layout
14628
14629 \begin_layout Verse
14630
14631 \family typewriter
14632 unsigned char foo(char i) __reentrant 
14633 \newline
14634
14635 \newline
14636 \InsetSpace ~
14637 \InsetSpace ~
14638 \InsetSpace ~
14639 \InsetSpace ~
14640 ...
14641  
14642 \newline
14643 }
14644 \end_layout
14645
14646 \begin_layout Standard
14647 Since stack space on 8051 is limited, the 
14648 \emph on
14649 reentrant
14650 \emph default
14651  keyword or the 
14652 \emph on
14653 -
14654 \begin_inset ERT
14655 status collapsed
14656
14657 \begin_layout Standard
14658
14659
14660 \backslash
14661 /
14662 \end_layout
14663
14664 \end_inset
14665
14666 -stack-auto
14667 \emph default
14668  option should be used sparingly.
14669  Note that the reentrant keyword just means that the parameters & local
14670  variables will be allocated to the stack, it 
14671 \emph on
14672 does not
14673 \emph default
14674  mean that the function is register bank
14675 \begin_inset LatexCommand index
14676 name "register bank (mcs51, ds390)"
14677
14678 \end_inset
14679
14680  independent.
14681 \newline
14682
14683 \newline
14684 Local variables
14685 \begin_inset LatexCommand index
14686 name "local variables"
14687
14688 \end_inset
14689
14690  can be assigned storage classes and absolute
14691 \begin_inset LatexCommand index
14692 name "Absolute addressing"
14693
14694 \end_inset
14695
14696  addresses, e.g.: 
14697 \end_layout
14698
14699 \begin_layout Verse
14700
14701 \family typewriter
14702 unsigned char foo() 
14703 \newline
14704 {
14705 \newline
14706 \InsetSpace ~
14707 \InsetSpace ~
14708 \InsetSpace ~
14709 \InsetSpace ~
14710 __xdata unsigned char i;
14711 \newline
14712 \InsetSpace ~
14713 \InsetSpace ~
14714 \InsetSpace ~
14715 \InsetSpace ~
14716 __bit bvar;
14717 \newline
14718 \InsetSpace ~
14719 \InsetSpace ~
14720 \InsetSpace ~
14721 \InsetSpace ~
14722 __data __at
14723 \begin_inset LatexCommand index
14724 name "at"
14725
14726 \end_inset
14727
14728  (0x31) unsigned char j;
14729 \newline
14730 \InsetSpace ~
14731 \InsetSpace ~
14732 \InsetSpace ~
14733 \InsetSpace ~
14734 ...
14735  
14736 \newline
14737 }
14738 \end_layout
14739
14740 \begin_layout Standard
14741 In the above example the variable 
14742 \emph on
14743 i
14744 \emph default
14745  will be allocated in the external ram, 
14746 \emph on
14747 bvar
14748 \emph default
14749  in bit addressable space and 
14750 \emph on
14751 j
14752 \emph default
14753  in internal ram.
14754  When compiled with 
14755 \emph on
14756 -
14757 \begin_inset ERT
14758 status collapsed
14759
14760 \begin_layout Standard
14761
14762
14763 \backslash
14764 /
14765 \end_layout
14766
14767 \end_inset
14768
14769 -stack-auto
14770 \emph default
14771  or when a function is declared as 
14772 \emph on
14773 reentrant
14774 \emph default
14775  this should only be done for static variables.
14776 \end_layout
14777
14778 \begin_layout Standard
14779 Parameters
14780 \begin_inset LatexCommand index
14781 name "function parameter"
14782
14783 \end_inset
14784
14785  however are not allowed any storage class
14786 \begin_inset LatexCommand index
14787 name "Storage class"
14788
14789 \end_inset
14790
14791 , (storage classes for parameters will be ignored), their allocation is
14792  governed by the memory model in use, and the reentrancy options.
14793 \end_layout
14794
14795 \begin_layout Standard
14796 It is however allowed to use bit parameters in reentrant functions and also
14797  non-static local bit variables are supported.
14798  Efficient use is limited to 8 semi-bitregisters in bit space.
14799  They are pushed and popped to stack
14800 \begin_inset LatexCommand index
14801 name "stack"
14802
14803 \end_inset
14804
14805  as a single byte just like the normal registers.
14806 \end_layout
14807
14808 \begin_layout Section
14809 Overlaying
14810 \begin_inset LatexCommand label
14811 name "sub:Overlaying"
14812
14813 \end_inset
14814
14815
14816 \begin_inset LatexCommand index
14817 name "Overlaying"
14818
14819 \end_inset
14820
14821
14822 \end_layout
14823
14824 \begin_layout Standard
14825 For non-reentrant
14826 \begin_inset LatexCommand index
14827 name "reentrant"
14828
14829 \end_inset
14830
14831  functions SDCC will try to reduce internal ram space usage by overlaying
14832  parameters and local variables of a function (if possible).
14833  Parameters and local variables
14834 \begin_inset LatexCommand index
14835 name "local variables"
14836
14837 \end_inset
14838
14839  of a function will be allocated to an overlayable segment if the function
14840  has 
14841 \emph on
14842 no other function calls and the function is non-reentrant and the memory
14843  model
14844 \begin_inset LatexCommand index
14845 name "Memory model"
14846
14847 \end_inset
14848
14849  is small.
14850
14851 \emph default
14852  If an explicit storage class
14853 \begin_inset LatexCommand index
14854 name "Storage class"
14855
14856 \end_inset
14857
14858  is specified for a local variable, it will NOT be overlaid.
14859 \end_layout
14860
14861 \begin_layout Standard
14862 Note that the compiler (not the linkage editor) makes the decision for overlayin
14863 g the data items.
14864  Functions that are called from an interrupt service routine
14865 \begin_inset Marginal
14866 status collapsed
14867
14868 \begin_layout Standard
14869
14870 \series bold
14871 !
14872 \end_layout
14873
14874 \end_inset
14875
14876  should be preceded by a #pragma\InsetSpace ~
14877 nooverlay
14878 \begin_inset LatexCommand index
14879 name "\\#pragma nooverlay"
14880
14881 \end_inset
14882
14883  if they are not reentrant.
14884 \end_layout
14885
14886 \begin_layout Standard
14887 Also note that the compiler does not do any processing of inline assembler
14888  code, so the compiler might incorrectly assign local variables and parameters
14889  of a function into the overlay segment if the inline assembler code calls
14890  other c-functions that might use the overlay.
14891  In that case the #pragma\InsetSpace ~
14892 nooverlay should be used.
14893 \end_layout
14894
14895 \begin_layout Standard
14896 Parameters and local variables of functions that contain 16 or 32 bit multiplica
14897 tion
14898 \begin_inset LatexCommand index
14899 name "Multiplication"
14900
14901 \end_inset
14902
14903  or division
14904 \begin_inset LatexCommand index
14905 name "Division"
14906
14907 \end_inset
14908
14909  will NOT be overlaid since these are implemented using external functions,
14910  e.g.:
14911 \end_layout
14912
14913 \begin_layout Verse
14914
14915 \family typewriter
14916 #pragma save 
14917 \newline
14918 #pragma nooverlay
14919 \begin_inset LatexCommand index
14920 name "\\#pragma nooverlay"
14921
14922 \end_inset
14923
14924  
14925 \newline
14926 void set_error(unsigned char errcd) 
14927 \newline
14928 {
14929 \newline
14930 \InsetSpace ~
14931 \InsetSpace ~
14932 \InsetSpace ~
14933 \InsetSpace ~
14934 P3 = errcd;
14935 \newline
14936
14937 \newline
14938 #pragma restore 
14939 \newline
14940
14941 \newline
14942 void
14943  some_isr () __interrupt
14944 \begin_inset LatexCommand index
14945 name "interrupt"
14946
14947 \end_inset
14948
14949  (2)
14950 \newline
14951 {
14952 \newline
14953 \InsetSpace ~
14954 \InsetSpace ~
14955 \InsetSpace ~
14956 \InsetSpace ~
14957 ...
14958 \newline
14959 \InsetSpace ~
14960 \InsetSpace ~
14961 \InsetSpace ~
14962 \InsetSpace ~
14963 set_error(10);
14964 \newline
14965 \InsetSpace ~
14966 \InsetSpace ~
14967 \InsetSpace ~
14968 \InsetSpace ~
14969 ...
14970  
14971 \newline
14972 }
14973 \end_layout
14974
14975 \begin_layout Standard
14976 In the above example the parameter 
14977 \emph on
14978 errcd
14979 \emph default
14980  for the function 
14981 \emph on
14982 set_error
14983 \emph default
14984  would be assigned to the overlayable segment if the #pragma\InsetSpace ~
14985 nooverlay was
14986  not present, this could cause unpredictable runtime behavior when called
14987  from an interrupt service routine.
14988  The #pragma\InsetSpace ~
14989 nooverlay ensures that the parameters and local variables for
14990  the function are NOT overlaid.
14991 \begin_inset VSpace bigskip
14992 \end_inset
14993
14994
14995 \end_layout
14996
14997 \begin_layout Section
14998 Interrupt Service Routines
14999 \begin_inset LatexCommand label
15000 name "sub:Interrupt-Service-Routines"
15001
15002 \end_inset
15003
15004
15005 \end_layout
15006
15007 \begin_layout Subsection
15008 General Information
15009 \end_layout
15010
15011 \begin_layout Standard
15012 SDCC allows 
15013 \emph on
15014 i
15015 \emph default
15016 nterrupt 
15017 \emph on
15018 s
15019 \emph default
15020 ervice 
15021 \emph on
15022 r
15023 \emph default
15024 outines to be coded in C, with some extended keywords.
15025 \end_layout
15026
15027 \begin_layout Verse
15028
15029 \family typewriter
15030 void timer_isr (void) __interrupt (1) __using (1) 
15031 \newline
15032
15033 \newline
15034 \InsetSpace ~
15035 \InsetSpace ~
15036 \InsetSpace ~
15037 \InsetSpace ~
15038 ...
15039  
15040 \newline
15041 }
15042 \end_layout
15043
15044 \begin_layout Standard
15045 The optional number following the 
15046 \emph on
15047 interrupt
15048 \begin_inset LatexCommand index
15049 name "interrupt"
15050
15051 \end_inset
15052
15053
15054 \begin_inset LatexCommand index
15055 name "\\_\\_interrupt"
15056
15057 \end_inset
15058
15059
15060 \emph default
15061  keyword is the interrupt number this routine will service.
15062  When present, the compiler will insert a call to this routine in the interrupt
15063  vector table
15064 \begin_inset LatexCommand index
15065 name "interrupt vector table"
15066
15067 \end_inset
15068
15069  for the interrupt number specified.
15070  If you have multiple source files in your project, interrupt service routines
15071  can be present in any of them, but a prototype of the isr MUST be present
15072  or included in the file that contains the function 
15073 \emph on
15074 main
15075 \emph default
15076 .
15077  The optional (8051 specific) keyword 
15078 \emph on
15079 using
15080 \begin_inset LatexCommand index
15081 name "using (mcs51, ds390 register bank)"
15082
15083 \end_inset
15084
15085
15086 \begin_inset LatexCommand index
15087 name "\\_\\_using (mcs51, ds390 register bank)"
15088
15089 \end_inset
15090
15091
15092 \emph default
15093  can be used to tell the compiler to use the specified register bank when
15094  generating code for this function.
15095  
15096 \newline
15097 Interrupt service routines open the door for some very interesting bugs:
15098 \end_layout
15099
15100 \begin_layout Subsubsection
15101 \begin_inset LatexCommand label
15102 name "sub:Common-interrupt-pitfall-volatile"
15103
15104 \end_inset
15105
15106 Common interrupt pitfall: variable not declared 
15107 \emph on
15108 volatile
15109 \end_layout
15110
15111 \begin_layout Standard
15112 If an interrupt service routine changes variables which are accessed by
15113  other functions these variables have to be declared 
15114 \emph on
15115 volatile
15116 \emph default
15117
15118 \begin_inset LatexCommand index
15119 name "volatile"
15120
15121 \end_inset
15122
15123 .
15124  See 
15125 \begin_inset LatexCommand url
15126 target "http://en.wikipedia.org/wiki/Volatile_variable"
15127
15128 \end_inset
15129
15130  .
15131 \end_layout
15132
15133 \begin_layout Subsubsection
15134 \begin_inset LatexCommand label
15135 name "sub:Common-interrupt-pitfall-non-atomic"
15136
15137 \end_inset
15138
15139 Common interrupt pitfall: 
15140 \emph on
15141 non-atomic access
15142 \end_layout
15143
15144 \begin_layout Standard
15145 If the access to these variables is not 
15146 \emph on
15147 atomic
15148 \begin_inset LatexCommand index
15149 name "atomic"
15150
15151 \end_inset
15152
15153
15154 \emph default
15155  (i.e.
15156  the processor needs more than one instruction for the access and could
15157  be interrupted while accessing the variable) the interrupt must be disabled
15158  during the access to avoid inconsistent data.
15159  
15160 \newline
15161 Access to 16 or 32 bit variables is obviously not atomic on 8 bit CPUs
15162  and should be protected by disabling interrupts.
15163  You're not automatically on the safe side if you use 8 bit variables though.
15164  We need an example here: f.e.
15165  on the 8051 the harmless looking 
15166 \begin_inset Quotes srd
15167 \end_inset
15168
15169
15170 \family typewriter
15171 flags\InsetSpace ~
15172 |=\InsetSpace ~
15173 0x80;
15174 \family default
15175
15176 \begin_inset Quotes sld
15177 \end_inset
15178
15179  is not atomic if 
15180 \family typewriter
15181 flags
15182 \family default
15183  resides in xdata.
15184  Setting 
15185 \begin_inset Quotes srd
15186 \end_inset
15187
15188
15189 \family typewriter
15190 flags\InsetSpace ~
15191 |=\InsetSpace ~
15192 0x40;
15193 \family default
15194
15195 \begin_inset Quotes sld
15196 \end_inset
15197
15198  from within an interrupt routine might get lost if the interrupt occurs
15199  at the wrong time.
15200  
15201 \begin_inset Quotes sld
15202 \end_inset
15203
15204
15205 \family typewriter
15206 counter\InsetSpace ~
15207 +=\InsetSpace ~
15208 8;
15209 \family default
15210
15211 \begin_inset Quotes srd
15212 \end_inset
15213
15214  is not atomic on the 8051 even if 
15215 \family typewriter
15216 counter
15217 \family default
15218  is located in data memory.
15219 \newline
15220 Bugs like these are hard to reproduce and can
15221  cause a lot of trouble.
15222  
15223 \end_layout
15224
15225 \begin_layout Subsubsection
15226 \begin_inset LatexCommand label
15227 name "sub:Common-interrupt-pitfall-stack-overflow"
15228
15229 \end_inset
15230
15231 Common interrupt pitfall: 
15232 \emph on
15233 stack overflow
15234 \end_layout
15235
15236 \begin_layout Standard
15237 The return address and the registers used in the interrupt service routine
15238  are saved on the stack
15239 \begin_inset LatexCommand index
15240 name "stack"
15241
15242 \end_inset
15243
15244  so there must be sufficient stack space.
15245  If there isn't variables or registers (or even the return address itself)
15246  will be corrupted.
15247  This 
15248 \emph on
15249 stack overflow
15250 \emph default
15251
15252 \begin_inset LatexCommand index
15253 name "stack overflow"
15254
15255 \end_inset
15256
15257  is most likely to happen if the interrupt occurs during the 
15258 \begin_inset Quotes sld
15259 \end_inset
15260
15261 deepest
15262 \begin_inset Quotes srd
15263 \end_inset
15264
15265  subroutine when the stack is already in use for f.e.
15266  many return addresses.
15267 \end_layout
15268
15269 \begin_layout Subsubsection
15270 \begin_inset LatexCommand label
15271 name "sub:Common-interrupt-pitfall-non-reentrant"
15272
15273 \end_inset
15274
15275 Common interrupt pitfall: 
15276 \emph on
15277 use of non-reentrant functions
15278 \end_layout
15279
15280 \begin_layout Standard
15281 A special note here, int (16 bit) and long (32 bit) integer division
15282 \begin_inset LatexCommand index
15283 name "Division"
15284
15285 \end_inset
15286
15287 , multiplication
15288 \begin_inset LatexCommand index
15289 name "Multiplication"
15290
15291 \end_inset
15292
15293  & modulus
15294 \begin_inset LatexCommand index
15295 name "Modulus"
15296
15297 \end_inset
15298
15299  and floating-point
15300 \begin_inset LatexCommand index
15301 name "Floating point support"
15302
15303 \end_inset
15304
15305  operations are implemented using external support routines.
15306  If an interrupt service routine needs to do any of these operations then
15307  the support routines (as mentioned in a following section) will have to
15308  be recompiled using the 
15309 \emph on
15310 -
15311 \begin_inset ERT
15312 status collapsed
15313
15314 \begin_layout Standard
15315
15316
15317 \backslash
15318 /
15319 \end_layout
15320
15321 \end_inset
15322
15323 -stack-auto
15324 \begin_inset LatexCommand index
15325 name "-\\/-stack-auto"
15326
15327 \end_inset
15328
15329
15330 \emph default
15331  option and the source file will need to be compiled using the 
15332 \emph on
15333 -
15334 \begin_inset ERT
15335 status collapsed
15336
15337 \begin_layout Standard
15338
15339
15340 \backslash
15341 /
15342 \end_layout
15343
15344 \end_inset
15345
15346 -int-long-reent
15347 \emph default
15348
15349 \begin_inset LatexCommand index
15350 name "-\\/-int-long-reent"
15351
15352 \end_inset
15353
15354  compiler option.
15355  
15356 \newline
15357 Note, the type promotion
15358 \begin_inset LatexCommand index
15359 name "type promotion"
15360
15361 \end_inset
15362
15363  required by ANSI C can cause 16 bit routines to be used
15364 \begin_inset Marginal
15365 status collapsed
15366
15367 \begin_layout Standard
15368
15369 \series bold
15370 \InsetSpace ~
15371 !
15372 \end_layout
15373
15374 \end_inset
15375
15376  without the programmer being aware of it.
15377  See f.e.
15378  the cast 
15379 \family typewriter
15380 \series bold
15381 (unsigned char)(tail-1)
15382 \family default
15383 \series default
15384  
15385 \series bold
15386 within the if clause in section 
15387 \begin_inset LatexCommand ref
15388 reference "sub:A-Step-by Assembler Introduction"
15389
15390 \end_inset
15391
15392 .
15393 \end_layout
15394
15395 \begin_layout Standard
15396 Calling other functions from an interrupt service routine is not recommended,
15397  avoid it if possible.
15398  Note that when some function is called from an interrupt service routine
15399  it should be preceded by a #pragma\InsetSpace ~
15400 nooverlay
15401 \begin_inset LatexCommand index
15402 name "\\#pragma nooverlay"
15403
15404 \end_inset
15405
15406  if it is not reentrant.
15407  Furthermore nonreentrant functions should not be called from the main program
15408  while the interrupt service routine might be active.
15409  They also must not be called from low priority interrupt service routines
15410  while a high priority interrupt service routine might be active.
15411  You could use semaphores or make the function 
15412 \emph on
15413 critical
15414 \emph default
15415  if all parameters are passed in registers.
15416 \newline
15417  Also see section 
15418 \begin_inset LatexCommand ref
15419 reference "sub:Overlaying"
15420
15421 \end_inset
15422
15423 \InsetSpace ~
15424 about Overlaying and section 
15425 \begin_inset LatexCommand ref
15426 reference "sub:Functions-using-private-banks"
15427
15428 \end_inset
15429
15430 \InsetSpace ~
15431 about Functions using private register banks.
15432 \begin_inset VSpace bigskip
15433 \end_inset
15434
15435
15436 \end_layout
15437
15438 \begin_layout Subsection
15439 MCS51/DS390 Interrupt Service Routines
15440 \end_layout
15441
15442 \begin_layout Standard
15443 Interrupt
15444 \begin_inset LatexCommand index
15445 name "interrupt"
15446
15447 \end_inset
15448
15449  numbers and the corresponding address & descriptions for the Standard 8051/8052
15450  are listed below.
15451  SDCC will automatically adjust the 
15452 \begin_inset LatexCommand index
15453 name "interrupt vector table"
15454
15455 \end_inset
15456
15457  to the maximum interrupt number specified.
15458 \newline
15459
15460 \end_layout
15461
15462 \begin_layout Standard
15463 \align center
15464 \begin_inset Tabular
15465 <lyxtabular version="3" rows="9" columns="3">
15466 <features>
15467 <column alignment="center" valignment="top" leftline="true" width="0in">
15468 <column alignment="left" valignment="top" leftline="true" width="0in">
15469 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0in">
15470 <row topline="true" bottomline="true">
15471 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15472 \begin_inset Text
15473
15474 \begin_layout Standard
15475 Interrupt #
15476 \end_layout
15477
15478 \end_inset
15479 </cell>
15480 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15481 \begin_inset Text
15482
15483 \begin_layout Standard
15484 Description
15485 \end_layout
15486
15487 \end_inset
15488 </cell>
15489 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
15490 \begin_inset Text
15491
15492 \begin_layout Standard
15493 Vector Address
15494 \end_layout
15495
15496 \end_inset
15497 </cell>
15498 </row>
15499 <row topline="true">
15500 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15501 \begin_inset Text
15502
15503 \begin_layout Standard
15504 0
15505 \end_layout
15506
15507 \end_inset
15508 </cell>
15509 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15510 \begin_inset Text
15511
15512 \begin_layout Standard
15513 External 0
15514 \end_layout
15515
15516 \end_inset
15517 </cell>
15518 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
15519 \begin_inset Text
15520
15521 \begin_layout Standard
15522 0x0003
15523 \end_layout
15524
15525 \end_inset
15526 </cell>
15527 </row>
15528 <row topline="true">
15529 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15530 \begin_inset Text
15531
15532 \begin_layout Standard
15533 1
15534 \end_layout
15535
15536 \end_inset
15537 </cell>
15538 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15539 \begin_inset Text
15540
15541 \begin_layout Standard
15542 Timer 0
15543 \end_layout
15544
15545 \end_inset
15546 </cell>
15547 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
15548 \begin_inset Text
15549
15550 \begin_layout Standard
15551 0x000b
15552 \end_layout
15553
15554 \end_inset
15555 </cell>
15556 </row>
15557 <row topline="true">
15558 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15559 \begin_inset Text
15560
15561 \begin_layout Standard
15562 2
15563 \end_layout
15564
15565 \end_inset
15566 </cell>
15567 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15568 \begin_inset Text
15569
15570 \begin_layout Standard
15571 External 1
15572 \end_layout
15573
15574 \end_inset
15575 </cell>
15576 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
15577 \begin_inset Text
15578
15579 \begin_layout Standard
15580 0x0013
15581 \end_layout
15582
15583 \end_inset
15584 </cell>
15585 </row>
15586 <row topline="true">
15587 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15588 \begin_inset Text
15589
15590 \begin_layout Standard
15591 3
15592 \end_layout
15593
15594 \end_inset
15595 </cell>
15596 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15597 \begin_inset Text
15598
15599 \begin_layout Standard
15600 Timer 1
15601 \end_layout
15602
15603 \end_inset
15604 </cell>
15605 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
15606 \begin_inset Text
15607
15608 \begin_layout Standard
15609 0x001b
15610 \end_layout
15611
15612 \end_inset
15613 </cell>
15614 </row>
15615 <row topline="true">
15616 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15617 \begin_inset Text
15618
15619 \begin_layout Standard
15620 4
15621 \end_layout
15622
15623 \end_inset
15624 </cell>
15625 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15626 \begin_inset Text
15627
15628 \begin_layout Standard
15629 Serial
15630 \end_layout
15631
15632 \end_inset
15633 </cell>
15634 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
15635 \begin_inset Text
15636
15637 \begin_layout Standard
15638 0x0023
15639 \end_layout
15640
15641 \end_inset
15642 </cell>
15643 </row>
15644 <row topline="true">
15645 <cell multicolumn="1" alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15646 \begin_inset Text
15647
15648 \begin_layout Standard
15649 5
15650 \end_layout
15651
15652 \end_inset
15653 </cell>
15654 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15655 \begin_inset Text
15656
15657 \begin_layout Standard
15658 Timer 2 (8052)
15659 \end_layout
15660
15661 \end_inset
15662 </cell>
15663 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
15664 \begin_inset Text
15665
15666 \begin_layout Standard
15667 0x002b
15668 \end_layout
15669
15670 \end_inset
15671 </cell>
15672 </row>
15673 <row topline="true">
15674 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15675 \begin_inset Text
15676
15677 \begin_layout Standard
15678 ...
15679 \end_layout
15680
15681 \end_inset
15682 </cell>
15683 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15684 \begin_inset Text
15685
15686 \begin_layout Standard
15687
15688 \end_layout
15689
15690 \end_inset
15691 </cell>
15692 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
15693 \begin_inset Text
15694
15695 \begin_layout Standard
15696 ...
15697 \end_layout
15698
15699 \end_inset
15700 </cell>
15701 </row>
15702 <row topline="true" bottomline="true">
15703 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15704 \begin_inset Text
15705
15706 \begin_layout Standard
15707 n
15708 \end_layout
15709
15710 \end_inset
15711 </cell>
15712 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
15713 \begin_inset Text
15714
15715 \begin_layout Standard
15716
15717 \end_layout
15718
15719 \end_inset
15720 </cell>
15721 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
15722 \begin_inset Text
15723
15724 \begin_layout Standard
15725 0x0003 + 8*n
15726 \end_layout
15727
15728 \end_inset
15729 </cell>
15730 </row>
15731 </lyxtabular>
15732
15733 \end_inset
15734
15735
15736 \newline
15737
15738 \end_layout
15739
15740 \begin_layout Standard
15741 If the interrupt service routine is defined without 
15742 \emph on
15743 using
15744 \begin_inset LatexCommand index
15745 name "using (mcs51, ds390 register bank)"
15746
15747 \end_inset
15748
15749
15750 \begin_inset LatexCommand index
15751 name "\\_\\_using (mcs51, ds390 register bank)"
15752
15753 \end_inset
15754
15755
15756 \emph default
15757  a register bank or with register bank 0 (
15758 \emph on
15759 using
15760 \emph default
15761  0), the compiler will save the registers used by itself on the stack upon
15762  entry and restore them at exit, however if such an interrupt service routine
15763  calls another function then the entire register bank will be saved on the
15764  stack.
15765  This scheme may be advantageous for small interrupt service routines which
15766  have low register usage.
15767 \end_layout
15768
15769 \begin_layout Standard
15770 If the interrupt service routine is defined to be using a specific register
15771  bank then only 
15772 \emph on
15773 a, b, dptr
15774 \emph default
15775  & psw are saved and restored, if such an interrupt service routine calls
15776  another function (using another register bank) then the entire register
15777  bank of the called function will be saved on the stack
15778 \begin_inset LatexCommand index
15779 name "stack"
15780
15781 \end_inset
15782
15783 .
15784  This scheme is recommended for larger interrupt service routines.
15785 \begin_inset VSpace bigskip
15786 \end_inset
15787
15788
15789 \end_layout
15790
15791 \begin_layout Subsection
15792 HC08
15793 \begin_inset LatexCommand index
15794 name "HC08"
15795
15796 \end_inset
15797
15798  Interrupt Service Routines
15799 \end_layout
15800
15801 \begin_layout Standard
15802 Since the number of interrupts
15803 \begin_inset LatexCommand index
15804 name "HC08!interrupt"
15805
15806 \end_inset
15807
15808  available is chip specific and the interrupt vector table always ends at
15809  the last byte of memory, the interrupt numbers corresponds to the interrupt
15810  vectors in reverse order of address.
15811  For example, interrupt 1 will use the interrupt vector at 0xfffc, interrupt
15812  2 will use the interrupt vector at 0xfffa, and so on.
15813  However, interrupt 0 (the reset vector at 0xfffe) is not redefinable in
15814  this way; instead see section 
15815 \begin_inset LatexCommand ref
15816 reference "sub:Startup-Code"
15817
15818 \end_inset
15819
15820  for details on customizing startup.
15821 \begin_inset VSpace bigskip
15822 \end_inset
15823
15824
15825 \end_layout
15826
15827 \begin_layout Subsection
15828 Z80 Interrupt Service Routines
15829 \end_layout
15830
15831 \begin_layout Standard
15832 The Z80
15833 \begin_inset LatexCommand index
15834 name "Z80"
15835
15836 \end_inset
15837
15838  uses several different methods for determining the correct interrupt
15839 \begin_inset LatexCommand index
15840 name "Z80!interrupt"
15841
15842 \end_inset
15843
15844  vector depending on the hardware implementation.
15845  Therefore, SDCC ignores the optional interrupt number and does not attempt
15846  to generate an interrupt vector table.
15847 \end_layout
15848
15849 \begin_layout Standard
15850 By default, SDCC generates code for a maskable interrupt, which uses a RETI
15851  instruction to return from the interrupt.
15852  To write an interrupt handler for the non-maskable interrupt, which needs
15853  a RETN instruction instead, add the 
15854 \emph on
15855 critical
15856 \emph default
15857  keyword:
15858 \end_layout
15859
15860 \begin_layout Verse
15861
15862 \family typewriter
15863 void nmi_isr (void) critical interrupt
15864 \newline
15865
15866 \newline
15867 \InsetSpace ~
15868 \InsetSpace ~
15869 \InsetSpace ~
15870 \InsetSpace ~
15871 ...
15872  
15873 \newline
15874 }
15875 \end_layout
15876
15877 \begin_layout Standard
15878 However if you need to create a non-interruptable interrupt service routine
15879  you would also require the 
15880 \emph on
15881 critical
15882 \emph default
15883  keyword.
15884  To distinguish between this and an nmi_isr you must provide an interrupt
15885  number.
15886 \begin_inset VSpace bigskip
15887 \end_inset
15888
15889
15890 \end_layout
15891
15892 \begin_layout Section
15893 Enabling and Disabling Interrupts
15894 \end_layout
15895
15896 \begin_layout Subsection
15897 Critical Functions and Critical Statements
15898 \end_layout
15899
15900 \begin_layout Standard
15901 A special keyword may be associated with a block or a function declaring
15902  it as 
15903 \emph on
15904 critical
15905 \emph default
15906 .
15907  SDCC will generate code to disable all interrupts
15908 \begin_inset LatexCommand index
15909 name "interrupt"
15910
15911 \end_inset
15912
15913  upon entry to a critical function and restore the interrupt enable to the
15914  previous state before returning.
15915  Nesting critical functions will need one additional byte on the stack
15916 \begin_inset LatexCommand index
15917 name "stack"
15918
15919 \end_inset
15920
15921  for each call.
15922 \end_layout
15923
15924 \begin_layout Verse
15925
15926 \family typewriter
15927 int foo () __critical
15928 \begin_inset LatexCommand index
15929 name "critical"
15930
15931 \end_inset
15932
15933
15934 \begin_inset LatexCommand index
15935 name "\\_\\_critical"
15936
15937 \end_inset
15938
15939  
15940 \newline
15941
15942 \newline
15943 \InsetSpace ~
15944 \InsetSpace ~
15945 \InsetSpace ~
15946 \InsetSpace ~
15947 ...
15948  
15949 \newline
15950 \InsetSpace ~
15951 \InsetSpace ~
15952 \InsetSpace ~
15953 \InsetSpace ~
15954 ...
15955  
15956 \newline
15957 }
15958 \end_layout
15959
15960 \begin_layout Standard
15961 The critical attribute maybe used with other attributes like 
15962 \emph on
15963 reentrant.
15964 \emph default
15965
15966 \newline
15967 The keyword 
15968 \emph on
15969 critical
15970 \emph default
15971  may also be used to disable interrupts more locally:
15972 \end_layout
15973
15974 \begin_layout Verse
15975
15976 \family typewriter
15977 __critical{ i++; }
15978 \end_layout
15979
15980 \begin_layout Standard
15981 More than one statement could have been included in the block.
15982 \end_layout
15983
15984 \begin_layout Subsection
15985 Enabling and Disabling Interrupts directly
15986 \end_layout
15987
15988 \begin_layout Standard
15989 Interrupts
15990 \begin_inset LatexCommand index
15991 name "interrupt"
15992
15993 \end_inset
15994
15995  can also be disabled and enabled directly (8051):
15996 \end_layout
15997
15998 \begin_layout Verse
15999
16000 \family typewriter
16001 EA = 0;\InsetSpace ~
16002 \InsetSpace ~
16003 \InsetSpace ~
16004 \InsetSpace ~
16005 \InsetSpace ~
16006 \InsetSpace ~
16007 \InsetSpace ~
16008 \InsetSpace ~
16009 \InsetSpace ~
16010 \InsetSpace ~
16011 \InsetSpace ~
16012 \InsetSpace ~
16013 or:\InsetSpace ~
16014 \InsetSpace ~
16015 \InsetSpace ~
16016 \InsetSpace ~
16017 \InsetSpace ~
16018 \InsetSpace ~
16019 \InsetSpace ~
16020 \InsetSpace ~
16021 \InsetSpace ~
16022 \InsetSpace ~
16023 \InsetSpace ~
16024 EA_SAVE = EA;
16025 \end_layout
16026
16027 \begin_layout Verse
16028
16029 \family typewriter
16030 ...\InsetSpace ~
16031 \InsetSpace ~
16032 \InsetSpace ~
16033 \InsetSpace ~
16034 \InsetSpace ~
16035 \InsetSpace ~
16036 \InsetSpace ~
16037 \InsetSpace ~
16038 \InsetSpace ~
16039 \InsetSpace ~
16040 \InsetSpace ~
16041 \InsetSpace ~
16042 \InsetSpace ~
16043 \InsetSpace ~
16044 \InsetSpace ~
16045 \InsetSpace ~
16046 \InsetSpace ~
16047 \InsetSpace ~
16048 \InsetSpace ~
16049 \InsetSpace ~
16050 \InsetSpace ~
16051 \InsetSpace ~
16052 \InsetSpace ~
16053 \InsetSpace ~
16054 \InsetSpace ~
16055 \InsetSpace ~
16056 \InsetSpace ~
16057 \InsetSpace ~
16058 \InsetSpace ~
16059 \InsetSpace ~
16060 EA = 0;
16061 \end_layout
16062
16063 \begin_layout Verse
16064
16065 \family typewriter
16066 EA = 1;\InsetSpace ~
16067 \InsetSpace ~
16068 \InsetSpace ~
16069 \InsetSpace ~
16070 \InsetSpace ~
16071 \InsetSpace ~
16072 \InsetSpace ~
16073 \InsetSpace ~
16074 \InsetSpace ~
16075 \InsetSpace ~
16076 \InsetSpace ~
16077 \InsetSpace ~
16078 \InsetSpace ~
16079 \InsetSpace ~
16080 \InsetSpace ~
16081 \InsetSpace ~
16082 \InsetSpace ~
16083 \InsetSpace ~
16084 \InsetSpace ~
16085 \InsetSpace ~
16086 \InsetSpace ~
16087 \InsetSpace ~
16088 \InsetSpace ~
16089 \InsetSpace ~
16090 \InsetSpace ~
16091 \InsetSpace ~
16092 ...
16093 \end_layout
16094
16095 \begin_layout Verse
16096
16097 \family typewriter
16098 \InsetSpace ~
16099 \InsetSpace ~
16100 \InsetSpace ~
16101 \InsetSpace ~
16102 \InsetSpace ~
16103 \InsetSpace ~
16104 \InsetSpace ~
16105 \InsetSpace ~
16106 \InsetSpace ~
16107 \InsetSpace ~
16108 \InsetSpace ~
16109 \InsetSpace ~
16110 \InsetSpace ~
16111 \InsetSpace ~
16112 \InsetSpace ~
16113 \InsetSpace ~
16114 \InsetSpace ~
16115 \InsetSpace ~
16116 \InsetSpace ~
16117 \InsetSpace ~
16118 \InsetSpace ~
16119 \InsetSpace ~
16120 \InsetSpace ~
16121 \InsetSpace ~
16122 \InsetSpace ~
16123 \InsetSpace ~
16124 \InsetSpace ~
16125 \InsetSpace ~
16126 \InsetSpace ~
16127 \InsetSpace ~
16128 \InsetSpace ~
16129 \InsetSpace ~
16130 \InsetSpace ~
16131 EA = EA_SAVE;
16132 \end_layout
16133
16134 \begin_layout Standard
16135 On other architectures which have separate opcodes for enabling and disabling
16136  interrupts you might want to make use of defines with inline assembly
16137 \begin_inset LatexCommand index
16138 name "Assembler routines"
16139
16140 \end_inset
16141
16142  (HC08
16143 \begin_inset LatexCommand index
16144 name "HC08!interrupt"
16145
16146 \end_inset
16147
16148 ):
16149 \end_layout
16150
16151 \begin_layout Verse
16152
16153 \family typewriter
16154 #define CLI _asm
16155 \begin_inset LatexCommand index
16156 name "\\_asm"
16157
16158 \end_inset
16159
16160 \InsetSpace ~
16161 \InsetSpace ~
16162 cli\InsetSpace ~
16163 \InsetSpace ~
16164 _endasm
16165 \begin_inset LatexCommand index
16166 name "\\_endasm"
16167
16168 \end_inset
16169
16170
16171 \end_layout
16172
16173 \begin_layout Verse
16174
16175 \family typewriter
16176 #define SEI _asm\InsetSpace ~
16177 \InsetSpace ~
16178 sei\InsetSpace ~
16179 \InsetSpace ~
16180 _endasm; 
16181 \end_layout
16182
16183 \begin_layout Verse
16184
16185 \family typewriter
16186 ...
16187 \end_layout
16188
16189 \begin_layout Standard
16190 Note: it is sometimes sufficient to disable only a specific interrupt source
16191  like f.e.
16192  a timer or serial interrupt by manipulating an 
16193 \emph on
16194 interrupt mask
16195 \begin_inset LatexCommand index
16196 name "interrupt mask"
16197
16198 \end_inset
16199
16200
16201 \emph default
16202  register.
16203  
16204 \end_layout
16205
16206 \begin_layout Standard
16207 Usually the time during which interrupts are disabled should be kept as
16208  short as possible.
16209  This minimizes both 
16210 \emph on
16211 interrupt latency
16212 \emph default
16213
16214 \begin_inset LatexCommand index
16215 name "interrupt latency"
16216
16217 \end_inset
16218
16219  (the time between the occurrence of the interrupt and the execution of
16220  the first code in the interrupt routine) and 
16221 \emph on
16222 interrupt jitter
16223 \emph default
16224
16225 \begin_inset LatexCommand index
16226 name "interrupt jitter"
16227
16228 \end_inset
16229
16230  (the difference between the shortest and the longest interrupt latency).
16231  These really are something different, f.e.
16232  a serial interrupt has to be served before its buffer overruns so it cares
16233  for the maximum interrupt latency, whereas it does not care about jitter.
16234  On a loudspeaker driven via a digital to analog converter which is fed
16235  by an interrupt a latency of a few milliseconds might be tolerable, whereas
16236  a much smaller jitter will be very audible.
16237 \end_layout
16238
16239 \begin_layout Standard
16240 You can reenable interrupts within an interrupt routine and on some architecture
16241 s you can make use of two (or more) levels of 
16242 \emph on
16243 interrupt priorities
16244 \emph default
16245
16246 \begin_inset LatexCommand index
16247 name "interrupt priority"
16248
16249 \end_inset
16250
16251 .
16252  On some architectures which don't support interrupt priorities these can
16253  be implemented by manipulating the interrupt mask and reenabling interrupts
16254  within the interrupt routine.
16255  Check there is sufficient space on the stack
16256 \begin_inset LatexCommand index
16257 name "stack"
16258
16259 \end_inset
16260
16261  and don't add complexity unless you have to.
16262  
16263 \end_layout
16264
16265 \begin_layout Subsection
16266 Semaphore
16267 \begin_inset LatexCommand index
16268 name "semaphore"
16269
16270 \end_inset
16271
16272  locking (mcs51/ds390)
16273 \end_layout
16274
16275 \begin_layout Standard
16276 Some architectures (mcs51/ds390) have an atomic
16277 \begin_inset LatexCommand index
16278 name "atomic"
16279
16280 \end_inset
16281
16282  bit test and clear instruction.
16283  These type of instructions are typically used in preemptive multitasking
16284  systems, where a routine f.e.
16285  claims the use of a data structure ('acquires a lock
16286 \begin_inset LatexCommand index
16287 name "lock"
16288
16289 \end_inset
16290
16291  on it'), makes some modifications and then releases the lock when the data
16292  structure is consistent again.
16293  The instruction may also be used if interrupt and non-interrupt code have
16294  to compete for a resource.
16295  With the atomic bit test and clear instruction interrupts
16296 \begin_inset LatexCommand index
16297 name "interrupt"
16298
16299 \end_inset
16300
16301  don't have to be disabled for the locking operation.
16302  
16303 \end_layout
16304
16305 \begin_layout Standard
16306 SDCC generates this instruction if the source follows this pattern:
16307 \end_layout
16308
16309 \begin_layout Verse
16310
16311 \family typewriter
16312 volatile
16313 \begin_inset LatexCommand index
16314 name "volatile"
16315
16316 \end_inset
16317
16318  bit resource_is_free; 
16319 \newline
16320
16321 \newline
16322 if (resource_is_free) 
16323 \newline
16324 \InsetSpace ~
16325 \InsetSpace ~
16326
16327 \newline
16328 \InsetSpace ~
16329 \InsetSpace ~
16330 \InsetSpace ~
16331 \InsetSpace ~
16332 resource_is_free=0; 
16333 \newline
16334 \InsetSpace ~
16335 \InsetSpace ~
16336 \InsetSpace ~
16337 \InsetSpace ~
16338 ...
16339  
16340 \newline
16341 \InsetSpace ~
16342 \InsetSpace ~
16343 \InsetSpace ~
16344 \InsetSpace ~
16345 resource_is_free=1;
16346 \newline
16347 \InsetSpace ~
16348 \InsetSpace ~
16349
16350 \end_layout
16351
16352 \begin_layout Standard
16353 Note, mcs51 and ds390 support only an atomic
16354 \begin_inset LatexCommand index
16355 name "atomic"
16356
16357 \end_inset
16358
16359  bit test and 
16360 \emph on
16361 clear
16362 \emph default
16363  instruction (as opposed to atomic bit test and 
16364 \emph on
16365 set).
16366 \end_layout
16367
16368 \begin_layout Section
16369 Functions using private register banks
16370 \begin_inset LatexCommand label
16371 name "sub:Functions-using-private-banks"
16372
16373 \end_inset
16374
16375  (mcs51/ds390)
16376 \end_layout
16377
16378 \begin_layout Standard
16379 Some architectures have support for quickly changing register sets.
16380  SDCC supports this feature with the 
16381 \emph on
16382 using
16383 \begin_inset LatexCommand index
16384 name "using (mcs51, ds390 register bank)"
16385
16386 \end_inset
16387
16388
16389 \begin_inset LatexCommand index
16390 name "\\_\\_using (mcs51, ds390 register bank)"
16391
16392 \end_inset
16393
16394
16395 \emph default
16396  attribute (which tells the compiler to use a register bank
16397 \begin_inset LatexCommand index
16398 name "register bank (mcs51, ds390)"
16399
16400 \end_inset
16401
16402  other than the default bank zero).
16403  It should only be applied to 
16404 \emph on
16405 interrupt
16406 \begin_inset LatexCommand index
16407 name "interrupt"
16408
16409 \end_inset
16410
16411
16412 \emph default
16413  functions (see footnote below).
16414  This will in most circumstances make the generated ISR code more efficient
16415  since it will not have to save registers on the stack.
16416 \end_layout
16417
16418 \begin_layout Standard
16419 The 
16420 \emph on
16421 using
16422 \emph default
16423  attribute will have no effect on the generated code for a 
16424 \emph on
16425 non-interrupt
16426 \emph default
16427  function (but may occasionally be useful anyway
16428 \begin_inset Foot
16429 status open
16430
16431 \begin_layout Standard
16432 possible exception: if a function is called ONLY from 'interrupt' functions
16433  using a particular bank, it can be declared with the same 'using' attribute
16434  as the calling 'interrupt' functions.
16435  For instance, if you have several ISRs using bank one, and all of them
16436  call memcpy(), it might make sense to create a specialized version of memcpy()
16437  'using 1', since this would prevent the ISR from having to save bank zero
16438  to the stack on entry and switch to bank zero before calling the function
16439 \end_layout
16440
16441 \end_inset
16442
16443 ).
16444 \newline
16445
16446 \emph on
16447 (pending: Note, nowadays the
16448 \emph default
16449  using 
16450 \emph on
16451 attribute has an effect on
16452 \emph default
16453  
16454 \emph on
16455 the generated code for a
16456 \emph default
16457  non-interrupt 
16458 \emph on
16459 function
16460 \emph default
16461 .
16462 \emph on
16463 )
16464 \end_layout
16465
16466 \begin_layout Standard
16467 An 
16468 \emph on
16469 interrupt
16470 \emph default
16471  function using a non-zero bank will assume that it can trash that register
16472  bank, and will not save it.
16473  Since high-priority interrupts
16474 \begin_inset LatexCommand index
16475 name "interrupts"
16476
16477 \end_inset
16478
16479
16480 \begin_inset LatexCommand index
16481 name "interrupt priority"
16482
16483 \end_inset
16484
16485  can interrupt low-priority ones on the 8051 and friends, this means that
16486  if a high-priority ISR 
16487 \emph on
16488 using
16489 \emph default
16490  a particular bank occurs while processing a low-priority ISR 
16491 \emph on
16492 using
16493 \emph default
16494  the same bank, terrible and bad things can happen.
16495  To prevent this, no single register bank should be 
16496 \emph on
16497 used
16498 \emph default
16499  by both a high priority and a low priority ISR.
16500  This is probably most easily done by having all high priority ISRs use
16501  one bank and all low priority ISRs use another.
16502  If you have an ISR which can change priority at runtime, you're on your
16503  own: I suggest using the default bank zero and taking the small performance
16504  hit.
16505 \end_layout
16506
16507 \begin_layout Standard
16508 It is most efficient if your ISR calls no other functions.
16509  If your ISR must call other functions, it is most efficient if those functions
16510  use the same bank as the ISR (see note 1 below); the next best is if the
16511  called functions use bank zero.
16512  It is very inefficient to call a function using a different, non-zero bank
16513  from an ISR.
16514  
16515 \begin_inset VSpace bigskip
16516 \end_inset
16517
16518
16519 \end_layout
16520
16521 \begin_layout Section
16522 Startup Code
16523 \begin_inset LatexCommand label
16524 name "sub:Startup-Code"
16525
16526 \end_inset
16527
16528
16529 \begin_inset LatexCommand index
16530 name "Startup code"
16531
16532 \end_inset
16533
16534
16535 \end_layout
16536
16537 \begin_layout Subsection
16538 MCS51/DS390 Startup Code
16539 \end_layout
16540
16541 \begin_layout Standard
16542 The compiler triggers the linker to link certain initialization modules
16543  from the runtime library
16544 \begin_inset LatexCommand index
16545 name "Runtime library"
16546
16547 \end_inset
16548
16549  called crt<something>.
16550  Only the necessary ones are linked, for instance crtxstack.asm (GSINIT1,
16551  GSINIT5) is not linked unless the -
16552 \series bold
16553
16554 \begin_inset ERT
16555 status open
16556
16557 \begin_layout Standard
16558
16559
16560 \backslash
16561 /
16562 \end_layout
16563
16564 \end_inset
16565
16566
16567 \series default
16568 -xstack option is used.
16569  These modules are highly entangled by the use of special segments/areas,
16570  but a common layout is shown below:
16571 \end_layout
16572
16573 \begin_layout Verse
16574
16575 \family typewriter
16576 \series bold
16577 \size footnotesize
16578 (main.asm)
16579 \end_layout
16580
16581 \begin_layout Verse
16582
16583 \family typewriter
16584 \size footnotesize
16585 \InsetSpace ~
16586 \InsetSpace ~
16587 \InsetSpace ~
16588 \InsetSpace ~
16589 \InsetSpace ~
16590 \InsetSpace ~
16591 \InsetSpace ~
16592 \InsetSpace ~
16593 .area HOME (CODE)
16594 \newline
16595 __interrupt_vect:
16596 \newline
16597 \InsetSpace ~
16598 \InsetSpace ~
16599 \InsetSpace ~
16600 \InsetSpace ~
16601 \InsetSpace ~
16602 \InsetSpace ~
16603 \InsetSpace ~
16604 \InsetSpace ~
16605 ljmp __sdcc_gsinit_startup
16606 \end_layout
16607
16608 \begin_layout Verse
16609
16610 \family typewriter
16611 \series bold
16612 \size footnotesize
16613 (crtstart.asm)
16614 \end_layout
16615
16616 \begin_layout Verse
16617
16618 \family typewriter
16619 \size footnotesize
16620 \InsetSpace ~
16621 \InsetSpace ~
16622 \InsetSpace ~
16623 \InsetSpace ~
16624 \InsetSpace ~
16625 \InsetSpace ~
16626 \InsetSpace ~
16627 \InsetSpace ~
16628 .area GSINIT0 (CODE)
16629 \newline
16630 __sdcc_gsinit_startup::
16631 \newline
16632 \InsetSpace ~
16633 \InsetSpace ~
16634 \InsetSpace ~
16635 \InsetSpace ~
16636 \InsetSpace ~
16637 \InsetSpace ~
16638 \InsetSpace ~
16639 \InsetSpace ~
16640 mov sp,#__start__stack - 1
16641 \end_layout
16642
16643 \begin_layout Verse
16644
16645 \family typewriter
16646 \series bold
16647 \size footnotesize
16648 (crtxstack.asm)
16649 \end_layout
16650
16651 \begin_layout Verse
16652
16653 \family typewriter
16654 \size footnotesize
16655 \InsetSpace ~
16656 \InsetSpace ~
16657 \InsetSpace ~
16658 \InsetSpace ~
16659 \InsetSpace ~
16660 \InsetSpace ~
16661 \InsetSpace ~
16662 \InsetSpace ~
16663 .area GSINIT1 (CODE)
16664 \newline
16665 __sdcc_init_xstack::
16666 \newline
16667 ; Need to initialize in GSINIT1 in
16668  case the user's __sdcc_external_startup uses the xstack.
16669 \newline
16670 \InsetSpace ~
16671 \InsetSpace ~
16672 \InsetSpace ~
16673 \InsetSpace ~
16674 \InsetSpace ~
16675 \InsetSpace ~
16676 \InsetSpace ~
16677 \InsetSpace ~
16678 mov __XPAGE,#(__start__x
16679 stack >> 8)
16680 \newline
16681 \InsetSpace ~
16682 \InsetSpace ~
16683 \InsetSpace ~
16684 \InsetSpace ~
16685 \InsetSpace ~
16686 \InsetSpace ~
16687 \InsetSpace ~
16688 \InsetSpace ~
16689 mov _spx,#__start__xstack
16690 \end_layout
16691
16692 \begin_layout Verse
16693
16694 \family typewriter
16695 \series bold
16696 \size footnotesize
16697 (crtstart.asm)
16698 \end_layout
16699
16700 \begin_layout Verse
16701
16702 \family typewriter
16703 \size footnotesize
16704 \InsetSpace ~
16705 \InsetSpace ~
16706 \InsetSpace ~
16707 \InsetSpace ~
16708 \InsetSpace ~
16709 \InsetSpace ~
16710 \InsetSpace ~
16711 \InsetSpace ~
16712 .area GSINIT2 (CODE)
16713 \newline
16714 \InsetSpace ~
16715 \InsetSpace ~
16716 \InsetSpace ~
16717 \InsetSpace ~
16718 \InsetSpace ~
16719 \InsetSpace ~
16720 \InsetSpace ~
16721 \InsetSpace ~
16722 lcall __sdcc_external_startup
16723 \newline
16724 \InsetSpace ~
16725 \InsetSpace ~
16726 \InsetSpace ~
16727 \InsetSpace ~
16728 \InsetSpace ~
16729 \InsetSpace ~
16730 \InsetSpace ~
16731 \InsetSpace ~
16732 mov a,dpl
16733 \newline
16734 \InsetSpace ~
16735 \InsetSpace ~
16736 \InsetSpace ~
16737 \InsetSpace ~
16738 \InsetSpace ~
16739 \InsetSpace ~
16740 \InsetSpace ~
16741 \InsetSpace ~
16742 jz __sdcc_init_data
16743 \newline
16744 \InsetSpace ~
16745 \InsetSpace ~
16746 \InsetSpace ~
16747 \InsetSpace ~
16748 \InsetSpace ~
16749 \InsetSpace ~
16750 \InsetSpace ~
16751 \InsetSpace ~
16752 ljmp
16753  __sdcc_program_startup
16754 \newline
16755 __sdcc_init_data:
16756 \end_layout
16757
16758 \begin_layout Verse
16759
16760 \family typewriter
16761 \series bold
16762 \size footnotesize
16763 (crtxinit.asm)
16764 \end_layout
16765
16766 \begin_layout Verse
16767
16768 \family typewriter
16769 \size footnotesize
16770 \InsetSpace ~
16771 \InsetSpace ~
16772 \InsetSpace ~
16773 \InsetSpace ~
16774 \InsetSpace ~
16775 \InsetSpace ~
16776 \InsetSpace ~
16777 \InsetSpace ~
16778 .area GSINIT3 (CODE)
16779 \newline
16780 __mcs51_genXINIT::
16781 \newline
16782 \InsetSpace ~
16783 \InsetSpace ~
16784 \InsetSpace ~
16785 \InsetSpace ~
16786 \InsetSpace ~
16787 \InsetSpace ~
16788 \InsetSpace ~
16789 \InsetSpace ~
16790 mov r1,#l_XINIT
16791 \newline
16792 \InsetSpace ~
16793 \InsetSpace ~
16794 \InsetSpace ~
16795 \InsetSpace ~
16796 \InsetSpace ~
16797 \InsetSpace ~
16798 \InsetSpace ~
16799 \InsetSpace ~
16800 mov a,r1
16801 \newline
16802 \InsetSpace ~
16803 \InsetSpace ~
16804 \InsetSpace ~
16805 \InsetSpace ~
16806 \InsetSpace ~
16807 \InsetSpace ~
16808 \InsetSpace ~
16809 \InsetSpace ~
16810 orl a,#(l_XINIT
16811  >> 8)
16812 \newline
16813 \InsetSpace ~
16814 \InsetSpace ~
16815 \InsetSpace ~
16816 \InsetSpace ~
16817 \InsetSpace ~
16818 \InsetSpace ~
16819 \InsetSpace ~
16820 \InsetSpace ~
16821 jz 00003$
16822 \newline
16823 \InsetSpace ~
16824 \InsetSpace ~
16825 \InsetSpace ~
16826 \InsetSpace ~
16827 \InsetSpace ~
16828 \InsetSpace ~
16829 \InsetSpace ~
16830 \InsetSpace ~
16831 mov r2,#((l_XINIT+255) >> 8)
16832 \newline
16833 \InsetSpace ~
16834 \InsetSpace ~
16835 \InsetSpace ~
16836 \InsetSpace ~
16837 \InsetSpace ~
16838 \InsetSpace ~
16839 \InsetSpace ~
16840 \InsetSpace ~
16841 mov dptr,#s_XINIT
16842 \newline
16843 \InsetSpace ~
16844 \InsetSpace ~
16845 \InsetSpace ~
16846 \InsetSpace ~
16847 \InsetSpace ~
16848 \InsetSpace ~
16849 \InsetSpace ~
16850 \InsetSpace ~
16851 mov r0,#s_XISEG
16852 \newline
16853 \InsetSpace ~
16854 \InsetSpace ~
16855 \InsetSpace ~
16856 \InsetSpace ~
16857 \InsetSpace ~
16858 \InsetSpace ~
16859 \InsetSpace ~
16860 \InsetSpace ~
16861 mov
16862  __XPAGE,#(s_XISEG >> 8)
16863 \newline
16864 00001$:\InsetSpace ~
16865 clr a
16866 \newline
16867 \InsetSpace ~
16868 \InsetSpace ~
16869 \InsetSpace ~
16870 \InsetSpace ~
16871 \InsetSpace ~
16872 \InsetSpace ~
16873 \InsetSpace ~
16874 \InsetSpace ~
16875 movc a,@a+dptr
16876 \newline
16877 \InsetSpace ~
16878 \InsetSpace ~
16879 \InsetSpace ~
16880 \InsetSpace ~
16881 \InsetSpace ~
16882 \InsetSpace ~
16883 \InsetSpace ~
16884 \InsetSpace ~
16885 movx @r0,a
16886 \newline
16887 \InsetSpace ~
16888 \InsetSpace ~
16889 \InsetSpace ~
16890 \InsetSpace ~
16891 \InsetSpace ~
16892 \InsetSpace ~
16893 \InsetSpace ~
16894 \InsetSpace ~
16895 inc dptr
16896 \newline
16897 \InsetSpace ~
16898 \InsetSpace ~
16899 \InsetSpace ~
16900 \InsetSpace ~
16901 \InsetSpace ~
16902 \InsetSpace ~
16903 \InsetSpace ~
16904 \InsetSpace ~
16905 inc
16906  r0
16907 \newline
16908 \InsetSpace ~
16909 \InsetSpace ~
16910 \InsetSpace ~
16911 \InsetSpace ~
16912 \InsetSpace ~
16913 \InsetSpace ~
16914 \InsetSpace ~
16915 \InsetSpace ~
16916 cjne r0,#0,00002$
16917 \newline
16918 \InsetSpace ~
16919 \InsetSpace ~
16920 \InsetSpace ~
16921 \InsetSpace ~
16922 \InsetSpace ~
16923 \InsetSpace ~
16924 \InsetSpace ~
16925 \InsetSpace ~
16926 inc __XPAGE
16927 \newline
16928 00002$:\InsetSpace ~
16929 djnz r1,00001$
16930 \newline
16931 \InsetSpace ~
16932 \InsetSpace ~
16933 \InsetSpace ~
16934 \InsetSpace ~
16935 \InsetSpace ~
16936 \InsetSpace ~
16937 \InsetSpace ~
16938 \InsetSpace ~
16939 djnz r2,00001$
16940 \newline
16941 \InsetSpace ~
16942 \InsetSpace ~
16943 \InsetSpace ~
16944 \InsetSpace ~
16945 \InsetSpace ~
16946 \InsetSpace ~
16947 \InsetSpace ~
16948 \InsetSpace ~
16949 mov __XPAGE,#0
16950 xFF
16951 \newline
16952 00003$:
16953 \end_layout
16954
16955 \begin_layout Verse
16956
16957 \family typewriter
16958 \series bold
16959 \size footnotesize
16960 (crtclear.asm)
16961 \end_layout
16962
16963 \begin_layout Verse
16964
16965 \family typewriter
16966 \size footnotesize
16967 \InsetSpace ~
16968 \InsetSpace ~
16969 \InsetSpace ~
16970 \InsetSpace ~
16971 \InsetSpace ~
16972 \InsetSpace ~
16973 \InsetSpace ~
16974 \InsetSpace ~
16975 .area GSINIT4 (CODE)
16976 \newline
16977 __mcs51_genRAMCLEAR::
16978 \newline
16979 \InsetSpace ~
16980 \InsetSpace ~
16981 \InsetSpace ~
16982 \InsetSpace ~
16983 \InsetSpace ~
16984 \InsetSpace ~
16985 \InsetSpace ~
16986 \InsetSpace ~
16987 clr a
16988 \newline
16989 \InsetSpace ~
16990 \InsetSpace ~
16991 \InsetSpace ~
16992 \InsetSpace ~
16993 \InsetSpace ~
16994 \InsetSpace ~
16995 \InsetSpace ~
16996 \InsetSpace ~
16997 mov r0,#(l_IRAM-1)
16998 \newline
16999 00004$:\InsetSpace ~
17000 mov
17001  @r0,a
17002 \newline
17003 \InsetSpace ~
17004 \InsetSpace ~
17005 \InsetSpace ~
17006 \InsetSpace ~
17007 \InsetSpace ~
17008 \InsetSpace ~
17009 \InsetSpace ~
17010 \InsetSpace ~
17011 djnz r0,00004$
17012 \newline
17013 ; _mcs51_genRAMCLEAR() end
17014 \end_layout
17015
17016 \begin_layout Verse
17017
17018 \family typewriter
17019 \series bold
17020 \size footnotesize
17021 (crtxclear.asm)
17022 \end_layout
17023
17024 \begin_layout Verse
17025
17026 \family typewriter
17027 \size footnotesize
17028 \InsetSpace ~
17029 \InsetSpace ~
17030 \InsetSpace ~
17031 \InsetSpace ~
17032 \InsetSpace ~
17033 \InsetSpace ~
17034 \InsetSpace ~
17035 \InsetSpace ~
17036 .area GSINIT4 (CODE)
17037 \newline
17038 __mcs51_genXRAMCLEAR::
17039 \newline
17040 \InsetSpace ~
17041 \InsetSpace ~
17042 \InsetSpace ~
17043 \InsetSpace ~
17044 \InsetSpace ~
17045 \InsetSpace ~
17046 \InsetSpace ~
17047 \InsetSpace ~
17048 mov r0,#l_PSEG
17049 \newline
17050 \InsetSpace ~
17051 \InsetSpace ~
17052 \InsetSpace ~
17053 \InsetSpace ~
17054 \InsetSpace ~
17055 \InsetSpace ~
17056 \InsetSpace ~
17057 \InsetSpace ~
17058 mov a,r0
17059 \newline
17060 \InsetSpace ~
17061 \InsetSpace ~
17062 \InsetSpace ~
17063 \InsetSpace ~
17064 \InsetSpace ~
17065 \InsetSpace ~
17066 \InsetSpace ~
17067 \InsetSpace ~
17068 orl a,#(l_PSEG
17069  >> 8)
17070 \newline
17071 \InsetSpace ~
17072 \InsetSpace ~
17073 \InsetSpace ~
17074 \InsetSpace ~
17075 \InsetSpace ~
17076 \InsetSpace ~
17077 \InsetSpace ~
17078 \InsetSpace ~
17079 jz 00006$
17080 \newline
17081 \InsetSpace ~
17082 \InsetSpace ~
17083 \InsetSpace ~
17084 \InsetSpace ~
17085 \InsetSpace ~
17086 \InsetSpace ~
17087 \InsetSpace ~
17088 \InsetSpace ~
17089 mov r1,#s_PSEG
17090 \newline
17091 \InsetSpace ~
17092 \InsetSpace ~
17093 \InsetSpace ~
17094 \InsetSpace ~
17095 \InsetSpace ~
17096 \InsetSpace ~
17097 \InsetSpace ~
17098 \InsetSpace ~
17099 mov __XPAGE,#(s_PSEG >> 8)
17100 \newline
17101 \InsetSpace ~
17102 \InsetSpace ~
17103 \InsetSpace ~
17104 \InsetSpace ~
17105 \InsetSpace ~
17106 \InsetSpace ~
17107 \InsetSpace ~
17108 \InsetSpace ~
17109 clr a
17110 \newline
17111 00005$:\InsetSpace ~
17112 movx
17113  @r1,a
17114 \newline
17115 \InsetSpace ~
17116 \InsetSpace ~
17117 \InsetSpace ~
17118 \InsetSpace ~
17119 \InsetSpace ~
17120 \InsetSpace ~
17121 \InsetSpace ~
17122 \InsetSpace ~
17123 inc r1
17124 \newline
17125 \InsetSpace ~
17126 \InsetSpace ~
17127 \InsetSpace ~
17128 \InsetSpace ~
17129 \InsetSpace ~
17130 \InsetSpace ~
17131 \InsetSpace ~
17132 \InsetSpace ~
17133 djnz r0,00005$
17134 \newline
17135 00006$:
17136 \newline
17137 \InsetSpace ~
17138 \InsetSpace ~
17139 \InsetSpace ~
17140 \InsetSpace ~
17141 \InsetSpace ~
17142 \InsetSpace ~
17143 \InsetSpace ~
17144 \InsetSpace ~
17145 mov r0,#l_XSEG
17146 \newline
17147 \InsetSpace ~
17148 \InsetSpace ~
17149 \InsetSpace ~
17150 \InsetSpace ~
17151 \InsetSpace ~
17152 \InsetSpace ~
17153 \InsetSpace ~
17154 \InsetSpace ~
17155 mov a,r0
17156 \newline
17157 \InsetSpace ~
17158 \InsetSpace ~
17159 \InsetSpace ~
17160 \InsetSpace ~
17161 \InsetSpace ~
17162 \InsetSpace ~
17163 \InsetSpace ~
17164 \InsetSpace ~
17165 orl a,#(l_XSEG >>
17166  8)
17167 \newline
17168 \InsetSpace ~
17169 \InsetSpace ~
17170 \InsetSpace ~
17171 \InsetSpace ~
17172 \InsetSpace ~
17173 \InsetSpace ~
17174 \InsetSpace ~
17175 \InsetSpace ~
17176 jz 00008$
17177 \newline
17178 \InsetSpace ~
17179 \InsetSpace ~
17180 \InsetSpace ~
17181 \InsetSpace ~
17182 \InsetSpace ~
17183 \InsetSpace ~
17184 \InsetSpace ~
17185 \InsetSpace ~
17186 mov r1,#((l_XSEG + 255) >> 8)
17187 \newline
17188 \InsetSpace ~
17189 \InsetSpace ~
17190 \InsetSpace ~
17191 \InsetSpace ~
17192 \InsetSpace ~
17193 \InsetSpace ~
17194 \InsetSpace ~
17195 \InsetSpace ~
17196 mov dptr,#s_XSEG
17197 \newline
17198 \InsetSpace ~
17199 \InsetSpace ~
17200 \InsetSpace ~
17201 \InsetSpace ~
17202 \InsetSpace ~
17203 \InsetSpace ~
17204 \InsetSpace ~
17205 \InsetSpace ~
17206 clr a
17207 \newline
17208 00007$:\InsetSpace ~
17209 movx
17210  @dptr,a
17211 \newline
17212 \InsetSpace ~
17213 \InsetSpace ~
17214 \InsetSpace ~
17215 \InsetSpace ~
17216 \InsetSpace ~
17217 \InsetSpace ~
17218 \InsetSpace ~
17219 \InsetSpace ~
17220 inc dptr
17221 \newline
17222 \InsetSpace ~
17223 \InsetSpace ~
17224 \InsetSpace ~
17225 \InsetSpace ~
17226 \InsetSpace ~
17227 \InsetSpace ~
17228 \InsetSpace ~
17229 \InsetSpace ~
17230 djnz r0,00007$
17231 \newline
17232 \InsetSpace ~
17233 \InsetSpace ~
17234 \InsetSpace ~
17235 \InsetSpace ~
17236 \InsetSpace ~
17237 \InsetSpace ~
17238 \InsetSpace ~
17239 \InsetSpace ~
17240 djnz r1,00007$
17241 \newline
17242 00008$:
17243 \end_layout
17244
17245 \begin_layout Verse
17246
17247 \family typewriter
17248 \series bold
17249 \size footnotesize
17250 (crtxstack.asm)
17251 \end_layout
17252
17253 \begin_layout Verse
17254
17255 \family typewriter
17256 \size footnotesize
17257 \InsetSpace ~
17258 \InsetSpace ~
17259 \InsetSpace ~
17260 \InsetSpace ~
17261 \InsetSpace ~
17262 \InsetSpace ~
17263 \InsetSpace ~
17264 \InsetSpace ~
17265 .area GSINIT5 (CODE)
17266 \newline
17267 ; Need to initialize in GSINIT5 because __mcs51_genXINIT
17268  modifies __XPAGE
17269 \newline
17270 ; and __mcs51_genRAMCLEAR modifies _spx.
17271 \newline
17272 \InsetSpace ~
17273 \InsetSpace ~
17274 \InsetSpace ~
17275 \InsetSpace ~
17276 \InsetSpace ~
17277 \InsetSpace ~
17278 \InsetSpace ~
17279 \InsetSpace ~
17280 mov __XPAGE,#(__start__x
17281 stack >> 8)
17282 \newline
17283 \InsetSpace ~
17284 \InsetSpace ~
17285 \InsetSpace ~
17286 \InsetSpace ~
17287 \InsetSpace ~
17288 \InsetSpace ~
17289 \InsetSpace ~
17290 \InsetSpace ~
17291 mov _spx,#__start__xstack
17292 \end_layout
17293
17294 \begin_layout Verse
17295
17296 \family typewriter
17297 \series bold
17298 \size footnotesize
17299 (application modules)
17300 \end_layout
17301
17302 \begin_layout Verse
17303
17304 \family typewriter
17305 \size footnotesize
17306 \InsetSpace ~
17307 \InsetSpace ~
17308 \InsetSpace ~
17309 \InsetSpace ~
17310 \InsetSpace ~
17311 \InsetSpace ~
17312 \InsetSpace ~
17313 \InsetSpace ~
17314 .area GSINIT (CODE)
17315 \end_layout
17316
17317 \begin_layout Verse
17318
17319 \family typewriter
17320 \series bold
17321 \size footnotesize
17322 (main.asm)
17323 \end_layout
17324
17325 \begin_layout Verse
17326
17327 \family typewriter
17328 \size footnotesize
17329 \InsetSpace ~
17330 \InsetSpace ~
17331 \InsetSpace ~
17332 \InsetSpace ~
17333 \InsetSpace ~
17334 \InsetSpace ~
17335 \InsetSpace ~
17336 \InsetSpace ~
17337 .area GSFINAL (CODE)
17338 \newline
17339 \InsetSpace ~
17340 \InsetSpace ~
17341 \InsetSpace ~
17342 \InsetSpace ~
17343 \InsetSpace ~
17344 \InsetSpace ~
17345 \InsetSpace ~
17346 \InsetSpace ~
17347 ljmp __sdcc_program_startup
17348 \newline
17349 ;---------------------------------
17350 -----------------------
17351 \newline
17352 ; Home
17353 \newline
17354 ;--------------------------------------------------
17355 ------
17356 \newline
17357 \InsetSpace ~
17358 \InsetSpace ~
17359 \InsetSpace ~
17360 \InsetSpace ~
17361 \InsetSpace ~
17362 \InsetSpace ~
17363 \InsetSpace ~
17364 \InsetSpace ~
17365 .area HOME (CODE)
17366 \newline
17367 \InsetSpace ~
17368 \InsetSpace ~
17369 \InsetSpace ~
17370 \InsetSpace ~
17371 \InsetSpace ~
17372 \InsetSpace ~
17373 \InsetSpace ~
17374 \InsetSpace ~
17375 .area CSEG (CODE)
17376 \newline
17377 __sdcc_program_startup:
17378 \newline
17379 \InsetSpace ~
17380 \InsetSpace ~
17381 \InsetSpace ~
17382 \InsetSpace ~
17383 \InsetSpace ~
17384 \InsetSpace ~
17385 \InsetSpace ~
17386 \InsetSpace ~
17387 lcall _main
17388 \newline
17389 ;
17390  return from main will lock up
17391 \newline
17392 \InsetSpace ~
17393 \InsetSpace ~
17394 \InsetSpace ~
17395 \InsetSpace ~
17396 \InsetSpace ~
17397 \InsetSpace ~
17398 \InsetSpace ~
17399 \InsetSpace ~
17400 sjmp .
17401 \end_layout
17402
17403 \begin_layout Standard
17404 One of these modules (crtstart.asm) contains a call to the C routine 
17405 \emph on
17406 _sdcc_external_startup()
17407 \begin_inset LatexCommand index
17408 name "\\_sdcc\\_external\\_startup()"
17409
17410 \end_inset
17411
17412
17413 \emph default
17414  at the start of the CODE area.
17415  This routine is also in the runtime library
17416 \begin_inset LatexCommand index
17417 name "Runtime library"
17418
17419 \end_inset
17420
17421  and returns 0 by default.
17422  If this routine returns a non-zero value, the static & global variable
17423  initialization will be skipped and the function main will be invoked.
17424  Otherwise static & global variables will be initialized before the function
17425  main is invoked.
17426  You could add an 
17427 \emph on
17428 _sdcc_external_startup()
17429 \emph default
17430  routine to your program to override the default if you need to setup hardware
17431  or perform some other critical operation prior to static & global variable
17432  initialization
17433 \begin_inset LatexCommand index
17434 name "Variable initialization"
17435
17436 \end_inset
17437
17438 .
17439  On some mcs51 variants xdata
17440 \begin_inset LatexCommand index
17441 name "xdata (mcs51, ds390 storage class)"
17442
17443 \end_inset
17444
17445  memory has to be explicitly enabled before it can be accessed or if the
17446  watchdog
17447 \begin_inset LatexCommand index
17448 name "watchdog"
17449
17450 \end_inset
17451
17452  needs to be disabled, this is the place to do it.
17453  The startup code clears all internal data memory, 256 bytes by default,
17454  but from 0 to n-1 if 
17455 \emph on
17456 -
17457 \begin_inset ERT
17458 status collapsed
17459
17460 \begin_layout Standard
17461
17462
17463 \backslash
17464 /
17465 \end_layout
17466
17467 \end_inset
17468
17469 -iram-size
17470 \begin_inset LatexCommand index
17471 name "-\\/-iram-size <Value>"
17472
17473 \end_inset
17474
17475 n
17476 \emph default
17477  is used.
17478  (recommended for Chipcon CC1010).
17479 \end_layout
17480
17481 \begin_layout Standard
17482 See also the compiler options 
17483 \emph on
17484 -
17485 \begin_inset ERT
17486 status collapsed
17487
17488 \begin_layout Standard
17489
17490
17491 \backslash
17492 /
17493 \end_layout
17494
17495 \end_inset
17496
17497 -no-xinit
17498 \emph default
17499 -
17500 \emph on
17501 opt
17502 \emph default
17503
17504 \begin_inset LatexCommand index
17505 name "-\\/-no-xinit-opt"
17506
17507 \end_inset
17508
17509
17510 \emph on
17511 -
17512 \begin_inset ERT
17513 status collapsed
17514
17515 \begin_layout Standard
17516
17517
17518 \backslash
17519 /
17520 \end_layout
17521
17522 \end_inset
17523
17524 -main-return
17525 \emph default
17526
17527 \begin_inset LatexCommand index
17528 name "-\\/-main-return"
17529
17530 \end_inset
17531
17532  and section 
17533 \begin_inset LatexCommand ref
17534 reference "sub:MCS51-variants"
17535
17536 \end_inset
17537
17538  about MCS51-variants.
17539 \newline
17540
17541 \end_layout
17542
17543 \begin_layout Standard
17544 While these initialization modules are meant as generic startup code there
17545  might be the need for customization.
17546  Let's assume the return value of 
17547 \emph on
17548 _sdcc_external_startup()
17549 \emph default
17550  in 
17551 \emph on
17552 crtstart.asm
17553 \emph default
17554  should not be checked (or 
17555 \emph on
17556 _sdcc_external_startup()
17557 \emph default
17558  should not be called at all).
17559  The recommended way would be to copy 
17560 \emph on
17561 crtstart.asm
17562 \emph default
17563  (f.e.
17564  from 
17565 \begin_inset LatexCommand url
17566 target "http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/device/lib/mcs51/crtstart.asm"
17567
17568 \end_inset
17569
17570 ) into the source directory, adapt it there, then assemble it with 
17571 \emph on
17572 asx8051 -plosgff
17573 \begin_inset Foot
17574 status open
17575
17576 \begin_layout Standard
17577 \begin_inset Quotes sld
17578 \end_inset
17579
17580 -plosgff
17581 \begin_inset Quotes srd
17582 \end_inset
17583
17584  are the assembler options used in 
17585 \begin_inset LatexCommand url
17586 target "http://sdcc.svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/device/lib/mcs51/Makefile.in?view=markup "
17587
17588 \end_inset
17589
17590
17591 \end_layout
17592
17593 \end_inset
17594
17595  crtstart.asm
17596 \emph default
17597  and when linking your project explicitly specify 
17598 \emph on
17599 crtstart.rel
17600 \emph default
17601 .
17602  As a bonus a listing of the relocated object file 
17603 \emph on
17604 crtstart.rst
17605 \emph default
17606  is generated.
17607 \end_layout
17608
17609 \begin_layout Standard
17610 \begin_inset VSpace bigskip
17611 \end_inset
17612
17613
17614 \end_layout
17615
17616 \begin_layout Subsection
17617 HC08 Startup Code
17618 \end_layout
17619
17620 \begin_layout Standard
17621 The HC08
17622 \begin_inset LatexCommand index
17623 name "HC08"
17624
17625 \end_inset
17626
17627  startup code follows the same scheme as the MCS51 startup code.
17628 \begin_inset VSpace bigskip
17629 \end_inset
17630
17631
17632 \end_layout
17633
17634 \begin_layout Subsection
17635 Z80 Startup Code
17636 \end_layout
17637
17638 \begin_layout Standard
17639 On the Z80
17640 \begin_inset LatexCommand index
17641 name "Z80"
17642
17643 \end_inset
17644
17645  the startup code is inserted by linking with crt0.o which is generated from
17646  sdcc/device/lib/z80/crt0.s.
17647  If you need a different startup code you can use the compiler option 
17648 \emph on
17649 -
17650 \series bold
17651 \emph default
17652
17653 \begin_inset ERT
17654 status collapsed
17655
17656 \begin_layout Standard
17657
17658
17659 \backslash
17660 /
17661 \end_layout
17662
17663 \end_inset
17664
17665
17666 \series default
17667 \emph on
17668 -no-std-crt0
17669 \emph default
17670
17671 \begin_inset LatexCommand index
17672 name "-\\/-no-std-crt0"
17673
17674 \end_inset
17675
17676  and provide your own crt0.o.
17677  
17678 \begin_inset VSpace bigskip
17679 \end_inset
17680
17681
17682 \end_layout
17683
17684 \begin_layout Section
17685 Inline Assembler Code
17686 \begin_inset LatexCommand index
17687 name "Assembler routines"
17688
17689 \end_inset
17690
17691
17692 \end_layout
17693
17694 \begin_layout Subsection
17695 A Step by Step Introduction
17696 \begin_inset LatexCommand label
17697 name "sub:A-Step-by Assembler Introduction"
17698
17699 \end_inset
17700
17701
17702 \end_layout
17703
17704 \begin_layout Standard
17705 Starting from a small snippet of c-code this example shows for the MCS51
17706  how to use inline assembly, access variables, a function parameter and
17707  an array in xdata memory.
17708  The example uses an MCS51 here but is easily adapted for other architectures.
17709  This is a buffer routine which should be optimized:
17710 \end_layout
17711
17712 \begin_layout Verse
17713
17714 \family typewriter
17715 \size footnotesize
17716 unsigned char __far
17717 \begin_inset LatexCommand index
17718 name "far (storage class)"
17719
17720 \end_inset
17721
17722
17723 \begin_inset LatexCommand index
17724 name "\\_\\_far (storage class)"
17725
17726 \end_inset
17727
17728  __at
17729 \begin_inset LatexCommand index
17730 name "at"
17731
17732 \end_inset
17733
17734
17735 \begin_inset LatexCommand index
17736 name "\\_\\_at"
17737
17738 \end_inset
17739
17740 (0x7f00) buf[0x100];
17741 \begin_inset LatexCommand index
17742 name "Aligned array"
17743
17744 \end_inset
17745
17746
17747 \newline
17748 unsigned char head, tail;\InsetSpace ~
17749 \InsetSpace ~
17750 \InsetSpace ~
17751 \InsetSpace ~
17752 \InsetSpace ~
17753 \InsetSpace ~
17754 \InsetSpace ~
17755 \InsetSpace ~
17756 \InsetSpace ~
17757 \InsetSpace ~
17758 \InsetSpace ~
17759 \InsetSpace ~
17760 \InsetSpace ~
17761 \InsetSpace ~
17762 \InsetSpace ~
17763 \InsetSpace ~
17764 \InsetSpace ~
17765 /* if interrupts
17766 \begin_inset LatexCommand index
17767 name "interrupt"
17768
17769 \end_inset
17770
17771  are involved see
17772 \newline
17773 \InsetSpace ~
17774 \InsetSpace ~
17775 \InsetSpace ~
17776 \InsetSpace ~
17777 \InsetSpace ~
17778 \InsetSpace ~
17779 \InsetSpace ~
17780 \InsetSpace ~
17781 \InsetSpace ~
17782 \InsetSpace ~
17783 \InsetSpace ~
17784 \InsetSpace ~
17785 \InsetSpace ~
17786 \InsetSpace ~
17787 \InsetSpace ~
17788 \InsetSpace ~
17789 \InsetSpace ~
17790 \InsetSpace ~
17791 \InsetSpace ~
17792 \InsetSpace ~
17793 \InsetSpace ~
17794 \InsetSpace ~
17795 \InsetSpace ~
17796 \InsetSpace ~
17797 \InsetSpace ~
17798 \InsetSpace ~
17799 \InsetSpace ~
17800 \InsetSpace ~
17801 \InsetSpace ~
17802 \InsetSpace ~
17803 \InsetSpace ~
17804 \InsetSpace ~
17805 \InsetSpace ~
17806 \InsetSpace ~
17807 \InsetSpace ~
17808 \InsetSpace ~
17809 \InsetSpace ~
17810 \InsetSpace ~
17811 \InsetSpace ~
17812 \InsetSpace ~
17813 \InsetSpace ~
17814 \InsetSpace ~
17815 \InsetSpace ~
17816 \InsetSpace ~
17817 \InsetSpace ~
17818 section 
17819 \begin_inset LatexCommand ref
17820 reference "sub:Common-interrupt-pitfall-volatile"
17821
17822 \end_inset
17823
17824  about
17825 \family default
17826  
17827 \family typewriter
17828 \series bold
17829 volatile
17830 \family default
17831 \series default
17832  
17833 \family typewriter
17834 */
17835 \newline
17836
17837 \newline
17838 void to_buffer( unsigned char c ) 
17839 \newline
17840 {
17841 \newline
17842 \InsetSpace ~
17843 \InsetSpace ~
17844 \InsetSpace ~
17845 \InsetSpace ~
17846 if( head != (unsigned char)(tail-1)
17847  )\InsetSpace ~
17848 /* cast
17849 \family default
17850  
17851 \family typewriter
17852 \series bold
17853 needed
17854 \family default
17855 \series default
17856  
17857 \family typewriter
17858 to avoid promotion
17859 \begin_inset LatexCommand index
17860 name "promotion to signed int"
17861
17862 \end_inset
17863
17864
17865 \begin_inset LatexCommand index
17866 name "type promotion"
17867
17868 \end_inset
17869
17870  to integer */
17871 \begin_inset Marginal
17872 status collapsed
17873
17874 \begin_layout Standard
17875
17876 \series bold
17877 \InsetSpace ~
17878 !
17879 \end_layout
17880
17881 \end_inset
17882
17883
17884 \newline
17885 \InsetSpace ~
17886 \InsetSpace ~
17887 \InsetSpace ~
17888 \InsetSpace ~
17889 \InsetSpace ~
17890 \InsetSpace ~
17891 \InsetSpace ~
17892 \InsetSpace ~
17893 buf[ head++ ] = c;\InsetSpace ~
17894 \InsetSpace ~
17895 \InsetSpace ~
17896 \InsetSpace ~
17897 \InsetSpace ~
17898 \InsetSpace ~
17899 \InsetSpace ~
17900 \InsetSpace ~
17901 \InsetSpace ~
17902 \InsetSpace ~
17903 \InsetSpace ~
17904 \InsetSpace ~
17905 \InsetSpace ~
17906 \InsetSpace ~
17907 \InsetSpace ~
17908 \InsetSpace ~
17909 /* access to a 256 byte aligned array */
17910 \newline
17911
17912 \end_layout
17913
17914 \begin_layout Standard
17915 If the code snippet (assume it is saved in buffer.c) is compiled with SDCC
17916  then a corresponding buffer.asm file is generated.
17917  We define a new function 
17918 \family typewriter
17919 to_buffer_asm()
17920 \family default
17921  in file buffer.c in which we cut and paste the generated code, removing
17922  unwanted comments and some ':'.
17923  Then add 
17924 \begin_inset Quotes sld
17925 \end_inset
17926
17927
17928 \series bold
17929 _asm
17930 \series default
17931
17932 \begin_inset Quotes srd
17933 \end_inset
17934
17935  and 
17936 \begin_inset Quotes sld
17937 \end_inset
17938
17939
17940 \series bold
17941 _endasm;
17942 \series default
17943
17944 \begin_inset Quotes srd
17945 \end_inset
17946
17947
17948 \begin_inset Foot
17949 status open
17950
17951 \begin_layout Standard
17952 Note, that the single underscore form (_asm and _endasm) are not C99-compatible,
17953  and for C-99 compatibility, the double-underscore form (__asm and __endasm)
17954  has to be used.
17955  The latter is also used in the library functions.
17956 \end_layout
17957
17958 \end_inset
17959
17960  to the beginning and the end of the function body:
17961 \end_layout
17962
17963 \begin_layout Verse
17964
17965 \family typewriter
17966 \size footnotesize
17967 /* With a cut and paste from the .asm file, we have something to start with.
17968 \newline
17969 \InsetSpace ~
17970 \InsetSpace ~
17971 \InsetSpace ~
17972 The
17973  function is not yet OK! (registers aren't saved) */ 
17974 \newline
17975 void to_buffer_asm(
17976  unsigned char c ) 
17977 \newline
17978
17979 \newline
17980 \InsetSpace ~
17981 \InsetSpace ~
17982 \InsetSpace ~
17983 \InsetSpace ~
17984 _asm
17985 \begin_inset LatexCommand index
17986 name "\\_asm"
17987
17988 \end_inset
17989
17990
17991 \begin_inset LatexCommand index
17992 name "\\_\\_asm"
17993
17994 \end_inset
17995
17996
17997 \newline
17998 \InsetSpace ~
17999 \InsetSpace ~
18000 \InsetSpace ~
18001 \InsetSpace ~
18002 mov\InsetSpace ~
18003 \InsetSpace ~
18004 r2,dpl 
18005 \newline
18006 ;buffer.c if( head != (unsigned char)(tail-1) ) \InsetSpace ~
18007 /* cast
18008 \family default
18009  
18010 \family typewriter
18011 \series bold
18012 needed
18013 \family default
18014 \series default
18015  
18016 \family typewriter
18017 to avoid promotion
18018 \begin_inset LatexCommand index
18019 name "promotion to signed int"
18020
18021 \end_inset
18022
18023
18024 \begin_inset LatexCommand index
18025 name "type promotion"
18026
18027 \end_inset
18028
18029  to integer */
18030 \newline
18031 \InsetSpace ~
18032 \InsetSpace ~
18033 \InsetSpace ~
18034 \InsetSpace ~
18035 mov\InsetSpace ~
18036 \InsetSpace ~
18037 a,_tail 
18038 \newline
18039 \InsetSpace ~
18040 \InsetSpace ~
18041 \InsetSpace ~
18042 \InsetSpace ~
18043 dec\InsetSpace ~
18044 \InsetSpace ~
18045
18046 \newline
18047 \InsetSpace ~
18048 \InsetSpace ~
18049 \InsetSpace ~
18050 \InsetSpace ~
18051 mov\InsetSpace ~
18052 \InsetSpace ~
18053 r3,a 
18054 \newline
18055 \InsetSpace ~
18056 \InsetSpace ~
18057 \InsetSpace ~
18058 \InsetSpace ~
18059 mov\InsetSpace ~
18060 \InsetSpace ~
18061 a,_head 
18062 \newline
18063 \InsetSpace ~
18064 \InsetSpace ~
18065 \InsetSpace ~
18066 \InsetSpace ~
18067 cjne a,ar3,00106$ 
18068 \newline
18069 \InsetSpace ~
18070 \InsetSpace ~
18071 \InsetSpace ~
18072 \InsetSpace ~
18073 ret
18074 \newline
18075 00106$:
18076  
18077 \newline
18078 ;buffer.c buf[ head++ ] = c; /* access to a 256 byte aligned array */
18079 \begin_inset LatexCommand index
18080 name "Aligned array"
18081
18082 \end_inset
18083
18084
18085 \newline
18086 \InsetSpace ~
18087 \InsetSpace ~
18088 \InsetSpace ~
18089 \InsetSpace ~
18090 mov\InsetSpace ~
18091 \InsetSpace ~
18092 r3,_head 
18093 \newline
18094 \InsetSpace ~
18095 \InsetSpace ~
18096 \InsetSpace ~
18097 \InsetSpace ~
18098 inc\InsetSpace ~
18099 \InsetSpace ~
18100 _head 
18101 \newline
18102 \InsetSpace ~
18103 \InsetSpace ~
18104 \InsetSpace ~
18105 \InsetSpace ~
18106 mov\InsetSpace ~
18107 \InsetSpace ~
18108 dpl,r3 
18109 \newline
18110 \InsetSpace ~
18111 \InsetSpace ~
18112 \InsetSpace ~
18113 \InsetSpace ~
18114 mov\InsetSpace ~
18115 \InsetSpace ~
18116 dph,#(_buf >> 8) 
18117 \newline
18118 \InsetSpace ~
18119 \InsetSpace ~
18120 \InsetSpace ~
18121 \InsetSpace ~
18122 mov\InsetSpace ~
18123 \InsetSpace ~
18124 a,r2 
18125 \newline
18126 \InsetSpace ~
18127 \InsetSpace ~
18128 \InsetSpace ~
18129 \InsetSpace ~
18130 movx @dptr,a
18131  
18132 \newline
18133 00103$: 
18134 \newline
18135 \InsetSpace ~
18136 \InsetSpace ~
18137 \InsetSpace ~
18138 \InsetSpace ~
18139 ret
18140 \newline
18141 \InsetSpace ~
18142 \InsetSpace ~
18143 \InsetSpace ~
18144 \InsetSpace ~
18145 _endasm
18146 \begin_inset LatexCommand index
18147 name "\\_endasm"
18148
18149 \end_inset
18150
18151
18152 \begin_inset LatexCommand index
18153 name "\\_\\_endasm"
18154
18155 \end_inset
18156
18157 ;
18158 \newline
18159
18160 \end_layout
18161
18162 \begin_layout Standard
18163 The new file buffer.c should compile with only one warning about the unreferenced
18164  function argument 'c'.
18165  Now we hand-optimize the assembly code and insert an #define USE_ASSEMBLY
18166  (1) and finally have:
18167 \end_layout
18168
18169 \begin_layout Verse
18170
18171 \family typewriter
18172 \size footnotesize
18173 unsigned char __far __at(0x7f00) buf[0x100];
18174 \newline
18175 unsigned char head, tail;
18176 \newline
18177 #define
18178  USE_ASSEMBLY (1)
18179 \newline
18180
18181 \newline
18182 #if !USE_ASSEMBLY
18183 \newline
18184
18185 \newline
18186 void to_buffer( unsigned char c )
18187 \newline
18188 {
18189 \newline
18190 \InsetSpace ~
18191 \InsetSpace ~
18192 \InsetSpace ~
18193 \InsetSpace ~
18194 if(
18195  head != (unsigned char)(tail-1) )
18196 \newline
18197 \InsetSpace ~
18198 \InsetSpace ~
18199 \InsetSpace ~
18200 \InsetSpace ~
18201 \InsetSpace ~
18202 \InsetSpace ~
18203 \InsetSpace ~
18204 \InsetSpace ~
18205 buf[ head++ ] = c;
18206 \newline
18207 }
18208 \newline
18209
18210 \newline
18211 #else
18212 \newline
18213
18214 \newline
18215 void to_buffer(
18216  unsigned char c )
18217 \newline
18218 {
18219 \newline
18220 \InsetSpace ~
18221 \InsetSpace ~
18222 \InsetSpace ~
18223 \InsetSpace ~
18224 c; // to avoid warning: unreferenced function argument
18225 \newline
18226 \InsetSpace ~
18227 \InsetSpace ~
18228 \InsetSpace ~
18229 \InsetSpace ~
18230 _asm
18231 \begin_inset LatexCommand index
18232 name "\\_asm"
18233
18234 \end_inset
18235
18236
18237 \begin_inset LatexCommand index
18238 name "\\_\\_asm"
18239
18240 \end_inset
18241
18242
18243 \newline
18244 \InsetSpace ~
18245 \InsetSpace ~
18246 \InsetSpace ~
18247 \InsetSpace ~
18248 \InsetSpace ~
18249 \InsetSpace ~
18250 \InsetSpace ~
18251 \InsetSpace ~
18252 ; save used registers here.
18253  
18254 \newline
18255 \InsetSpace ~
18256 \InsetSpace ~
18257 \InsetSpace ~
18258 \InsetSpace ~
18259 \InsetSpace ~
18260 \InsetSpace ~
18261 \InsetSpace ~
18262 \InsetSpace ~
18263 ; If we were still using r2,r3 we would have to push them here.
18264  
18265 \newline
18266 ; if( head != (unsigned char)(tail-1) )
18267 \newline
18268 \InsetSpace ~
18269 \InsetSpace ~
18270 \InsetSpace ~
18271 \InsetSpace ~
18272 \InsetSpace ~
18273 \InsetSpace ~
18274 \InsetSpace ~
18275 \InsetSpace ~
18276 mov\InsetSpace ~
18277  a,_tail
18278 \newline
18279 \InsetSpace ~
18280 \InsetSpace ~
18281 \InsetSpace ~
18282 \InsetSpace ~
18283 \InsetSpace ~
18284 \InsetSpace ~
18285 \InsetSpace ~
18286 \InsetSpace ~
18287 dec\InsetSpace ~
18288  a
18289 \newline
18290 \InsetSpace ~
18291 \InsetSpace ~
18292 \InsetSpace ~
18293 \InsetSpace ~
18294 \InsetSpace ~
18295 \InsetSpace ~
18296 \InsetSpace ~
18297 \InsetSpace ~
18298 xrl\InsetSpace ~
18299  a,_head
18300 \newline
18301 \InsetSpace ~
18302 \InsetSpace ~
18303 \InsetSpace ~
18304 \InsetSpace ~
18305 \InsetSpace ~
18306 \InsetSpace ~
18307 \InsetSpace ~
18308 \InsetSpace ~
18309 ; we
18310  could do an ANL a,#0x0f here to use a smaller buffer (see below)
18311 \newline
18312 \InsetSpace ~
18313 \InsetSpace ~
18314 \InsetSpace ~
18315 \InsetSpace ~
18316 \InsetSpace ~
18317 \InsetSpace ~
18318 \InsetSpace ~
18319 \InsetSpace ~
18320 jz\InsetSpace ~
18321 \InsetSpace ~
18322  t_b_end$
18323 \newline
18324 \InsetSpace ~
18325 \InsetSpace ~
18326 \InsetSpace ~
18327 \InsetSpace ~
18328 \InsetSpace ~
18329 \InsetSpace ~
18330 \InsetSpace ~
18331 \InsetSpace ~
18332 ;
18333 \newline
18334 ;
18335  buf[ head++ ] = c;
18336 \newline
18337 \InsetSpace ~
18338 \InsetSpace ~
18339 \InsetSpace ~
18340 \InsetSpace ~
18341 \InsetSpace ~
18342 \InsetSpace ~
18343 \InsetSpace ~
18344 \InsetSpace ~
18345 mov\InsetSpace ~
18346  a,dpl \InsetSpace ~
18347 \InsetSpace ~
18348 \InsetSpace ~
18349 \InsetSpace ~
18350 \InsetSpace ~
18351 \InsetSpace ~
18352 \InsetSpace ~
18353 ; dpl holds lower byte of function argument
18354 \newline
18355 \InsetSpace ~
18356 \InsetSpace ~
18357 \InsetSpace ~
18358 \InsetSpace ~
18359 \InsetSpace ~
18360 \InsetSpace ~
18361 \InsetSpace ~
18362 \InsetSpace ~
18363 mov\InsetSpace ~
18364
18365  dpl,_head \InsetSpace ~
18366 \InsetSpace ~
18367 \InsetSpace ~
18368 ; buf is 0x100 byte aligned so head can be used directly
18369 \newline
18370 \InsetSpace ~
18371 \InsetSpace ~
18372 \InsetSpace ~
18373 \InsetSpace ~
18374 \InsetSpace ~
18375 \InsetSpace ~
18376 \InsetSpace ~
18377 \InsetSpace ~
18378 mov\InsetSpace ~
18379  dph,#(_bu
18380 f>>8)
18381 \newline
18382 \InsetSpace ~
18383 \InsetSpace ~
18384 \InsetSpace ~
18385 \InsetSpace ~
18386 \InsetSpace ~
18387 \InsetSpace ~
18388 \InsetSpace ~
18389 \InsetSpace ~
18390 movx @dptr,a
18391 \newline
18392 \InsetSpace ~
18393 \InsetSpace ~
18394 \InsetSpace ~
18395 \InsetSpace ~
18396 \InsetSpace ~
18397 \InsetSpace ~
18398 \InsetSpace ~
18399 \InsetSpace ~
18400 inc \InsetSpace ~
18401 _head
18402 \newline
18403 \InsetSpace ~
18404 \InsetSpace ~
18405 \InsetSpace ~
18406 \InsetSpace ~
18407 \InsetSpace ~
18408 \InsetSpace ~
18409 \InsetSpace ~
18410 \InsetSpace ~
18411 ; we could do an ANL _head,#0x0f here to use a
18412  smaller buffer (see above)
18413 \newline
18414 t_b_end$:
18415 \newline
18416 \InsetSpace ~
18417 \InsetSpace ~
18418 \InsetSpace ~
18419 \InsetSpace ~
18420 \InsetSpace ~
18421 \InsetSpace ~
18422 \InsetSpace ~
18423 \InsetSpace ~
18424 ; restore used registers here 
18425 \newline
18426 \InsetSpace ~
18427 \InsetSpace ~
18428 \InsetSpace ~
18429 \InsetSpace ~
18430 _endasm
18431 \begin_inset LatexCommand index
18432 name "\\_endasm"
18433
18434 \end_inset
18435
18436
18437 \begin_inset LatexCommand index
18438 name "\\_\\_endasm"
18439
18440 \end_inset
18441
18442 ;
18443 \newline
18444 }
18445 \newline
18446 #endif
18447 \end_layout
18448
18449 \begin_layout Standard
18450 The inline assembler code can contain any valid code understood by the assembler
18451 , this includes any assembler directives and comment lines.
18452  The assembler does not like some characters like ':' or ''' in comments.
18453  You'll find an 100+ pages assembler manual in sdcc/as/doc/asxhtm.html
18454 \begin_inset LatexCommand index
18455 name "asXXXX (as-gbz80, as-hc08, asx8051, as-z80)"
18456
18457 \end_inset
18458
18459
18460 \begin_inset LatexCommand index
18461 name "Assembler documentation"
18462
18463 \end_inset
18464
18465  or online at 
18466 \begin_inset LatexCommand url
18467 target "http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/as/doc/asxhtm.html"
18468
18469 \end_inset
18470
18471 \InsetSpace ~
18472 .
18473 \end_layout
18474
18475 \begin_layout Standard
18476 The compiler does not do any validation of the code within the 
18477 \family typewriter
18478 _asm
18479 \begin_inset LatexCommand index
18480 name "\\_asm"
18481
18482 \end_inset
18483
18484
18485 \begin_inset LatexCommand index
18486 name "\\_\\_asm"
18487
18488 \end_inset
18489
18490  ...
18491  _endasm
18492 \size footnotesize
18493
18494 \begin_inset LatexCommand index
18495 name "\\_endasm"
18496
18497 \end_inset
18498
18499
18500 \begin_inset LatexCommand index
18501 name "\\_\\_endasm"
18502
18503 \end_inset
18504
18505
18506 \size default
18507 ;
18508 \family default
18509  keyword pair.
18510  Specifically it will not know which registers are used and thus register
18511  pushing/popping
18512 \begin_inset LatexCommand index
18513 name "push/pop"
18514
18515 \end_inset
18516
18517  has to be done manually.
18518  
18519 \end_layout
18520
18521 \begin_layout Standard
18522 It is recommended that each assembly instruction (including labels) be placed
18523  in a separate line (as the example shows).
18524  When the -
18525 \begin_inset ERT
18526 status collapsed
18527
18528 \begin_layout Standard
18529
18530
18531 \backslash
18532 /
18533 \end_layout
18534
18535 \end_inset
18536
18537 -
18538 \emph on
18539 peep-asm
18540 \begin_inset LatexCommand index
18541 name "-\\/-peep-asm"
18542
18543 \end_inset
18544
18545
18546 \emph default
18547  command line option is used, the inline assembler code will be passed through
18548  the peephole optimizer
18549 \begin_inset LatexCommand index
18550 name "Peephole optimizer"
18551
18552 \end_inset
18553
18554 .
18555  There are only a few (if any) cases where this option makes sense, it might
18556  cause some unexpected changes in the inline assembler code.
18557  Please go through the peephole optimizer rules defined in file 
18558 \emph on
18559 SDCCpeeph.def
18560 \emph default
18561  before using this option.
18562 \end_layout
18563
18564 \begin_layout Subsection
18565 Naked Functions
18566 \begin_inset LatexCommand label
18567 name "sub:Naked-Functions"
18568
18569 \end_inset
18570
18571
18572 \begin_inset LatexCommand index
18573 name "Naked functions"
18574
18575 \end_inset
18576
18577
18578 \end_layout
18579
18580 \begin_layout Standard
18581 A special keyword may be associated with a function declaring it as 
18582 \emph on
18583 _naked
18584 \begin_inset LatexCommand index
18585 name "\\_naked"
18586
18587 \end_inset
18588
18589
18590 \begin_inset LatexCommand index
18591 name "\\_\\_naked"
18592
18593 \end_inset
18594
18595 .
18596
18597 \emph default
18598  The 
18599 \emph on
18600 _naked
18601 \emph default
18602  function modifier attribute prevents the compiler from generating prologue
18603 \begin_inset LatexCommand index
18604 name "function prologue"
18605
18606 \end_inset
18607
18608  and epilogue
18609 \begin_inset LatexCommand index
18610 name "function epilogue"
18611
18612 \end_inset
18613
18614  code for that function.
18615  This means that the user is entirely responsible for such things as saving
18616  any registers that may need to be preserved, selecting the proper register
18617  bank, generating the 
18618 \emph on
18619 return
18620 \emph default
18621  instruction at the end, etc.
18622  Practically, this means that the contents of the function must be written
18623  in inline assembler.
18624  This is particularly useful for interrupt functions, which can have a large
18625  (and often unnecessary) prologue/epilogue.
18626  For example, compare the code generated by these two functions:
18627 \end_layout
18628
18629 \begin_layout Verse
18630
18631 \family typewriter
18632 volatile
18633 \begin_inset LatexCommand index
18634 name "volatile"
18635
18636 \end_inset
18637
18638  data unsigned char counter;
18639 \newline
18640
18641 \newline
18642 void simpleInterrupt(void) __interrupt
18643 \begin_inset LatexCommand index
18644 name "interrupt"
18645
18646 \end_inset
18647
18648
18649 \begin_inset LatexCommand index
18650 name "\\_\\_interrupt"
18651
18652 \end_inset
18653
18654  (1)
18655 \newline
18656 {
18657 \newline
18658 \InsetSpace ~
18659 \InsetSpace ~
18660 \InsetSpace ~
18661 \InsetSpace ~
18662 counter++;
18663 \newline
18664 }
18665 \newline
18666
18667 \newline
18668 void nakedInterrupt(void) __interrupt (2) __naked
18669 \newline
18670 {
18671 \newline
18672 \InsetSpace ~
18673 \InsetSpace ~
18674 \InsetSpace ~
18675 \InsetSpace ~
18676 _asm
18677 \begin_inset LatexCommand index
18678 name "\\_asm"
18679
18680 \end_inset
18681
18682
18683 \begin_inset LatexCommand index
18684 name "\\_\\_asm"
18685
18686 \end_inset
18687
18688
18689 \newline
18690 \InsetSpace ~
18691 \InsetSpace ~
18692 \InsetSpace ~
18693 \InsetSpace ~
18694 \InsetSpace ~
18695 \InsetSpace ~
18696 inc\InsetSpace ~
18697 \InsetSpace ~
18698 \InsetSpace ~
18699 \InsetSpace ~
18700 \InsetSpace ~
18701 _counter ; does not change flags, no need to save psw
18702 \newline
18703 \InsetSpace ~
18704 \InsetSpace ~
18705 \InsetSpace ~
18706 \InsetSpace ~
18707 \InsetSpace ~
18708 \InsetSpace ~
18709 reti\InsetSpace ~
18710 \InsetSpace ~
18711 \InsetSpace ~
18712 \InsetSpace ~
18713 ; MUST explicitly
18714  include ret or reti in _naked function.
18715 \newline
18716 \InsetSpace ~
18717 \InsetSpace ~
18718 \InsetSpace ~
18719 \InsetSpace ~
18720 _endasm
18721 \begin_inset LatexCommand index
18722 name "\\_endasm"
18723
18724 \end_inset
18725
18726
18727 \begin_inset LatexCommand index
18728 name "\\_\\_endasm"
18729
18730 \end_inset
18731
18732 ;
18733 \newline
18734 }
18735 \end_layout
18736
18737 \begin_layout Standard
18738 For an 8051 target, the generated simpleInterrupt looks like:
18739 \end_layout
18740
18741 \begin_layout Verse
18742
18743 \family typewriter
18744 Note, this is an
18745 \family default
18746  
18747 \family typewriter
18748 \emph on
18749 outdated
18750 \family default
18751 \emph default
18752  
18753 \family typewriter
18754 example, recent versions of SDCC generate
18755 \newline
18756 the
18757 \family default
18758  
18759 \family typewriter
18760 \emph on
18761 same
18762 \family default
18763 \emph default
18764  
18765 \family typewriter
18766 code for simpleInterrupt() and nakedInterrupt()!
18767 \newline
18768
18769 \newline
18770 _simpleInterrupt:
18771 \newline
18772 \InsetSpace ~
18773 \InsetSpace ~
18774 \InsetSpace ~
18775 \InsetSpace ~
18776 push\InsetSpace ~
18777 \InsetSpace ~
18778 \InsetSpace ~
18779 \InsetSpace ~
18780 acc
18781 \newline
18782 \InsetSpace ~
18783 \InsetSpace ~
18784 \InsetSpace ~
18785 \InsetSpace ~
18786 push\InsetSpace ~
18787 \InsetSpace ~
18788 \InsetSpace ~
18789 \InsetSpace ~
18790 b
18791 \newline
18792 \InsetSpace ~
18793 \InsetSpace ~
18794 \InsetSpace ~
18795 \InsetSpace ~
18796 pus
18797 h\InsetSpace ~
18798 \InsetSpace ~
18799 \InsetSpace ~
18800 \InsetSpace ~
18801 dpl
18802 \newline
18803 \InsetSpace ~
18804 \InsetSpace ~
18805 \InsetSpace ~
18806 \InsetSpace ~
18807 push\InsetSpace ~
18808 \InsetSpace ~
18809 \InsetSpace ~
18810 \InsetSpace ~
18811 dph
18812 \newline
18813 \InsetSpace ~
18814 \InsetSpace ~
18815 \InsetSpace ~
18816 \InsetSpace ~
18817 push\InsetSpace ~
18818 \InsetSpace ~
18819 \InsetSpace ~
18820 \InsetSpace ~
18821 psw
18822 \newline
18823 \InsetSpace ~
18824 \InsetSpace ~
18825 \InsetSpace ~
18826 \InsetSpace ~
18827 mov\InsetSpace ~
18828 \InsetSpace ~
18829 \InsetSpace ~
18830 \InsetSpace ~
18831 \InsetSpace ~
18832 psw,#0x00
18833 \newline
18834 \InsetSpace ~
18835 \InsetSpace ~
18836 \InsetSpace ~
18837 \InsetSpace ~
18838 inc\InsetSpace ~
18839 \InsetSpace ~
18840 \InsetSpace ~
18841 \InsetSpace ~
18842 \InsetSpace ~
18843 _counter
18844 \newline
18845 \InsetSpace ~
18846 \InsetSpace ~
18847 \InsetSpace ~
18848 \InsetSpace ~
18849 pop\InsetSpace ~
18850 \InsetSpace ~
18851 \InsetSpace ~
18852 \InsetSpace ~
18853 \InsetSpace ~
18854 psw
18855 \newline
18856 \InsetSpace ~
18857 \InsetSpace ~
18858 \InsetSpace ~
18859 \InsetSpace ~
18860 pop\InsetSpace ~
18861 \InsetSpace ~
18862 \InsetSpace ~
18863 \InsetSpace ~
18864 \InsetSpace ~
18865 dph
18866 \newline
18867 \InsetSpace ~
18868 \InsetSpace ~
18869 \InsetSpace ~
18870 \InsetSpace ~
18871 pop\InsetSpace ~
18872 \InsetSpace ~
18873 \InsetSpace ~
18874 \InsetSpace ~
18875 \InsetSpace ~
18876 dpl
18877 \newline
18878 \InsetSpace ~
18879 \InsetSpace ~
18880 \InsetSpace ~
18881 \InsetSpace ~
18882 pop\InsetSpace ~
18883 \InsetSpace ~
18884 \InsetSpace ~
18885 \InsetSpace ~
18886 \InsetSpace ~
18887 b
18888 \newline
18889 \InsetSpace ~
18890 \InsetSpace ~
18891 \InsetSpace ~
18892 \InsetSpace ~
18893 pop\InsetSpace ~
18894 \InsetSpace ~
18895 \InsetSpace ~
18896 \InsetSpace ~
18897 \InsetSpace ~
18898 acc
18899 \newline
18900 \InsetSpace ~
18901 \InsetSpace ~
18902 \InsetSpace ~
18903 \InsetSpace ~
18904 reti
18905 \end_layout
18906
18907 \begin_layout Standard
18908 whereas nakedInterrupt looks like:
18909 \end_layout
18910
18911 \begin_layout Verse
18912
18913 \family typewriter
18914 _nakedInterrupt:
18915 \newline
18916 \InsetSpace ~
18917 \InsetSpace ~
18918 \InsetSpace ~
18919 \InsetSpace ~
18920 inc\InsetSpace ~
18921 \InsetSpace ~
18922 \InsetSpace ~
18923 \InsetSpace ~
18924 _counter ; does not change flags, no need to save psw
18925 \newline
18926 \InsetSpace ~
18927 \InsetSpace ~
18928 \InsetSpace ~
18929 \InsetSpace ~
18930 reti\InsetSpace ~
18931 \InsetSpace ~
18932 \InsetSpace ~
18933 \InsetSpace ~
18934 \InsetSpace ~
18935 \InsetSpace ~
18936 \InsetSpace ~
18937 \InsetSpace ~
18938 \InsetSpace ~
18939 \InsetSpace ~
18940 \InsetSpace ~
18941 \InsetSpace ~
18942 ;
18943  MUST explicitly include ret or reti in _naked function
18944 \end_layout
18945
18946 \begin_layout Standard
18947 The related directive #pragma exclude
18948 \begin_inset LatexCommand index
18949 name "\\#pragma exclude"
18950
18951 \end_inset
18952
18953  allows a more fine grained control over pushing & popping
18954 \begin_inset LatexCommand index
18955 name "push/pop"
18956
18957 \end_inset
18958
18959  the registers.
18960 \end_layout
18961
18962 \begin_layout Standard
18963 While there is nothing preventing you from writing C code inside a 
18964 \family typewriter
18965 _naked
18966 \family default
18967  function, there are many ways to shoot yourself in the foot doing this,
18968  and it is recommended that you stick to inline assembler.
18969 \end_layout
18970
18971 \begin_layout Subsection
18972 Use of Labels within Inline Assembler
18973 \end_layout
18974
18975 \begin_layout Standard
18976 SDCC allows the use of in-line assembler with a few restrictions regarding
18977  labels.
18978  All labels defined within inline assembler code have to be of the form
18979  
18980 \emph on
18981 nnnnn$
18982 \emph default
18983  where nnnnn is a number less than 100 (which implies a limit of utmost
18984  100 inline assembler labels 
18985 \emph on
18986 per function
18987 \emph default
18988 \noun on
18989 )
18990 \noun default
18991 .
18992 \begin_inset Foot
18993 status open
18994
18995 \begin_layout Standard
18996 This is a slightly more stringent rule than absolutely necessary, but stays
18997  always on the safe side.
18998  Labels in the form of nnnnn$ are local labels in the assembler, locality
18999  of which is confined within two labels of the standard form.
19000  The compiler uses the same form for labels within a function (but starting
19001  from nnnnn=00100); and places always a standard label at the beginning
19002  of a function, thus limiting the locality of labels within the scope of
19003  the function.
19004  So, if the inline assembler part would be embedded into C-code, an improperly
19005  placed non-local label in the assembler would break up the reference space
19006  for labels created by the compiler for the C-code, leading to an assembling
19007  error.
19008 \end_layout
19009
19010 \begin_layout Standard
19011 The numeric part of local labels does not need to have 5 digits (although
19012  this is the form of labels output by the compiler), any valid integer will
19013  do.
19014  Please refer to the assemblers documentation for further details.
19015 \end_layout
19016
19017 \end_inset
19018
19019  
19020 \end_layout
19021
19022 \begin_layout Verse
19023
19024 \family typewriter
19025 _asm
19026 \begin_inset LatexCommand index
19027 name "\\_asm"
19028
19029 \end_inset
19030
19031
19032 \begin_inset LatexCommand index
19033 name "\\_\\_asm"
19034
19035 \end_inset
19036
19037  
19038 \newline
19039 \InsetSpace ~
19040 \InsetSpace ~
19041 \InsetSpace ~
19042 \InsetSpace ~
19043 mov\InsetSpace ~
19044 \InsetSpace ~
19045 \InsetSpace ~
19046 \InsetSpace ~
19047 \InsetSpace ~
19048 b,#10 
19049 \newline
19050 00001$: 
19051 \newline
19052 \InsetSpace ~
19053 \InsetSpace ~
19054 \InsetSpace ~
19055 \InsetSpace ~
19056 djnz\InsetSpace ~
19057 \InsetSpace ~
19058 \InsetSpace ~
19059 \InsetSpace ~
19060 b,00001$ 
19061 \newline
19062 _endasm
19063 \begin_inset LatexCommand index
19064 name "\\_endasm"
19065
19066 \end_inset
19067
19068
19069 \begin_inset LatexCommand index
19070 name "\\_\\_endasm"
19071
19072 \end_inset
19073
19074  ;
19075 \end_layout
19076
19077 \begin_layout Standard
19078 Inline assembler code cannot reference any C-labels, however it can reference
19079  labels
19080 \begin_inset LatexCommand index
19081 name "Labels"
19082
19083 \end_inset
19084
19085  defined by the inline assembler, e.g.:
19086 \end_layout
19087
19088 \begin_layout Verse
19089
19090 \family typewriter
19091 foo() { 
19092 \newline
19093 \InsetSpace ~
19094 \InsetSpace ~
19095 \InsetSpace ~
19096 \InsetSpace ~
19097 /* some c code */ 
19098 \newline
19099 \InsetSpace ~
19100 \InsetSpace ~
19101 \InsetSpace ~
19102 \InsetSpace ~
19103 _asm 
19104 \newline
19105 \InsetSpace ~
19106 \InsetSpace ~
19107 \InsetSpace ~
19108 \InsetSpace ~
19109 \InsetSpace ~
19110 \InsetSpace ~
19111 ; some assembler code 
19112 \newline
19113 \InsetSpace ~
19114 \InsetSpace ~
19115 \InsetSpace ~
19116 \InsetSpace ~
19117 \InsetSpace ~
19118 \InsetSpace ~
19119 ljmp 0003$ 
19120 \newline
19121 \InsetSpace ~
19122 \InsetSpace ~
19123 \InsetSpace ~
19124 \InsetSpace ~
19125 _endasm;
19126  
19127 \newline
19128 \InsetSpace ~
19129 \InsetSpace ~
19130 \InsetSpace ~
19131 \InsetSpace ~
19132 /* some more c code */ 
19133 \newline
19134 clabel:\InsetSpace ~
19135 \InsetSpace ~
19136 /* inline assembler cannot reference this
19137  label */ 
19138 \begin_inset Foot
19139 status open
19140
19141 \begin_layout Standard
19142 Here, the C-label 
19143 \family typewriter
19144 clabel
19145 \family default
19146  is translated by the compiler into a local label, so the locality of labels
19147  within the function is not broken.
19148 \end_layout
19149
19150 \end_inset
19151
19152
19153 \newline
19154 \InsetSpace ~
19155 \InsetSpace ~
19156 \InsetSpace ~
19157 \InsetSpace ~
19158 _asm
19159 \newline
19160 \InsetSpace ~
19161 \InsetSpace ~
19162 \InsetSpace ~
19163 \InsetSpace ~
19164 0003$: ;label (can be referenced by inline assembler only) 
19165 \newline
19166 \InsetSpace ~
19167 \InsetSpace ~
19168 \InsetSpace ~
19169 \InsetSpace ~
19170 _endasm
19171 \begin_inset LatexCommand index
19172 name "\\_endasm"
19173
19174 \end_inset
19175
19176
19177 \begin_inset LatexCommand index
19178 name "\\_\\_endasm"
19179
19180 \end_inset
19181
19182  ; 
19183 \newline
19184 \InsetSpace ~
19185 \InsetSpace ~
19186 \InsetSpace ~
19187 \InsetSpace ~
19188 /* some more c code */
19189 \newline
19190 }
19191 \end_layout
19192
19193 \begin_layout Standard
19194 In other words inline assembly code can access labels defined in inline
19195  assembly within the scope of the function.
19196  The same goes the other way, i.e.
19197  labels defines in inline assembly can not be accessed by C statements.
19198 \end_layout
19199
19200 \begin_layout Section
19201 Interfacing with Assembler Code
19202 \begin_inset LatexCommand index
19203 name "Assembler routines"
19204
19205 \end_inset
19206
19207
19208 \end_layout
19209
19210 \begin_layout Subsection
19211 Global Registers used for Parameter Passing
19212 \begin_inset LatexCommand index
19213 name "Parameter passing"
19214
19215 \end_inset
19216
19217
19218 \end_layout
19219
19220 \begin_layout Standard
19221 The compiler always uses the global registers 
19222 \emph on
19223 DPL, DPH
19224 \begin_inset LatexCommand index
19225 name "DPTR, DPH, DPL"
19226
19227 \end_inset
19228
19229
19230 \begin_inset LatexCommand index
19231 name "DPTR"
19232
19233 \end_inset
19234
19235 , B
19236 \begin_inset LatexCommand index
19237 name "B (mcs51, ds390 register)"
19238
19239 \end_inset
19240
19241
19242 \emph default
19243  and 
19244 \emph on
19245 ACC
19246 \begin_inset LatexCommand index
19247 name "ACC (mcs51, ds390 register)"
19248
19249 \end_inset
19250
19251
19252 \emph default
19253  to pass the first (non-bit) parameter to a function, and also to pass the
19254  return value 
19255 \begin_inset LatexCommand index
19256 name "return value"
19257
19258 \end_inset
19259
19260 of function; according to the following scheme: one byte return value in
19261  
19262 \emph on
19263 DPL
19264 \emph default
19265 , two byte value in 
19266 \emph on
19267 DPL
19268 \emph default
19269  (LSB) and 
19270 \emph on
19271 DPH
19272 \emph default
19273  (MSB).
19274  three byte values (generic pointers) in 
19275 \emph on
19276 DPH
19277 \emph default
19278
19279 \emph on
19280 DPL
19281 \emph default
19282  and 
19283 \emph on
19284 B
19285 \emph default
19286 , and four byte values in 
19287 \emph on
19288 DPH
19289 \emph default
19290
19291 \emph on
19292 DPL
19293 \emph default
19294
19295 \emph on
19296 B
19297 \emph default
19298  and 
19299 \emph on
19300 ACC
19301 \emph default
19302 .
19303  Generic pointers
19304 \begin_inset LatexCommand index
19305 name "generic pointer"
19306
19307 \end_inset
19308
19309  contain type of accessed memory in 
19310 \emph on
19311 B
19312 \emph default
19313
19314 \series bold
19315 0x00
19316 \series default
19317  -- xdata/far, 
19318 \series bold
19319 0x40
19320 \series default
19321  -- idata/near -- , 
19322 \series bold
19323 0x60
19324 \series default
19325  -- pdata, 
19326 \series bold
19327 0x80
19328 \series default
19329  -- code
19330 \begin_inset Note Note
19331 status collapsed
19332
19333 \begin_layout Standard
19334 This might not be the case of certain memory models (medium???)
19335 \end_layout
19336
19337 \end_inset
19338
19339 .
19340 \end_layout
19341
19342 \begin_layout Standard
19343 The second parameter onwards is either allocated on the stack (for reentrant
19344  routines or if -
19345 \begin_inset ERT
19346 status collapsed
19347
19348 \begin_layout Standard
19349
19350
19351 \backslash
19352 /
19353 \end_layout
19354
19355 \end_inset
19356
19357 -stack-auto is used) or in data/xdata memory (depending on the memory model).
19358 \end_layout
19359
19360 \begin_layout Standard
19361 Bit parameters are passed in a virtual register called 'bits' in bit-addressable
19362  space for reentrant functions or allocated directly in bit memory otherwise.
19363 \end_layout
19364
19365 \begin_layout Standard
19366 Functions (with two or more parameters or bit parameters) that are called
19367  through function pointers
19368 \begin_inset LatexCommand index
19369 name "function pointers"
19370
19371 \end_inset
19372
19373  must therefor be reentrant so the compiler knows how to pass the parameters.
19374 \end_layout
19375
19376 \begin_layout Subsection
19377 Registers usage
19378 \end_layout
19379
19380 \begin_layout Standard
19381 Unless the called function is declared as 
19382 \family typewriter
19383 _naked
19384 \family default
19385
19386 \begin_inset LatexCommand index
19387 name "naked"
19388
19389 \end_inset
19390
19391 , or the -
19392 \begin_inset ERT
19393 status collapsed
19394
19395 \begin_layout Standard
19396
19397
19398 \backslash
19399 /
19400 \end_layout
19401
19402 \end_inset
19403
19404 -callee-saves
19405 \begin_inset LatexCommand index
19406 name "-\\/-callee-saves"
19407
19408 \end_inset
19409
19410 /-
19411 \begin_inset ERT
19412 status collapsed
19413
19414 \begin_layout Standard
19415
19416
19417 \backslash
19418 /
19419 \end_layout
19420
19421 \end_inset
19422
19423 -all-callee-saves command line option or the corresponding callee_saves
19424  pragma are used, the caller will save the registers (
19425 \emph on
19426 R0-R7
19427 \emph default
19428 ) around the call, so the called function can destroy they content freely.
19429 \end_layout
19430
19431 \begin_layout Standard
19432 If the called function is not declared as 
19433 \family typewriter
19434 _naked
19435 \family default
19436 , the caller will swap register banks around the call, if caller and callee
19437  use different register banks (having them defined by the 
19438 \family typewriter
19439 _using
19440 \family default
19441  modifier).
19442  
19443 \end_layout
19444
19445 \begin_layout Standard
19446 The called function can also use 
19447 \emph on
19448 DPL
19449 \emph default
19450
19451 \emph on
19452 DPH
19453 \emph default
19454
19455 \emph on
19456 B
19457 \emph default
19458  and 
19459 \emph on
19460 ACC
19461 \emph default
19462  observing that they are used for parameter/return value passing.
19463 \end_layout
19464
19465 \begin_layout Subsection
19466 Assembler Routine (non-reentrant)
19467 \end_layout
19468
19469 \begin_layout Standard
19470 In the following example
19471 \begin_inset LatexCommand index
19472 name "reentrant"
19473
19474 \end_inset
19475
19476
19477 \begin_inset LatexCommand index
19478 name "Assembler routines (non-reentrant)"
19479
19480 \end_inset
19481
19482  the function c_func calls an assembler routine asm_func, which takes two
19483  parameters
19484 \begin_inset LatexCommand index
19485 name "function parameter"
19486
19487 \end_inset
19488
19489 .
19490 \end_layout
19491
19492 \begin_layout Verse
19493
19494 \family typewriter
19495 extern int asm_func(unsigned char, unsigned char);
19496 \newline
19497
19498 \newline
19499 int c_func (unsigned char
19500  i, unsigned char j)
19501 \newline
19502 {
19503 \newline
19504 \InsetSpace ~
19505 \InsetSpace ~
19506 \InsetSpace ~
19507 \InsetSpace ~
19508 return asm_func(i,j);
19509 \newline
19510 }
19511 \newline
19512
19513 \newline
19514 int main()
19515 \newline
19516 {
19517 \newline
19518 \InsetSpace ~
19519 \InsetSpace ~
19520 \InsetSpace ~
19521 \InsetSpace ~
19522 return c_func(10,9);
19523 \newline
19524 }
19525 \end_layout
19526
19527 \begin_layout Standard
19528 The corresponding assembler function is:
19529 \end_layout
19530
19531 \begin_layout Verse
19532
19533 \family typewriter
19534 .globl _asm_func_PARM_2 
19535 \newline
19536 \InsetSpace ~
19537 \InsetSpace ~
19538 \InsetSpace ~
19539 \InsetSpace ~
19540 \InsetSpace ~
19541 \InsetSpace ~
19542 \InsetSpace ~
19543 \InsetSpace ~
19544 .globl _asm_func 
19545 \newline
19546 \InsetSpace ~
19547 \InsetSpace ~
19548 \InsetSpace ~
19549 \InsetSpace ~
19550 \InsetSpace ~
19551 \InsetSpace ~
19552 \InsetSpace ~
19553 \InsetSpace ~
19554 .area OSEG 
19555 \newline
19556 _asm_func_PARM_2:
19557 \newline
19558 \InsetSpace ~
19559 \InsetSpace ~
19560 \InsetSpace ~
19561 \InsetSpace ~
19562 \InsetSpace ~
19563 \InsetSpace ~
19564 \InsetSpace ~
19565 \InsetSpace ~
19566 .ds   
19567  1 
19568 \newline
19569 \InsetSpace ~
19570 \InsetSpace ~
19571 \InsetSpace ~
19572 \InsetSpace ~
19573 \InsetSpace ~
19574 \InsetSpace ~
19575 \InsetSpace ~
19576 \InsetSpace ~
19577 .area CSEG 
19578 \newline
19579 _asm_func: 
19580 \newline
19581 \InsetSpace ~
19582 \InsetSpace ~
19583 \InsetSpace ~
19584 \InsetSpace ~
19585 \InsetSpace ~
19586 \InsetSpace ~
19587 \InsetSpace ~
19588 \InsetSpace ~
19589 mov\InsetSpace ~
19590 \InsetSpace ~
19591 \InsetSpace ~
19592 \InsetSpace ~
19593 a,dpl 
19594 \newline
19595 \InsetSpace ~
19596 \InsetSpace ~
19597 \InsetSpace ~
19598 \InsetSpace ~
19599 \InsetSpace ~
19600 \InsetSpace ~
19601 \InsetSpace ~
19602 \InsetSpace ~
19603 add\InsetSpace ~
19604 \InsetSpace ~
19605 \InsetSpace ~
19606 \InsetSpace ~
19607 a,_asm_func_PARM_2 
19608 \newline
19609 \InsetSpace ~
19610 \InsetSpace ~
19611 \InsetSpace ~
19612 \InsetSpace ~
19613 \InsetSpace ~
19614 \InsetSpace ~
19615 \InsetSpace ~
19616 \InsetSpace ~
19617 mov\InsetSpace ~
19618 \InsetSpace ~
19619 \InsetSpace ~
19620 \InsetSpace ~
19621 dpl,a 
19622 \newline
19623 \InsetSpace ~
19624 \InsetSpace ~
19625 \InsetSpace ~
19626 \InsetSpace ~
19627 \InsetSpace ~
19628 \InsetSpace ~
19629 \InsetSpace ~
19630 \InsetSpace ~
19631 mov\InsetSpace ~
19632 \InsetSpace ~
19633 \InsetSpace ~
19634 \InsetSpace ~
19635 dph
19636 \begin_inset LatexCommand index
19637 name "DPTR, DPH, DPL"
19638
19639 \end_inset
19640
19641 ,#0x00 
19642 \newline
19643 \InsetSpace ~
19644 \InsetSpace ~
19645 \InsetSpace ~
19646 \InsetSpace ~
19647 \InsetSpace ~
19648 \InsetSpace ~
19649 \InsetSpace ~
19650 \InsetSpace ~
19651 ret
19652 \end_layout
19653
19654 \begin_layout Standard
19655 The parameter naming convention is _<function_name>_PARM_<n>, where n is
19656  the parameter number starting from 1, and counting from the left.
19657  The first parameter is passed in 
19658 \emph on
19659 DPH
19660 \emph default
19661
19662 \emph on
19663 DPL
19664 \emph default
19665
19666 \emph on
19667 B
19668 \emph default
19669  and 
19670 \emph on
19671 ACC
19672 \emph default
19673  according to the description above.
19674  The variable name for the second parameter will be _<function_name>_PARM_2.
19675 \newline
19676
19677 \newline
19678 Assem
19679 ble the assembler routine with the following command:
19680 \newline
19681
19682 \newline
19683
19684 \family sans
19685 \series bold
19686 asx8051 -losg asmfunc.asm
19687 \newline
19688
19689 \newline
19690
19691 \family default
19692 \series default
19693 Then compile and link the assembler routine to the C source file with the
19694  following command:
19695 \newline
19696
19697 \newline
19698
19699 \family sans
19700 \series bold
19701 sdcc cfunc.c asmfunc.rel
19702 \end_layout
19703
19704 \begin_layout Subsection
19705 Assembler Routine (reentrant)
19706 \end_layout
19707
19708 \begin_layout Standard
19709 In this case
19710 \begin_inset LatexCommand index
19711 name "reentrant"
19712
19713 \end_inset
19714
19715
19716 \begin_inset LatexCommand index
19717 name "Assembler routines (reentrant)"
19718
19719 \end_inset
19720
19721  the second parameter
19722 \begin_inset LatexCommand index
19723 name "function parameter"
19724
19725 \end_inset
19726
19727  onwards will be passed on the stack, the parameters are pushed from right
19728  to left i.e.
19729  before the call the second leftmost parameter will be on the top of the
19730  stack (the leftmost parameter is passed in registers).
19731  Here is an example:
19732 \end_layout
19733
19734 \begin_layout Verse
19735
19736 \family typewriter
19737 extern int asm_func(unsigned char, unsigned char, unsigned char) reentrant;
19738 \newline
19739
19740 \newline
19741 int
19742  c_func (unsigned char i, unsigned char j, unsigned char k) reentrant 
19743 \newline
19744 {
19745  
19746 \newline
19747 \InsetSpace ~
19748 \InsetSpace ~
19749 \InsetSpace ~
19750 \InsetSpace ~
19751 return asm_func(i,j,k); 
19752 \newline
19753
19754 \newline
19755
19756 \newline
19757 int main() 
19758 \newline
19759
19760 \newline
19761 \InsetSpace ~
19762 \InsetSpace ~
19763 \InsetSpace ~
19764 \InsetSpace ~
19765 return c_func(10,9,8); 
19766 \newline
19767 }
19768 \end_layout
19769
19770 \begin_layout Standard
19771 The corresponding (unoptimized) assembler routine is:
19772 \end_layout
19773
19774 \begin_layout Verse
19775
19776 \family typewriter
19777 .globl _asm_func 
19778 \newline
19779 _asm_func: 
19780 \newline
19781 \InsetSpace ~
19782 \InsetSpace ~
19783 \InsetSpace ~
19784 \InsetSpace ~
19785 push\InsetSpace ~
19786 _bp 
19787 \newline
19788 \InsetSpace ~
19789 \InsetSpace ~
19790 \InsetSpace ~
19791 \InsetSpace ~
19792 mov\InsetSpace ~
19793 \InsetSpace ~
19794 _bp,sp\InsetSpace ~
19795 \InsetSpace ~
19796 \InsetSpace ~
19797 \InsetSpace ~
19798 \InsetSpace ~
19799 \InsetSpace ~
19800 ;stack contains: _bp, return
19801  address, second parameter, third parameter
19802 \newline
19803 \InsetSpace ~
19804 \InsetSpace ~
19805 \InsetSpace ~
19806 \InsetSpace ~
19807 mov\InsetSpace ~
19808 \InsetSpace ~
19809 r2,dpl
19810 \newline
19811 \InsetSpace ~
19812 \InsetSpace ~
19813 \InsetSpace ~
19814 \InsetSpace ~
19815 mov\InsetSpace ~
19816 \InsetSpace ~
19817 a,_bp
19818 \newline
19819 \InsetSpace ~
19820 \InsetSpace ~
19821 \InsetSpace ~
19822 \InsetSpace ~
19823 add\InsetSpace ~
19824 \InsetSpace ~
19825 a,#0xfd\InsetSpace ~
19826 \InsetSpace ~
19827 \InsetSpace ~
19828 \InsetSpace ~
19829 \InsetSpace ~
19830 ;calculate
19831  pointer to the second parameter
19832 \newline
19833 \InsetSpace ~
19834 \InsetSpace ~
19835 \InsetSpace ~
19836 \InsetSpace ~
19837 mov\InsetSpace ~
19838 \InsetSpace ~
19839 r0,a 
19840 \newline
19841 \InsetSpace ~
19842 \InsetSpace ~
19843 \InsetSpace ~
19844 \InsetSpace ~
19845 mov\InsetSpace ~
19846 \InsetSpace ~
19847 a,_bp 
19848 \newline
19849 \InsetSpace ~
19850 \InsetSpace ~
19851 \InsetSpace ~
19852 \InsetSpace ~
19853 add\InsetSpace ~
19854 \InsetSpace ~
19855 a,#0xfc\InsetSpace ~
19856 \InsetSpace ~
19857 \InsetSpace ~
19858 \InsetSpace ~
19859 \InsetSpace ~
19860 ;calculate pointer
19861  to the rightmost parameter
19862 \newline
19863 \InsetSpace ~
19864 \InsetSpace ~
19865 \InsetSpace ~
19866 \InsetSpace ~
19867 mov\InsetSpace ~
19868 \InsetSpace ~
19869 r1,a 
19870 \newline
19871 \InsetSpace ~
19872 \InsetSpace ~
19873 \InsetSpace ~
19874 \InsetSpace ~
19875 mov\InsetSpace ~
19876 \InsetSpace ~
19877 a,@r0
19878 \newline
19879 \InsetSpace ~
19880 \InsetSpace ~
19881 \InsetSpace ~
19882 \InsetSpace ~
19883 add\InsetSpace ~
19884 \InsetSpace ~
19885 a,@r1
19886 \newline
19887 \InsetSpace ~
19888 \InsetSpace ~
19889 \InsetSpace ~
19890 \InsetSpace ~
19891 add\InsetSpace ~
19892 \InsetSpace ~
19893 a,r2\InsetSpace ~
19894 \InsetSpace ~
19895 \InsetSpace ~
19896 \InsetSpace ~
19897 \InsetSpace ~
19898 \InsetSpace ~
19899 \InsetSpace ~
19900 \InsetSpace ~
19901 ;calculate the
19902  result (= sum of all three parameters)
19903 \newline
19904 \InsetSpace ~
19905 \InsetSpace ~
19906 \InsetSpace ~
19907 \InsetSpace ~
19908 mov\InsetSpace ~
19909 \InsetSpace ~
19910 dpl,a\InsetSpace ~
19911 \InsetSpace ~
19912 \InsetSpace ~
19913 \InsetSpace ~
19914 \InsetSpace ~
19915 \InsetSpace ~
19916 \InsetSpace ~
19917 ;return value goes into dptr
19918  (cast into int)
19919 \newline
19920 \InsetSpace ~
19921 \InsetSpace ~
19922 \InsetSpace ~
19923 \InsetSpace ~
19924 mov\InsetSpace ~
19925 \InsetSpace ~
19926 dph,#0x00 
19927 \newline
19928 \InsetSpace ~
19929 \InsetSpace ~
19930 \InsetSpace ~
19931 \InsetSpace ~
19932 mov\InsetSpace ~
19933 \InsetSpace ~
19934 sp,_bp 
19935 \newline
19936 \InsetSpace ~
19937 \InsetSpace ~
19938 \InsetSpace ~
19939 \InsetSpace ~
19940 pop\InsetSpace ~
19941 \InsetSpace ~
19942 _bp 
19943 \newline
19944 \InsetSpace ~
19945 \InsetSpace ~
19946 \InsetSpace ~
19947 \InsetSpace ~
19948 ret
19949 \end_layout
19950
19951 \begin_layout Standard
19952 The compiling and linking procedure remains the same, however note the extra
19953  entry & exit linkage required for the assembler code, _bp is the stack
19954  frame pointer and is used to compute the offset into the stack for parameters
19955  and local variables.
19956 \begin_inset VSpace bigskip
19957 \end_inset
19958
19959
19960 \end_layout
19961
19962 \begin_layout Section
19963 int (16 bit)
19964 \begin_inset LatexCommand index
19965 name "int (16 bit)"
19966
19967 \end_inset
19968
19969  and long (32 bit)
19970 \begin_inset LatexCommand index
19971 name "long (32 bit)"
19972
19973 \end_inset
19974
19975  Support
19976 \end_layout
19977
19978 \begin_layout Standard
19979 For signed & unsigned int (16 bit) and long (32 bit) variables, division,
19980  multiplication and modulus operations are implemented by support routines.
19981  These support routines are all developed in ANSI-C to facilitate porting
19982  to other MCUs, although some model specific assembler optimizations are
19983  used.
19984  The following files contain the described routines, all of them can be
19985  found in <installdir>/share/sdcc/lib.
19986 \newline
19987
19988 \end_layout
19989
19990 \begin_layout Standard
19991 \align center
19992 \begin_inset Tabular
19993 <lyxtabular version="3" rows="11" columns="2">
19994 <features>
19995 <column alignment="left" valignment="top" leftline="true" width="0">
19996 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0">
19997 <row topline="true" bottomline="true">
19998 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
19999 \begin_inset Text
20000
20001 \begin_layout Standard
20002
20003 \series bold
20004 Function
20005 \end_layout
20006
20007 \end_inset
20008 </cell>
20009 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20010 \begin_inset Text
20011
20012 \begin_layout Standard
20013
20014 \series bold
20015 Description
20016 \end_layout
20017
20018 \end_inset
20019 </cell>
20020 </row>
20021 <row topline="true">
20022 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20023 \begin_inset Text
20024
20025 \begin_layout Standard
20026 _mulint.c 
20027 \end_layout
20028
20029 \end_inset
20030 </cell>
20031 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20032 \begin_inset Text
20033
20034 \begin_layout Standard
20035 16 bit multiplication
20036 \end_layout
20037
20038 \end_inset
20039 </cell>
20040 </row>
20041 <row topline="true">
20042 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20043 \begin_inset Text
20044
20045 \begin_layout Standard
20046 _divsint.c 
20047 \end_layout
20048
20049 \end_inset
20050 </cell>
20051 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20052 \begin_inset Text
20053
20054 \begin_layout Standard
20055  signed 16 bit division (calls _divuint)
20056 \end_layout
20057
20058 \end_inset
20059 </cell>
20060 </row>
20061 <row topline="true">
20062 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20063 \begin_inset Text
20064
20065 \begin_layout Standard
20066 _divuint.c 
20067 \end_layout
20068
20069 \end_inset
20070 </cell>
20071 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20072 \begin_inset Text
20073
20074 \begin_layout Standard
20075  unsigned 16 bit division
20076 \end_layout
20077
20078 \end_inset
20079 </cell>
20080 </row>
20081 <row topline="true">
20082 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20083 \begin_inset Text
20084
20085 \begin_layout Standard
20086 _modsint.c
20087 \end_layout
20088
20089 \end_inset
20090 </cell>
20091 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20092 \begin_inset Text
20093
20094 \begin_layout Standard
20095 signed 16 bit modulus (calls _moduint)
20096 \end_layout
20097
20098 \end_inset
20099 </cell>
20100 </row>
20101 <row topline="true">
20102 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20103 \begin_inset Text
20104
20105 \begin_layout Standard
20106 _moduint.c
20107 \end_layout
20108
20109 \end_inset
20110 </cell>
20111 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20112 \begin_inset Text
20113
20114 \begin_layout Standard
20115 unsigned 16 bit modulus
20116 \end_layout
20117
20118 \end_inset
20119 </cell>
20120 </row>
20121 <row topline="true">
20122 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20123 \begin_inset Text
20124
20125 \begin_layout Standard
20126 _mullong.c
20127 \end_layout
20128
20129 \end_inset
20130 </cell>
20131 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20132 \begin_inset Text
20133
20134 \begin_layout Standard
20135 32 bit multiplication
20136 \end_layout
20137
20138 \end_inset
20139 </cell>
20140 </row>
20141 <row topline="true">
20142 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20143 \begin_inset Text
20144
20145 \begin_layout Standard
20146 _divslong.c 
20147 \end_layout
20148
20149 \end_inset
20150 </cell>
20151 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20152 \begin_inset Text
20153
20154 \begin_layout Standard
20155  signed 32 division (calls _divulong)
20156 \end_layout
20157
20158 \end_inset
20159 </cell>
20160 </row>
20161 <row topline="true">
20162 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20163 \begin_inset Text
20164
20165 \begin_layout Standard
20166 _divulong.c 
20167 \end_layout
20168
20169 \end_inset
20170 </cell>
20171 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20172 \begin_inset Text
20173
20174 \begin_layout Standard
20175 unsigned 32 division
20176 \end_layout
20177
20178 \end_inset
20179 </cell>
20180 </row>
20181 <row topline="true">
20182 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20183 \begin_inset Text
20184
20185 \begin_layout Standard
20186 _modslong.c
20187 \end_layout
20188
20189 \end_inset
20190 </cell>
20191 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20192 \begin_inset Text
20193
20194 \begin_layout Standard
20195  signed 32 bit modulus (calls _modulong)
20196 \end_layout
20197
20198 \end_inset
20199 </cell>
20200 </row>
20201 <row topline="true" bottomline="true">
20202 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20203 \begin_inset Text
20204
20205 \begin_layout Standard
20206 _modulong.c
20207 \end_layout
20208
20209 \end_inset
20210 </cell>
20211 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20212 \begin_inset Text
20213
20214 \begin_layout Standard
20215 unsigned 32 bit modulus
20216 \end_layout
20217
20218 \end_inset
20219 </cell>
20220 </row>
20221 </lyxtabular>
20222
20223 \end_inset
20224
20225
20226 \newline
20227
20228 \end_layout
20229
20230 \begin_layout Standard
20231 Since they are compiled as 
20232 \emph on
20233 non-reentrant
20234 \emph default
20235
20236 \begin_inset LatexCommand index
20237 name "reentrant"
20238
20239 \end_inset
20240
20241 , interrupt
20242 \begin_inset LatexCommand index
20243 name "interrupt"
20244
20245 \end_inset
20246
20247  service routines should not do any of the above operations.
20248  If this is unavoidable then the above routines will need to be compiled
20249  with the 
20250 \emph on
20251 -
20252 \begin_inset ERT
20253 status collapsed
20254
20255 \begin_layout Standard
20256
20257
20258 \backslash
20259 /
20260 \end_layout
20261
20262 \end_inset
20263
20264 -stack-auto
20265 \begin_inset LatexCommand index
20266 name "-\\/-stack-auto"
20267
20268 \end_inset
20269
20270
20271 \emph default
20272  option, after which the source program will have to be compiled with 
20273 \emph on
20274 -
20275 \begin_inset ERT
20276 status collapsed
20277
20278 \begin_layout Standard
20279
20280
20281 \backslash
20282 /
20283 \end_layout
20284
20285 \end_inset
20286
20287 -int-long-reent
20288 \begin_inset LatexCommand index
20289 name "-\\/-int-long-reent"
20290
20291 \end_inset
20292
20293
20294 \emph default
20295  option.
20296  Notice that you don't have to call these routines directly.
20297  The compiler will use them automatically every time an integer operation
20298  is required.
20299 \end_layout
20300
20301 \begin_layout Section
20302 Floating Point Support
20303 \begin_inset LatexCommand index
20304 name "Floating point support"
20305
20306 \end_inset
20307
20308
20309 \end_layout
20310
20311 \begin_layout Standard
20312 SDCC supports IEEE (single precision 4 bytes) floating point numbers.
20313  The floating point support routines are derived from gcc's floatlib.c and
20314  consist of the following routines:
20315 \newline
20316
20317 \end_layout
20318
20319 \begin_layout Standard
20320 \align center
20321
20322 \size footnotesize
20323 \begin_inset Tabular
20324 <lyxtabular version="3" rows="17" columns="2">
20325 <features>
20326 <column alignment="left" valignment="top" leftline="true" width="0">
20327 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0">
20328 <row topline="true" bottomline="true">
20329 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20330 \begin_inset Text
20331
20332 \begin_layout Standard
20333
20334 \family roman
20335 \series medium
20336 \shape up
20337 \size normal
20338 \emph off
20339 \bar no
20340 \noun off
20341 \color none
20342 Function 
20343 \end_layout
20344
20345 \end_inset
20346 </cell>
20347 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20348 \begin_inset Text
20349
20350 \begin_layout Standard
20351 Description
20352 \end_layout
20353
20354 \end_inset
20355 </cell>
20356 </row>
20357 <row topline="true">
20358 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20359 \begin_inset Text
20360
20361 \begin_layout Standard
20362
20363 \family roman
20364 \series medium
20365 \shape up
20366 \size normal
20367 \emph off
20368 \bar no
20369 \noun off
20370 \color none
20371 _fsadd.c
20372 \end_layout
20373
20374 \end_inset
20375 </cell>
20376 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20377 \begin_inset Text
20378
20379 \begin_layout Standard
20380
20381 \family roman
20382 \series medium
20383 \shape up
20384 \size normal
20385 \emph off
20386 \bar no
20387 \noun off
20388 \color none
20389 add floating point numbers
20390 \end_layout
20391
20392 \end_inset
20393 </cell>
20394 </row>
20395 <row topline="true">
20396 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20397 \begin_inset Text
20398
20399 \begin_layout Standard
20400
20401 \family roman
20402 \series medium
20403 \shape up
20404 \size normal
20405 \emph off
20406 \bar no
20407 \noun off
20408 \color none
20409 _fssub.c 
20410 \end_layout
20411
20412 \end_inset
20413 </cell>
20414 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20415 \begin_inset Text
20416
20417 \begin_layout Standard
20418
20419 \family roman
20420 \series medium
20421 \shape up
20422 \size normal
20423 \emph off
20424 \bar no
20425 \noun off
20426 \color none
20427 subtract floating point numbers 
20428 \end_layout
20429
20430 \end_inset
20431 </cell>
20432 </row>
20433 <row topline="true">
20434 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20435 \begin_inset Text
20436
20437 \begin_layout Standard
20438
20439 \family roman
20440 \series medium
20441 \shape up
20442 \size normal
20443 \emph off
20444 \bar no
20445 \noun off
20446 \color none
20447 _fsdiv.c 
20448 \end_layout
20449
20450 \end_inset
20451 </cell>
20452 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20453 \begin_inset Text
20454
20455 \begin_layout Standard
20456
20457 \family roman
20458 \series medium
20459 \shape up
20460 \size normal
20461 \emph off
20462 \bar no
20463 \noun off
20464 \color none
20465 divide floating point numbers 
20466 \end_layout
20467
20468 \end_inset
20469 </cell>
20470 </row>
20471 <row topline="true">
20472 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20473 \begin_inset Text
20474
20475 \begin_layout Standard
20476
20477 \family roman
20478 \series medium
20479 \shape up
20480 \size normal
20481 \emph off
20482 \bar no
20483 \noun off
20484 \color none
20485 _fsmul.c 
20486 \end_layout
20487
20488 \end_inset
20489 </cell>
20490 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20491 \begin_inset Text
20492
20493 \begin_layout Standard
20494
20495 \family roman
20496 \series medium
20497 \shape up
20498 \size normal
20499 \emph off
20500 \bar no
20501 \noun off
20502 \color none
20503 multiply floating point numbers 
20504 \end_layout
20505
20506 \end_inset
20507 </cell>
20508 </row>
20509 <row topline="true">
20510 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20511 \begin_inset Text
20512
20513 \begin_layout Standard
20514
20515 \family roman
20516 \series medium
20517 \shape up
20518 \size normal
20519 \emph off
20520 \bar no
20521 \noun off
20522 \color none
20523 _fs2uchar.c
20524 \end_layout
20525
20526 \end_inset
20527 </cell>
20528 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20529 \begin_inset Text
20530
20531 \begin_layout Standard
20532
20533 \family roman
20534 \series medium
20535 \shape up
20536 \size normal
20537 \emph off
20538 \bar no
20539 \noun off
20540 \color none
20541 convert floating point to unsigned char
20542 \end_layout
20543
20544 \end_inset
20545 </cell>
20546 </row>
20547 <row topline="true">
20548 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20549 \begin_inset Text
20550
20551 \begin_layout Standard
20552
20553 \family roman
20554 \series medium
20555 \shape up
20556 \size normal
20557 \emph off
20558 \bar no
20559 \noun off
20560 \color none
20561 _fs2char.c
20562 \end_layout
20563
20564 \end_inset
20565 </cell>
20566 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20567 \begin_inset Text
20568
20569 \begin_layout Standard
20570
20571 \family roman
20572 \series medium
20573 \shape up
20574 \size normal
20575 \emph off
20576 \bar no
20577 \noun off
20578 \color none
20579 convert floating point to signed char
20580 \end_layout
20581
20582 \end_inset
20583 </cell>
20584 </row>
20585 <row topline="true">
20586 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20587 \begin_inset Text
20588
20589 \begin_layout Standard
20590
20591 \family roman
20592 \series medium
20593 \shape up
20594 \size normal
20595 \emph off
20596 \bar no
20597 \noun off
20598 \color none
20599 _fs2uint.c
20600 \end_layout
20601
20602 \end_inset
20603 </cell>
20604 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20605 \begin_inset Text
20606
20607 \begin_layout Standard
20608
20609 \family roman
20610 \series medium
20611 \shape up
20612 \size normal
20613 \emph off
20614 \bar no
20615 \noun off
20616 \color none
20617 convert floating point to unsigned int
20618 \end_layout
20619
20620 \end_inset
20621 </cell>
20622 </row>
20623 <row topline="true">
20624 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20625 \begin_inset Text
20626
20627 \begin_layout Standard
20628
20629 \family roman
20630 \series medium
20631 \shape up
20632 \size normal
20633 \emph off
20634 \bar no
20635 \noun off
20636 \color none
20637 _fs2int.c
20638 \end_layout
20639
20640 \end_inset
20641 </cell>
20642 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20643 \begin_inset Text
20644
20645 \begin_layout Standard
20646
20647 \family roman
20648 \series medium
20649 \shape up
20650 \size normal
20651 \emph off
20652 \bar no
20653 \noun off
20654 \color none
20655 convert floating point to signed int
20656 \end_layout
20657
20658 \end_inset
20659 </cell>
20660 </row>
20661 <row topline="true">
20662 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20663 \begin_inset Text
20664
20665 \begin_layout Standard
20666
20667 \family roman
20668 \series medium
20669 \shape up
20670 \size normal
20671 \emph off
20672 \bar no
20673 \noun off
20674 \color none
20675 _fs2ulong.
20676 \family default
20677 \series default
20678 \shape default
20679 \size default
20680 \emph default
20681 \bar default
20682 \noun default
20683 c
20684 \end_layout
20685
20686 \end_inset
20687 </cell>
20688 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20689 \begin_inset Text
20690
20691 \begin_layout Standard
20692
20693 \family roman
20694 \series medium
20695 \shape up
20696 \size normal
20697 \emph off
20698 \bar no
20699 \noun off
20700 \color none
20701 convert floating point to unsigned long
20702 \end_layout
20703
20704 \end_inset
20705 </cell>
20706 </row>
20707 <row topline="true">
20708 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20709 \begin_inset Text
20710
20711 \begin_layout Standard
20712
20713 \family roman
20714 \series medium
20715 \shape up
20716 \size normal
20717 \emph off
20718 \bar no
20719 \noun off
20720 \color none
20721 _fs2long.c
20722 \end_layout
20723
20724 \end_inset
20725 </cell>
20726 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20727 \begin_inset Text
20728
20729 \begin_layout Standard
20730
20731 \family roman
20732 \series medium
20733 \shape up
20734 \size normal
20735 \emph off
20736 \bar no
20737 \noun off
20738 \color none
20739 convert floating point to signed long
20740 \end_layout
20741
20742 \end_inset
20743 </cell>
20744 </row>
20745 <row topline="true">
20746 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20747 \begin_inset Text
20748
20749 \begin_layout Standard
20750
20751 \family roman
20752 \series medium
20753 \shape up
20754 \size normal
20755 \emph off
20756 \bar no
20757 \noun off
20758 \color none
20759 _uchar2fs.c
20760 \end_layout
20761
20762 \end_inset
20763 </cell>
20764 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20765 \begin_inset Text
20766
20767 \begin_layout Standard
20768
20769 \family roman
20770 \series medium
20771 \shape up
20772 \size normal
20773 \emph off
20774 \bar no
20775 \noun off
20776 \color none
20777 convert unsigned char to floating point
20778 \end_layout
20779
20780 \end_inset
20781 </cell>
20782 </row>
20783 <row topline="true">
20784 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20785 \begin_inset Text
20786
20787 \begin_layout Standard
20788
20789 \family roman
20790 \series medium
20791 \shape up
20792 \size normal
20793 \emph off
20794 \bar no
20795 \noun off
20796 \color none
20797 _char2fs.c
20798 \end_layout
20799
20800 \end_inset
20801 </cell>
20802 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20803 \begin_inset Text
20804
20805 \begin_layout Standard
20806
20807 \family roman
20808 \series medium
20809 \shape up
20810 \size normal
20811 \emph off
20812 \bar no
20813 \noun off
20814 \color none
20815 convert char to floating point number
20816 \end_layout
20817
20818 \end_inset
20819 </cell>
20820 </row>
20821 <row topline="true">
20822 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20823 \begin_inset Text
20824
20825 \begin_layout Standard
20826
20827 \family roman
20828 \series medium
20829 \shape up
20830 \size normal
20831 \emph off
20832 \bar no
20833 \noun off
20834 \color none
20835 _uint2fs.c
20836 \end_layout
20837
20838 \end_inset
20839 </cell>
20840 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20841 \begin_inset Text
20842
20843 \begin_layout Standard
20844
20845 \family roman
20846 \series medium
20847 \shape up
20848 \size normal
20849 \emph off
20850 \bar no
20851 \noun off
20852 \color none
20853 convert unsigned int to floating point
20854 \end_layout
20855
20856 \end_inset
20857 </cell>
20858 </row>
20859 <row topline="true">
20860 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20861 \begin_inset Text
20862
20863 \begin_layout Standard
20864
20865 \family roman
20866 \series medium
20867 \shape up
20868 \size normal
20869 \emph off
20870 \bar no
20871 \noun off
20872 \color none
20873 _int2fs.c
20874 \end_layout
20875
20876 \end_inset
20877 </cell>
20878 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20879 \begin_inset Text
20880
20881 \begin_layout Standard
20882
20883 \family roman
20884 \series medium
20885 \shape up
20886 \size normal
20887 \emph off
20888 \bar no
20889 \noun off
20890 \color none
20891 convert int to floating point numbers
20892 \end_layout
20893
20894 \end_inset
20895 </cell>
20896 </row>
20897 <row topline="true">
20898 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20899 \begin_inset Text
20900
20901 \begin_layout Standard
20902
20903 \family roman
20904 \series medium
20905 \shape up
20906 \size normal
20907 \emph off
20908 \bar no
20909 \noun off
20910 \color none
20911 _ulong2fs.c
20912 \end_layout
20913
20914 \end_inset
20915 </cell>
20916 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20917 \begin_inset Text
20918
20919 \begin_layout Standard
20920
20921 \family roman
20922 \series medium
20923 \shape up
20924 \size normal
20925 \emph off
20926 \bar no
20927 \noun off
20928 \color none
20929 convert unsigned long to floating point number
20930 \end_layout
20931
20932 \end_inset
20933 </cell>
20934 </row>
20935 <row topline="true" bottomline="true">
20936 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
20937 \begin_inset Text
20938
20939 \begin_layout Standard
20940
20941 \family roman
20942 \series medium
20943 \shape up
20944 \size normal
20945 \emph off
20946 \bar no
20947 \noun off
20948 \color none
20949 _long2fs.c
20950 \end_layout
20951
20952 \end_inset
20953 </cell>
20954 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
20955 \begin_inset Text
20956
20957 \begin_layout Standard
20958
20959 \family roman
20960 \series medium
20961 \shape up
20962 \size normal
20963 \emph off
20964 \bar no
20965 \noun off
20966 \color none
20967 convert long to floating point number
20968 \end_layout
20969
20970 \end_inset
20971 </cell>
20972 </row>
20973 </lyxtabular>
20974
20975 \end_inset
20976
20977
20978 \newline
20979
20980 \end_layout
20981
20982 \begin_layout Standard
20983 These support routines are developed in ANSI-C so there is room for space
20984  and speed improvement
20985 \begin_inset Foot
20986 status open
20987
20988 \begin_layout Standard
20989 These floating point routines (
20990 \emph on
20991 not
20992 \emph default
20993  sinf(), cosf(), ...) for the mcs51 are implemented in assembler.
20994  
20995 \end_layout
20996
20997 \end_inset
20998
20999 .
21000  Note if all these routines are used simultaneously the data space might
21001  overflow.
21002  For serious floating point usage the large model might be needed.
21003  Also notice that you don't have to call this routines directly.
21004  The compiler will use them automatically every time a floating point operation
21005  is required.
21006 \begin_inset VSpace bigskip
21007 \end_inset
21008
21009
21010 \end_layout
21011
21012 \begin_layout Section
21013 Library Routines
21014 \begin_inset LatexCommand index
21015 name "Libraries"
21016
21017 \end_inset
21018
21019
21020 \end_layout
21021
21022 \begin_layout Standard
21023
21024 \emph on
21025 <pending: this is messy and incomplete - a little more information is in
21026  sdcc/doc/libdoc.txt
21027 \emph default
21028  >
21029 \end_layout
21030
21031 \begin_layout Subsection
21032 Compiler support routines (_gptrget, _mulint etc.)
21033 \end_layout
21034
21035 \begin_layout Subsection
21036 Stdclib functions (puts, printf, strcat etc.)
21037 \end_layout
21038
21039 \begin_layout Subsubsection
21040 <stdio.h>
21041 \end_layout
21042
21043 \begin_layout Paragraph
21044 getchar(), putchar()
21045 \end_layout
21046
21047 \begin_layout Standard
21048 \begin_inset LatexCommand index
21049 name "<stdio.h>"
21050
21051 \end_inset
21052
21053 As usual on embedded systems you have to provide your own 
21054 \family typewriter
21055 getchar()
21056 \begin_inset LatexCommand index
21057 name "getchar()"
21058
21059 \end_inset
21060
21061
21062 \family default
21063  and 
21064 \family typewriter
21065 putchar()
21066 \begin_inset LatexCommand index
21067 name "putchar()"
21068
21069 \end_inset
21070
21071
21072 \family default
21073  routines.
21074  SDCC does not know whether the system connects to a serial line with or
21075  without handshake, LCD, keyboard or other device.
21076  And whether a 
21077 \family typewriter
21078 lf
21079 \family default
21080  to 
21081 \family typewriter
21082 crlf
21083 \family default
21084  conversion within 
21085 \family typewriter
21086 putchar()
21087 \family default
21088  is intended.
21089  You'll find examples for serial routines f.e.
21090  in sdcc/device/lib.
21091  For the mcs51 this minimalistic polling 
21092 \family typewriter
21093 putchar()
21094 \family default
21095  routine might be a start:
21096 \end_layout
21097
21098 \begin_layout Verse
21099
21100 \family typewriter
21101 void putchar (char c) { 
21102 \newline
21103 \InsetSpace ~
21104 \InsetSpace ~
21105 \InsetSpace ~
21106 \InsetSpace ~
21107 while (!TI)\InsetSpace ~
21108 \InsetSpace ~
21109 \InsetSpace ~
21110  /* assumes UART is initialized */
21111 \newline
21112 \InsetSpace ~
21113 \InsetSpace ~
21114 \InsetSpace ~
21115 \InsetSpace ~
21116 \InsetSpace ~
21117 \InsetSpace ~
21118 \InsetSpace ~
21119 \InsetSpace ~
21120 ;
21121 \newline
21122 \InsetSpace ~
21123 \InsetSpace ~
21124 \InsetSpace ~
21125 \InsetSpace ~
21126 TI
21127  = 0;
21128 \newline
21129 \InsetSpace ~
21130 \InsetSpace ~
21131 \InsetSpace ~
21132 \InsetSpace ~
21133 SBUF = c;
21134 \newline
21135 }
21136 \end_layout
21137
21138 \begin_layout Paragraph
21139 printf()
21140 \end_layout
21141
21142 \begin_layout Standard
21143 The default 
21144 \family typewriter
21145 printf()
21146 \begin_inset LatexCommand index
21147 name "printf()"
21148
21149 \end_inset
21150
21151
21152 \family default
21153  implementation in 
21154 \family typewriter
21155 printf_large.c
21156 \family default
21157  does not support float
21158 \begin_inset LatexCommand index
21159 name "Floating point support"
21160
21161 \end_inset
21162
21163  (except on ds390), only <NO FLOAT>
21164 \begin_inset LatexCommand index
21165 name "<NO FLOAT>"
21166
21167 \end_inset
21168
21169
21170 \begin_inset LatexCommand index
21171 name "printf floating point support"
21172
21173 \end_inset
21174
21175  will be printed instead of the value.
21176  To enable floating point output, recompile it with the option 
21177 \emph on
21178 -
21179 \begin_inset ERT
21180 status collapsed
21181
21182 \begin_layout Standard
21183
21184
21185 \backslash
21186 /
21187 \end_layout
21188
21189 \end_inset
21190
21191 DUSE_FLOATS=1
21192 \begin_inset LatexCommand index
21193 name "USE\\_FLOATS"
21194
21195 \end_inset
21196
21197
21198 \emph default
21199  on the command line.
21200  Use 
21201 \emph on
21202 -
21203 \begin_inset ERT
21204 status open
21205
21206 \begin_layout Standard
21207
21208
21209 \backslash
21210 /
21211 \end_layout
21212
21213 \end_inset
21214
21215 -model-large
21216 \begin_inset LatexCommand index
21217 name "-\\/-model-large"
21218
21219 \end_inset
21220
21221
21222 \emph default
21223  for the mcs51 port, since this uses a lot of memory.
21224  To enable float support for the pic16 targets, see 
21225 \begin_inset LatexCommand ref
21226 reference "sub:pic16Libraries"
21227
21228 \end_inset
21229
21230 .
21231 \end_layout
21232
21233 \begin_layout Standard
21234 If you're short on code memory you might want to use 
21235 \family typewriter
21236 printf_small()
21237 \begin_inset LatexCommand index
21238 name "printf\\_small()"
21239
21240 \end_inset
21241
21242
21243 \family default
21244  
21245 \emph on
21246 instead
21247 \emph default
21248  of 
21249 \family typewriter
21250 printf().
21251
21252 \family default
21253  For the mcs51 there additionally are assembly versions 
21254 \family typewriter
21255 printf_tiny()
21256 \begin_inset LatexCommand index
21257 name "printf\\_tiny() (mcs51)"
21258
21259 \end_inset
21260
21261
21262 \family default
21263  (subset of printf using less than 270 bytes) and 
21264 \family typewriter
21265 printf_fast()
21266 \begin_inset LatexCommand index
21267 name "printf\\_fast() (mcs51)"
21268
21269 \end_inset
21270
21271
21272 \family default
21273  and 
21274 \family typewriter
21275 printf_fast_f()
21276 \begin_inset LatexCommand index
21277 name "printf\\_fast\\_f() (mcs51)"
21278
21279 \end_inset
21280
21281
21282 \family default
21283  (floating-point aware version of printf_fast) which should fit the requirements
21284  of many embedded systems (printf_fast() can be customized by unsetting
21285  #defines to 
21286 \emph on
21287 not
21288 \emph default
21289  support long variables and field widths).
21290  Be sure to use only one of these printf options within a project.
21291 \newline
21292
21293 \end_layout
21294
21295 \begin_layout Standard
21296 Feature matrix of different 
21297 \emph on
21298 printf
21299 \emph default
21300  options on mcs51.
21301 \end_layout
21302
21303 \begin_layout Standard
21304 \begin_inset Tabular
21305 <lyxtabular version="3" rows="14" columns="7">
21306 <features islongtable="true">
21307 <column alignment="left" valignment="middle" leftline="true" width="14col%">
21308 <column alignment="center" valignment="top" leftline="true" width="0">
21309 <column alignment="center" valignment="top" leftline="true" width="12col%">
21310 <column alignment="center" valignment="top" leftline="true" width="10col%">
21311 <column alignment="center" valignment="top" leftline="true" width="0">
21312 <column alignment="center" valignment="top" leftline="true" rightline="true" width="12col%">
21313 <column alignment="center" valignment="top" rightline="true" width="0">
21314 <row topline="true" bottomline="true" endhead="true">
21315 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21316 \begin_inset Text
21317
21318 \begin_layout Standard
21319
21320 \series bold
21321 \size large
21322 mcs51
21323 \end_layout
21324
21325 \end_inset
21326 </cell>
21327 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21328 \begin_inset Text
21329
21330 \begin_layout Standard
21331 printf
21332 \begin_inset LatexCommand index
21333 name "printf()"
21334
21335 \end_inset
21336
21337
21338 \end_layout
21339
21340 \end_inset
21341 </cell>
21342 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21343 \begin_inset Text
21344
21345 \begin_layout Standard
21346 printf 
21347 \size scriptsize
21348 USE_FLOATS=1
21349 \end_layout
21350
21351 \end_inset
21352 </cell>
21353 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21354 \begin_inset Text
21355
21356 \begin_layout Standard
21357 printf_small
21358 \end_layout
21359
21360 \end_inset
21361 </cell>
21362 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21363 \begin_inset Text
21364
21365 \begin_layout Standard
21366 printf_fast
21367 \end_layout
21368
21369 \end_inset
21370 </cell>
21371 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21372 \begin_inset Text
21373
21374 \begin_layout Standard
21375 printf_fast_f
21376 \end_layout
21377
21378 \end_inset
21379 </cell>
21380 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21381 \begin_inset Text
21382
21383 \begin_layout Standard
21384 printf_tiny
21385 \end_layout
21386
21387 \end_inset
21388 </cell>
21389 </row>
21390 <row topline="true" endhead="true">
21391 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21392 \begin_inset Text
21393
21394 \begin_layout Standard
21395 filename
21396 \end_layout
21397
21398 \end_inset
21399 </cell>
21400 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21401 \begin_inset Text
21402
21403 \begin_layout Standard
21404
21405 \size scriptsize
21406 printf_large.c
21407 \end_layout
21408
21409 \end_inset
21410 </cell>
21411 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21412 \begin_inset Text
21413
21414 \begin_layout Standard
21415
21416 \size scriptsize
21417 printf_large.c
21418 \end_layout
21419
21420 \end_inset
21421 </cell>
21422 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21423 \begin_inset Text
21424
21425 \begin_layout Standard
21426
21427 \size scriptsize
21428 printfl.c
21429 \end_layout
21430
21431 \end_inset
21432 </cell>
21433 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21434 \begin_inset Text
21435
21436 \begin_layout Standard
21437
21438 \size scriptsize
21439 printf_fast.c
21440 \end_layout
21441
21442 \end_inset
21443 </cell>
21444 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21445 \begin_inset Text
21446
21447 \begin_layout Standard
21448
21449 \size scriptsize
21450 printf_fast_f.c
21451 \end_layout
21452
21453 \end_inset
21454 </cell>
21455 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21456 \begin_inset Text
21457
21458 \begin_layout Standard
21459
21460 \size scriptsize
21461 printf_tiny.c
21462 \end_layout
21463
21464 \end_inset
21465 </cell>
21466 </row>
21467 <row topline="true" endhead="true">
21468 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21469 \begin_inset Text
21470
21471 \begin_layout Standard
21472 \begin_inset Quotes sld
21473 \end_inset
21474
21475 Hello World
21476 \begin_inset Quotes srd
21477 \end_inset
21478
21479  size
21480 \end_layout
21481
21482 \begin_layout Standard
21483 small / large
21484 \end_layout
21485
21486 \end_inset
21487 </cell>
21488 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21489 \begin_inset Text
21490
21491 \begin_layout Standard
21492 1.7k / 2.4k
21493 \end_layout
21494
21495 \end_inset
21496 </cell>
21497 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21498 \begin_inset Text
21499
21500 \begin_layout Standard
21501 4.3k / 5.6k
21502 \end_layout
21503
21504 \end_inset
21505 </cell>
21506 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21507 \begin_inset Text
21508
21509 \begin_layout Standard
21510 1.2k / 1.8k
21511 \end_layout
21512
21513 \end_inset
21514 </cell>
21515 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21516 \begin_inset Text
21517
21518 \begin_layout Standard
21519 1.3k / 1.3k
21520 \end_layout
21521
21522 \end_inset
21523 </cell>
21524 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21525 \begin_inset Text
21526
21527 \begin_layout Standard
21528 1.9k / 1.9k
21529 \end_layout
21530
21531 \end_inset
21532 </cell>
21533 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21534 \begin_inset Text
21535
21536 \begin_layout Standard
21537 0.44k / 0.44k
21538 \end_layout
21539
21540 \end_inset
21541 </cell>
21542 </row>
21543 <row topline="true" endhead="true">
21544 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21545 \begin_inset Text
21546
21547 \begin_layout Standard
21548 code size
21549 \end_layout
21550
21551 \begin_layout Standard
21552 small / large
21553 \end_layout
21554
21555 \end_inset
21556 </cell>
21557 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21558 \begin_inset Text
21559
21560 \begin_layout Standard
21561 1.4k / 2.0k
21562 \end_layout
21563
21564 \end_inset
21565 </cell>
21566 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21567 \begin_inset Text
21568
21569 \begin_layout Standard
21570 2.8k / 3.7k
21571 \end_layout
21572
21573 \end_inset
21574 </cell>
21575 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21576 \begin_inset Text
21577
21578 \begin_layout Standard
21579 0.45k / 0.47k (+ _ltoa)
21580 \end_layout
21581
21582 \end_inset
21583 </cell>
21584 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21585 \begin_inset Text
21586
21587 \begin_layout Standard
21588 1.2k / 1.2k
21589 \end_layout
21590
21591 \end_inset
21592 </cell>
21593 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21594 \begin_inset Text
21595
21596 \begin_layout Standard
21597 1.6k / 1.6k
21598 \end_layout
21599
21600 \end_inset
21601 </cell>
21602 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21603 \begin_inset Text
21604
21605 \begin_layout Standard
21606 0.26k / 0.26k
21607 \end_layout
21608
21609 \end_inset
21610 </cell>
21611 </row>
21612 <row topline="true">
21613 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21614 \begin_inset Text
21615
21616 \begin_layout Standard
21617 formats
21618 \end_layout
21619
21620 \end_inset
21621 </cell>
21622 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21623 \begin_inset Text
21624
21625 \begin_layout Standard
21626 cdi
21627 \emph on
21628 o
21629 \emph default
21630 psux
21631 \end_layout
21632
21633 \end_inset
21634 </cell>
21635 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21636 \begin_inset Text
21637
21638 \begin_layout Standard
21639
21640 \family roman
21641 \series medium
21642 \shape up
21643 \size normal
21644 \emph off
21645 \bar no
21646 \noun off
21647 \color none
21648 cd
21649 \family default
21650 \series default
21651 \shape default
21652 \size default
21653 \emph default
21654 \bar default
21655 \noun default
21656 f
21657 \family roman
21658 \series medium
21659 \shape up
21660 \size normal
21661 \emph off
21662 \bar no
21663 \noun off
21664 i
21665 \family default
21666 \series default
21667 \shape default
21668 \size default
21669 \emph on
21670 \bar default
21671 \noun default
21672 o
21673 \family roman
21674 \series medium
21675 \shape up
21676 \size normal
21677 \emph off
21678 \bar no
21679 \noun off
21680 psux
21681 \end_layout
21682
21683 \end_inset
21684 </cell>
21685 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21686 \begin_inset Text
21687
21688 \begin_layout Standard
21689 c
21690 \family roman
21691 \series medium
21692 \shape up
21693 \size normal
21694 \emph off
21695 \bar no
21696 \noun off
21697 \color none
21698 d
21699 \family default
21700 \series default
21701 \shape default
21702 \size default
21703 \emph on
21704 \bar default
21705 \noun default
21706 o
21707 \family roman
21708 \series medium
21709 \shape up
21710 \size normal
21711 \emph off
21712 \bar no
21713 \noun off
21714 s
21715 \family default
21716 \series default
21717 \shape default
21718 \size default
21719 \emph default
21720 \bar default
21721 \noun default
21722 x
21723 \end_layout
21724
21725 \end_inset
21726 </cell>
21727 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21728 \begin_inset Text
21729
21730 \begin_layout Standard
21731 cdsux
21732 \end_layout
21733
21734 \end_inset
21735 </cell>
21736 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21737 \begin_inset Text
21738
21739 \begin_layout Standard
21740 cdfsux
21741 \end_layout
21742
21743 \end_inset
21744 </cell>
21745 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21746 \begin_inset Text
21747
21748 \begin_layout Standard
21749 cdsux
21750 \end_layout
21751
21752 \end_inset
21753 </cell>
21754 </row>
21755 <row topline="true">
21756 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21757 \begin_inset Text
21758
21759 \begin_layout Standard
21760 long (32 bit) support
21761 \end_layout
21762
21763 \end_inset
21764 </cell>
21765 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21766 \begin_inset Text
21767
21768 \begin_layout Standard
21769 x
21770 \end_layout
21771
21772 \end_inset
21773 </cell>
21774 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21775 \begin_inset Text
21776
21777 \begin_layout Standard
21778 x
21779 \end_layout
21780
21781 \end_inset
21782 </cell>
21783 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21784 \begin_inset Text
21785
21786 \begin_layout Standard
21787 x
21788 \end_layout
21789
21790 \end_inset
21791 </cell>
21792 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21793 \begin_inset Text
21794
21795 \begin_layout Standard
21796 x
21797 \end_layout
21798
21799 \end_inset
21800 </cell>
21801 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21802 \begin_inset Text
21803
21804 \begin_layout Standard
21805
21806 \family roman
21807 \series medium
21808 \shape up
21809 \size normal
21810 \emph off
21811 \bar no
21812 \noun off
21813 \color none
21814 x
21815 \end_layout
21816
21817 \end_inset
21818 </cell>
21819 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21820 \begin_inset Text
21821
21822 \begin_layout Standard
21823 -
21824 \end_layout
21825
21826 \end_inset
21827 </cell>
21828 </row>
21829 <row topline="true">
21830 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21831 \begin_inset Text
21832
21833 \begin_layout Standard
21834 byte arguments on stack
21835 \end_layout
21836
21837 \end_inset
21838 </cell>
21839 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21840 \begin_inset Text
21841
21842 \begin_layout Standard
21843 b
21844 \end_layout
21845
21846 \end_inset
21847 </cell>
21848 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21849 \begin_inset Text
21850
21851 \begin_layout Standard
21852 b
21853 \end_layout
21854
21855 \end_inset
21856 </cell>
21857 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21858 \begin_inset Text
21859
21860 \begin_layout Standard
21861 -
21862 \end_layout
21863
21864 \end_inset
21865 </cell>
21866 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21867 \begin_inset Text
21868
21869 \begin_layout Standard
21870 -
21871 \end_layout
21872
21873 \end_inset
21874 </cell>
21875 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21876 \begin_inset Text
21877
21878 \begin_layout Standard
21879 -
21880 \end_layout
21881
21882 \end_inset
21883 </cell>
21884 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21885 \begin_inset Text
21886
21887 \begin_layout Standard
21888 -
21889 \end_layout
21890
21891 \end_inset
21892 </cell>
21893 </row>
21894 <row topline="true">
21895 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21896 \begin_inset Text
21897
21898 \begin_layout Standard
21899 float format
21900 \begin_inset LatexCommand index
21901 name "Floating point support"
21902
21903 \end_inset
21904
21905
21906 \end_layout
21907
21908 \end_inset
21909 </cell>
21910 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21911 \begin_inset Text
21912
21913 \begin_layout Standard
21914 -
21915 \end_layout
21916
21917 \end_inset
21918 </cell>
21919 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21920 \begin_inset Text
21921
21922 \begin_layout Standard
21923 %f
21924 \end_layout
21925
21926 \end_inset
21927 </cell>
21928 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21929 \begin_inset Text
21930
21931 \begin_layout Standard
21932 -
21933 \end_layout
21934
21935 \end_inset
21936 </cell>
21937 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21938 \begin_inset Text
21939
21940 \begin_layout Standard
21941 -
21942 \end_layout
21943
21944 \end_inset
21945 </cell>
21946 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21947 \begin_inset Text
21948
21949 \begin_layout Standard
21950 %f
21951 \begin_inset Foot
21952 status collapsed
21953
21954 \begin_layout Standard
21955 Range limited to +/- 4294967040, precision limited to 8 digits past decimal
21956 \end_layout
21957
21958 \end_inset
21959
21960
21961 \end_layout
21962
21963 \end_inset
21964 </cell>
21965 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
21966 \begin_inset Text
21967
21968 \begin_layout Standard
21969 -
21970 \end_layout
21971
21972 \end_inset
21973 </cell>
21974 </row>
21975 <row topline="true">
21976 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21977 \begin_inset Text
21978
21979 \begin_layout Standard
21980 float formats %e %g
21981 \end_layout
21982
21983 \end_inset
21984 </cell>
21985 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21986 \begin_inset Text
21987
21988 \begin_layout Standard
21989 -
21990 \end_layout
21991
21992 \end_inset
21993 </cell>
21994 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
21995 \begin_inset Text
21996
21997 \begin_layout Standard
21998 -
21999 \end_layout
22000
22001 \end_inset
22002 </cell>
22003 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22004 \begin_inset Text
22005
22006 \begin_layout Standard
22007 -
22008 \end_layout
22009
22010 \end_inset
22011 </cell>
22012 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22013 \begin_inset Text
22014
22015 \begin_layout Standard
22016 -
22017 \end_layout
22018
22019 \end_inset
22020 </cell>
22021 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22022 \begin_inset Text
22023
22024 \begin_layout Standard
22025 -
22026 \end_layout
22027
22028 \end_inset
22029 </cell>
22030 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22031 \begin_inset Text
22032
22033 \begin_layout Standard
22034 -
22035 \end_layout
22036
22037 \end_inset
22038 </cell>
22039 </row>
22040 <row topline="true" bottomline="true">
22041 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22042 \begin_inset Text
22043
22044 \begin_layout Standard
22045 field width
22046 \end_layout
22047
22048 \end_inset
22049 </cell>
22050 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22051 \begin_inset Text
22052
22053 \begin_layout Standard
22054 x
22055 \end_layout
22056
22057 \end_inset
22058 </cell>
22059 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22060 \begin_inset Text
22061
22062 \begin_layout Standard
22063 x
22064 \end_layout
22065
22066 \end_inset
22067 </cell>
22068 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22069 \begin_inset Text
22070
22071 \begin_layout Standard
22072 -
22073 \end_layout
22074
22075 \end_inset
22076 </cell>
22077 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22078 \begin_inset Text
22079
22080 \begin_layout Standard
22081 x
22082 \end_layout
22083
22084 \end_inset
22085 </cell>
22086 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22087 \begin_inset Text
22088
22089 \begin_layout Standard
22090 x
22091 \end_layout
22092
22093 \end_inset
22094 </cell>
22095 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22096 \begin_inset Text
22097
22098 \begin_layout Standard
22099 -
22100 \end_layout
22101
22102 \end_inset
22103 </cell>
22104 </row>
22105 <row bottomline="true">
22106 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22107 \begin_inset Text
22108
22109 \begin_layout Standard
22110 string speed
22111 \begin_inset Foot
22112 status collapsed
22113
22114 \begin_layout Standard
22115 Execution time of printf("%s%c%s%c%c%c", "Hello", ' ', "World", '!', '
22116 \backslash
22117 r', '
22118 \backslash
22119 n'); standard 8051 @ 22.1184 MHz, empty putchar()
22120 \end_layout
22121
22122 \end_inset
22123
22124 ,
22125 \end_layout
22126
22127 \begin_layout Standard
22128 small / large
22129 \end_layout
22130
22131 \end_inset
22132 </cell>
22133 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22134 \begin_inset Text
22135
22136 \begin_layout Standard
22137 1.52 / 2.59 ms
22138 \end_layout
22139
22140 \end_inset
22141 </cell>
22142 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22143 \begin_inset Text
22144
22145 \begin_layout Standard
22146 1.53 / 2.62 ms
22147 \end_layout
22148
22149 \end_inset
22150 </cell>
22151 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22152 \begin_inset Text
22153
22154 \begin_layout Standard
22155 0.92 / 0.93 ms
22156 \end_layout
22157
22158 \end_inset
22159 </cell>
22160 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22161 \begin_inset Text
22162
22163 \begin_layout Standard
22164 0.45 / 0.45 ms
22165 \end_layout
22166
22167 \end_inset
22168 </cell>
22169 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22170 \begin_inset Text
22171
22172 \begin_layout Standard
22173 0.46 / 0.46 ms
22174 \end_layout
22175
22176 \end_inset
22177 </cell>
22178 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22179 \begin_inset Text
22180
22181 \begin_layout Standard
22182 0.45 / 0.45 ms
22183 \end_layout
22184
22185 \end_inset
22186 </cell>
22187 </row>
22188 <row bottomline="true">
22189 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22190 \begin_inset Text
22191
22192 \begin_layout Standard
22193 int speed
22194 \begin_inset Foot
22195 status collapsed
22196
22197 \begin_layout Standard
22198 Execution time of printf("%d", -12345); standard 8051 @ 22.1184 MHz, empty
22199  putchar()
22200 \end_layout
22201
22202 \end_inset
22203
22204 ,
22205 \end_layout
22206
22207 \begin_layout Standard
22208 small / large
22209 \end_layout
22210
22211 \end_inset
22212 </cell>
22213 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22214 \begin_inset Text
22215
22216 \begin_layout Standard
22217 3.01 / 3.61 ms
22218 \end_layout
22219
22220 \end_inset
22221 </cell>
22222 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22223 \begin_inset Text
22224
22225 \begin_layout Standard
22226 3.01 / 3.61 ms
22227 \end_layout
22228
22229 \end_inset
22230 </cell>
22231 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22232 \begin_inset Text
22233
22234 \begin_layout Standard
22235 3.51 / 18.13 ms
22236 \end_layout
22237
22238 \end_inset
22239 </cell>
22240 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22241 \begin_inset Text
22242
22243 \begin_layout Standard
22244 0.22 / 0.22 ms
22245 \end_layout
22246
22247 \end_inset
22248 </cell>
22249 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22250 \begin_inset Text
22251
22252 \begin_layout Standard
22253 0.23 / 0.23 ms
22254 \end_layout
22255
22256 \end_inset
22257 </cell>
22258 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22259 \begin_inset Text
22260
22261 \begin_layout Standard
22262 0.25 / 0.25 ms
22263 \begin_inset Foot
22264 status collapsed
22265
22266 \begin_layout Standard
22267 printf_tiny integer speed is data dependent, worst case is 0.33 ms
22268 \end_layout
22269
22270 \end_inset
22271
22272
22273 \end_layout
22274
22275 \end_inset
22276 </cell>
22277 </row>
22278 <row bottomline="true">
22279 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22280 \begin_inset Text
22281
22282 \begin_layout Standard
22283 long speed
22284 \begin_inset Foot
22285 status collapsed
22286
22287 \begin_layout Standard
22288 Execution time of printf("%ld", -123456789); standard 8051 @ 22.1184 MHz,
22289  empty putchar()
22290 \end_layout
22291
22292 \end_inset
22293
22294 ,
22295 \end_layout
22296
22297 \begin_layout Standard
22298 small / large
22299 \end_layout
22300
22301 \end_inset
22302 </cell>
22303 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22304 \begin_inset Text
22305
22306 \begin_layout Standard
22307 5.37 / 6.31 ms
22308 \end_layout
22309
22310 \end_inset
22311 </cell>
22312 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22313 \begin_inset Text
22314
22315 \begin_layout Standard
22316 5.37 / 6.31 ms
22317 \end_layout
22318
22319 \end_inset
22320 </cell>
22321 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22322 \begin_inset Text
22323
22324 \begin_layout Standard
22325 8.71 / 40.65 ms
22326 \end_layout
22327
22328 \end_inset
22329 </cell>
22330 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22331 \begin_inset Text
22332
22333 \begin_layout Standard
22334 0.40 / 0.40 ms
22335 \end_layout
22336
22337 \end_inset
22338 </cell>
22339 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22340 \begin_inset Text
22341
22342 \begin_layout Standard
22343 0.40 / 0.40 ms
22344 \end_layout
22345
22346 \end_inset
22347 </cell>
22348 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22349 \begin_inset Text
22350
22351 \begin_layout Standard
22352 -
22353 \end_layout
22354
22355 \end_inset
22356 </cell>
22357 </row>
22358 <row bottomline="true">
22359 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22360 \begin_inset Text
22361
22362 \begin_layout Standard
22363 float speed
22364 \begin_inset Foot
22365 status collapsed
22366
22367 \begin_layout Standard
22368 Execution time of printf("%.3f", -12345.678); standard 8051 @ 22.1184 MHz,
22369  empty putchar()
22370 \end_layout
22371
22372 \end_inset
22373
22374 ,
22375 \end_layout
22376
22377 \begin_layout Standard
22378 small / large
22379 \end_layout
22380
22381 \end_inset
22382 </cell>
22383 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22384 \begin_inset Text
22385
22386 \begin_layout Standard
22387 -
22388 \end_layout
22389
22390 \end_inset
22391 </cell>
22392 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22393 \begin_inset Text
22394
22395 \begin_layout Standard
22396 7.49 / 22.47 ms
22397 \end_layout
22398
22399 \end_inset
22400 </cell>
22401 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22402 \begin_inset Text
22403
22404 \begin_layout Standard
22405 -
22406 \end_layout
22407
22408 \end_inset
22409 </cell>
22410 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22411 \begin_inset Text
22412
22413 \begin_layout Standard
22414 -
22415 \end_layout
22416
22417 \end_inset
22418 </cell>
22419 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
22420 \begin_inset Text
22421
22422 \begin_layout Standard
22423 1.04 / 1.04 ms
22424 \end_layout
22425
22426 \end_inset
22427 </cell>
22428 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
22429 \begin_inset Text
22430
22431 \begin_layout Standard
22432 -
22433 \end_layout
22434
22435 \end_inset
22436 </cell>
22437 </row>
22438 </lyxtabular>
22439
22440 \end_inset
22441
22442
22443 \end_layout
22444
22445 \begin_layout Subsubsection
22446 <malloc.h>
22447 \begin_inset LatexCommand index
22448 name "malloc.h"
22449
22450 \end_inset
22451
22452
22453 \end_layout
22454
22455 \begin_layout Standard
22456 As of SDCC 2.6.2 you no longer need to call an initialization routine before
22457  using dynamic memory allocation
22458 \begin_inset LatexCommand index
22459 name "dynamic memory allocation (malloc)"
22460
22461 \end_inset
22462
22463  and a default heap
22464 \begin_inset LatexCommand index
22465 name "heap (malloc)"
22466
22467 \end_inset
22468
22469  space of 1024 bytes is provided for malloc to allocate memory from.
22470  If you need a different heap size you need to recompile _heap.c with the
22471  required size defined in HEAP_SIZE.
22472  It is recommended to make a copy of this file into your project directory
22473  and compile it there with:
22474 \end_layout
22475
22476 \begin_layout Verse
22477
22478 \family typewriter
22479 sdcc -c _heap.c -D HEAP_SIZE=2048
22480 \end_layout
22481
22482 \begin_layout Standard
22483 And then link it with:
22484 \end_layout
22485
22486 \begin_layout Verse
22487
22488 \family typewriter
22489 sdcc main.rel _heap.rel
22490 \end_layout
22491
22492 \begin_layout Subsection
22493 Math functions (sinf, powf, sqrtf etc.)
22494 \end_layout
22495
22496 \begin_layout Subsubsection
22497 <math.h>
22498 \end_layout
22499
22500 \begin_layout Standard
22501 See definitions in file <math.h>.
22502 \end_layout
22503
22504 \begin_layout Subsection
22505 Other libraries
22506 \end_layout
22507
22508 \begin_layout Standard
22509 Libraries
22510 \begin_inset LatexCommand index
22511 name "Libraries"
22512
22513 \end_inset
22514
22515  included in SDCC should have a license at least as liberal as the GNU Lesser
22516  General Public License
22517 \begin_inset LatexCommand index
22518 name "GNU Lesser General Public License, LGPL"
22519
22520 \end_inset
22521
22522  
22523 \emph on
22524 LGPL
22525 \emph default
22526 .
22527 \end_layout
22528
22529 \begin_layout Standard
22530 \begin_inset Note Note
22531 status collapsed
22532
22533 \begin_layout Standard
22534 license statements for the libraries are missing.
22535  sdcc/device/lib/ser_ir.c
22536 \end_layout
22537
22538 \begin_layout Standard
22539 or _decdptr f.e.
22540  come with a GPL (as opposed to LGPL) License - this will not be liberal
22541  enough for many embedded programmers.
22542 \end_layout
22543
22544 \end_inset
22545
22546
22547 \end_layout
22548
22549 \begin_layout Standard
22550 If you have ported some library or want to share experience about some code
22551  which f.e.
22552  falls into any of these categories Busses (I
22553 \begin_inset Formula $^{\textrm{2}}$
22554 \end_inset
22555
22556 C, CAN, Ethernet, Profibus, Modbus, USB, SPI, JTAG ...), Media (IDE, Memory
22557  cards, eeprom, flash...), En-/Decryption, Remote debugging, Realtime kernel,
22558  Keyboard, LCD, RTC, FPGA, PID then the sdcc-user mailing list 
22559 \begin_inset LatexCommand url
22560 target "http://sourceforge.net/mail/?group_id=599"
22561
22562 \end_inset
22563
22564 \InsetSpace ~
22565 would certainly like to hear about it.
22566 \end_layout
22567
22568 \begin_layout Standard
22569 Programmers coding for embedded systems are not especially famous for being
22570  enthusiastic, so don't expect a big hurray but as the mailing list is searchabl
22571 e these references are very valuable.
22572  Let's help to create a climate where information is shared.
22573 \begin_inset VSpace bigskip
22574 \end_inset
22575
22576
22577 \end_layout
22578
22579 \begin_layout Section
22580 Memory Models
22581 \end_layout
22582
22583 \begin_layout Subsection
22584 MCS51 Memory Models
22585 \begin_inset LatexCommand index
22586 name "Memory model"
22587
22588 \end_inset
22589
22590
22591 \begin_inset LatexCommand index
22592 name "MCS51 memory model"
22593
22594 \end_inset
22595
22596
22597 \end_layout
22598
22599 \begin_layout Subsubsection
22600 Small, Medium and Large
22601 \end_layout
22602
22603 \begin_layout Standard
22604 SDCC allows three memory models for MCS51 code, 
22605 \shape slanted
22606 small, medium
22607 \shape default
22608  and 
22609 \shape slanted
22610 large
22611 \shape default
22612 .
22613  Modules compiled with different memory models should 
22614 \emph on
22615 never
22616 \emph default
22617  be combined together or the results would be unpredictable.
22618  The library routines supplied with the compiler are compiled as small,
22619  medium and large.
22620  The compiled library modules are contained in separate directories as small,
22621  medium and large so that you can link to the appropriate set.
22622 \end_layout
22623
22624 \begin_layout Standard
22625 When the medium or large model is used all variables declared without a
22626  storage class will be allocated into the external ram, this includes all
22627  parameters and local variables (for non-reentrant
22628 \begin_inset LatexCommand index
22629 name "reentrant"
22630
22631 \end_inset
22632
22633  functions).
22634  When the small model is used variables without storage class are allocated
22635  in the internal ram.
22636 \end_layout
22637
22638 \begin_layout Standard
22639 Judicious usage of the processor specific storage classes
22640 \begin_inset LatexCommand index
22641 name "Storage class"
22642
22643 \end_inset
22644
22645  and the 'reentrant' function type will yield much more efficient code,
22646  than using the large model.
22647  Several optimizations are disabled when the program is compiled using the
22648  large model, it is therefore recommended that the small model be used unless
22649  absolutely required.
22650 \end_layout
22651
22652 \begin_layout Subsubsection
22653 External Stack
22654 \begin_inset LatexCommand label
22655 name "sub:External-Stack"
22656
22657 \end_inset
22658
22659
22660 \begin_inset LatexCommand index
22661 name "stack"
22662
22663 \end_inset
22664
22665
22666 \begin_inset LatexCommand index
22667 name "External stack (mcs51)"
22668
22669 \end_inset
22670
22671
22672 \end_layout
22673
22674 \begin_layout Standard
22675 The external stack (-
22676 \begin_inset ERT
22677 status collapsed
22678
22679 \begin_layout Standard
22680
22681
22682 \backslash
22683 /
22684 \end_layout
22685
22686 \end_inset
22687
22688 -xstack option
22689 \begin_inset LatexCommand index
22690 name "-\\/-xstack"
22691
22692 \end_inset
22693
22694 ) is located in pdata
22695 \begin_inset LatexCommand index
22696 name "pdata (mcs51, ds390 storage class)"
22697
22698 \end_inset
22699
22700  memory (usually at the start of the external ram segment) and uses all
22701  unused space in pdata (max.
22702  256 bytes).
22703  When -
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 -xstack option is used to compile the program, the parameters and local
22717  variables
22718 \begin_inset LatexCommand index
22719 name "local variables"
22720
22721 \end_inset
22722
22723  of all reentrant functions are allocated in this area.
22724  This option is provided for programs with large stack space requirements.
22725  When used with the -
22726 \begin_inset ERT
22727 status collapsed
22728
22729 \begin_layout Standard
22730
22731
22732 \backslash
22733 /
22734 \end_layout
22735
22736 \end_inset
22737
22738 -stack-auto
22739 \begin_inset LatexCommand index
22740 name "-\\/-stack-auto"
22741
22742 \end_inset
22743
22744  option, all parameters and local variables are allocated on the external
22745  stack (note: support libraries will need to be recompiled with the same
22746  options.
22747  There is a predefined target in the library makefile).
22748 \end_layout
22749
22750 \begin_layout Standard
22751 The compiler outputs the higher order address byte of the external ram segment
22752  into port P2
22753 \begin_inset LatexCommand index
22754 name "P2 (mcs51 sfr)"
22755
22756 \end_inset
22757
22758  (see also section 
22759 \begin_inset LatexCommand ref
22760 reference "sub:MCS51-variants"
22761
22762 \end_inset
22763
22764 ), therefore when using the External Stack option, this port 
22765 \emph on
22766 may not
22767 \emph default
22768  be used by the application program.
22769 \end_layout
22770
22771 \begin_layout Subsection
22772 DS390 Memory Model
22773 \begin_inset LatexCommand index
22774 name "Memory model"
22775
22776 \end_inset
22777
22778
22779 \begin_inset LatexCommand index
22780 name "DS390 memory model"
22781
22782 \end_inset
22783
22784
22785 \end_layout
22786
22787 \begin_layout Standard
22788 The only model supported is Flat 24
22789 \begin_inset LatexCommand index
22790 name "Flat 24 (DS390 memory model)"
22791
22792 \end_inset
22793
22794 .
22795  This generates code for the 24 bit contiguous addressing mode of the Dallas
22796  DS80C390 part.
22797  In this mode, up to four meg of external RAM or code space can be directly
22798  addressed.
22799  See the data sheets at www.dalsemi.com for further information on this part.
22800 \newline
22801
22802 \newline
22803 Note
22804  that the compiler does not generate any code to place the processor into
22805  24 bitmode (although 
22806 \emph on
22807 tinibios
22808 \emph default
22809  in the ds390 libraries will do that for you).
22810  If you don't use 
22811 \emph on
22812 tinibios
22813 \emph default
22814
22815 \begin_inset LatexCommand index
22816 name "Tinibios (DS390)"
22817
22818 \end_inset
22819
22820 , the boot loader or similar code must ensure that the processor is in 24
22821  bit contiguous addressing mode before calling the SDCC startup code.
22822 \newline
22823
22824 \newline
22825 Like
22826  the 
22827 \emph on
22828 -
22829 \begin_inset ERT
22830 status collapsed
22831
22832 \begin_layout Standard
22833
22834
22835 \backslash
22836 /
22837 \end_layout
22838
22839 \end_inset
22840
22841 -model-large
22842 \emph default
22843  option, variables will by default be placed into the XDATA segment.
22844  
22845 \newline
22846
22847 \newline
22848 Segments may be placed anywhere in the 4 meg address space using the usual
22849  -
22850 \begin_inset ERT
22851 status collapsed
22852
22853 \begin_layout Standard
22854
22855
22856 \backslash
22857 /
22858 \end_layout
22859
22860 \end_inset
22861
22862 -*-loc options.
22863  Note that if any segments are located above 64K, the -r flag must be passed
22864  to the linker to generate the proper segment relocations, and the Intel
22865  HEX output format must be used.
22866  The -r flag can be passed to the linker by using the option 
22867 \emph on
22868 -Wl-r
22869 \emph default
22870  on the SDCC command line.
22871  However, currently the linker can not handle code segments > 64k.
22872 \end_layout
22873
22874 \begin_layout Section
22875 Pragmas
22876 \begin_inset LatexCommand label
22877 name "sec:Pragmas"
22878
22879 \end_inset
22880
22881
22882 \begin_inset LatexCommand index
22883 name "Pragmas"
22884
22885 \end_inset
22886
22887
22888 \end_layout
22889
22890 \begin_layout Standard
22891 Pragmas are used to turn on and/or off certain compiler options.
22892  Some of them are closely related to corresponding command-line options
22893  (see section 
22894 \begin_inset LatexCommand vref
22895 reference "sec:Command-Line-Options"
22896
22897 \end_inset
22898
22899 ).
22900 \newline
22901 Pragmas should be placed before and/or after a function, placing pragmas
22902  inside a function body could have unpredictable results.
22903 \newline
22904
22905 \newline
22906 SDCC supports the
22907  following #pragma directives:
22908 \end_layout
22909
22910 \begin_layout Itemize
22911
22912 \series bold
22913 save
22914 \series default
22915
22916 \begin_inset LatexCommand index
22917 name "\\#pragma save"
22918
22919 \end_inset
22920
22921  - this will save most current options to the save/restore stack.
22922  See #pragma\InsetSpace ~
22923 restore.
22924 \end_layout
22925
22926 \begin_layout Itemize
22927
22928 \series bold
22929 restore
22930 \series default
22931
22932 \begin_inset LatexCommand index
22933 name "\\#pragma restore"
22934
22935 \end_inset
22936
22937  - will restore saved options from the last save.
22938  saves & restores can be nested.
22939  SDCC uses a save/restore stack: save pushes current options to the stack,
22940  restore pulls current options from the stack.
22941  See #pragma\InsetSpace ~
22942 save.
22943 \newline
22944
22945 \end_layout
22946
22947 \begin_layout Itemize
22948
22949 \series bold
22950 callee_saves
22951 \series default
22952
22953 \begin_inset LatexCommand index
22954 name "\\#pragma callee\\_saves"
22955
22956 \end_inset
22957
22958
22959 \begin_inset LatexCommand index
22960 name "function prologue"
22961
22962 \end_inset
22963
22964  function1[,function2[,function3...]] 
22965 \begin_inset LatexCommand label
22966 name "ite:callee_saves-function1[,function2[,function3...]]--"
22967
22968 \end_inset
22969
22970 - The compiler by default uses a caller saves convention for register saving
22971  across function calls, however this can cause unnecessary register pushing
22972  and popping
22973 \begin_inset LatexCommand index
22974 name "push/pop"
22975
22976 \end_inset
22977
22978  when calling small functions from larger functions.
22979  This option can be used to switch off the register saving convention for
22980  the function names specified.
22981  The compiler will not save registers when calling these functions, extra
22982  code need to be manually inserted at the entry and exit for these functions
22983  to save and restore the registers used by these functions, this can SUBSTANTIAL
22984 LY reduce code and improve run time performance of the generated code.
22985  In the future the compiler (with inter procedural analysis) may be able
22986  to determine the appropriate scheme to use for each function call.
22987  If -
22988 \begin_inset ERT
22989 status collapsed
22990
22991 \begin_layout Standard
22992
22993
22994 \backslash
22995 /
22996 \end_layout
22997
22998 \end_inset
22999
23000 -callee-saves command line option is used (see page 
23001 \begin_inset LatexCommand vpageref
23002 reference "lyx:--callee-saves-function1[,function2][,function3]..."
23003
23004 \end_inset
23005
23006 ), the function names specified in #pragma\InsetSpace ~
23007 callee_saves
23008 \begin_inset LatexCommand index
23009 name "\\#pragma callee\\_saves"
23010
23011 \end_inset
23012
23013  is appended to the list of functions specified in the command line.
23014 \end_layout
23015
23016 \begin_layout Itemize
23017
23018 \series bold
23019 exclude
23020 \series default
23021
23022 \begin_inset LatexCommand index
23023 name "\\#pragma exclude"
23024
23025 \end_inset
23026
23027  none | {acc[,b[,dpl[,dph]]] - The exclude pragma disables the generation
23028  of pairs of push/pop
23029 \begin_inset LatexCommand index
23030 name "push/pop"
23031
23032 \end_inset
23033
23034  instructions in 
23035 \emph on
23036 I
23037 \emph default
23038 nterrupt
23039 \begin_inset LatexCommand index
23040 name "interrupt"
23041
23042 \end_inset
23043
23044  
23045 \emph on
23046 S
23047 \emph default
23048 ervice 
23049 \emph on
23050 R
23051 \emph default
23052 outines.
23053  The directive should be placed immediately before the ISR function definition
23054  and it affects ALL ISR functions following it.
23055  To enable the normal register saving for ISR functions use #pragma\InsetSpace ~
23056 exclude\InsetSpace ~
23057 none
23058 \begin_inset LatexCommand index
23059 name "\\#pragma exclude"
23060
23061 \end_inset
23062
23063 .
23064  See also the related keyword _naked
23065 \begin_inset LatexCommand index
23066 name "\\_naked"
23067
23068 \end_inset
23069
23070
23071 \begin_inset LatexCommand index
23072 name "\\_\\_naked"
23073
23074 \end_inset
23075
23076 .
23077 \end_layout
23078
23079 \begin_layout Itemize
23080
23081 \series bold
23082 less_pedantic
23083 \series default
23084
23085 \begin_inset LatexCommand index
23086 name "pedantic"
23087
23088 \end_inset
23089
23090
23091 \begin_inset LatexCommand index
23092 name "\\#pragma less\\_pedantic"
23093
23094 \end_inset
23095
23096  
23097 \begin_inset LatexCommand label
23098 name "ite:less_pedantic"
23099
23100 \end_inset
23101
23102 - the compiler will not warn you anymore for obvious mistakes, you're on
23103  your own now ;-( .
23104  See also the command line option -
23105 \begin_inset ERT
23106 status collapsed
23107
23108 \begin_layout Standard
23109
23110
23111 \backslash
23112 /
23113 \end_layout
23114
23115 \end_inset
23116
23117 -less-pedantic 
23118 \begin_inset LatexCommand vpageref
23119 reference "lyx:--less-pedantic"
23120
23121 \end_inset
23122
23123 .
23124  
23125 \newline
23126 More specifically, the following warnings will be disabled: 
23127 \shape italic
23128 comparison is always [true/false] due to limited range of data type
23129 \shape default
23130  (94); 
23131 \shape italic
23132 overflow in implicit constant conversion
23133 \shape default
23134  (158); [the (in)famous] 
23135 \shape italic
23136 conditional flow changed by optimizer: so said EVELYN the modified DOG
23137 \shape default
23138  (110); 
23139 \shape italic
23140 function '[function name]' must return value
23141 \shape default
23142  (59).
23143  
23144 \newline
23145 Furthermore, warnings of less importance (of PEDANTIC and INFO warning
23146  level) are disabled, too, namely: 
23147 \shape italic
23148 constant value '[
23149 \begin_inset Note Note
23150 status collapsed
23151
23152 \begin_layout Standard
23153 dunno what comes here - this warning appears to be unused altogether
23154 \end_layout
23155
23156 \end_inset
23157
23158 ]', out of range
23159 \shape default
23160  (81); 
23161 \shape italic
23162 [left/right] shifting more than size of object changed to zero
23163 \shape default
23164  (116); 
23165 \shape italic
23166 unreachable code
23167 \shape default
23168  (126); 
23169 \shape italic
23170 integer overflow in expression
23171 \shape default
23172  (165); 
23173 \shape italic
23174 unmatched #pragma save and #pragma restore
23175 \shape default
23176  (170); 
23177 \shape italic
23178 comparison of 'signed char' with 'unsigned char' requires promotion to int
23179 \shape default
23180  (185); 
23181 \shape italic
23182 ISO C90 does not support flexible array members
23183 \shape default
23184  (187); 
23185 \shape italic
23186 extended stack by [number] bytes for compiler temp(s) :in function '[function\InsetSpace ~
23187 nam
23188 e]':\InsetSpace ~
23189 [
23190 \begin_inset Note Note
23191 status collapsed
23192
23193 \begin_layout Standard
23194 appears to be always blank - what was supposed to be here?
23195 \end_layout
23196
23197 \end_inset
23198
23199 ]
23200 \shape default
23201  (114); 
23202 \shape italic
23203 function '[function name]', # edges [number] , # nodes [number] , cyclomatic
23204  complexity [number]
23205 \shape default
23206  (121).
23207 \end_layout
23208
23209 \begin_layout Itemize
23210
23211 \series bold
23212 disable_warning
23213 \series default
23214  <nnnn>
23215 \begin_inset LatexCommand index
23216 name "\\#pragma disable\\_warning"
23217
23218 \end_inset
23219
23220  - the compiler will not warn you anymore about warning number <nnnn>.
23221 \end_layout
23222
23223 \begin_layout Itemize
23224
23225 \series bold
23226 nogcse
23227 \series default
23228
23229 \begin_inset LatexCommand index
23230 name "\\#pragma nogcse"
23231
23232 \end_inset
23233
23234  - will stop global common subexpression elimination.
23235 \end_layout
23236
23237 \begin_layout Itemize
23238
23239 \series bold
23240 noinduction
23241 \series default
23242
23243 \begin_inset LatexCommand index
23244 name "\\#pragma noinduction"
23245
23246 \end_inset
23247
23248  - will stop loop induction optimizations.
23249 \end_layout
23250
23251 \begin_layout Itemize
23252
23253 \series bold
23254 noinvariant
23255 \series default
23256
23257 \begin_inset LatexCommand index
23258 name "\\#pragma noinvariant"
23259
23260 \end_inset
23261
23262  - will not do loop invariant optimizations.
23263  For more details see Loop Invariants in section
23264 \begin_inset LatexCommand ref
23265 reference "sub:Loop-Optimizations"
23266
23267 \end_inset
23268
23269 .
23270 \end_layout
23271
23272 \begin_layout Itemize
23273
23274 \series bold
23275 noiv
23276 \series default
23277
23278 \begin_inset LatexCommand index
23279 name "\\#pragma noiv"
23280
23281 \end_inset
23282
23283  - Do not generate interrupt
23284 \begin_inset LatexCommand index
23285 name "interrupt"
23286
23287 \end_inset
23288
23289  vector table
23290 \begin_inset LatexCommand index
23291 name "interrupt vector table"
23292
23293 \end_inset
23294
23295  entries for all ISR functions defined after the pragma.
23296  This is useful in cases where the interrupt vector table must be defined
23297  manually, or when there is a secondary, manually defined interrupt vector
23298  table (e.g.
23299  for the autovector feature of the Cypress EZ-USB FX2).
23300  More elegantly this can be achieved by omitting the optional interrupt
23301  number after the interrupt keyword, see section 
23302 \begin_inset LatexCommand ref
23303 reference "sub:Interrupt-Service-Routines"
23304
23305 \end_inset
23306
23307 \InsetSpace ~
23308 about interrupts.
23309 \end_layout
23310
23311 \begin_layout Itemize
23312
23313 \series bold
23314 nojtbound
23315 \series default
23316
23317 \begin_inset LatexCommand index
23318 name "\\#pragma nojtbound"
23319
23320 \end_inset
23321
23322  - will not generate code for boundary value checking, when switch statements
23323  are turned into jump-tables (dangerous).
23324  For more details see section 
23325 \begin_inset LatexCommand ref
23326 reference "sub:'switch'-Statements"
23327
23328 \end_inset
23329
23330 .
23331 \end_layout
23332
23333 \begin_layout Itemize
23334
23335 \series bold
23336 noloopreverse
23337 \series default
23338
23339 \begin_inset LatexCommand index
23340 name "\\#pragma noloopreverse"
23341
23342 \end_inset
23343
23344  - Will not do loop reversal optimization
23345 \end_layout
23346
23347 \begin_layout Itemize
23348
23349 \series bold
23350 nooverlay
23351 \series default
23352
23353 \begin_inset LatexCommand index
23354 name "\\#pragma nooverlay"
23355
23356 \end_inset
23357
23358  - the compiler will not overlay the parameters and local variables of a
23359  function.
23360 \end_layout
23361
23362 \begin_layout Itemize
23363
23364 \series bold
23365 stackauto
23366 \series default
23367
23368 \begin_inset LatexCommand index
23369 name "\\#pragma stackauto"
23370
23371 \end_inset
23372
23373 - See option -
23374 \begin_inset ERT
23375 status collapsed
23376
23377 \begin_layout Standard
23378
23379
23380 \backslash
23381 /
23382 \end_layout
23383
23384 \end_inset
23385
23386 -stack-auto
23387 \begin_inset LatexCommand index
23388 name "-\\/-stack-auto"
23389
23390 \end_inset
23391
23392  and section 
23393 \begin_inset LatexCommand ref
23394 reference "sec:Parameters-and-Local-Variables"
23395
23396 \end_inset
23397
23398  Parameters and Local Variables.
23399 \end_layout
23400
23401 \begin_layout Itemize
23402
23403 \series bold
23404 opt_code_speed
23405 \series default
23406  
23407 \begin_inset LatexCommand index
23408 name "\\#pragma opt\\_code\\_speed"
23409
23410 \end_inset
23411
23412 - The compiler will optimize code generation towards fast code, possibly
23413  at the expense of code size.
23414  Currently this has little effect.
23415 \end_layout
23416
23417 \begin_layout Itemize
23418
23419 \series bold
23420 opt_code_size
23421 \series default
23422  
23423 \begin_inset LatexCommand index
23424 name "\\#pragma opt\\_code\\_size"
23425
23426 \end_inset
23427
23428 - The compiler will optimize code generation towards compact code, possibly
23429  at the expense of code speed.
23430  Currently this has little effect.
23431 \end_layout
23432
23433 \begin_layout Itemize
23434
23435 \series bold
23436 opt_code_balanced
23437 \series default
23438  
23439 \begin_inset LatexCommand index
23440 name "\\#pragma opt\\_code\\_balanced"
23441
23442 \end_inset
23443
23444 - The compiler will attempt to generate code that is both compact and fast,
23445  as long as meeting one goal is not a detriment to the other (this is the
23446  default).
23447  
23448 \end_layout
23449
23450 \begin_layout Itemize
23451
23452 \series bold
23453 std_sdcc89
23454 \series default
23455  
23456 \begin_inset LatexCommand index
23457 name "\\#pragma std\\_sdcc89"
23458
23459 \end_inset
23460
23461 - Generally follow the C89 standard, but allow SDCC features that conflict
23462  with the standard (default).
23463 \end_layout
23464
23465 \begin_layout Itemize
23466
23467 \series bold
23468 std_c89
23469 \series default
23470  
23471 \begin_inset LatexCommand index
23472 name "\\#pragma std\\_c89"
23473
23474 \end_inset
23475
23476 - Follow the C89 standard and disable SDCC features that conflict with the
23477  standard.
23478 \end_layout
23479
23480 \begin_layout Itemize
23481
23482 \series bold
23483 std_sdcc99
23484 \series default
23485  
23486 \begin_inset LatexCommand index
23487 name "\\#pragma std\\_sdcc99"
23488
23489 \end_inset
23490
23491 - Generally follow the C99 standard, but allow SDCC features that conflict
23492  with the standard (incomplete support).
23493 \end_layout
23494
23495 \begin_layout Itemize
23496
23497 \series bold
23498 std_c99
23499 \series default
23500  
23501 \begin_inset LatexCommand index
23502 name "\\#pragma std\\_c99"
23503
23504 \end_inset
23505
23506 - Follow the C99 standard and disable SDCC features that conflict with the
23507  standard (incomplete support).
23508 \end_layout
23509
23510 \begin_layout Itemize
23511
23512 \series bold
23513 codeseg
23514 \series default
23515  <name>
23516 \begin_inset LatexCommand index
23517 name "\\#pragma codeseg"
23518
23519 \end_inset
23520
23521 - Use this name (max.
23522  8 characters) for the code segment.
23523  See option -
23524 \begin_inset ERT
23525 status collapsed
23526
23527 \begin_layout Standard
23528
23529
23530 \backslash
23531 /
23532 \end_layout
23533
23534 \end_inset
23535
23536 -codeseg.
23537 \end_layout
23538
23539 \begin_layout Itemize
23540
23541 \series bold
23542 constseg
23543 \series default
23544  <name>
23545 \begin_inset LatexCommand index
23546 name "\\#pragma constseg"
23547
23548 \end_inset
23549
23550 - Use this name (max.
23551  8 characters) for the const segment.
23552  See option -
23553 \begin_inset ERT
23554 status collapsed
23555
23556 \begin_layout Standard
23557
23558
23559 \backslash
23560 /
23561 \end_layout
23562
23563 \end_inset
23564
23565 -constseg.
23566 \end_layout
23567
23568 \begin_layout Standard
23569 The preprocessor SDCPP
23570 \begin_inset LatexCommand index
23571 name "sdcpp (preprocessor)"
23572
23573 \end_inset
23574
23575  supports the following #pragma directives:
23576 \end_layout
23577
23578 \begin_layout Itemize
23579
23580 \series bold
23581 pedantic_parse_number
23582 \series default
23583
23584 \begin_inset LatexCommand index
23585 name "pedantic"
23586
23587 \end_inset
23588
23589
23590 \begin_inset LatexCommand index
23591 name "\\#pragma pedantic\\_parse\\_number"
23592
23593 \end_inset
23594
23595  (+ | -) 
23596 \begin_inset LatexCommand label
23597 name "ite:pedantic_parse_number"
23598
23599 \end_inset
23600
23601 - Pedantic parse numbers so that situations like 0xfe-LO_B(3) are parsed
23602  properly and the macro LO_B(3) gets expanded.
23603  Default is off.
23604  See also the -
23605 \begin_inset ERT
23606 status collapsed
23607
23608 \begin_layout Standard
23609
23610
23611 \backslash
23612 /
23613 \end_layout
23614
23615 \end_inset
23616
23617 -pedantic-parse-number command line option 
23618 \begin_inset LatexCommand vpageref
23619 reference "lyx:-pedantic-parse-number"
23620
23621 \end_inset
23622
23623 .
23624  
23625 \newline
23626 Below is an example on how to use this pragma.
23627  
23628 \emph on
23629 Note: this functionality is not in conformance with standard!
23630 \end_layout
23631
23632 \begin_layout Verse
23633
23634 \family typewriter
23635 #pragma pedantic_parse_number +
23636 \begin_inset LatexCommand index
23637 name "\\#pragma pedantic\\_parse\\_number"
23638
23639 \end_inset
23640
23641
23642 \newline
23643
23644 \newline
23645 #define LO_B(x) ((x) & 0xff)
23646 \newline
23647
23648 \newline
23649 unsigned char foo(void)
23650 \newline
23651 {
23652 \newline
23653 \InsetSpace ~
23654 \InsetSpace ~
23655 \InsetSpace ~
23656 unsigned char c=0xfe-LO_B(3)
23657 ;
23658 \newline
23659
23660 \newline
23661 \InsetSpace ~
23662 \InsetSpace ~
23663 \InsetSpace ~
23664 return c;
23665 \newline
23666 }
23667 \newline
23668
23669 \end_layout
23670
23671 \begin_layout Itemize
23672
23673 \series bold
23674 preproc_asm
23675 \series default
23676
23677 \begin_inset LatexCommand index
23678 name "\\#pragma preproc\\_asm"
23679
23680 \end_inset
23681
23682  (+ | -) - switch _asm _endasm block preprocessing on / off.
23683  Default is on.
23684  You use this pragma to define multilines of assembly code.
23685  This will prevent the preprocessor from changing the formatting required
23686  by assembly code.
23687  Below is an example on how to use this pragma.
23688 \end_layout
23689
23690 \begin_layout Verse
23691
23692 \family typewriter
23693 #pragma preproc_asm -
23694 \begin_inset LatexCommand index
23695 name "\\#pragma preproc\\_asm"
23696
23697 \end_inset
23698
23699
23700 \newline
23701 #define MYDELAY _asm
23702 \newline
23703 \InsetSpace ~
23704 \InsetSpace ~
23705 \InsetSpace ~
23706 nop ;my assembly comment...
23707 \newline
23708 \InsetSpace ~
23709 \InsetSpace ~
23710 \InsetSpace ~
23711 nop
23712 \newline
23713 \InsetSpace ~
23714 \InsetSpace ~
23715 \InsetSpace ~
23716 nop
23717 \newline
23718 _endasm
23719 \newline
23720 #pragma preproc_asm
23721  +
23722 \newline
23723
23724 \newline
23725 void foo (void) 
23726 \newline
23727
23728 \newline
23729 \InsetSpace ~
23730 \InsetSpace ~
23731 \InsetSpace ~
23732  ...
23733  
23734 \newline
23735 \InsetSpace ~
23736 \InsetSpace ~
23737 \InsetSpace ~
23738  MYDELAY;
23739 \newline
23740 \InsetSpace ~
23741 \InsetSpace ~
23742 \InsetSpace ~
23743  ...
23744  
23745 \newline
23746
23747 \newline
23748
23749 \end_layout
23750
23751 \begin_layout Itemize
23752
23753 \series bold
23754 sdcc_hash
23755 \series default
23756
23757 \begin_inset LatexCommand index
23758 name "\\#pragma sdcc\\_hash"
23759
23760 \end_inset
23761
23762  (+ | -) - Allow "naked" hash in macro definition, for example:
23763 \newline
23764
23765 \family typewriter
23766 #define DIR_LO(x) #(x & 0xff)
23767 \family default
23768
23769 \newline
23770 Default is off.
23771  Below is an example on how to use this pragma.
23772 \end_layout
23773
23774 \begin_layout Verse
23775
23776 \family typewriter
23777 #pragma preproc_asm +
23778 \newline
23779 #pragma sdcc_hash +
23780 \begin_inset LatexCommand index
23781 name "\\#pragma sdcc\\_hash"
23782
23783 \end_inset
23784
23785
23786 \newline
23787
23788 \newline
23789 #define ROMCALL(x) 
23790 \backslash
23791
23792 \newline
23793 \InsetSpace ~
23794 \InsetSpace ~
23795 \InsetSpace ~
23796 mov R6_B3, #(x & 0xff) 
23797 \backslash
23798
23799 \newline
23800 \InsetSpace ~
23801 \InsetSpace ~
23802 \InsetSpace ~
23803 mov R7_B3, #((x >> 8) & 0xff) 
23804 \backslash
23805
23806 \newline
23807 \InsetSpace ~
23808 \InsetSpace ~
23809 \InsetSpace ~
23810 lcall __romcall
23811 \newline
23812
23813 \newline
23814 ...
23815 \newline
23816 _asm
23817 \newline
23818 ROMCALL(72)
23819 \newline
23820 _endasm;
23821 \newline
23822 ...
23823 \newline
23824
23825 \end_layout
23826
23827 \begin_layout Standard
23828 Some of the pragmas are intended to be used to turn-on or off certain optimizati
23829 ons which might cause the compiler to generate extra stack and/or data space
23830  to store compiler generated temporary variables.
23831  This usually happens in large functions.
23832  Pragma directives should be used as shown in the following example, they
23833  are used to control options and optimizations for a given function.
23834  
23835 \end_layout
23836
23837 \begin_layout Verse
23838
23839 \family typewriter
23840 #pragma save
23841 \begin_inset LatexCommand index
23842 name "\\#pragma save"
23843
23844 \end_inset
23845
23846  \InsetSpace ~
23847 \InsetSpace ~
23848 \InsetSpace ~
23849 \InsetSpace ~
23850 \InsetSpace ~
23851 \InsetSpace ~
23852 \InsetSpace ~
23853 /* save the current settings */ 
23854 \newline
23855 #pragma nogcse
23856 \begin_inset LatexCommand index
23857 name "\\#pragma nogcse"
23858
23859 \end_inset
23860
23861  \InsetSpace ~
23862 \InsetSpace ~
23863 \InsetSpace ~
23864 \InsetSpace ~
23865 \InsetSpace ~
23866 /* turnoff global subexpression elimination */ 
23867 \newline
23868 #pragma noinduction
23869 \begin_inset LatexCommand index
23870 name "\\#pragma noinduction"
23871
23872 \end_inset
23873
23874  /* turn off induction optimizations */ 
23875 \newline
23876 int foo () 
23877 \newline
23878
23879 \newline
23880 \InsetSpace ~
23881  \InsetSpace ~
23882  ...
23883  
23884 \newline
23885 \InsetSpace ~
23886  \InsetSpace ~
23887  /* large code */ 
23888 \newline
23889 \InsetSpace ~
23890  \InsetSpace ~
23891  ...
23892  
23893 \newline
23894
23895 \newline
23896 #pragma restore
23897 \begin_inset LatexCommand index
23898 name "\\#pragma restore"
23899
23900 \end_inset
23901
23902  /* turn the optimizations back on */
23903 \end_layout
23904
23905 \begin_layout Standard
23906 The compiler will generate a warning message when extra space is allocated.
23907  It is strongly recommended that the save and restore pragmas be used when
23908  changing options for a function.
23909 \newline
23910
23911 \newline
23912
23913 \newline
23914
23915 \end_layout
23916
23917 \begin_layout Section
23918 Defines Created by the Compiler
23919 \end_layout
23920
23921 \begin_layout Standard
23922 The compiler creates the following #defines
23923 \begin_inset LatexCommand index
23924 name "\\#defines"
23925
23926 \end_inset
23927
23928
23929 \begin_inset LatexCommand index
23930 name "Defines created by the compiler"
23931
23932 \end_inset
23933
23934 :
23935 \newline
23936
23937 \end_layout
23938
23939 \begin_layout Standard
23940 \begin_inset Tabular
23941 <lyxtabular version="3" rows="15" columns="2">
23942 <features>
23943 <column alignment="left" valignment="top" leftline="true" width="3in">
23944 <column alignment="left" valignment="top" leftline="true" rightline="true" width="3in">
23945 <row topline="true" bottomline="true">
23946 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23947 \begin_inset Text
23948
23949 \begin_layout Standard
23950
23951 \series bold
23952 #define
23953 \end_layout
23954
23955 \end_inset
23956 </cell>
23957 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23958 \begin_inset Text
23959
23960 \begin_layout Standard
23961
23962 \series bold
23963 Description
23964 \end_layout
23965
23966 \end_inset
23967 </cell>
23968 </row>
23969 <row topline="true">
23970 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23971 \begin_inset Text
23972
23973 \begin_layout Standard
23974 SDCC
23975 \begin_inset LatexCommand index
23976 name "SDCC"
23977
23978 \end_inset
23979
23980  
23981 \end_layout
23982
23983 \end_inset
23984 </cell>
23985 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
23986 \begin_inset Text
23987
23988 \begin_layout Standard
23989 Always defined.
23990  Since version 2.5.6 the version number as an int (ex.
23991  256)
23992 \end_layout
23993
23994 \end_inset
23995 </cell>
23996 </row>
23997 <row topline="true">
23998 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
23999 \begin_inset Text
24000
24001 \begin_layout Standard
24002 SDCC_mcs51
24003 \begin_inset LatexCommand index
24004 name "SDCC\\_mcs51"
24005
24006 \end_inset
24007
24008  or SDCC_ds390
24009 \begin_inset LatexCommand index
24010 name "SDCC\\_ds390"
24011
24012 \end_inset
24013
24014  or SDCC_z80
24015 \begin_inset LatexCommand index
24016 name "SDCC\\_z80"
24017
24018 \end_inset
24019
24020 , etc.
24021 \end_layout
24022
24023 \end_inset
24024 </cell>
24025 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24026 \begin_inset Text
24027
24028 \begin_layout Standard
24029 depending on the model used (e.g.: -mds390)
24030 \end_layout
24031
24032 \end_inset
24033 </cell>
24034 </row>
24035 <row topline="true">
24036 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24037 \begin_inset Text
24038
24039 \begin_layout Standard
24040 __mcs51
24041 \begin_inset LatexCommand index
24042 name "\\_\\_mcs51"
24043
24044 \end_inset
24045
24046 , __ds390
24047 \begin_inset LatexCommand index
24048 name "\\_\\_ds390"
24049
24050 \end_inset
24051
24052 , __hc08
24053 \begin_inset LatexCommand index
24054 name "\\_\\_hc08"
24055
24056 \end_inset
24057
24058 , __z80
24059 \begin_inset LatexCommand index
24060 name "\\_\\_z80"
24061
24062 \end_inset
24063
24064 , etc
24065 \end_layout
24066
24067 \end_inset
24068 </cell>
24069 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24070 \begin_inset Text
24071
24072 \begin_layout Standard
24073 depending on the model used (e.g.
24074  -mz80)
24075 \end_layout
24076
24077 \end_inset
24078 </cell>
24079 </row>
24080 <row topline="true">
24081 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24082 \begin_inset Text
24083
24084 \begin_layout Standard
24085 SDCC_STACK_AUTO
24086 \begin_inset LatexCommand index
24087 name "SDCC\\_STACK\\_AUTO"
24088
24089 \end_inset
24090
24091
24092 \end_layout
24093
24094 \end_inset
24095 </cell>
24096 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24097 \begin_inset Text
24098
24099 \begin_layout Standard
24100 when 
24101 \emph on
24102 -
24103 \begin_inset ERT
24104 status collapsed
24105
24106 \begin_layout Standard
24107
24108
24109 \backslash
24110 /
24111 \end_layout
24112
24113 \end_inset
24114
24115 -stack-auto
24116 \emph default
24117  option is used
24118 \end_layout
24119
24120 \end_inset
24121 </cell>
24122 </row>
24123 <row topline="true">
24124 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24125 \begin_inset Text
24126
24127 \begin_layout Standard
24128 SDCC_MODEL_SMALL
24129 \begin_inset LatexCommand index
24130 name "SDCC\\_MODEL\\_SMALL"
24131
24132 \end_inset
24133
24134
24135 \end_layout
24136
24137 \end_inset
24138 </cell>
24139 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24140 \begin_inset Text
24141
24142 \begin_layout Standard
24143 when 
24144 \emph on
24145 -
24146 \begin_inset ERT
24147 status collapsed
24148
24149 \begin_layout Standard
24150
24151
24152 \backslash
24153 /
24154 \end_layout
24155
24156 \end_inset
24157
24158 -model-small
24159 \emph default
24160  is used
24161 \end_layout
24162
24163 \end_inset
24164 </cell>
24165 </row>
24166 <row topline="true">
24167 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24168 \begin_inset Text
24169
24170 \begin_layout Standard
24171 SDCC_MODEL_MEDIUM
24172 \begin_inset LatexCommand index
24173 name "SDCC\\_MODEL\\_MEDIUM"
24174
24175 \end_inset
24176
24177
24178 \end_layout
24179
24180 \end_inset
24181 </cell>
24182 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24183 \begin_inset Text
24184
24185 \begin_layout Standard
24186 when 
24187 \emph on
24188 -
24189 \begin_inset ERT
24190 status collapsed
24191
24192 \begin_layout Standard
24193
24194
24195 \backslash
24196 /
24197 \end_layout
24198
24199 \end_inset
24200
24201 -model-medium
24202 \emph default
24203  is used
24204 \end_layout
24205
24206 \end_inset
24207 </cell>
24208 </row>
24209 <row topline="true">
24210 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24211 \begin_inset Text
24212
24213 \begin_layout Standard
24214 SDCC_MODEL_LARGE
24215 \begin_inset LatexCommand index
24216 name "SDCC\\_MODEL\\_LARGE"
24217
24218 \end_inset
24219
24220
24221 \end_layout
24222
24223 \end_inset
24224 </cell>
24225 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24226 \begin_inset Text
24227
24228 \begin_layout Standard
24229 when 
24230 \emph on
24231 -
24232 \begin_inset ERT
24233 status collapsed
24234
24235 \begin_layout Standard
24236
24237
24238 \backslash
24239 /
24240 \end_layout
24241
24242 \end_inset
24243
24244 -model-large
24245 \emph default
24246  is used
24247 \end_layout
24248
24249 \end_inset
24250 </cell>
24251 </row>
24252 <row topline="true">
24253 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24254 \begin_inset Text
24255
24256 \begin_layout Standard
24257 SDCC_USE_XSTACK
24258 \begin_inset LatexCommand index
24259 name "SDCC\\_USE\\_XSTACK"
24260
24261 \end_inset
24262
24263
24264 \end_layout
24265
24266 \end_inset
24267 </cell>
24268 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24269 \begin_inset Text
24270
24271 \begin_layout Standard
24272 when 
24273 \emph on
24274 -
24275 \begin_inset ERT
24276 status collapsed
24277
24278 \begin_layout Standard
24279
24280
24281 \backslash
24282 /
24283 \end_layout
24284
24285 \end_inset
24286
24287 -xstack
24288 \emph default
24289  option is used
24290 \end_layout
24291
24292 \end_inset
24293 </cell>
24294 </row>
24295 <row topline="true">
24296 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24297 \begin_inset Text
24298
24299 \begin_layout Standard
24300 SDCC_STACK_TENBIT
24301 \begin_inset LatexCommand index
24302 name "SDCC\\_STACK\\_TENBIT"
24303
24304 \end_inset
24305
24306  
24307 \end_layout
24308
24309 \end_inset
24310 </cell>
24311 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24312 \begin_inset Text
24313
24314 \begin_layout Standard
24315 when 
24316 \emph on
24317 -mds390
24318 \emph default
24319  is used
24320 \end_layout
24321
24322 \end_inset
24323 </cell>
24324 </row>
24325 <row topline="true">
24326 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24327 \begin_inset Text
24328
24329 \begin_layout Standard
24330 SDCC_MODEL_FLAT24
24331 \begin_inset LatexCommand index
24332 name "SDCC\\_MODEL\\_FLAT24"
24333
24334 \end_inset
24335
24336
24337 \end_layout
24338
24339 \end_inset
24340 </cell>
24341 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24342 \begin_inset Text
24343
24344 \begin_layout Standard
24345 when 
24346 \emph on
24347 -mds390
24348 \emph default
24349  is used
24350 \end_layout
24351
24352 \end_inset
24353 </cell>
24354 </row>
24355 <row topline="true">
24356 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24357 \begin_inset Text
24358
24359 \begin_layout Standard
24360 SDCC_REVISION
24361 \begin_inset LatexCommand index
24362 name "SDCC\\_REVISION"
24363
24364 \end_inset
24365
24366
24367 \end_layout
24368
24369 \end_inset
24370 </cell>
24371 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24372 \begin_inset Text
24373
24374 \begin_layout Standard
24375 Always defined.
24376  SDCC svn revision number
24377 \end_layout
24378
24379 \end_inset
24380 </cell>
24381 </row>
24382 <row topline="true">
24383 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24384 \begin_inset Text
24385
24386 \begin_layout Standard
24387 SDCC_PARMS_IN_BANK1
24388 \begin_inset LatexCommand index
24389 name "SDCC\\_PARMS\\_IN\\_BANK1"
24390
24391 \end_inset
24392
24393
24394 \end_layout
24395
24396 \end_inset
24397 </cell>
24398 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24399 \begin_inset Text
24400
24401 \begin_layout Standard
24402 when 
24403 \emph on
24404 -
24405 \begin_inset ERT
24406 status collapsed
24407
24408 \begin_layout Standard
24409
24410
24411 \backslash
24412 /
24413 \end_layout
24414
24415 \end_inset
24416
24417 -parms-in-bank1
24418 \emph default
24419  is used
24420 \end_layout
24421
24422 \end_inset
24423 </cell>
24424 </row>
24425 <row topline="true">
24426 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24427 \begin_inset Text
24428
24429 \begin_layout Standard
24430 SDCC_FLOAT_REENT
24431 \begin_inset LatexCommand index
24432 name "SDCC\\_MODEL\\_FLAT24"
24433
24434 \end_inset
24435
24436
24437 \end_layout
24438
24439 \end_inset
24440 </cell>
24441 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24442 \begin_inset Text
24443
24444 \begin_layout Standard
24445 when 
24446 \emph on
24447 -
24448 \begin_inset ERT
24449 status collapsed
24450
24451 \begin_layout Standard
24452
24453
24454 \backslash
24455 /
24456 \end_layout
24457
24458 \end_inset
24459
24460 -float-reent
24461 \emph default
24462  is used
24463 \end_layout
24464
24465 \end_inset
24466 </cell>
24467 </row>
24468 <row topline="true" bottomline="true">
24469 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24470 \begin_inset Text
24471
24472 \begin_layout Standard
24473 SDCC_INT_LONG_REENT
24474 \begin_inset LatexCommand index
24475 name "SDCC\\_INT\\_LONG\\_REENT"
24476
24477 \end_inset
24478
24479
24480 \end_layout
24481
24482 \end_inset
24483 </cell>
24484 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24485 \begin_inset Text
24486
24487 \begin_layout Standard
24488 when 
24489 \emph on
24490 -
24491 \begin_inset ERT
24492 status collapsed
24493
24494 \begin_layout Standard
24495
24496
24497 \backslash
24498 /
24499 \end_layout
24500
24501 \end_inset
24502
24503 -int-long-reent
24504 \emph default
24505  is used
24506 \end_layout
24507
24508 \end_inset
24509 </cell>
24510 </row>
24511 </lyxtabular>
24512
24513 \end_inset
24514
24515
24516 \end_layout
24517
24518 \begin_layout Chapter
24519 Notes on supported Processors
24520 \end_layout
24521
24522 \begin_layout Section
24523 MCS51 variants
24524 \begin_inset LatexCommand label
24525 name "sub:MCS51-variants"
24526
24527 \end_inset
24528
24529
24530 \begin_inset LatexCommand index
24531 name "MCS51 variants"
24532
24533 \end_inset
24534
24535
24536 \end_layout
24537
24538 \begin_layout Standard
24539 MCS51 processors are available from many vendors and come in many different
24540  flavours.
24541  While they might differ considerably in respect to Special Function Registers
24542  the core MCS51 is usually not modified or is kept compatible.
24543  
24544 \end_layout
24545
24546 \begin_layout Subsection
24547 pdata access by SFR 
24548 \end_layout
24549
24550 \begin_layout Standard
24551 With the upcome of devices with internal xdata and flash memory devices
24552  using port P2
24553 \begin_inset LatexCommand index
24554 name "P2 (mcs51 sfr)"
24555
24556 \end_inset
24557
24558  as dedicated I/O port is becoming more popular.
24559  Switching the high byte for pdata
24560 \begin_inset LatexCommand index
24561 name "pdata (mcs51, ds390 storage class)"
24562
24563 \end_inset
24564
24565  access which was formerly done by port P2 is then achieved by a Special
24566  Function Register
24567 \begin_inset LatexCommand index
24568 name "sfr"
24569
24570 \end_inset
24571
24572 .
24573  In well-established MCS51 tradition the address of this 
24574 \emph on
24575 sfr
24576 \emph default
24577  is where the chip designers decided to put it.
24578  Needless to say that they didn't agree on a common name either.
24579  So that the startup code can correctly initialize xdata variables, you
24580  should define an sfr with the name _XPAGE
24581 \family typewriter
24582
24583 \begin_inset LatexCommand index
24584 name "\\_XPAGE (mcs51)"
24585
24586 \end_inset
24587
24588
24589 \family default
24590  at the appropriate location if the default, port P2, is not used for this.
24591  Some examples are:
24592 \end_layout
24593
24594 \begin_layout Verse
24595
24596 \family typewriter
24597 __sfr __at (0x85) _XPAGE; /* Ramtron VRS51 family a.k.a.
24598  MPAGE */
24599 \end_layout
24600
24601 \begin_layout Verse
24602
24603 \family typewriter
24604 __sfr __at (0x92) _XPAGE; /* Cypress EZ-USB family, Texas Instruments (Chipcon)
24605  a.k.a.
24606  MPAGE */
24607 \end_layout
24608
24609 \begin_layout Verse
24610
24611 \family typewriter
24612 __sfr __at (0x91) _XPAGE; /* Infineon (Siemens) C500 family a.k.a.
24613  XPAGE */
24614 \end_layout
24615
24616 \begin_layout Verse
24617
24618 \family typewriter
24619 __sfr __at (0xaf) _XPAGE; /* some Silicon Labs (Cygnal) chips a.k.a.
24620  EMI0CN */
24621 \end_layout
24622
24623 \begin_layout Verse
24624
24625 \family typewriter
24626 __sfr __at (0xaa) _XPAGE; /* some Silicon Labs (Cygnal) chips a.k.a.
24627  EMI0CN */
24628 \end_layout
24629
24630 \begin_layout Standard
24631 For more exotic implementations further customizations may be needed.
24632  See section 
24633 \begin_inset LatexCommand ref
24634 reference "sub:Startup-Code"
24635
24636 \end_inset
24637
24638  for other possibilities.
24639 \end_layout
24640
24641 \begin_layout Subsection
24642 Other Features available by SFR
24643 \end_layout
24644
24645 \begin_layout Standard
24646 Some MCS51 variants offer features like Double DPTR
24647 \begin_inset LatexCommand index
24648 name "DPTR"
24649
24650 \end_inset
24651
24652 , multiple DPTR, decrementing DPTR, 16x16 Multiply.
24653  These are currently not used for the MCS51 port.
24654  If you absolutely need them you can fall back to inline assembly or submit
24655  a patch to SDCC.
24656 \end_layout
24657
24658 \begin_layout Subsection
24659 Bankswitching
24660 \end_layout
24661
24662 \begin_layout Standard
24663 Bankswitching
24664 \begin_inset LatexCommand index
24665 name "Bankswitching"
24666
24667 \end_inset
24668
24669  (a.k.a.
24670  code banking
24671 \begin_inset LatexCommand index
24672 name "code banking"
24673
24674 \end_inset
24675
24676 ) is a technique to increase the code space above the 64k limit of the 8051.
24677 \end_layout
24678
24679 \begin_layout Subsubsection
24680 Hardware
24681 \end_layout
24682
24683 \begin_layout Standard
24684 \begin_inset Tabular
24685 <lyxtabular version="3" rows="3" columns="4">
24686 <features>
24687 <column alignment="center" valignment="top" width="0">
24688 <column alignment="center" valignment="top" leftline="true" width="0">
24689 <column alignment="center" valignment="top" leftline="true" width="0">
24690 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
24691 <row topline="true" bottomline="true">
24692 <cell multicolumn="1" alignment="center" valignment="top" usebox="none">
24693 \begin_inset Text
24694
24695 \begin_layout Standard
24696 8000-FFFF
24697 \end_layout
24698
24699 \end_inset
24700 </cell>
24701 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24702 \begin_inset Text
24703
24704 \begin_layout Standard
24705 bank1
24706 \end_layout
24707
24708 \end_inset
24709 </cell>
24710 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24711 \begin_inset Text
24712
24713 \begin_layout Standard
24714 bank2
24715 \end_layout
24716
24717 \end_inset
24718 </cell>
24719 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24720 \begin_inset Text
24721
24722 \begin_layout Standard
24723 bank3
24724 \end_layout
24725
24726 \end_inset
24727 </cell>
24728 </row>
24729 <row topline="true" bottomline="true">
24730 <cell multicolumn="1" alignment="center" valignment="top" usebox="none">
24731 \begin_inset Text
24732
24733 \begin_layout Standard
24734 0000-7FFF
24735 \end_layout
24736
24737 \end_inset
24738 </cell>
24739 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24740 \begin_inset Text
24741
24742 \begin_layout Standard
24743 common
24744 \end_layout
24745
24746 \end_inset
24747 </cell>
24748 <cell multicolumn="1" alignment="center" valignment="top" usebox="none">
24749 \begin_inset Text
24750
24751 \begin_layout Standard
24752
24753 \end_layout
24754
24755 \end_inset
24756 </cell>
24757 <cell multicolumn="2" alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24758 \begin_inset Text
24759
24760 \begin_layout Standard
24761
24762 \end_layout
24763
24764 \end_inset
24765 </cell>
24766 </row>
24767 <row>
24768 <cell multicolumn="1" alignment="center" valignment="top" usebox="none">
24769 \begin_inset Text
24770
24771 \begin_layout Standard
24772 SiLabs C8051F120 example
24773 \end_layout
24774
24775 \end_inset
24776 </cell>
24777 <cell multicolumn="2" alignment="center" valignment="top" usebox="none">
24778 \begin_inset Text
24779
24780 \begin_layout Standard
24781
24782 \end_layout
24783
24784 \end_inset
24785 </cell>
24786 <cell multicolumn="2" alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24787 \begin_inset Text
24788
24789 \begin_layout Standard
24790
24791 \end_layout
24792
24793 \end_inset
24794 </cell>
24795 <cell multicolumn="2" alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24796 \begin_inset Text
24797
24798 \begin_layout Standard
24799
24800 \end_layout
24801
24802 \end_inset
24803 </cell>
24804 </row>
24805 </lyxtabular>
24806
24807 \end_inset
24808
24809
24810 \newline
24811
24812 \newline
24813 Usually the hardware uses some sfr (an output port or an internal sfr) to
24814  select a bank and put it in the banked area of the memory map.
24815  The selected bank usually becomes active immediately upon assignment to
24816  this sfr and when running inside a bank it will switch out this code it
24817  is currently running.
24818  Therefor you cannot jump or call directly from one bank to another and
24819  need to use a so-called trampoline in the common area.
24820  For SDCC an example trampoline is in crtbank.asm and you may need to change
24821  it to your 8051 derivative or schematic.
24822  The presented code is written for the C8051F120.
24823 \newline
24824
24825 \newline
24826 When calling a banked function
24827  SDCC will put the LSB of the functions address in register R0, the MSB
24828  in R1 and the bank in R2 and then call this trampoline 
24829 \emph on
24830 __sdcc_banked_call
24831 \emph default
24832 .
24833  The current selected bank is saved on the stack, the new bank is selected
24834  and an indirect jump is made.
24835  When the banked function returns it jumps to 
24836 \emph on
24837 __sdcc_banked_ret
24838 \emph default
24839  which restores the previous bank and returns to the caller.
24840 \end_layout
24841
24842 \begin_layout Subsubsection
24843 Software
24844 \end_layout
24845
24846 \begin_layout Standard
24847 When writing banked software using SDCC you need to use some special keywords
24848  and options.
24849  You also need to take over a bit of work from the linker.
24850 \newline
24851
24852 \newline
24853 To create a function
24854  that can be called from another bank it requires the keyword 
24855 \emph on
24856 banked
24857 \emph default
24858
24859 \begin_inset LatexCommand index
24860 name "banked"
24861
24862 \end_inset
24863
24864 .
24865  The caller must see this in the prototype of the callee and the callee
24866  needs it for a proper return.
24867  Called functions within the same bank as the caller do not need the 
24868 \emph on
24869 banked
24870 \emph default
24871  keyword nor do functions in the common area.
24872  Beware: SDCC does not know or check if functions are in the same bank.
24873  This is your responsibility!
24874 \newline
24875
24876 \newline
24877 Normally all functions you write end up in
24878  the segment CSEG.
24879  If you want a function explicitly to reside in the common area put it in
24880  segment HOME.
24881  This applies for instance to interrupt service routines as they should
24882  not be banked.
24883 \end_layout
24884
24885 \begin_layout Standard
24886 Functions that need to be in a switched bank must be put in a named segment.
24887  The name can be mostly anything up to eight characters (e.g.
24888  BANK1).
24889  To do this you either use -
24890 \begin_inset ERT
24891 status collapsed
24892
24893 \begin_layout Standard
24894
24895
24896 \backslash
24897 /
24898 \end_layout
24899
24900 \end_inset
24901
24902 -codeseg BANK1 (See 
24903 \begin_inset LatexCommand ref
24904 reference "lyx:-codeseg"
24905
24906 \end_inset
24907
24908 ) on the command line when compiling or #pragma codeseg BANK1 (See 
24909 \begin_inset LatexCommand ref
24910 reference "sec:Pragmas"
24911
24912 \end_inset
24913
24914 ) at the top of the C source file.
24915  The segment name always applies to the whole source file and generated
24916  object so functions for different banks need to be defined in different
24917  source files.
24918 \newline
24919
24920 \newline
24921 When linking your objects you need to tell the linker where
24922  to put your segments.
24923  To do this you use the following command line option to SDCC: -Wl-b BANK1=0x180
24924 00 (See 
24925 \begin_inset LatexCommand ref
24926 reference "lyx:-Wl option"
24927
24928 \end_inset
24929
24930 ).
24931  This sets the virtual start address of this segment.
24932  It sets the banknumber to 0x01 and maps the bank to 0x8000 and up.
24933  The linker will not check for overflows, again this is your responsibility.
24934 \end_layout
24935
24936 \begin_layout Standard
24937 \begin_inset VSpace bigskip
24938 \end_inset
24939
24940
24941 \end_layout
24942
24943 \begin_layout Section
24944 DS400 port
24945 \end_layout
24946
24947 \begin_layout Standard
24948 The DS80C400
24949 \begin_inset LatexCommand index
24950 name "DS80C400"
24951
24952 \end_inset
24953
24954
24955 \begin_inset LatexCommand index
24956 name "DS400"
24957
24958 \end_inset
24959
24960  microcontroller has a rich set of peripherals.
24961  In its built-in ROM library it includes functions to access some of the
24962  features, among them is a TCP stack with IP4 and IP6 support.
24963  Library headers (currently in beta status) and other files are provided
24964  at 
24965 \size footnotesize
24966
24967 \begin_inset LatexCommand url
24968 target "ftp://ftp.dalsemi.com/pub/tini/ds80c400/c_libraries/sdcc/index.html"
24969
24970 \end_inset
24971
24972 .
24973  
24974 \begin_inset VSpace bigskip
24975 \end_inset
24976
24977
24978 \end_layout
24979
24980 \begin_layout Section
24981 The Z80 and gbz80 port
24982 \end_layout
24983
24984 \begin_layout Standard
24985 SDCC can target both the Zilog Z80
24986 \begin_inset LatexCommand index
24987 name "Z80"
24988
24989 \end_inset
24990
24991  and the Nintendo Gameboy's Z80-like gbz80
24992 \begin_inset LatexCommand index
24993 name "gbz80 (GameBoy Z80)"
24994
24995 \end_inset
24996
24997 .
24998  The Z80 port is passed through the same 
24999 \emph on
25000 regressions tests
25001 \begin_inset LatexCommand index
25002 name "Regression test"
25003
25004 \end_inset
25005
25006
25007 \emph default
25008  (see section 
25009 \begin_inset LatexCommand ref
25010 reference "sec:Quality-control"
25011
25012 \end_inset
25013
25014 ) as the MCS51 and DS390 ports, so floating point support, support for long
25015  variables and bitfield support is fine.
25016  See mailing lists and forums about interrupt routines.
25017 \end_layout
25018
25019 \begin_layout Standard
25020 As always, the code is the authoritative reference - see z80/ralloc.c and
25021  z80/gen.c.
25022  The stack
25023 \begin_inset LatexCommand index
25024 name "Z80!stack"
25025
25026 \end_inset
25027
25028  frame is similar to that generated by the IAR Z80 compiler.
25029  IX is used as the base pointer, HL and IY are used as a temporary registers,
25030  and BC and DE are available for holding variables.
25031  Return values
25032 \begin_inset LatexCommand index
25033 name "Z80!return value"
25034
25035 \end_inset
25036
25037  for the Z80 port are stored in L (one byte), HL (two bytes), or DEHL (four
25038  bytes).
25039  The gbz80 port use the same set of registers for the return values, but
25040  in a different order of significance: E (one byte), DE (two bytes), or
25041  HLDE (four bytes).
25042 \begin_inset VSpace bigskip
25043 \end_inset
25044
25045
25046 \end_layout
25047
25048 \begin_layout Section
25049 The HC08 port
25050 \end_layout
25051
25052 \begin_layout Standard
25053 The port to the Freescale/Motorola HC08
25054 \begin_inset LatexCommand index
25055 name "HC08"
25056
25057 \end_inset
25058
25059  family has been added in October 2003, and is still undergoing some basic
25060  development.
25061  The code generator is complete, but the register allocation is still quite
25062  unoptimized.
25063  Some of the SDCC's standard C library functions have embedded non-HC08
25064  inline assembly and so are not yet usable.
25065 \end_layout
25066
25067 \begin_layout Standard
25068 The HC08 port passes the regression test suite (see section 
25069 \begin_inset LatexCommand ref
25070 reference "sec:Quality-control"
25071
25072 \end_inset
25073
25074 ).
25075 \begin_inset VSpace bigskip
25076 \end_inset
25077
25078
25079 \end_layout
25080
25081 \begin_layout Section
25082 The PIC14
25083 \begin_inset LatexCommand index
25084 name "PIC14"
25085
25086 \end_inset
25087
25088  port
25089 \end_layout
25090
25091 \begin_layout Standard
25092 The PIC14 port adds support for Microchip
25093 \begin_inset LatexCommand index
25094 name "Microchip"
25095
25096 \end_inset
25097
25098
25099 \begin_inset Formula $^{\text{TM}}$
25100 \end_inset
25101
25102  PIC
25103 \begin_inset LatexCommand index
25104 name "PIC14"
25105
25106 \end_inset
25107
25108
25109 \begin_inset Formula $^{\text{TM}}$
25110 \end_inset
25111
25112  MCUs with 14 bit wide instructions.
25113  This port is not yet mature and still lacks many features.
25114  However, it can work for simple code.
25115 \end_layout
25116
25117 \begin_layout Standard
25118 \noindent
25119 Currently supported devices include:
25120 \end_layout
25121
25122 \begin_layout Standard
25123 12F: 629, 635, 675, 683
25124 \end_layout
25125
25126 \begin_layout Standard
25127 16C: 432, 433
25128 \end_layout
25129
25130 \begin_layout Standard
25131 16C: 554, 557, 558
25132 \end_layout
25133
25134 \begin_layout Standard
25135 16C: 62, 620, 620a, 621, 621a, 622, 622a, 63a, 65b
25136 \end_layout
25137
25138 \begin_layout Standard
25139 16C: 71, 710, 711, 715, 717, 72, 73b, 745, 74b, 765, 770, 771, 773, 774,
25140  781, 782
25141 \end_layout
25142
25143 \begin_layout Standard
25144 16C: 925, 926
25145 \end_layout
25146
25147 \begin_layout Standard
25148 16CR: 620a, 73, 74, 76, 77
25149 \end_layout
25150
25151 \begin_layout Standard
25152 16F: 616, 627, 627a, 628, 628a, 630, 636, 639, 648, 648a, 676, 684, 685,
25153  687, 688, 689, 690
25154 \end_layout
25155
25156 \begin_layout Standard
25157 16F: 716, 72, 73, 737, 74, 747, 76, 767, 77, 777, 785
25158 \end_layout
25159
25160 \begin_layout Standard
25161 16F: 818, 819, 84, 84a, 87, 870, 871, 872, 873, 873a, 874, 874a, 876, 876a,
25162  877, 877a, 88, 886, 887
25163 \end_layout
25164
25165 \begin_layout Standard
25166 16F: 913, 914, 916, 917, 946
25167 \end_layout
25168
25169 \begin_layout Standard
25170 26HV: 626, 785
25171 \end_layout
25172
25173 \begin_layout Standard
25174 \noindent
25175 An up-to-date list of currently supported devices can be obtained via 
25176 \family typewriter
25177 sdcc -mpic14 -phelp foo.c
25178 \family default
25179  (foo.c must exist...).
25180 \end_layout
25181
25182 \begin_layout Subsection
25183 PIC Code Pages
25184 \begin_inset LatexCommand index
25185 name "code page (pic14)"
25186
25187 \end_inset
25188
25189  and Memory Banks
25190 \begin_inset LatexCommand index
25191 name "Memory bank (pic14)"
25192
25193 \end_inset
25194
25195
25196 \end_layout
25197
25198 \begin_layout Standard
25199 The linker organizes allocation for the code page and RAM banks.
25200  It does not have intimate knowledge of the code flow.
25201  It will put all the code section of a single .asm file into a single code
25202  page.
25203  In order to make use of multiple code pages, separate asm files must be
25204  used.
25205  The compiler assigns all 
25206 \emph on
25207 static
25208 \emph default
25209  functions of a single .c file into the same code page.
25210 \newline
25211
25212 \newline
25213 To get the best results,
25214  follow these guidelines:
25215 \end_layout
25216
25217 \begin_layout Enumerate
25218 Make local functions static, as non static functions require code page selection
25219  overhead.
25220 \newline
25221 Due to the way sdcc handles functions, place called functions prior
25222  to calling functions in the file wherever possible: Otherwise sdcc will
25223  insert unnecessary pagesel directives around the call, believing that the
25224  called function is externally defined.
25225 \end_layout
25226
25227 \begin_layout Enumerate
25228 For devices that have multiple code pages it is more efficient to use the
25229  same number of files as pages: Use up to 4 separate .c files for the 16F877,
25230  but only 2 files for the 16F874.
25231  This way the linker can put the code for each file into different code
25232  pages and there will be less page selection overhead.
25233 \end_layout
25234
25235 \begin_layout Enumerate
25236 And as for any 8 bit micro (especially for PIC14 as they have a very simple
25237  instruction set), use `unsigned char' wherever possible instead of `int'.
25238 \end_layout
25239
25240 \begin_layout Subsection
25241 Adding New Devices to the Port 
25242 \end_layout
25243
25244 \begin_layout Standard
25245 Adding support for a new 14
25246 \begin_inset ERT
25247 status open
25248
25249 \begin_layout Standard
25250
25251
25252 \backslash
25253 ,
25254 \end_layout
25255
25256 \end_inset
25257
25258 bit PIC MCU requires the following steps:
25259 \end_layout
25260
25261 \begin_layout Enumerate
25262 Create a new device description.
25263 \newline
25264 Each device is described in two files: pic16f*.h
25265  and pic16f*.c.
25266  These files primarily define SFRs, structs to access their bits, and symbolic
25267  configuration options.
25268  Both files can be generated from gputils' .inc files using the perl script
25269  
25270 \family typewriter
25271 support/scripts/inc2h.pl
25272 \family default
25273 .
25274  This file also contains further instructions on how to proceed.
25275 \end_layout
25276
25277 \begin_layout Enumerate
25278 Copy the .h file into SDCC's include path and either add the .c file to your
25279  project or copy it to 
25280 \family typewriter
25281 device/lib/pic/libdev
25282 \family default
25283 .
25284  Afterwards, rebuild and install the libraries.
25285 \end_layout
25286
25287 \begin_layout Enumerate
25288 Edit pic14devices.txt in SDCC's include path (
25289 \family typewriter
25290 device/include/pic/
25291 \family default
25292  in the source tree or 
25293 \family typewriter
25294 /usr/local/share/sdcc/include/pic
25295 \family default
25296  after installation).
25297 \newline
25298 You need to add a device specification here to make
25299  the memory layout (code banks, RAM, aliased memory regions, ...) known to
25300  the compiler.
25301  Probably you can copy and modify an existing entry.
25302  The file format is documented at the top of the file.
25303 \end_layout
25304
25305 \begin_layout Subsection
25306 Interrupt Code
25307 \end_layout
25308
25309 \begin_layout Standard
25310 For the interrupt function, use the keyword `__interrupt'
25311 \begin_inset LatexCommand index
25312 name "PIC14!interrupt"
25313
25314 \end_inset
25315
25316  with level number of 0 (PIC14 only has 1 interrupt so this number is only
25317  there to avoid a syntax error - it ought to be fixed).
25318  E.g.:
25319 \end_layout
25320
25321 \begin_layout Verse
25322
25323 \family typewriter
25324 void Intr(void) __interrupt 0
25325 \newline
25326 {
25327 \newline
25328 \InsetSpace ~
25329 \InsetSpace ~
25330 T0IF = 0; /* Clear timer interrupt */
25331 \newline
25332 }
25333 \end_layout
25334
25335 \begin_layout Subsection
25336 Linking and Assembling
25337 \end_layout
25338
25339 \begin_layout Standard
25340 For assembling you can use either GPUTILS'
25341 \begin_inset LatexCommand index
25342 name "gputils (pic tools)"
25343
25344 \end_inset
25345
25346  gpasm.exe or MPLAB's mpasmwin.exe.
25347  GPUTILS are available from 
25348 \begin_inset LatexCommand url
25349 target "http://sourceforge.net/projects/gputils"
25350
25351 \end_inset
25352
25353 .
25354  For linking you can use either GPUTILS' gplink or MPLAB's mplink.exe.
25355  If you use MPLAB and an interrupt function then the linker script file
25356  vectors section will need to be enlarged to link with mplink.
25357 \newline
25358
25359 \newline
25360 Here is a 
25361 \family typewriter
25362 Makefile
25363 \family default
25364  using GPUTILS:
25365 \end_layout
25366
25367 \begin_layout Verse
25368
25369 \family typewriter
25370 .c.o:
25371 \newline
25372 \InsetSpace ~
25373 \InsetSpace ~
25374 \InsetSpace ~
25375 \InsetSpace ~
25376 \InsetSpace ~
25377 \InsetSpace ~
25378 \InsetSpace ~
25379 \InsetSpace ~
25380 sdcc -V -mpic14 -p16f877 -c $< 
25381 \newline
25382
25383 \newline
25384 $(PRJ).hex: $(OBJS) 
25385 \newline
25386 \InsetSpace ~
25387 \InsetSpace ~
25388 \InsetSpace ~
25389 \InsetSpace ~
25390 \InsetSpace ~
25391 \InsetSpace ~
25392 \InsetSpace ~
25393 \InsetSpace ~
25394 gplink -m -s $(PRJ).lkr
25395  -o $(PRJ).hex $(OBJS) libsdcc.lib
25396 \end_layout
25397
25398 \begin_layout Standard
25399 Here is a 
25400 \family typewriter
25401 Makefile
25402 \family default
25403  using MPLAB:
25404 \end_layout
25405
25406 \begin_layout Verse
25407
25408 \family typewriter
25409 .c.o: 
25410 \newline
25411 \InsetSpace ~
25412 \InsetSpace ~
25413 \InsetSpace ~
25414 \InsetSpace ~
25415 \InsetSpace ~
25416 \InsetSpace ~
25417 \InsetSpace ~
25418 \InsetSpace ~
25419 sdcc -S -V -mpic14 -p16f877 $< 
25420 \newline
25421 \InsetSpace ~
25422 \InsetSpace ~
25423 \InsetSpace ~
25424 \InsetSpace ~
25425 \InsetSpace ~
25426 \InsetSpace ~
25427 \InsetSpace ~
25428 \InsetSpace ~
25429 mpasmwin /q /o $*.asm
25430 \newline
25431
25432 \newline
25433 $(PRJ).hex: $(OBJS)
25434  
25435 \newline
25436 \InsetSpace ~
25437 \InsetSpace ~
25438 \InsetSpace ~
25439 \InsetSpace ~
25440 \InsetSpace ~
25441 \InsetSpace ~
25442 \InsetSpace ~
25443 \InsetSpace ~
25444 mplink /v $(PRJ).lkr /m $(PRJ).map /o $(PRJ).hex $(OBJS) libsdcc.lib
25445 \end_layout
25446
25447 \begin_layout Standard
25448 Please note that indentations within a 
25449 \family typewriter
25450 Makefile
25451 \family default
25452  have to be done with a tabulator character.
25453 \end_layout
25454
25455 \begin_layout Subsection
25456 Command-Line Options
25457 \end_layout
25458
25459 \begin_layout Standard
25460 Besides the switches common to all SDCC backends, the PIC14 port accepts
25461  the following options (for an updated list see sdcc -
25462 \begin_inset ERT
25463 status collapsed
25464
25465 \begin_layout Standard
25466
25467
25468 \backslash
25469 /
25470 \end_layout
25471
25472 \end_inset
25473
25474 -help):
25475 \end_layout
25476
25477 \begin_layout Description
25478 -
25479 \begin_inset ERT
25480 status collapsed
25481
25482 \begin_layout Standard
25483
25484
25485 \backslash
25486 /
25487 \end_layout
25488
25489 \end_inset
25490
25491 -debug-xtra
25492 \begin_inset LatexCommand index
25493 name "PIC14!Options!-\\/-debug-extra"
25494
25495 \end_inset
25496
25497  emit debug info in assembly output
25498 \end_layout
25499
25500 \begin_layout Description
25501 -
25502 \begin_inset ERT
25503 status collapsed
25504
25505 \begin_layout Standard
25506
25507
25508 \backslash
25509 /
25510 \end_layout
25511
25512 \end_inset
25513
25514 -no-pcode-opt
25515 \begin_inset LatexCommand index
25516 name "PIC14!Options!-\\/-no-pcode-opt"
25517
25518 \end_inset
25519
25520  disable (slightly faulty) optimization on pCode
25521 \end_layout
25522
25523 \begin_layout Description
25524 -
25525 \begin_inset ERT
25526 status collapsed
25527
25528 \begin_layout Standard
25529
25530
25531 \backslash
25532 /
25533 \end_layout
25534
25535 \end_inset
25536
25537 -stack-loc
25538 \begin_inset LatexCommand index
25539 name "PIC14!Options!-\\/-stack-loc"
25540
25541 \end_inset
25542
25543  sets the lowest address of the argument passing stack (defaults to a suitably
25544  large shared databank to reduce BANKSEL overhead)
25545 \end_layout
25546
25547 \begin_layout Description
25548 -
25549 \begin_inset ERT
25550 status collapsed
25551
25552 \begin_layout Standard
25553
25554
25555 \backslash
25556 /
25557 \end_layout
25558
25559 \end_inset
25560
25561 -stack-size
25562 \begin_inset LatexCommand index
25563 name "PIC14!Options!-\\/-stack-size"
25564
25565 \end_inset
25566
25567  sets the size if the argument passing stack (default: 16, minimum: 4)
25568 \end_layout
25569
25570 \begin_layout Subsection
25571 Environment Variables
25572 \end_layout
25573
25574 \begin_layout Standard
25575 The PIC14 port recognizes the following environment variables:
25576 \end_layout
25577
25578 \begin_layout Description
25579 SDCC_PIC14_SPLIT_LOCALS If set and not empty, sdcc will allocate each temporary
25580  register (the ones called r0xNNNN) in a section of its own.
25581  By default (if this variable is unset), sdcc tries to cluster registers
25582  in sections in order to reduce the BANKSEL overhead when accessing them.
25583 \end_layout
25584
25585 \begin_layout Subsection
25586 The Library
25587 \end_layout
25588
25589 \begin_layout Standard
25590 The PIC14 library currently only contains support routines required by the
25591  compiler to implement multiplication, division, and floating point support.
25592  No libc-like replacement is available at the moment, though many of the
25593  common sdcc library sources (in 
25594 \family typewriter
25595 device/lib
25596 \family default
25597 ) should also compile with the PIC14 port.
25598 \end_layout
25599
25600 \begin_layout Subsubsection
25601 error: missing definition for symbol ``__gptrget1''
25602 \end_layout
25603
25604 \begin_layout Standard
25605 The PIC14 port uses library routines to provide more complex operations
25606  like multiplication, division/modulus and (generic) pointer dereferencing.
25607  In order to add these routines to your project, you must link with PIC14's
25608  
25609 \family typewriter
25610 libsdcc.lib
25611 \family default
25612 .
25613  For single source file projects this is done automatically, more complex
25614  projects must add 
25615 \family typewriter
25616 libsdcc.lib
25617 \family default
25618  to the linker's arguments.
25619  Make sure you also add an include path for the library (using the -I switch
25620  to the linker)!
25621 \end_layout
25622
25623 \begin_layout Subsubsection
25624 Processor mismatch in file ``XXX''.
25625 \end_layout
25626
25627 \begin_layout Standard
25628 This warning can usually be ignored due to the very good compatibility amongst
25629  14
25630 \begin_inset ERT
25631 status open
25632
25633 \begin_layout Standard
25634
25635
25636 \backslash
25637 ,
25638 \end_layout
25639
25640 \end_inset
25641
25642 bit PIC
25643 \begin_inset LatexCommand index
25644 name "PIC14"
25645
25646 \end_inset
25647
25648  devices.
25649 \end_layout
25650
25651 \begin_layout Standard
25652 You might also consider recompiling the library for your specific device
25653  by changing the ARCH=p16f877 (default target) entry in 
25654 \family typewriter
25655 device/lib/pic/Makefile.in
25656 \family default
25657  and 
25658 \family typewriter
25659 device/lib/pic/Makefile
25660 \family default
25661  to reflect your device.
25662  This might even improve performance for smaller devices as unnecessary
25663  BANKSELs might be removed.
25664 \end_layout
25665
25666 \begin_layout Subsection
25667 Known Bugs
25668 \end_layout
25669
25670 \begin_layout Subsubsection
25671 Function arguments
25672 \end_layout
25673
25674 \begin_layout Standard
25675 Functions with variable argument lists (like printf) are not yet supported.
25676  Similarly, taking the address of the first argument passed into a function
25677  does not work: It is currently passed in WREG and has no address...
25678 \end_layout
25679
25680 \begin_layout Subsubsection
25681 Regression tests fail
25682 \end_layout
25683
25684 \begin_layout Standard
25685 Though the small subset of regression tests in src/regression passes, SDCC
25686  regression test suite does not, indicating that there are still major bugs
25687  in the port.
25688  However, many smaller projects have successfully used SDCC in the past...
25689 \end_layout
25690
25691 \begin_layout Standard
25692
25693 \size footnotesize
25694
25695 \newpage
25696
25697 \end_layout
25698
25699 \begin_layout Section
25700 The PIC16
25701 \begin_inset LatexCommand index
25702 name "PIC16"
25703
25704 \end_inset
25705
25706  port
25707 \end_layout
25708
25709 \begin_layout Standard
25710 The PIC16 port adds support for Microchip
25711 \begin_inset LatexCommand index
25712 name "Microchip"
25713
25714 \end_inset
25715
25716
25717 \begin_inset Formula $^{\text{TM}}$
25718 \end_inset
25719
25720  PIC
25721 \begin_inset LatexCommand index
25722 name "PIC"
25723
25724 \end_inset
25725
25726
25727 \begin_inset Formula $^{\text{TM}}$
25728 \end_inset
25729
25730  MCUs with 16 bit wide instructions.
25731  Currently this family of microcontrollers contains the PIC18Fxxx and PIC18Fxxxx
25732 ; devices supported by the port include:
25733 \end_layout
25734
25735 \begin_layout Standard
25736 18F: 242, 248, 252, 258, 442, 448, 452, 458
25737 \end_layout
25738
25739 \begin_layout Standard
25740 18F: 1220, 1320
25741 \end_layout
25742
25743 \begin_layout Standard
25744 18F: 2220, 2221, 2320, 2321, 2331, 23k20
25745 \end_layout
25746
25747 \begin_layout Standard
25748 18F: 2410, 2420, 2423, 2431, 2450, 2455, 2480, 24j10, 24k20
25749 \end_layout
25750
25751 \begin_layout Standard
25752 18F: 2510, 2515, 2520, 2523, 2525, 2550, 2580, 2585, 25j10, 25k20
25753 \end_layout
25754
25755 \begin_layout Standard
25756 18F: 2610, 2620, 2680, 2682, 2685
25757 \end_layout
25758
25759 \begin_layout Standard
25760 18F: 4220, 4221, 4320, 4321, 4331, 43k20
25761 \end_layout
25762
25763 \begin_layout Standard
25764 18F: 4410, 4420, 4423, 4431, 4450, 4455, 4480, 44j10, 44k20
25765 \end_layout
25766
25767 \begin_layout Standard
25768 18F: 4510, 4515, 4520, 4523, 4525, 4550, 4580, 4585, 45j10, 45k20
25769 \end_layout
25770
25771 \begin_layout Standard
25772 18F: 4610, 4620, 4680, 4682, 4685, 46k20
25773 \end_layout
25774
25775 \begin_layout Standard
25776 18F: 6520, 6585, 65j50, 6620, 6680, 66j50, 66j55, 66j60, 66j65, 6720, 67j50,
25777  67j60
25778 \end_layout
25779
25780 \begin_layout Standard
25781 18F: 8520, 8585, 85j50, 8620, 8680, 86j50, 86j55, 86j60, 86j65, 8720, 87j50,
25782  87j60
25783 \end_layout
25784
25785 \begin_layout Standard
25786 18F: 96j60, 96j65, 97j60
25787 \end_layout
25788
25789 \begin_layout Standard
25790 \noindent
25791 An up-to-date list of supported devices is also available via '
25792 \family typewriter
25793 sdcc -mpic16 -plist
25794 \family default
25795 '.
25796 \end_layout
25797
25798 \begin_layout Subsection
25799 Global Options
25800 \end_layout
25801
25802 \begin_layout Standard
25803 PIC16 port supports the standard command line arguments as supposed, with
25804  the exception of certain cases that will be mentioned in the following
25805  list:
25806 \end_layout
25807
25808 \begin_layout Description
25809 -
25810 \begin_inset ERT
25811 status collapsed
25812
25813 \begin_layout Standard
25814
25815
25816 \backslash
25817 /
25818 \end_layout
25819
25820 \end_inset
25821
25822 -callee-saves
25823 \begin_inset LatexCommand index
25824 name "PIC16!Options!-\\/-callee-saves"
25825
25826 \end_inset
25827
25828  See -
25829 \begin_inset ERT
25830 status collapsed
25831
25832 \begin_layout Standard
25833
25834
25835 \backslash
25836 /
25837 \end_layout
25838
25839 \end_inset
25840
25841 -all-callee-saves
25842 \end_layout
25843
25844 \begin_layout Description
25845 -
25846 \begin_inset ERT
25847 status collapsed
25848
25849 \begin_layout Standard
25850
25851
25852 \backslash
25853 /
25854 \end_layout
25855
25856 \end_inset
25857
25858 -fommit-frame-pointer
25859 \begin_inset LatexCommand index
25860 name "PIC16!Options!-\\/-fommit-frame-pointer"
25861
25862 \end_inset
25863
25864  Frame pointer will be omitted when the function uses no local variables.
25865 \end_layout
25866
25867 \begin_layout Subsection
25868 Port Specific Options
25869 \begin_inset LatexCommand index
25870 name "Options PIC16"
25871
25872 \end_inset
25873
25874
25875 \end_layout
25876
25877 \begin_layout Standard
25878 The port specific options appear after the global options in the sdcc -
25879 \begin_inset ERT
25880 status collapsed
25881
25882 \begin_layout Standard
25883
25884
25885 \backslash
25886 /
25887 \end_layout
25888
25889 \end_inset
25890
25891 -help output.
25892 \end_layout
25893
25894 \begin_layout Subsubsection
25895 Code Generation Options
25896 \end_layout
25897
25898 \begin_layout Standard
25899 These options influence the generated assembler code.
25900 \end_layout
25901
25902 \begin_layout Description
25903 -
25904 \begin_inset ERT
25905 status collapsed
25906
25907 \begin_layout Standard
25908
25909
25910 \backslash
25911 /
25912 \end_layout
25913
25914 \end_inset
25915
25916 -pstack-model=[model] Used in conjunction with the command above.
25917  Defines the stack model to be used, valid stack models are:
25918 \end_layout
25919
25920 \begin_deeper
25921 \begin_layout List
25922 \labelwidthstring 00.00.0000
25923
25924 \emph on
25925 small
25926 \emph default
25927  Selects small stack model.
25928  8 bit stack and frame pointers.
25929  Supports 256 bytes stack size.
25930 \end_layout
25931
25932 \begin_layout List
25933 \labelwidthstring 00.00.0000
25934
25935 \emph on
25936 large
25937 \emph default
25938  Selects large stack model.
25939  16 bit stack and frame pointers.
25940  Supports 65536 bytes stack size.
25941 \end_layout
25942
25943 \end_deeper
25944 \begin_layout Description
25945 -
25946 \begin_inset ERT
25947 status collapsed
25948
25949 \begin_layout Standard
25950
25951
25952 \backslash
25953 /
25954 \end_layout
25955
25956 \end_inset
25957
25958 -pno-banksel Do not generate BANKSEL assembler directives.
25959 \end_layout
25960
25961 \begin_layout Description
25962 -
25963 \begin_inset ERT
25964 status collapsed
25965
25966 \begin_layout Standard
25967
25968
25969 \backslash
25970 /
25971 \end_layout
25972
25973 \end_inset
25974
25975 -extended Enable extended instruction set/literal offset addressing mode.
25976  Use with care!
25977 \end_layout
25978
25979 \begin_layout Subsubsection
25980 Optimization Options
25981 \end_layout
25982
25983 \begin_layout Description
25984 -
25985 \begin_inset ERT
25986 status collapsed
25987
25988 \begin_layout Standard
25989
25990
25991 \backslash
25992 /
25993 \end_layout
25994
25995 \end_inset
25996
25997 -obanksel=n Set optimization level for inserting BANKSELs.
25998 \newline
25999
26000 \end_layout
26001
26002 \begin_deeper
26003 \begin_layout List
26004 \labelwidthstring 00.00.0000
26005 0 no optimization
26006 \end_layout
26007
26008 \begin_layout List
26009 \labelwidthstring 00.00.0000
26010 1 checks previous used register and if it is the same then does not emit
26011  BANKSEL, accounts only for labels.
26012 \end_layout
26013
26014 \begin_layout List
26015 \labelwidthstring 00.00.0000
26016 2 tries to check the location of (even different) symbols and removes BANKSELs
26017  if they are in the same bank.
26018  
26019 \newline
26020
26021 \emph on
26022 Important: There might be problems if the linker script has data sections
26023  across bank borders!
26024 \end_layout
26025
26026 \end_deeper
26027 \begin_layout Description
26028 -
26029 \begin_inset ERT
26030 status collapsed
26031
26032 \begin_layout Standard
26033
26034
26035 \backslash
26036 /
26037 \end_layout
26038
26039 \end_inset
26040
26041 -denable-peeps Force the usage of peepholes.
26042  Use with care.
26043 \end_layout
26044
26045 \begin_layout Description
26046 -
26047 \begin_inset ERT
26048 status collapsed
26049
26050 \begin_layout Standard
26051
26052
26053 \backslash
26054 /
26055 \end_layout
26056
26057 \end_inset
26058
26059 -no-optimize-goto Do not use (conditional) BRA instead of GOTO.
26060 \end_layout
26061
26062 \begin_layout Description
26063 -
26064 \begin_inset ERT
26065 status collapsed
26066
26067 \begin_layout Standard
26068
26069
26070 \backslash
26071 /
26072 \end_layout
26073
26074 \end_inset
26075
26076 -optimize-cmp Try to optimize some compares.
26077 \end_layout
26078
26079 \begin_layout Description
26080 -
26081 \begin_inset ERT
26082 status collapsed
26083
26084 \begin_layout Standard
26085
26086
26087 \backslash
26088 /
26089 \end_layout
26090
26091 \end_inset
26092
26093 -optimize-df Analyze the dataflow of the generated code and improve it.
26094 \end_layout
26095
26096 \begin_layout Subsubsection
26097 Assembling Options
26098 \end_layout
26099
26100 \begin_layout Description
26101 -
26102 \begin_inset ERT
26103 status collapsed
26104
26105 \begin_layout Standard
26106
26107
26108 \backslash
26109 /
26110 \end_layout
26111
26112 \end_inset
26113
26114 -asm= Sets the full path and name of an external assembler to call.
26115 \end_layout
26116
26117 \begin_layout Description
26118 -
26119 \begin_inset ERT
26120 status collapsed
26121
26122 \begin_layout Standard
26123
26124
26125 \backslash
26126 /
26127 \end_layout
26128
26129 \end_inset
26130
26131 -mplab-comp MPLAB
26132 \begin_inset LatexCommand index
26133 name "PIC16!MPLAB"
26134
26135 \end_inset
26136
26137  compatibility option.
26138  Currently only suppresses special gpasm directives.
26139 \end_layout
26140
26141 \begin_layout Subsubsection
26142 Linking Options
26143 \end_layout
26144
26145 \begin_layout Description
26146 -
26147 \begin_inset ERT
26148 status collapsed
26149
26150 \begin_layout Standard
26151
26152
26153 \backslash
26154 /
26155 \end_layout
26156
26157 \end_inset
26158
26159 -link= Sets the full path and name of an external linker to call.
26160 \end_layout
26161
26162 \begin_layout Description
26163 -
26164 \begin_inset ERT
26165 status collapsed
26166
26167 \begin_layout Standard
26168
26169
26170 \backslash
26171 /
26172 \end_layout
26173
26174 \end_inset
26175
26176 -preplace-udata-with=[kword] Replaces the default udata keyword for allocating
26177  unitialized data variables with [kword].
26178  Valid keywords are: "udata_acs", "udata_shr", "udata_ovr".
26179 \end_layout
26180
26181 \begin_layout Description
26182 -
26183 \begin_inset ERT
26184 status collapsed
26185
26186 \begin_layout Standard
26187
26188
26189 \backslash
26190 /
26191 \end_layout
26192
26193 \end_inset
26194
26195 -ivt-loc=n Place the interrupt vector table at address 
26196 \emph on
26197 n
26198 \emph default
26199 .
26200  Useful for bootloaders.
26201 \end_layout
26202
26203 \begin_layout Description
26204 -
26205 \begin_inset ERT
26206 status collapsed
26207
26208 \begin_layout Standard
26209
26210
26211 \backslash
26212 /
26213 \end_layout
26214
26215 \end_inset
26216
26217 -nodefaultlibs Do not link default libraries when linking.
26218 \end_layout
26219
26220 \begin_layout Description
26221 -
26222 \begin_inset ERT
26223 status collapsed
26224
26225 \begin_layout Standard
26226
26227
26228 \backslash
26229 /
26230 \end_layout
26231
26232 \end_inset
26233
26234 -use-crt= Use a custom run-time module instead of the defaults.
26235 \end_layout
26236
26237 \begin_layout Description
26238 -
26239 \begin_inset ERT
26240 status collapsed
26241
26242 \begin_layout Standard
26243
26244
26245 \backslash
26246 /
26247 \end_layout
26248
26249 \end_inset
26250
26251 -no-crt Don't link the default run-time modules
26252 \end_layout
26253
26254 \begin_layout Subsubsection
26255 Debugging Options
26256 \end_layout
26257
26258 \begin_layout Standard
26259 Debugging options enable extra debugging information in the output files.
26260 \end_layout
26261
26262 \begin_layout Description
26263 -
26264 \begin_inset ERT
26265 status collapsed
26266
26267 \begin_layout Standard
26268
26269
26270 \backslash
26271 /
26272 \end_layout
26273
26274 \end_inset
26275
26276 -debug-xtra Similar to -
26277 \begin_inset ERT
26278 status collapsed
26279
26280 \begin_layout Standard
26281
26282
26283 \backslash
26284 /
26285 \end_layout
26286
26287 \end_inset
26288
26289 -debug
26290 \begin_inset LatexCommand index
26291 name "-\\/-debug"
26292
26293 \end_inset
26294
26295 , but dumps more information.
26296 \end_layout
26297
26298 \begin_layout Description
26299 -
26300 \begin_inset ERT
26301 status collapsed
26302
26303 \begin_layout Standard
26304
26305
26306 \backslash
26307 /
26308 \end_layout
26309
26310 \end_inset
26311
26312 -debug-ralloc Force register allocator to dump <source>.d file with debugging
26313  information.
26314  <source> is the name of the file being compiled.
26315 \end_layout
26316
26317 \begin_layout Description
26318 -
26319 \begin_inset ERT
26320 status collapsed
26321
26322 \begin_layout Standard
26323
26324
26325 \backslash
26326 /
26327 \end_layout
26328
26329 \end_inset
26330
26331 -pcode-verbose Enable pcode debugging information in translation.
26332 \end_layout
26333
26334 \begin_layout Description
26335 -
26336 \begin_inset ERT
26337 status collapsed
26338
26339 \begin_layout Standard
26340
26341
26342 \backslash
26343 /
26344 \end_layout
26345
26346 \end_inset
26347
26348 -calltree Dump call tree in .calltree file.
26349 \end_layout
26350
26351 \begin_layout Description
26352 -
26353 \begin_inset ERT
26354 status collapsed
26355
26356 \begin_layout Standard
26357
26358
26359 \backslash
26360 /
26361 \end_layout
26362
26363 \end_inset
26364
26365 -gstack Trace push/pops for stack pointer overflow.
26366 \end_layout
26367
26368 \begin_layout Subsection
26369 Environment Variables
26370 \end_layout
26371
26372 \begin_layout Standard
26373 There is a number of environmental variables that can be used when running
26374  SDCC to enable certain optimizations or force a specific program behaviour.
26375  these variables are primarily for debugging purposes so they can be enabled/dis
26376 abled at will.
26377 \end_layout
26378
26379 \begin_layout Standard
26380 Currently there is only two such variables available:
26381 \end_layout
26382
26383 \begin_layout Description
26384 OPTIMIZE_BITFIELD_POINTER_GET When this variable exists, reading of structure
26385  bitfields is optimized by directly loading FSR0 with the address of the
26386  bitfield structure.
26387  Normally SDCC will cast the bitfield structure to a bitfield pointer and
26388  then load FSR0.
26389  This step saves data ram and code space for functions that make heavy use
26390  of bitfields.
26391  (i.e., 80 bytes of code space are saved when compiling malloc.c with this
26392  option).
26393  
26394 \end_layout
26395
26396 \begin_layout Description
26397 NO_REG_OPT Do not perform pCode registers optimization.
26398  This should be used for debugging purposes.
26399  If bugs in the pcode optimizer are found, users can benefit from temporarily
26400  disabling the optimizer until the bug is fixed.
26401 \end_layout
26402
26403 \begin_layout Subsection
26404 Preprocessor Macros
26405 \end_layout
26406
26407 \begin_layout Standard
26408 PIC16
26409 \begin_inset LatexCommand index
26410 name "PIC16"
26411
26412 \end_inset
26413
26414  port defines the following preprocessor macros while translating a source.
26415 \end_layout
26416
26417 \begin_layout Standard
26418 \align center
26419 \begin_inset Tabular
26420 <lyxtabular version="3" rows="6" columns="2">
26421 <features>
26422 <column alignment="center" valignment="top" leftline="true" width="0">
26423 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26424 <row topline="true" bottomline="true">
26425 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26426 \begin_inset Text
26427
26428 \begin_layout Standard
26429 Macro
26430 \end_layout
26431
26432 \end_inset
26433 </cell>
26434 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26435 \begin_inset Text
26436
26437 \begin_layout Standard
26438 Description
26439 \end_layout
26440
26441 \end_inset
26442 </cell>
26443 </row>
26444 <row topline="true">
26445 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26446 \begin_inset Text
26447
26448 \begin_layout Standard
26449 SDCC_pic16
26450 \end_layout
26451
26452 \end_inset
26453 </cell>
26454 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26455 \begin_inset Text
26456
26457 \begin_layout Standard
26458 Port identification
26459 \end_layout
26460
26461 \end_inset
26462 </cell>
26463 </row>
26464 <row topline="true">
26465 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26466 \begin_inset Text
26467
26468 \begin_layout Standard
26469 _
26470 \begin_inset ERT
26471 status collapsed
26472
26473 \begin_layout Standard
26474
26475
26476 \backslash
26477 /
26478 \end_layout
26479
26480 \end_inset
26481
26482 _pic16
26483 \end_layout
26484
26485 \end_inset
26486 </cell>
26487 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26488 \begin_inset Text
26489
26490 \begin_layout Standard
26491 Port identification (same as above)
26492 \end_layout
26493
26494 \end_inset
26495 </cell>
26496 </row>
26497 <row topline="true">
26498 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26499 \begin_inset Text
26500
26501 \begin_layout Standard
26502 pic18fxxxx
26503 \end_layout
26504
26505 \end_inset
26506 </cell>
26507 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26508 \begin_inset Text
26509
26510 \begin_layout Standard
26511 MCU Identification.
26512  
26513 \emph on
26514 xxxx
26515 \emph default
26516  is the microcontrol identification number, i.e.
26517  452, 6620, etc
26518 \end_layout
26519
26520 \end_inset
26521 </cell>
26522 </row>
26523 <row topline="true">
26524 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26525 \begin_inset Text
26526
26527 \begin_layout Standard
26528 _
26529 \begin_inset ERT
26530 status collapsed
26531
26532 \begin_layout Standard
26533
26534
26535 \backslash
26536 /
26537 \end_layout
26538
26539 \end_inset
26540
26541 _18Fxxxx
26542 \end_layout
26543
26544 \end_inset
26545 </cell>
26546 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26547 \begin_inset Text
26548
26549 \begin_layout Standard
26550 MCU Identification (same as above)
26551 \end_layout
26552
26553 \end_inset
26554 </cell>
26555 </row>
26556 <row topline="true" bottomline="true">
26557 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26558 \begin_inset Text
26559
26560 \begin_layout Standard
26561 STACK_MODEL_nnn
26562 \end_layout
26563
26564 \end_inset
26565 </cell>
26566 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26567 \begin_inset Text
26568
26569 \begin_layout Standard
26570 nnn = SMALL or LARGE respectively according to the stack model used
26571 \end_layout
26572
26573 \end_inset
26574 </cell>
26575 </row>
26576 </lyxtabular>
26577
26578 \end_inset
26579
26580
26581 \end_layout
26582
26583 \begin_layout Standard
26584 \noindent
26585 In addition the following macros are defined when calling assembler:
26586 \end_layout
26587
26588 \begin_layout Standard
26589 \align center
26590 \begin_inset Tabular
26591 <lyxtabular version="3" rows="4" columns="2">
26592 <features>
26593 <column alignment="center" valignment="top" leftline="true" width="0">
26594 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26595 <row topline="true" bottomline="true">
26596 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26597 \begin_inset Text
26598
26599 \begin_layout Standard
26600 Macro
26601 \end_layout
26602
26603 \end_inset
26604 </cell>
26605 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26606 \begin_inset Text
26607
26608 \begin_layout Standard
26609 Description
26610 \end_layout
26611
26612 \end_inset
26613 </cell>
26614 </row>
26615 <row topline="true">
26616 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26617 \begin_inset Text
26618
26619 \begin_layout Standard
26620 __18Fxxxx
26621 \end_layout
26622
26623 \end_inset
26624 </cell>
26625 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26626 \begin_inset Text
26627
26628 \begin_layout Standard
26629 MCU Identification.
26630  
26631 \emph on
26632 xxxx
26633 \emph default
26634  is the microcontrol identification number, i.e.
26635  452, 6620, etc
26636 \end_layout
26637
26638 \end_inset
26639 </cell>
26640 </row>
26641 <row topline="true">
26642 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26643 \begin_inset Text
26644
26645 \begin_layout Standard
26646 SDCC_MODEL_nnn
26647 \end_layout
26648
26649 \end_inset
26650 </cell>
26651 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26652 \begin_inset Text
26653
26654 \begin_layout Standard
26655 nnn = SMALL or LARGE respectively according to the memory model used for
26656  SDCC
26657 \end_layout
26658
26659 \end_inset
26660 </cell>
26661 </row>
26662 <row topline="true" bottomline="true">
26663 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26664 \begin_inset Text
26665
26666 \begin_layout Standard
26667 STACK_MODEL_nnn
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 nnn = SMALL or LARGE respectively according to the stack model used
26677 \end_layout
26678
26679 \end_inset
26680 </cell>
26681 </row>
26682 </lyxtabular>
26683
26684 \end_inset
26685
26686
26687 \end_layout
26688
26689 \begin_layout Subsection
26690 Directories
26691 \end_layout
26692
26693 \begin_layout Standard
26694 PIC16
26695 \begin_inset LatexCommand index
26696 name "PIC16"
26697
26698 \end_inset
26699
26700  port uses the following directories for searching header files and libraries.
26701 \end_layout
26702
26703 \begin_layout Standard
26704 \align center
26705 \begin_inset Tabular
26706 <lyxtabular version="3" rows="3" columns="4">
26707 <features>
26708 <column alignment="center" valignment="top" leftline="true" width="0">
26709 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26710 <column alignment="center" valignment="top" width="0">
26711 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26712 <row topline="true" bottomline="true">
26713 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26714 \begin_inset Text
26715
26716 \begin_layout Standard
26717 Directory
26718 \end_layout
26719
26720 \end_inset
26721 </cell>
26722 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26723 \begin_inset Text
26724
26725 \begin_layout Standard
26726 Description
26727 \end_layout
26728
26729 \end_inset
26730 </cell>
26731 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26732 \begin_inset Text
26733
26734 \begin_layout Standard
26735 Target
26736 \end_layout
26737
26738 \end_inset
26739 </cell>
26740 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26741 \begin_inset Text
26742
26743 \begin_layout Standard
26744 Command prefix
26745 \end_layout
26746
26747 \end_inset
26748 </cell>
26749 </row>
26750 <row topline="true">
26751 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26752 \begin_inset Text
26753
26754 \begin_layout Standard
26755 PREFIX/sdcc/include/pic16
26756 \end_layout
26757
26758 \end_inset
26759 </cell>
26760 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26761 \begin_inset Text
26762
26763 \begin_layout Standard
26764 PIC16 specific headers
26765 \end_layout
26766
26767 \end_inset
26768 </cell>
26769 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26770 \begin_inset Text
26771
26772 \begin_layout Standard
26773 Compiler
26774 \end_layout
26775
26776 \end_inset
26777 </cell>
26778 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26779 \begin_inset Text
26780
26781 \begin_layout Standard
26782 -I
26783 \end_layout
26784
26785 \end_inset
26786 </cell>
26787 </row>
26788 <row topline="true" bottomline="true">
26789 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26790 \begin_inset Text
26791
26792 \begin_layout Standard
26793 PREFIX/sdcc/lib/pic16
26794 \end_layout
26795
26796 \end_inset
26797 </cell>
26798 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26799 \begin_inset Text
26800
26801 \begin_layout Standard
26802 PIC16 specific libraries
26803 \end_layout
26804
26805 \end_inset
26806 </cell>
26807 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26808 \begin_inset Text
26809
26810 \begin_layout Standard
26811 Linker
26812 \end_layout
26813
26814 \end_inset
26815 </cell>
26816 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26817 \begin_inset Text
26818
26819 \begin_layout Standard
26820 -L
26821 \end_layout
26822
26823 \end_inset
26824 </cell>
26825 </row>
26826 </lyxtabular>
26827
26828 \end_inset
26829
26830
26831 \end_layout
26832
26833 \begin_layout Subsection
26834 Pragmas
26835 \begin_inset LatexCommand label
26836 name "sub:PIC16_Pragmas"
26837
26838 \end_inset
26839
26840
26841 \end_layout
26842
26843 \begin_layout Standard
26844 The PIC16
26845 \begin_inset LatexCommand index
26846 name "PIC16"
26847
26848 \end_inset
26849
26850  port currently supports the following pragmas:
26851 \end_layout
26852
26853 \begin_layout Description
26854 stack
26855 \begin_inset LatexCommand index
26856 name "PIC16!Pragmas!\\#pragma stack"
26857
26858 \end_inset
26859
26860  This forces the code generator to initialize the stack & frame pointers
26861  at a specific address.
26862  This is an ad hoc solution for cases where no STACK directive is available
26863  in the linker script or gplink is not instructed to create a stack section.
26864 \newline
26865 The
26866  stack pragma should be used only once in a project.
26867  Multiple pragmas may result in indeterminate behaviour of the program.
26868 \begin_inset Foot
26869 status open
26870
26871 \begin_layout Standard
26872 The old format (ie.
26873  #pragma stack 0x5ff) is deprecated and will cause the stack pointer to
26874  cross page boundaries (or even exceed the available data RAM) and crash
26875  the program.
26876  Make sure that stack does not cross page boundaries when using the SMALL
26877  stack model.
26878 \end_layout
26879
26880 \end_inset
26881
26882
26883 \newline
26884 The format is as follows:
26885 \newline
26886
26887 \end_layout
26888
26889 \begin_layout LyX-Code
26890 #pragma stack bottom_address [stack_size]
26891 \newline
26892
26893 \end_layout
26894
26895 \begin_layout Standard
26896
26897 \emph on
26898 bottom_address
26899 \emph default
26900  is the lower bound of the stack section.
26901  The stack pointer initially will point at address (bottom_address+stack_size-1).
26902 \end_layout
26903
26904 \begin_layout LyX-Code
26905 Example:
26906 \end_layout
26907
26908 \begin_layout LyX-Code
26909
26910 \end_layout
26911
26912 \begin_layout LyX-Code
26913 /* initializes stack of 100 bytes at RAM address 0x200 */
26914 \end_layout
26915
26916 \begin_layout LyX-Code
26917 #pragma stack 0x200 100
26918 \end_layout
26919
26920 \begin_layout Standard
26921 If the stack_size field is omitted then a stack is created with the default
26922  size of 64.
26923  This size might be enough for most programs, but its not enough for operations
26924  with deep function nesting or excessive stack usage.
26925 \end_layout
26926
26927 \begin_layout Description
26928 code
26929 \begin_inset LatexCommand index
26930 name "PIC16!Pragmas!\\#pragma code"
26931
26932 \end_inset
26933
26934  Force a function to a static FLASH address.
26935 \end_layout
26936
26937 \begin_layout LyX-Code
26938 Example:
26939 \end_layout
26940
26941 \begin_layout LyX-Code
26942
26943 \end_layout
26944
26945 \begin_layout LyX-Code
26946 /* place function test_func at 0x4000 */
26947 \end_layout
26948
26949 \begin_layout LyX-Code
26950 #pragma code test_func 0x4000
26951 \end_layout
26952
26953 \begin_layout LyX-Code
26954
26955 \end_layout
26956
26957 \begin_layout Description
26958 library instructs the linker to use a library module.
26959 \newline
26960 Usage:
26961 \end_layout
26962
26963 \begin_layout LyX-Code
26964 #pragma library module_name
26965 \end_layout
26966
26967 \begin_layout Standard
26968
26969 \emph on
26970 module_name
26971 \emph default
26972  can be any library or object file (including its path).
26973  Note that there are four reserved keywords which have special meaning.
26974  These are:
26975 \end_layout
26976
26977 \begin_layout Standard
26978 \align center
26979 \begin_inset Tabular
26980 <lyxtabular version="3" rows="6" columns="3">
26981 <features>
26982 <column alignment="center" valignment="top" leftline="true" width="0">
26983 <column alignment="block" valignment="top" leftline="true" width="20page%">
26984 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0">
26985 <row topline="true" bottomline="true">
26986 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26987 \begin_inset Text
26988
26989 \begin_layout Standard
26990 Keyword
26991 \end_layout
26992
26993 \end_inset
26994 </cell>
26995 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26996 \begin_inset Text
26997
26998 \begin_layout Standard
26999 Description
27000 \end_layout
27001
27002 \end_inset
27003 </cell>
27004 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27005 \begin_inset Text
27006
27007 \begin_layout Standard
27008 Module to link
27009 \end_layout
27010
27011 \end_inset
27012 </cell>
27013 </row>
27014 <row topline="true">
27015 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27016 \begin_inset Text
27017
27018 \begin_layout Standard
27019
27020 \series bold
27021 ignore
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 ignore all library pragmas
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
27040 \emph on
27041 (none)
27042 \end_layout
27043
27044 \end_inset
27045 </cell>
27046 </row>
27047 <row topline="true">
27048 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27049 \begin_inset Text
27050
27051 \begin_layout Standard
27052
27053 \series bold
27054 c
27055 \end_layout
27056
27057 \end_inset
27058 </cell>
27059 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27060 \begin_inset Text
27061
27062 \begin_layout Standard
27063 link the C library
27064 \end_layout
27065
27066 \end_inset
27067 </cell>
27068 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27069 \begin_inset Text
27070
27071 \begin_layout Standard
27072
27073 \emph on
27074 libc18f
27075 \emph default
27076 .lib
27077 \end_layout
27078
27079 \end_inset
27080 </cell>
27081 </row>
27082 <row topline="true">
27083 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27084 \begin_inset Text
27085
27086 \begin_layout Standard
27087
27088 \series bold
27089 math
27090 \end_layout
27091
27092 \end_inset
27093 </cell>
27094 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27095 \begin_inset Text
27096
27097 \begin_layout Standard
27098 link the Math libarary
27099 \end_layout
27100
27101 \end_inset
27102 </cell>
27103 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27104 \begin_inset Text
27105
27106 \begin_layout Standard
27107
27108 \emph on
27109 libm18f
27110 \emph default
27111 .lib
27112 \end_layout
27113
27114 \end_inset
27115 </cell>
27116 </row>
27117 <row topline="true">
27118 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27119 \begin_inset Text
27120
27121 \begin_layout Standard
27122
27123 \series bold
27124 io
27125 \end_layout
27126
27127 \end_inset
27128 </cell>
27129 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27130 \begin_inset Text
27131
27132 \begin_layout Standard
27133 link the I/O library
27134 \end_layout
27135
27136 \end_inset
27137 </cell>
27138 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27139 \begin_inset Text
27140
27141 \begin_layout Standard
27142
27143 \emph on
27144 libio18f*
27145 \emph default
27146 .lib
27147 \end_layout
27148
27149 \end_inset
27150 </cell>
27151 </row>
27152 <row topline="true" bottomline="true">
27153 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27154 \begin_inset Text
27155
27156 \begin_layout Standard
27157
27158 \series bold
27159 debug
27160 \end_layout
27161
27162 \end_inset
27163 </cell>
27164 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27165 \begin_inset Text
27166
27167 \begin_layout Standard
27168 link the debug library
27169 \end_layout
27170
27171 \end_inset
27172 </cell>
27173 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27174 \begin_inset Text
27175
27176 \begin_layout Standard
27177
27178 \emph on
27179 libdebug
27180 \emph default
27181 .lib
27182 \end_layout
27183
27184 \end_inset
27185 </cell>
27186 </row>
27187 </lyxtabular>
27188
27189 \end_inset
27190
27191
27192 \newline
27193 * is the device number, i.e.
27194  452 for PIC18F452 MCU.
27195 \end_layout
27196
27197 \begin_layout Standard
27198 \noindent
27199 This feature allows for linking with specific libraries without having to
27200  explicit name them in the command line.
27201  Note that the 
27202 \noun on
27203 ignore
27204 \noun default
27205  keyword will reject all modules specified by the library pragma.
27206 \end_layout
27207
27208 \begin_layout Description
27209 udata The pragma udata instructs the compiler to emit code so that linker
27210  will place a variable at a specific memory bank.
27211 \end_layout
27212
27213 \begin_layout LyX-Code
27214 Example:
27215 \end_layout
27216
27217 \begin_layout LyX-Code
27218
27219 \end_layout
27220
27221 \begin_layout LyX-Code
27222 /* places variable foo at bank2 */
27223 \end_layout
27224
27225 \begin_layout LyX-Code
27226 #pragma udata bank2 foo
27227 \end_layout
27228
27229 \begin_layout LyX-Code
27230 char foo;
27231 \end_layout
27232
27233 \begin_layout Standard
27234 In order for this pragma to work extra SECTION directives should be added
27235  in the .lkr script.
27236  In the following example a sample .lkr file is shown:
27237 \end_layout
27238
27239 \begin_layout LyX-Code
27240
27241 \end_layout
27242
27243 \begin_layout LyX-Code
27244 // Sample linker script for the PIC18F452 processor
27245 \end_layout
27246
27247 \begin_layout LyX-Code
27248 LIBPATH .
27249 \end_layout
27250
27251 \begin_layout LyX-Code
27252 CODEPAGE   NAME=vectors    START=0x0            END=0x29           PROTECTED
27253 \end_layout
27254
27255 \begin_layout LyX-Code
27256 CODEPAGE   NAME=page       START=0x2A           END=0x7FFF
27257 \end_layout
27258
27259 \begin_layout LyX-Code
27260 CODEPAGE   NAME=idlocs     START=0x200000       END=0x200007       PROTECTED
27261 \end_layout
27262
27263 \begin_layout LyX-Code
27264 CODEPAGE   NAME=config     START=0x300000       END=0x30000D       PROTECTED
27265 \end_layout
27266
27267 \begin_layout LyX-Code
27268 CODEPAGE   NAME=devid      START=0x3FFFFE       END=0x3FFFFF       PROTECTED
27269 \end_layout
27270
27271 \begin_layout LyX-Code
27272 CODEPAGE   NAME=eedata     START=0xF00000       END=0xF000FF       PROTECTED
27273 \end_layout
27274
27275 \begin_layout LyX-Code
27276 ACCESSBANK NAME=accessram  START=0x0            END=0x7F
27277 \end_layout
27278
27279 \begin_layout LyX-Code
27280
27281 \end_layout
27282
27283 \begin_layout LyX-Code
27284 DATABANK   NAME=gpr0       START=0x80           END=0xFF
27285 \end_layout
27286
27287 \begin_layout LyX-Code
27288 DATABANK   NAME=gpr1       START=0x100          END=0x1FF
27289 \end_layout
27290
27291 \begin_layout LyX-Code
27292 DATABANK   NAME=gpr2       START=0x200          END=0x2FF
27293 \end_layout
27294
27295 \begin_layout LyX-Code
27296 DATABANK   NAME=gpr3       START=0x300          END=0x3FF
27297 \end_layout
27298
27299 \begin_layout LyX-Code
27300 DATABANK   NAME=gpr4       START=0x400          END=0x4FF
27301 \end_layout
27302
27303 \begin_layout LyX-Code
27304 DATABANK   NAME=gpr5       START=0x500          END=0x5FF
27305 \end_layout
27306
27307 \begin_layout LyX-Code
27308 ACCESSBANK NAME=accesssfr  START=0xF80          END=0xFFF          PROTECTED
27309 \end_layout
27310
27311 \begin_layout LyX-Code
27312
27313 \end_layout
27314
27315 \begin_layout LyX-Code
27316 SECTION    NAME=CONFIG     ROM=config
27317 \end_layout
27318
27319 \begin_layout LyX-Code
27320
27321 \end_layout
27322
27323 \begin_layout LyX-Code
27324 SECTION    NAME=bank0      RAM=gpr0       # these SECTION directives
27325 \end_layout
27326
27327 \begin_layout LyX-Code
27328 SECTION    NAME=bank1      RAM=gpr1       # should be added to link
27329 \end_layout
27330
27331 \begin_layout LyX-Code
27332 SECTION    NAME=bank2      RAM=gpr2       # section name 'bank?' with
27333 \end_layout
27334
27335 \begin_layout LyX-Code
27336 SECTION    NAME=bank3      RAM=gpr3       # a specific DATABANK name
27337 \end_layout
27338
27339 \begin_layout LyX-Code
27340 SECTION    NAME=bank4      RAM=gpr4
27341 \end_layout
27342
27343 \begin_layout LyX-Code
27344 SECTION    NAME=bank5      RAM=gpr5
27345 \end_layout
27346
27347 \begin_layout Standard
27348 The linker will recognise the section name set in the pragma statement and
27349  will position the variable at the memory bank set with the RAM field at
27350  the SECTION line in the linker script file.
27351 \end_layout
27352
27353 \begin_layout Subsection
27354 Header Files
27355 \begin_inset LatexCommand label
27356 name "sub:PIC16_Header-Files"
27357
27358 \end_inset
27359
27360
27361 \end_layout
27362
27363 \begin_layout Standard
27364 There is one main header file
27365 \begin_inset LatexCommand index
27366 name "PIC16!Header files"
27367
27368 \end_inset
27369
27370  that can be included to the source files using the pic16
27371 \begin_inset LatexCommand index
27372 name "PIC16"
27373
27374 \end_inset
27375
27376  port.
27377  That file is the 
27378 \series bold
27379 pic18fregs.h
27380 \series default
27381 .
27382  This header file contains the definitions for the processor special registers,
27383  so it is necessary if the source accesses them.
27384  It can be included by adding the following line in the beginning of the
27385  file:
27386 \end_layout
27387
27388 \begin_layout LyX-Code
27389 #include <pic18fregs.h>
27390 \end_layout
27391
27392 \begin_layout Standard
27393 The specific microcontroller is selected within the pic18fregs.h automatically,
27394  so the same source can be used with a variety of devices.
27395 \end_layout
27396
27397 \begin_layout Subsection
27398 Libraries
27399 \begin_inset LatexCommand label
27400 name "sub:pic16Libraries"
27401
27402 \end_inset
27403
27404
27405 \end_layout
27406
27407 \begin_layout Standard
27408 The libraries
27409 \begin_inset LatexCommand index
27410 name "PIC16!Libraries"
27411
27412 \end_inset
27413
27414  that PIC16
27415 \begin_inset LatexCommand index
27416 name "PIC16"
27417
27418 \end_inset
27419
27420  port depends on are the microcontroller device libraries which contain
27421  the symbol definitions for the microcontroller special function registers.
27422  These libraries have the format pic18fxxxx.lib, where 
27423 \emph on
27424 xxxx
27425 \emph default
27426  is the microcontroller identification number.
27427  The specific library is selected automatically by the compiler at link
27428  stage according to the selected device.
27429 \end_layout
27430
27431 \begin_layout Standard
27432 \noindent
27433 Libraries are created with gplib which is part of the gputils package 
27434 \begin_inset LatexCommand url
27435 target "http://sourceforge.net/projects/gputils"
27436
27437 \end_inset
27438
27439 .
27440 \end_layout
27441
27442 \begin_layout Subsubsection*
27443 Building the libraries
27444 \end_layout
27445
27446 \begin_layout Standard
27447 Before using SDCC/pic16 there are some libraries that need to be compiled.
27448  This process is done automatically if gputils are found at SDCC's compile
27449  time.
27450  Should you require to rebuild the pic16 libraries manually (e.g.
27451  in order to enable output of float values
27452 \begin_inset LatexCommand index
27453 name "Floating point support"
27454
27455 \end_inset
27456
27457  via 
27458 \family typewriter
27459 printf()
27460 \family default
27461 , see below), these are the steps required to do so under Linux or Mac OS
27462  X (cygwin might work as well, but is untested):
27463 \end_layout
27464
27465 \begin_layout LyX-Code
27466 cd device/lib/pic16
27467 \end_layout
27468
27469 \begin_layout LyX-Code
27470 ./configure.gnu
27471 \end_layout
27472
27473 \begin_layout LyX-Code
27474 cd ..
27475 \end_layout
27476
27477 \begin_layout LyX-Code
27478 make model-pic16
27479 \end_layout
27480
27481 \begin_layout LyX-Code
27482 su -c 'make install'     # install the libraries, you need the root password
27483 \end_layout
27484
27485 \begin_layout LyX-Code
27486 cd ../..
27487 \end_layout
27488
27489 \begin_layout Standard
27490 If you need to install the headers too, do:
27491 \end_layout
27492
27493 \begin_layout LyX-Code
27494 cd device/include
27495 \end_layout
27496
27497 \begin_layout LyX-Code
27498 su -c 'make install'     # install the headers, you need the root password
27499 \end_layout
27500
27501 \begin_layout Subsubsection*
27502 Output of float values via printf()
27503 \end_layout
27504
27505 \begin_layout Standard
27506 The library is normally built without support for displaying float values,
27507  only <NO FLOAT>
27508 \begin_inset LatexCommand index
27509 name "<NO FLOAT>"
27510
27511 \end_inset
27512
27513
27514 \begin_inset LatexCommand index
27515 name "printf floating point support"
27516
27517 \end_inset
27518
27519  will appear instead of the value.
27520  To change this, rebuild the library as stated above, but call 
27521 \family typewriter
27522 ./configure.gnu --enable-floats 
27523 \family default
27524 instead of just 
27525 \family typewriter
27526 ./configure.gnu
27527 \family default
27528 .
27529  Also make sure that at least 
27530 \family typewriter
27531 libc/stdio/vfprintf.c
27532 \family default
27533  is actually recompiled, e.g.
27534  by 
27535 \family typewriter
27536 touch
27537 \family default
27538 ing it after the 
27539 \family typewriter
27540 configure
27541 \family default
27542  run or deleting its 
27543 \family typewriter
27544 .o
27545 \family default
27546  file.
27547 \end_layout
27548
27549 \begin_layout Standard
27550 The more common appraoch of compiling 
27551 \family typewriter
27552 vfprintf.c
27553 \family default
27554  manually with 
27555 \family typewriter
27556 -DUSE_FLOATS=1
27557 \family default
27558  should also work, but is untested.
27559 \end_layout
27560
27561 \begin_layout Subsection
27562 Adding New Devices to the Port
27563 \end_layout
27564
27565 \begin_layout Standard
27566 Adding support for a new 16
27567 \begin_inset ERT
27568 status collapsed
27569
27570 \begin_layout Standard
27571
27572
27573 \backslash
27574 ,
27575 \end_layout
27576
27577 \end_inset
27578
27579 bit PIC MCU requires the following steps:
27580 \end_layout
27581
27582 \begin_layout Enumerate
27583 Create picDEVICE.c and picDEVICE.h from pDEVICE.inc using
27584 \newline
27585
27586 \family typewriter
27587 perl /path/to/sdcc/support/scripts/inc2h-pic16.pl /path/to/gputils/header/pDEVICE.
27588 inc
27589 \end_layout
27590
27591 \begin_layout Enumerate
27592
27593 \family typewriter
27594 mv picDEVICE.h /path/to/sdcc/device/include/pic16
27595 \end_layout
27596
27597 \begin_layout Enumerate
27598
27599 \family typewriter
27600 mv picDEVICE.c /path/to/sdcc/device/lib/pic16/libdev
27601 \end_layout
27602
27603 \begin_layout Enumerate
27604 Add DEVICE to 
27605 \family typewriter
27606 /path/to/sdcc/device/lib/pic16/pics.all
27607 \family default
27608
27609 \newline
27610 Note: No 18f prefix here!
27611 \end_layout
27612
27613 \begin_layout Enumerate
27614 Edit 
27615 \family typewriter
27616 /path/to/sdcc/device/include/pic16/adc.h
27617 \newline
27618
27619 \family default
27620 Add the new devices to the correct ADC style class (depending on the number
27621  of ADC channels).
27622 \newline
27623 Do not touch 
27624 \family typewriter
27625 adc.h
27626 \family default
27627  if the device does not offer any ADC at all.
27628 \end_layout
27629
27630 \begin_layout Enumerate
27631 Edit 
27632 \family typewriter
27633 /path/to/sdcc/device/include/pic16/pic18fregs.h
27634 \family default
27635
27636 \newline
27637 The file format is self-explanatory, just add
27638 \newline
27639
27640 \family typewriter
27641 #elif defined(picDEVICE)
27642 \newline
27643 #
27644 \begin_inset ERT
27645 status collapsed
27646
27647 \begin_layout Standard
27648
27649
27650 \backslash
27651  
27652 \backslash
27653  
27654 \end_layout
27655
27656 \end_inset
27657
27658 include <picDEVICE.h>
27659 \family default
27660
27661 \newline
27662 at the right place (keep the file sorted, please).
27663 \end_layout
27664
27665 \begin_layout Enumerate
27666 Edit 
27667 \family typewriter
27668 /path/to/sdcc/device/include/pic16devices.txt
27669 \newline
27670
27671 \family default
27672 Copy and modify an existing entry or create a new one and insert it at the
27673  correct place (keep the file sorted, please).
27674 \end_layout
27675
27676 \begin_layout Enumerate
27677 Add the device to 
27678 \family typewriter
27679 /path/to/sdcc/device/lib/pic16/libdev/Makefile.am
27680 \family default
27681
27682 \newline
27683 Copy an existing entry and adjust the device name.
27684 \end_layout
27685
27686 \begin_layout Enumerate
27687 Add the device to 
27688 \family typewriter
27689 /path/to/sdcc/device/lib/pic16/libio/Makefile.am
27690 \family default
27691
27692 \newline
27693 Copy the record from the 18f2220 and adjust the device name.
27694 \newline
27695 If the new device
27696  does not offer ADC, I
27697 \begin_inset Formula $^{\text{2}}$
27698 \end_inset
27699
27700 C, and/or (E)USART functionality as assumed by the library, remove the lines
27701  with references to 
27702 \family typewriter
27703 adc/*.c
27704 \family default
27705
27706 \family typewriter
27707 usart/*.c
27708 \family default
27709 , or 
27710 \family typewriter
27711 usart/*.c
27712 \family default
27713 , respectively.
27714 \end_layout
27715
27716 \begin_layout Enumerate
27717 Update 
27718 \family typewriter
27719 libdev/Makefile.in
27720 \family default
27721  and 
27722 \family typewriter
27723 libio/Makefile.in
27724 \family default
27725  using
27726 \newline
27727
27728 \family typewriter
27729 ./bootstrap.sh
27730 \family default
27731
27732 \newline
27733 in 
27734 \family typewriter
27735 /path/to/sdcc/device/lib/pic16
27736 \family default
27737 .
27738 \end_layout
27739
27740 \begin_layout Enumerate
27741 Recompile the pic16 libraries as described in 
27742 \begin_inset LatexCommand ref
27743 reference "sub:pic16Libraries"
27744
27745 \end_inset
27746
27747 .
27748 \end_layout
27749
27750 \begin_layout Subsection
27751 Memory Models
27752 \end_layout
27753
27754 \begin_layout Standard
27755 The following memory models are supported by the PIC16 port:
27756 \end_layout
27757
27758 \begin_layout Itemize
27759 small model
27760 \end_layout
27761
27762 \begin_layout Itemize
27763 large model
27764 \end_layout
27765
27766 \begin_layout Standard
27767 Memory model affects the default size of pointers within the source.
27768  The sizes are shown in the next table:
27769 \end_layout
27770
27771 \begin_layout Standard
27772 \align center
27773 \begin_inset Tabular
27774 <lyxtabular version="3" rows="3" columns="3">
27775 <features>
27776 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
27777 <column alignment="center" valignment="top" leftline="true" width="0">
27778 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
27779 <row topline="true" bottomline="true">
27780 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27781 \begin_inset Text
27782
27783 \begin_layout Standard
27784 Pointer sizes according to memory model
27785 \end_layout
27786
27787 \end_inset
27788 </cell>
27789 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27790 \begin_inset Text
27791
27792 \begin_layout Standard
27793 small model
27794 \end_layout
27795
27796 \end_inset
27797 </cell>
27798 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27799 \begin_inset Text
27800
27801 \begin_layout Standard
27802 large model
27803 \end_layout
27804
27805 \end_inset
27806 </cell>
27807 </row>
27808 <row topline="true" bottomline="true">
27809 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27810 \begin_inset Text
27811
27812 \begin_layout Standard
27813 code pointers
27814 \end_layout
27815
27816 \end_inset
27817 </cell>
27818 <cell multicolumn="1" alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27819 \begin_inset Text
27820
27821 \begin_layout Standard
27822 16-bits
27823 \end_layout
27824
27825 \end_inset
27826 </cell>
27827 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27828 \begin_inset Text
27829
27830 \begin_layout Standard
27831 24-bits
27832 \end_layout
27833
27834 \end_inset
27835 </cell>
27836 </row>
27837 <row topline="true" bottomline="true">
27838 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27839 \begin_inset Text
27840
27841 \begin_layout Standard
27842 data pointers
27843 \end_layout
27844
27845 \end_inset
27846 </cell>
27847 <cell multicolumn="1" alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
27848 \begin_inset Text
27849
27850 \begin_layout Standard
27851 16-bits
27852 \end_layout
27853
27854 \end_inset
27855 </cell>
27856 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27857 \begin_inset Text
27858
27859 \begin_layout Standard
27860 16-bits
27861 \end_layout
27862
27863 \end_inset
27864 </cell>
27865 </row>
27866 </lyxtabular>
27867
27868 \end_inset
27869
27870
27871 \end_layout
27872
27873 \begin_layout Standard
27874 It is advisable that all sources within a project are compiled with the
27875  same memory model.
27876  If one wants to override the default memory model, this can be done by
27877  declaring a pointer as 
27878 \series bold
27879 far
27880 \series default
27881  or 
27882 \series bold
27883 near
27884 \series default
27885 .
27886  Far selects large memory model's pointers, while near selects small memory
27887  model's pointers.
27888 \end_layout
27889
27890 \begin_layout Standard
27891 The standard device libraries (see 
27892 \begin_inset LatexCommand ref
27893 reference "sub:PIC16_Header-Files"
27894
27895 \end_inset
27896
27897 ) contain no reference to pointers, so they can be used with both memory
27898  models.
27899 \end_layout
27900
27901 \begin_layout Subsection
27902 Stack
27903 \end_layout
27904
27905 \begin_layout Standard
27906 The stack
27907 \begin_inset LatexCommand index
27908 name "PIC16!stack"
27909
27910 \end_inset
27911
27912  implementation for the PIC16 port uses two indirect registers, FSR1 and
27913  FSR2.
27914 \end_layout
27915
27916 \begin_layout Description
27917 FSR1 is assigned as stack pointer
27918 \end_layout
27919
27920 \begin_layout Description
27921 FSR2 is assigned as frame pointer
27922 \end_layout
27923
27924 \begin_layout Standard
27925 The following stack models are supported by the PIC16 port
27926 \end_layout
27927
27928 \begin_layout Itemize
27929
27930 \noun on
27931 small
27932 \noun default
27933  model
27934 \end_layout
27935
27936 \begin_layout Itemize
27937
27938 \noun on
27939 large
27940 \noun default
27941  model
27942 \end_layout
27943
27944 \begin_layout Standard
27945
27946 \noun on
27947 Small
27948 \noun default
27949  model means that only the FSRxL byte is used to access stack and frame,
27950  while 
27951 \emph on
27952 \noun on
27953 large
27954 \emph default
27955 \noun default
27956  uses both FSRxL and FSRxH registers.
27957  The following table shows the stack/frame pointers sizes according to stack
27958  model and the maximum space they can address:
27959 \end_layout
27960
27961 \begin_layout Standard
27962 \align center
27963 \begin_inset Tabular
27964 <lyxtabular version="3" rows="3" columns="3">
27965 <features>
27966 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
27967 <column alignment="center" valignment="top" leftline="true" width="0">
27968 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
27969 <row topline="true" bottomline="true">
27970 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27971 \begin_inset Text
27972
27973 \begin_layout Standard
27974 Stack & Frame pointer sizes according to stack model
27975 \end_layout
27976
27977 \end_inset
27978 </cell>
27979 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27980 \begin_inset Text
27981
27982 \begin_layout Standard
27983 small
27984 \end_layout
27985
27986 \end_inset
27987 </cell>
27988 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27989 \begin_inset Text
27990
27991 \begin_layout Standard
27992 large
27993 \end_layout
27994
27995 \end_inset
27996 </cell>
27997 </row>
27998 <row topline="true">
27999 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28000 \begin_inset Text
28001
28002 \begin_layout Standard
28003 Stack pointer FSR1
28004 \end_layout
28005
28006 \end_inset
28007 </cell>
28008 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28009 \begin_inset Text
28010
28011 \begin_layout Standard
28012 8-bits
28013 \end_layout
28014
28015 \end_inset
28016 </cell>
28017 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28018 \begin_inset Text
28019
28020 \begin_layout Standard
28021 16-bits
28022 \end_layout
28023
28024 \end_inset
28025 </cell>
28026 </row>
28027 <row topline="true" bottomline="true">
28028 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28029 \begin_inset Text
28030
28031 \begin_layout Standard
28032 Frame pointer FSR2
28033 \end_layout
28034
28035 \end_inset
28036 </cell>
28037 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28038 \begin_inset Text
28039
28040 \begin_layout Standard
28041 8-bits
28042 \end_layout
28043
28044 \end_inset
28045 </cell>
28046 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28047 \begin_inset Text
28048
28049 \begin_layout Standard
28050 16-bits
28051 \end_layout
28052
28053 \end_inset
28054 </cell>
28055 </row>
28056 </lyxtabular>
28057
28058 \end_inset
28059
28060
28061 \end_layout
28062
28063 \begin_layout Standard
28064 \noindent
28065
28066 \noun on
28067 Large 
28068 \noun default
28069 stack model is currently not working properly throughout the code generator.
28070  So its use is not advised.
28071  Also there are some other points that need special care:
28072 \newline
28073
28074 \end_layout
28075
28076 \begin_layout Enumerate
28077 Do not create stack sections with size more than one physical bank (that
28078  is 256 bytes)
28079 \end_layout
28080
28081 \begin_layout Enumerate
28082 Stack sections should no cross physical bank limits (i.e.
28083  #pragma stack 0x50 0x100)
28084 \end_layout
28085
28086 \begin_layout Standard
28087 These limitations are caused by the fact that only FSRxL is modified when
28088  using SMALL stack model, so no more than 256 bytes of stack can be used.
28089  This problem will disappear after LARGE model is fully implemented.
28090 \end_layout
28091
28092 \begin_layout Subsection
28093 Functions
28094 \end_layout
28095
28096 \begin_layout Standard
28097 In addition to the standard SDCC function keywords, PIC16
28098 \begin_inset LatexCommand index
28099 name "PIC16"
28100
28101 \end_inset
28102
28103  port makes available two more:
28104 \end_layout
28105
28106 \begin_layout Description
28107 wparam
28108 \begin_inset LatexCommand index
28109 name "PIC16!wparam"
28110
28111 \end_inset
28112
28113  Use the WREG to pass one byte of the first function argument.
28114  This improves speed but you may not use this for functions with arguments
28115  that are called via function pointers, otherwise the first byte of the
28116  first parameter will get lost.
28117  Usage:
28118 \end_layout
28119
28120 \begin_layout LyX-Code
28121 void func_wparam(int a) wparam
28122 \end_layout
28123
28124 \begin_layout LyX-Code
28125 {
28126 \end_layout
28127
28128 \begin_layout LyX-Code
28129     /* WREG hold the lower part of a */
28130 \end_layout
28131
28132 \begin_layout LyX-Code
28133     /* the high part of a is stored in FSR2+2 (or +3 for large stack model)
28134  */
28135 \end_layout
28136
28137 \begin_layout LyX-Code
28138 ...
28139 \end_layout
28140
28141 \begin_layout LyX-Code
28142 }
28143 \end_layout
28144
28145 \begin_layout Description
28146 shadowregs
28147 \begin_inset LatexCommand index
28148 name "PIC16!shadowregs"
28149
28150 \end_inset
28151
28152  When entering/exiting an ISR, it is possible to take advantage of the PIC18F
28153  hardware shadow registers which hold the values of WREG, STATUS and BSR
28154  registers.
28155  This can be done by adding the keyword 
28156 \emph on
28157 shadowregs
28158 \emph default
28159  before the 
28160 \emph on
28161 interrupt
28162 \emph default
28163  keyword in the function's header.
28164 \end_layout
28165
28166 \begin_layout LyX-Code
28167 void isr_shadow(void) shadowregs interrupt 1
28168 \end_layout
28169
28170 \begin_layout LyX-Code
28171 {
28172 \end_layout
28173
28174 \begin_layout LyX-Code
28175 ...
28176 \end_layout
28177
28178 \begin_layout LyX-Code
28179 }
28180 \end_layout
28181
28182 \begin_layout Standard
28183
28184 \emph on
28185 shadowregs
28186 \emph default
28187  instructs the code generator not to store/restore WREG, STATUS, BSR when
28188  entering/exiting the ISR.
28189 \end_layout
28190
28191 \begin_layout Subsection
28192 Function return values
28193 \end_layout
28194
28195 \begin_layout Standard
28196 Return values from functions are placed to the appropriate registers following
28197  a modified Microchip policy optimized for SDCC.
28198  The following table shows these registers:
28199 \end_layout
28200
28201 \begin_layout Standard
28202 \align center
28203 \begin_inset Tabular
28204 <lyxtabular version="3" rows="6" columns="2">
28205 <features>
28206 <column alignment="center" valignment="top" leftline="true" width="0">
28207 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
28208 <row topline="true" bottomline="true">
28209 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28210 \begin_inset Text
28211
28212 \begin_layout Standard
28213 size
28214 \end_layout
28215
28216 \end_inset
28217 </cell>
28218 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28219 \begin_inset Text
28220
28221 \begin_layout Standard
28222 destination register
28223 \end_layout
28224
28225 \end_inset
28226 </cell>
28227 </row>
28228 <row topline="true">
28229 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28230 \begin_inset Text
28231
28232 \begin_layout Standard
28233 8 bits
28234 \end_layout
28235
28236 \end_inset
28237 </cell>
28238 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28239 \begin_inset Text
28240
28241 \begin_layout Standard
28242 WREG
28243 \end_layout
28244
28245 \end_inset
28246 </cell>
28247 </row>
28248 <row topline="true">
28249 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28250 \begin_inset Text
28251
28252 \begin_layout Standard
28253 16 bits
28254 \end_layout
28255
28256 \end_inset
28257 </cell>
28258 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28259 \begin_inset Text
28260
28261 \begin_layout Standard
28262 PRODL:WREG
28263 \end_layout
28264
28265 \end_inset
28266 </cell>
28267 </row>
28268 <row topline="true">
28269 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28270 \begin_inset Text
28271
28272 \begin_layout Standard
28273 24 bits
28274 \end_layout
28275
28276 \end_inset
28277 </cell>
28278 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28279 \begin_inset Text
28280
28281 \begin_layout Standard
28282 PRODH:PRODL:WREG
28283 \end_layout
28284
28285 \end_inset
28286 </cell>
28287 </row>
28288 <row topline="true">
28289 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28290 \begin_inset Text
28291
28292 \begin_layout Standard
28293 32 bits
28294 \end_layout
28295
28296 \end_inset
28297 </cell>
28298 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28299 \begin_inset Text
28300
28301 \begin_layout Standard
28302 FSR0L:PRODH:PRODL:WREG
28303 \end_layout
28304
28305 \end_inset
28306 </cell>
28307 </row>
28308 <row topline="true" bottomline="true">
28309 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28310 \begin_inset Text
28311
28312 \begin_layout Standard
28313 >32 bits
28314 \end_layout
28315
28316 \end_inset
28317 </cell>
28318 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28319 \begin_inset Text
28320
28321 \begin_layout Standard
28322 on stack, FSR0 points to the beginning
28323 \end_layout
28324
28325 \end_inset
28326 </cell>
28327 </row>
28328 </lyxtabular>
28329
28330 \end_inset
28331
28332
28333 \end_layout
28334
28335 \begin_layout Subsection
28336 Interrupts
28337 \end_layout
28338
28339 \begin_layout Standard
28340 An interrupt
28341 \begin_inset LatexCommand index
28342 name "PIC16!interrupt"
28343
28344 \end_inset
28345
28346  service routine (ISR) is declared using the 
28347 \emph on
28348 interrupt
28349 \emph default
28350  keyword.
28351 \end_layout
28352
28353 \begin_layout LyX-Code
28354 void isr(void) interrupt 
28355 \emph on
28356 n
28357 \end_layout
28358
28359 \begin_layout LyX-Code
28360 {
28361 \end_layout
28362
28363 \begin_layout LyX-Code
28364 ...
28365 \end_layout
28366
28367 \begin_layout LyX-Code
28368 }
28369 \end_layout
28370
28371 \begin_layout Standard
28372
28373 \emph on
28374 n
28375 \emph default
28376  is the interrupt number, which for PIC18F devices can be:
28377 \end_layout
28378
28379 \begin_layout Standard
28380 \align center
28381 \begin_inset Tabular
28382 <lyxtabular version="3" rows="4" columns="3">
28383 <features>
28384 <column alignment="center" valignment="top" leftline="true" width="0">
28385 <column alignment="center" valignment="top" leftline="true" width="0">
28386 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
28387 <row topline="true" bottomline="true">
28388 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28389 \begin_inset Text
28390
28391 \begin_layout Standard
28392
28393 \emph on
28394 n
28395 \end_layout
28396
28397 \end_inset
28398 </cell>
28399 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28400 \begin_inset Text
28401
28402 \begin_layout Standard
28403 Interrupt Vector
28404 \end_layout
28405
28406 \end_inset
28407 </cell>
28408 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28409 \begin_inset Text
28410
28411 \begin_layout Standard
28412 Interrupt Vector Address
28413 \end_layout
28414
28415 \end_inset
28416 </cell>
28417 </row>
28418 <row topline="true">
28419 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28420 \begin_inset Text
28421
28422 \begin_layout Standard
28423 0
28424 \end_layout
28425
28426 \end_inset
28427 </cell>
28428 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28429 \begin_inset Text
28430
28431 \begin_layout Standard
28432 RESET vector
28433 \end_layout
28434
28435 \end_inset
28436 </cell>
28437 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28438 \begin_inset Text
28439
28440 \begin_layout Standard
28441 0x000000
28442 \end_layout
28443
28444 \end_inset
28445 </cell>
28446 </row>
28447 <row topline="true">
28448 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28449 \begin_inset Text
28450
28451 \begin_layout Standard
28452
28453 \family roman
28454 \series medium
28455 \shape up
28456 \size normal
28457 \emph off
28458 \bar no
28459 \noun off
28460 \color none
28461 1
28462 \end_layout
28463
28464 \end_inset
28465 </cell>
28466 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28467 \begin_inset Text
28468
28469 \begin_layout Standard
28470
28471 \family roman
28472 \series medium
28473 \shape up
28474 \size normal
28475 \emph off
28476 \bar no
28477 \noun off
28478 \color none
28479 HIGH priority interrupts
28480 \end_layout
28481
28482 \end_inset
28483 </cell>
28484 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28485 \begin_inset Text
28486
28487 \begin_layout Standard
28488 0x000008
28489 \end_layout
28490
28491 \end_inset
28492 </cell>
28493 </row>
28494 <row topline="true" bottomline="true">
28495 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28496 \begin_inset Text
28497
28498 \begin_layout Standard
28499 2
28500 \end_layout
28501
28502 \end_inset
28503 </cell>
28504 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28505 \begin_inset Text
28506
28507 \begin_layout Standard
28508 LOW priority interrupts
28509 \end_layout
28510
28511 \end_inset
28512 </cell>
28513 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28514 \begin_inset Text
28515
28516 \begin_layout Standard
28517 0x000018
28518 \end_layout
28519
28520 \end_inset
28521 </cell>
28522 </row>
28523 </lyxtabular>
28524
28525 \end_inset
28526
28527
28528 \end_layout
28529
28530 \begin_layout Standard
28531 When generating assembly code for ISR the code generator places a 
28532 \noun on
28533 goto 
28534 \noun default
28535 instruction at the 
28536 \emph on
28537 Interrupt Vector Address
28538 \emph default
28539  which points at the generated ISR.
28540  This single GOTO instruction is part of an automatically generated 
28541 \emph on
28542 interrupt entry point
28543 \emph default
28544  function.
28545  The actuall ISR code is placed as normally would in the code space.
28546  Upon interrupt request, the GOTO instruction is executed which jumps to
28547  the ISR code.
28548  When declaring interrupt functions as _naked this GOTO instruction is 
28549 \series bold
28550 not
28551 \series default
28552  generated.
28553  The whole interrupt functions is therefore placed at the Interrupt Vector
28554  Address of the specific interrupt.
28555  This is not a problem for the LOW priority interrupts, but it is a problem
28556  for the RESET and the HIGH priority interrupts because code may be written
28557  at the next interrupt's vector address and cause indeterminate program
28558  behaviour if that interrupt is raised.
28559 \begin_inset Foot
28560 status open
28561
28562 \begin_layout Standard
28563 This is not a problem when
28564 \end_layout
28565
28566 \begin_layout Enumerate
28567 this is a HIGH interrupt ISR and LOW interrupts are 
28568 \emph on
28569 disabled
28570 \emph default
28571  or not used.
28572 \end_layout
28573
28574 \begin_layout Enumerate
28575 when the ISR is small enough not to reach the next interrupt's vector address.
28576 \end_layout
28577
28578 \end_inset
28579
28580
28581 \end_layout
28582
28583 \begin_layout Standard
28584
28585 \emph on
28586 n
28587 \emph default
28588  may be omitted.
28589  This way a function is generated similar to an ISR, but it is not assigned
28590  to any interrupt.
28591 \end_layout
28592
28593 \begin_layout Standard
28594 When entering an interrupt, currently the PIC16
28595 \begin_inset LatexCommand index
28596 name "PIC16"
28597
28598 \end_inset
28599
28600  port automatically saves the following registers:
28601 \end_layout
28602
28603 \begin_layout Itemize
28604 WREG
28605 \end_layout
28606
28607 \begin_layout Itemize
28608 STATUS
28609 \end_layout
28610
28611 \begin_layout Itemize
28612 BSR
28613 \end_layout
28614
28615 \begin_layout Itemize
28616 PROD (PRODL and PRODH)
28617 \end_layout
28618
28619 \begin_layout Itemize
28620 FSR0 (FSR0L and FSR0H)
28621 \end_layout
28622
28623 \begin_layout Standard
28624 These registers are restored upon return from the interrupt routine.
28625 \begin_inset Foot
28626 status open
28627
28628 \begin_layout Standard
28629 NOTE that when the _naked attribute is specified for an interrupt routine,
28630  then NO registers are stored or restored.
28631 \end_layout
28632
28633 \end_inset
28634
28635
28636 \end_layout
28637
28638 \begin_layout Subsection
28639 Generic Pointers
28640 \end_layout
28641
28642 \begin_layout Standard
28643 Generic pointers are implemented in PIC16 port as 3-byte (24-bit) types.
28644  There are 3 types of generic pointers currently implemented data, code
28645  and eeprom pointers.
28646  They are differentiated by the value of the 7th and 6th bits of the upper
28647  byte:
28648 \end_layout
28649
28650 \begin_layout Standard
28651 \align center
28652 \begin_inset Tabular
28653 <lyxtabular version="3" rows="5" columns="5">
28654 <features>
28655 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
28656 <column alignment="center" valignment="top" width="0">
28657 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
28658 <column alignment="center" valignment="top" width="0">
28659 <column alignment="left" valignment="top" rightline="true" width="0">
28660 <row topline="true" bottomline="true">
28661 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28662 \begin_inset Text
28663
28664 \begin_layout Standard
28665 pointer type
28666 \end_layout
28667
28668 \end_inset
28669 </cell>
28670 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28671 \begin_inset Text
28672
28673 \begin_layout Standard
28674 7th bit
28675 \end_layout
28676
28677 \end_inset
28678 </cell>
28679 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28680 \begin_inset Text
28681
28682 \begin_layout Standard
28683 6th bit
28684 \end_layout
28685
28686 \end_inset
28687 </cell>
28688 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28689 \begin_inset Text
28690
28691 \begin_layout Standard
28692 rest of the pointer
28693 \end_layout
28694
28695 \end_inset
28696 </cell>
28697 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28698 \begin_inset Text
28699
28700 \begin_layout Standard
28701 description
28702 \end_layout
28703
28704 \end_inset
28705 </cell>
28706 </row>
28707 <row topline="true" bottomline="true">
28708 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28709 \begin_inset Text
28710
28711 \begin_layout Standard
28712 data 
28713 \end_layout
28714
28715 \end_inset
28716 </cell>
28717 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28718 \begin_inset Text
28719
28720 \begin_layout Standard
28721 1
28722 \end_layout
28723
28724 \end_inset
28725 </cell>
28726 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28727 \begin_inset Text
28728
28729 \begin_layout Standard
28730 0
28731 \end_layout
28732
28733 \end_inset
28734 </cell>
28735 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28736 \begin_inset Text
28737
28738 \begin_layout Standard
28739
28740 \family typewriter
28741 \shape slanted
28742 \emph on
28743 uuuuuu uuuuxxxx xxxxxxxx
28744 \end_layout
28745
28746 \end_inset
28747 </cell>
28748 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28749 \begin_inset Text
28750
28751 \begin_layout Standard
28752 a 12-bit data pointer in data RAM memory
28753 \end_layout
28754
28755 \end_inset
28756 </cell>
28757 </row>
28758 <row bottomline="true">
28759 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28760 \begin_inset Text
28761
28762 \begin_layout Standard
28763 code
28764 \end_layout
28765
28766 \end_inset
28767 </cell>
28768 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28769 \begin_inset Text
28770
28771 \begin_layout Standard
28772 0
28773 \end_layout
28774
28775 \end_inset
28776 </cell>
28777 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28778 \begin_inset Text
28779
28780 \begin_layout Standard
28781 0
28782 \end_layout
28783
28784 \end_inset
28785 </cell>
28786 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28787 \begin_inset Text
28788
28789 \begin_layout Standard
28790
28791 \family typewriter
28792 \shape slanted
28793 \emph on
28794 uxxxxx xxxxxxxx xxxxxxxx
28795 \end_layout
28796
28797 \end_inset
28798 </cell>
28799 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28800 \begin_inset Text
28801
28802 \begin_layout Standard
28803 a 21-bit code pointer in FLASH memory
28804 \end_layout
28805
28806 \end_inset
28807 </cell>
28808 </row>
28809 <row bottomline="true">
28810 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28811 \begin_inset Text
28812
28813 \begin_layout Standard
28814 eeprom
28815 \end_layout
28816
28817 \end_inset
28818 </cell>
28819 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28820 \begin_inset Text
28821
28822 \begin_layout Standard
28823 0
28824 \end_layout
28825
28826 \end_inset
28827 </cell>
28828 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28829 \begin_inset Text
28830
28831 \begin_layout Standard
28832 1
28833 \end_layout
28834
28835 \end_inset
28836 </cell>
28837 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28838 \begin_inset Text
28839
28840 \begin_layout Standard
28841
28842 \family typewriter
28843 \shape slanted
28844 \emph on
28845 uuuuuu uuuuuuxx xxxxxxxx
28846 \end_layout
28847
28848 \end_inset
28849 </cell>
28850 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28851 \begin_inset Text
28852
28853 \begin_layout Standard
28854 a 10-bit eeprom pointer in EEPROM memory
28855 \end_layout
28856
28857 \end_inset
28858 </cell>
28859 </row>
28860 <row bottomline="true">
28861 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28862 \begin_inset Text
28863
28864 \begin_layout Standard
28865 (unimplemented)
28866 \end_layout
28867
28868 \end_inset
28869 </cell>
28870 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28871 \begin_inset Text
28872
28873 \begin_layout Standard
28874 1
28875 \end_layout
28876
28877 \end_inset
28878 </cell>
28879 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28880 \begin_inset Text
28881
28882 \begin_layout Standard
28883 1
28884 \end_layout
28885
28886 \end_inset
28887 </cell>
28888 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28889 \begin_inset Text
28890
28891 \begin_layout Standard
28892
28893 \family typewriter
28894 \shape slanted
28895 \emph on
28896 xxxxxx xxxxxxxx xxxxxxxx
28897 \end_layout
28898
28899 \end_inset
28900 </cell>
28901 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28902 \begin_inset Text
28903
28904 \begin_layout Standard
28905 unimplemented pointer type
28906 \end_layout
28907
28908 \end_inset
28909 </cell>
28910 </row>
28911 </lyxtabular>
28912
28913 \end_inset
28914
28915
28916 \end_layout
28917
28918 \begin_layout Standard
28919 \noindent
28920 Generic pointer are read and written with a set of library functions which
28921  read/write 1, 2, 3, 4 bytes.
28922 \end_layout
28923
28924 \begin_layout Subsection
28925 PIC16 C Libraries
28926 \end_layout
28927
28928 \begin_layout Subsubsection
28929 Standard I/O Streams
28930 \end_layout
28931
28932 \begin_layout Standard
28933 In the 
28934 \emph on
28935 stdio.h
28936 \emph default
28937  the type FILE is defined as:
28938 \end_layout
28939
28940 \begin_layout LyX-Code
28941 typedef char * FILE;
28942 \end_layout
28943
28944 \begin_layout Standard
28945 This type is the stream type implemented I/O in the PIC18F devices.
28946  Also the standard input and output streams are declared in stdio.h:
28947 \end_layout
28948
28949 \begin_layout LyX-Code
28950 extern FILE * stdin;
28951 \end_layout
28952
28953 \begin_layout LyX-Code
28954 extern FILE * stdout;
28955 \end_layout
28956
28957 \begin_layout Standard
28958 The FILE type is actually a generic pointer which defines one more type
28959  of generic pointers, the 
28960 \emph on
28961 stream
28962 \emph default
28963  pointer.
28964  This new type has the format:
28965 \end_layout
28966
28967 \begin_layout Standard
28968 \noindent
28969 \align center
28970 \begin_inset Tabular
28971 <lyxtabular version="3" rows="2" columns="7">
28972 <features>
28973 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
28974 <column alignment="center" valignment="top" width="0">
28975 <column alignment="center" valignment="top" leftline="true" width="0">
28976 <column alignment="center" valignment="top" leftline="true" width="0">
28977 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
28978 <column alignment="center" valignment="top" width="0">
28979 <column alignment="left" valignment="top" rightline="true" width="0">
28980 <row topline="true" bottomline="true">
28981 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28982 \begin_inset Text
28983
28984 \begin_layout Standard
28985 pointer type
28986 \end_layout
28987
28988 \end_inset
28989 </cell>
28990 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28991 \begin_inset Text
28992
28993 \begin_layout Standard
28994 <7:6>
28995 \end_layout
28996
28997 \end_inset
28998 </cell>
28999 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29000 \begin_inset Text
29001
29002 \begin_layout Standard
29003 <5>
29004 \end_layout
29005
29006 \end_inset
29007 </cell>
29008 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29009 \begin_inset Text
29010
29011 \begin_layout Standard
29012 <4>
29013 \end_layout
29014
29015 \end_inset
29016 </cell>
29017 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29018 \begin_inset Text
29019
29020 \begin_layout Standard
29021 <3:0>
29022 \end_layout
29023
29024 \end_inset
29025 </cell>
29026 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29027 \begin_inset Text
29028
29029 \begin_layout Standard
29030 rest of the pointer
29031 \end_layout
29032
29033 \end_inset
29034 </cell>
29035 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29036 \begin_inset Text
29037
29038 \begin_layout Standard
29039 descrption
29040 \end_layout
29041
29042 \end_inset
29043 </cell>
29044 </row>
29045 <row topline="true" bottomline="true">
29046 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29047 \begin_inset Text
29048
29049 \begin_layout Standard
29050 stream
29051 \end_layout
29052
29053 \end_inset
29054 </cell>
29055 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29056 \begin_inset Text
29057
29058 \begin_layout Standard
29059 00
29060 \end_layout
29061
29062 \end_inset
29063 </cell>
29064 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29065 \begin_inset Text
29066
29067 \begin_layout Standard
29068 1
29069 \end_layout
29070
29071 \end_inset
29072 </cell>
29073 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29074 \begin_inset Text
29075
29076 \begin_layout Standard
29077 0
29078 \end_layout
29079
29080 \end_inset
29081 </cell>
29082 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29083 \begin_inset Text
29084
29085 \begin_layout Standard
29086 nnnn
29087 \end_layout
29088
29089 \end_inset
29090 </cell>
29091 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29092 \begin_inset Text
29093
29094 \begin_layout Standard
29095
29096 \family typewriter
29097 \shape slanted
29098 \emph on
29099 uuuuuuuu uuuuuuuu
29100 \end_layout
29101
29102 \end_inset
29103 </cell>
29104 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29105 \begin_inset Text
29106
29107 \begin_layout Standard
29108 upper byte high nubble is 0x2n, the rest are zeroes
29109 \end_layout
29110
29111 \end_inset
29112 </cell>
29113 </row>
29114 </lyxtabular>
29115
29116 \end_inset
29117
29118
29119 \end_layout
29120
29121 \begin_layout Standard
29122 \noindent
29123 Currently implemented there are 3 types of streams defined:
29124 \end_layout
29125
29126 \begin_layout Standard
29127 \noindent
29128 \align center
29129 \begin_inset Tabular
29130 <lyxtabular version="3" rows="4" columns="4">
29131 <features>
29132 <column alignment="center" valignment="top" leftline="true" width="0">
29133 <column alignment="center" valignment="top" leftline="true" width="0">
29134 <column alignment="center" valignment="top" leftline="true" width="0">
29135 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
29136 <row topline="true" bottomline="true">
29137 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29138 \begin_inset Text
29139
29140 \begin_layout Standard
29141 stream type
29142 \end_layout
29143
29144 \end_inset
29145 </cell>
29146 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29147 \begin_inset Text
29148
29149 \begin_layout Standard
29150 value
29151 \end_layout
29152
29153 \end_inset
29154 </cell>
29155 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29156 \begin_inset Text
29157
29158 \begin_layout Standard
29159 module
29160 \end_layout
29161
29162 \end_inset
29163 </cell>
29164 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29165 \begin_inset Text
29166
29167 \begin_layout Standard
29168 description
29169 \end_layout
29170
29171 \end_inset
29172 </cell>
29173 </row>
29174 <row topline="true">
29175 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29176 \begin_inset Text
29177
29178 \begin_layout Standard
29179 STREAM_USART
29180 \end_layout
29181
29182 \end_inset
29183 </cell>
29184 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29185 \begin_inset Text
29186
29187 \begin_layout Standard
29188
29189 \family typewriter
29190 0x200000UL
29191 \end_layout
29192
29193 \end_inset
29194 </cell>
29195 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29196 \begin_inset Text
29197
29198 \begin_layout Standard
29199 USART
29200 \end_layout
29201
29202 \end_inset
29203 </cell>
29204 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29205 \begin_inset Text
29206
29207 \begin_layout Standard
29208 Writes/Reads characters via the USART peripheral
29209 \end_layout
29210
29211 \end_inset
29212 </cell>
29213 </row>
29214 <row topline="true">
29215 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29216 \begin_inset Text
29217
29218 \begin_layout Standard
29219 STREAM_MSSP
29220 \end_layout
29221
29222 \end_inset
29223 </cell>
29224 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29225 \begin_inset Text
29226
29227 \begin_layout Standard
29228
29229 \family typewriter
29230 0x210000UL
29231 \end_layout
29232
29233 \end_inset
29234 </cell>
29235 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29236 \begin_inset Text
29237
29238 \begin_layout Standard
29239 MSSP
29240 \end_layout
29241
29242 \end_inset
29243 </cell>
29244 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29245 \begin_inset Text
29246
29247 \begin_layout Standard
29248 Writes/Reads characters via the MSSP peripheral
29249 \end_layout
29250
29251 \end_inset
29252 </cell>
29253 </row>
29254 <row topline="true" bottomline="true">
29255 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29256 \begin_inset Text
29257
29258 \begin_layout Standard
29259 STREAM_USER
29260 \end_layout
29261
29262 \end_inset
29263 </cell>
29264 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29265 \begin_inset Text
29266
29267 \begin_layout Standard
29268
29269 \family typewriter
29270 0x2f0000UL
29271 \end_layout
29272
29273 \end_inset
29274 </cell>
29275 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29276 \begin_inset Text
29277
29278 \begin_layout Standard
29279 (none)
29280 \end_layout
29281
29282 \end_inset
29283 </cell>
29284 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29285 \begin_inset Text
29286
29287 \begin_layout Standard
29288 Writes/Reads characters via used defined functions
29289 \end_layout
29290
29291 \end_inset
29292 </cell>
29293 </row>
29294 </lyxtabular>
29295
29296 \end_inset
29297
29298
29299 \end_layout
29300
29301 \begin_layout Standard
29302 \noindent
29303 The stream identifiers are declared as macros in the stdio.h header.
29304 \end_layout
29305
29306 \begin_layout Standard
29307 \noindent
29308 In the libc library there exist the functions that are used to write to
29309  each of the above streams.
29310  These are
29311 \end_layout
29312
29313 \begin_layout Description
29314 _
29315 \begin_inset ERT
29316 status collapsed
29317
29318 \begin_layout Standard
29319
29320
29321 \backslash
29322 /
29323 \end_layout
29324
29325 \end_inset
29326
29327 _stream_usart_putchar writes a character at the USART stream
29328 \end_layout
29329
29330 \begin_layout Description
29331 _
29332 \begin_inset ERT
29333 status collapsed
29334
29335 \begin_layout Standard
29336
29337
29338 \backslash
29339 /
29340 \end_layout
29341
29342 \end_inset
29343
29344 _stream_mssp_putchar writes a character at the MSSP stream
29345 \end_layout
29346
29347 \begin_layout Description
29348 putchar dummy function.
29349  This writes a character to a user specified manner.
29350 \end_layout
29351
29352 \begin_layout Standard
29353 In order to increase performance 
29354 \emph on
29355 putchar
29356 \emph default
29357  is declared in stdio.h as having its parameter in WREG (it has the wparam
29358  keyword).
29359  In stdio.h exists the macro PUTCHAR(arg) that defines the putchar function
29360  in a user-friendly way.
29361  
29362 \emph on
29363 arg
29364 \emph default
29365  is the name of the variable that holds the character to print.
29366  An example follows:
29367 \end_layout
29368
29369 \begin_layout LyX-Code
29370 #include <pic18fregs.h>
29371 \newline
29372 #include <stdio.h>
29373 \newline
29374
29375 \newline
29376 PUTCHAR( c )
29377 \end_layout
29378
29379 \begin_layout LyX-Code
29380 {
29381 \end_layout
29382
29383 \begin_layout LyX-Code
29384     PORTA = c;    /* dump character c to PORTA */
29385 \end_layout
29386
29387 \begin_layout LyX-Code
29388
29389 \newline
29390
29391 \newline
29392 void main(void)
29393 \end_layout
29394
29395 \begin_layout LyX-Code
29396 {
29397 \end_layout
29398
29399 \begin_layout LyX-Code
29400     stdout = STREAM_USER;    /* this is not necessary, since stdout points
29401 \end_layout
29402
29403 \begin_layout LyX-Code
29404                               * by default to STREAM_USER */
29405 \end_layout
29406
29407 \begin_layout LyX-Code
29408     printf (
29409 \begin_inset Quotes sld
29410 \end_inset
29411
29412 This is a printf test
29413 \backslash
29414 n
29415 \begin_inset Quotes srd
29416 \end_inset
29417
29418 );
29419 \end_layout
29420
29421 \begin_layout LyX-Code
29422 }
29423 \end_layout
29424
29425 \begin_layout LyX-Code
29426
29427 \end_layout
29428
29429 \begin_layout Subsubsection
29430 Printing functions
29431 \end_layout
29432
29433 \begin_layout Standard
29434 PIC16 contains an implementation of the printf-family of functions.
29435  There exist the following functions:
29436 \end_layout
29437
29438 \begin_layout LyX-Code
29439 extern unsigned int sprintf(char *buf, char *fmt, ...);
29440 \end_layout
29441
29442 \begin_layout LyX-Code
29443 extern unsigned int vsprintf(char *buf, char *fmt, va_list ap);
29444 \end_layout
29445
29446 \begin_layout LyX-Code
29447
29448 \end_layout
29449
29450 \begin_layout LyX-Code
29451 extern unsigned int printf(char *fmt, ...);
29452 \end_layout
29453
29454 \begin_layout LyX-Code
29455 extern unsigned int vprintf(char *fmt, va_lista ap);
29456 \end_layout
29457
29458 \begin_layout LyX-Code
29459
29460 \end_layout
29461
29462 \begin_layout LyX-Code
29463 extern unsigned int fprintf(FILE *fp, char *fmt, ...);
29464 \end_layout
29465
29466 \begin_layout LyX-Code
29467 extern unsigned int vfprintf(FILE *fp, char *fmt, va_list ap);
29468 \end_layout
29469
29470 \begin_layout Standard
29471 For sprintf and vsprintf 
29472 \emph on
29473 buf
29474 \emph default
29475  should normally be a data pointer where the resulting string will be placed.
29476  No range checking is done so the user should allocate the necessary buffer.
29477  For fprintf and vfprintf 
29478 \emph on
29479 fp
29480 \emph default
29481  should be a stream pointer (i.e.
29482  stdout, STREAM_MSSP, etc...).
29483 \end_layout
29484
29485 \begin_layout Subsubsection
29486 Signals
29487 \end_layout
29488
29489 \begin_layout Standard
29490 The PIC18F family of microcontrollers supports a number of interrupt sources.
29491  A list of these interrupts is shown in the following table:
29492 \end_layout
29493
29494 \begin_layout Standard
29495 \align center
29496 \begin_inset Tabular
29497 <lyxtabular version="3" rows="11" columns="4">
29498 <features>
29499 <column alignment="left" valignment="top" leftline="true" width="0">
29500 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
29501 <column alignment="left" valignment="top" leftline="true" width="0">
29502 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
29503 <row topline="true" bottomline="true">
29504 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29505 \begin_inset Text
29506
29507 \begin_layout Standard
29508 signal name
29509 \end_layout
29510
29511 \end_inset
29512 </cell>
29513 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29514 \begin_inset Text
29515
29516 \begin_layout Standard
29517 description
29518 \end_layout
29519
29520 \end_inset
29521 </cell>
29522 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29523 \begin_inset Text
29524
29525 \begin_layout Standard
29526 signal name
29527 \end_layout
29528
29529 \end_inset
29530 </cell>
29531 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29532 \begin_inset Text
29533
29534 \begin_layout Standard
29535 description
29536 \end_layout
29537
29538 \end_inset
29539 </cell>
29540 </row>
29541 <row topline="true">
29542 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29543 \begin_inset Text
29544
29545 \begin_layout Standard
29546 SIG_RB
29547 \end_layout
29548
29549 \end_inset
29550 </cell>
29551 <cell multicolumn="1" alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29552 \begin_inset Text
29553
29554 \begin_layout Standard
29555 PORTB change interrupt
29556 \end_layout
29557
29558 \end_inset
29559 </cell>
29560 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29561 \begin_inset Text
29562
29563 \begin_layout Standard
29564 SIG_EE
29565 \end_layout
29566
29567 \end_inset
29568 </cell>
29569 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29570 \begin_inset Text
29571
29572 \begin_layout Standard
29573 EEPROM/FLASH write complete interrupt
29574 \end_layout
29575
29576 \end_inset
29577 </cell>
29578 </row>
29579 <row topline="true">
29580 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29581 \begin_inset Text
29582
29583 \begin_layout Standard
29584 SIG_INT0
29585 \end_layout
29586
29587 \end_inset
29588 </cell>
29589 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29590 \begin_inset Text
29591
29592 \begin_layout Standard
29593 INT0 external interrupt
29594 \end_layout
29595
29596 \end_inset
29597 </cell>
29598 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29599 \begin_inset Text
29600
29601 \begin_layout Standard
29602 SIG_BCOL
29603 \end_layout
29604
29605 \end_inset
29606 </cell>
29607 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29608 \begin_inset Text
29609
29610 \begin_layout Standard
29611 Bus collision interrupt
29612 \end_layout
29613
29614 \end_inset
29615 </cell>
29616 </row>
29617 <row topline="true">
29618 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29619 \begin_inset Text
29620
29621 \begin_layout Standard
29622 SIG_INT1
29623 \end_layout
29624
29625 \end_inset
29626 </cell>
29627 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29628 \begin_inset Text
29629
29630 \begin_layout Standard
29631 INT1 external interrupt
29632 \end_layout
29633
29634 \end_inset
29635 </cell>
29636 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29637 \begin_inset Text
29638
29639 \begin_layout Standard
29640 SIG_LVD
29641 \end_layout
29642
29643 \end_inset
29644 </cell>
29645 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29646 \begin_inset Text
29647
29648 \begin_layout Standard
29649 Low voltage detect interrupt
29650 \end_layout
29651
29652 \end_inset
29653 </cell>
29654 </row>
29655 <row topline="true">
29656 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29657 \begin_inset Text
29658
29659 \begin_layout Standard
29660 SIG_INT2
29661 \end_layout
29662
29663 \end_inset
29664 </cell>
29665 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29666 \begin_inset Text
29667
29668 \begin_layout Standard
29669 INT2 external interrupt
29670 \end_layout
29671
29672 \end_inset
29673 </cell>
29674 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29675 \begin_inset Text
29676
29677 \begin_layout Standard
29678 SIG_PSP
29679 \end_layout
29680
29681 \end_inset
29682 </cell>
29683 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29684 \begin_inset Text
29685
29686 \begin_layout Standard
29687 Parallel slave port interrupt
29688 \end_layout
29689
29690 \end_inset
29691 </cell>
29692 </row>
29693 <row topline="true">
29694 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29695 \begin_inset Text
29696
29697 \begin_layout Standard
29698 SIG_CCP1
29699 \end_layout
29700
29701 \end_inset
29702 </cell>
29703 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29704 \begin_inset Text
29705
29706 \begin_layout Standard
29707 CCP1 module interrupt
29708 \end_layout
29709
29710 \end_inset
29711 </cell>
29712 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29713 \begin_inset Text
29714
29715 \begin_layout Standard
29716 SIG_AD
29717 \end_layout
29718
29719 \end_inset
29720 </cell>
29721 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29722 \begin_inset Text
29723
29724 \begin_layout Standard
29725 AD convertion complete interrupt
29726 \end_layout
29727
29728 \end_inset
29729 </cell>
29730 </row>
29731 <row topline="true">
29732 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29733 \begin_inset Text
29734
29735 \begin_layout Standard
29736 SIG_CCP2
29737 \end_layout
29738
29739 \end_inset
29740 </cell>
29741 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29742 \begin_inset Text
29743
29744 \begin_layout Standard
29745 CCP2 module interrupt
29746 \end_layout
29747
29748 \end_inset
29749 </cell>
29750 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29751 \begin_inset Text
29752
29753 \begin_layout Standard
29754 SIG_RC
29755 \end_layout
29756
29757 \end_inset
29758 </cell>
29759 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29760 \begin_inset Text
29761
29762 \begin_layout Standard
29763 USART receive interrupt
29764 \end_layout
29765
29766 \end_inset
29767 </cell>
29768 </row>
29769 <row topline="true">
29770 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29771 \begin_inset Text
29772
29773 \begin_layout Standard
29774 SIG_TMR0
29775 \end_layout
29776
29777 \end_inset
29778 </cell>
29779 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29780 \begin_inset Text
29781
29782 \begin_layout Standard
29783 TMR0 overflow interrupt
29784 \end_layout
29785
29786 \end_inset
29787 </cell>
29788 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29789 \begin_inset Text
29790
29791 \begin_layout Standard
29792 SIG_TX
29793 \end_layout
29794
29795 \end_inset
29796 </cell>
29797 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29798 \begin_inset Text
29799
29800 \begin_layout Standard
29801 USART transmit interrupt
29802 \end_layout
29803
29804 \end_inset
29805 </cell>
29806 </row>
29807 <row topline="true">
29808 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29809 \begin_inset Text
29810
29811 \begin_layout Standard
29812 SIG_TMR1
29813 \end_layout
29814
29815 \end_inset
29816 </cell>
29817 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29818 \begin_inset Text
29819
29820 \begin_layout Standard
29821 TMR1 overflow interrupt
29822 \end_layout
29823
29824 \end_inset
29825 </cell>
29826 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29827 \begin_inset Text
29828
29829 \begin_layout Standard
29830 SIG_MSSP
29831 \end_layout
29832
29833 \end_inset
29834 </cell>
29835 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29836 \begin_inset Text
29837
29838 \begin_layout Standard
29839 SSP receive/transmit interrupt
29840 \end_layout
29841
29842 \end_inset
29843 </cell>
29844 </row>
29845 <row topline="true">
29846 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29847 \begin_inset Text
29848
29849 \begin_layout Standard
29850 SIG_TMR2
29851 \end_layout
29852
29853 \end_inset
29854 </cell>
29855 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29856 \begin_inset Text
29857
29858 \begin_layout Standard
29859 TMR2 matches PR2 interrupt
29860 \end_layout
29861
29862 \end_inset
29863 </cell>
29864 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29865 \begin_inset Text
29866
29867 \begin_layout Standard
29868
29869 \end_layout
29870
29871 \end_inset
29872 </cell>
29873 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29874 \begin_inset Text
29875
29876 \begin_layout Standard
29877
29878 \end_layout
29879
29880 \end_inset
29881 </cell>
29882 </row>
29883 <row topline="true" bottomline="true">
29884 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29885 \begin_inset Text
29886
29887 \begin_layout Standard
29888 SIG_TMR3
29889 \end_layout
29890
29891 \end_inset
29892 </cell>
29893 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29894 \begin_inset Text
29895
29896 \begin_layout Standard
29897 TMR3 overflow interrupt
29898 \end_layout
29899
29900 \end_inset
29901 </cell>
29902 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29903 \begin_inset Text
29904
29905 \begin_layout Standard
29906
29907 \end_layout
29908
29909 \end_inset
29910 </cell>
29911 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29912 \begin_inset Text
29913
29914 \begin_layout Standard
29915
29916 \end_layout
29917
29918 \end_inset
29919 </cell>
29920 </row>
29921 </lyxtabular>
29922
29923 \end_inset
29924
29925
29926 \end_layout
29927
29928 \begin_layout Standard
29929 \noindent
29930 The prototypes for these names are defined in the header file 
29931 \emph on
29932 signal.h
29933 \emph default
29934  .
29935 \end_layout
29936
29937 \begin_layout Standard
29938 \noindent
29939 In order to simplify signal handling, a number of macros is provided:
29940 \end_layout
29941
29942 \begin_layout List
29943 \labelwidthstring 00.00.0000
29944 DEF_INTHIGH(name) begin the definition of the interrupt dispatch table for
29945  high priority interrupts.
29946  
29947 \emph on
29948 name
29949 \emph default
29950  is the function name to use.
29951 \end_layout
29952
29953 \begin_layout List
29954 \labelwidthstring 00.00.0000
29955 DEF_INTLOW(name) begin the definition of the interrupt dispatch table fo
29956  low priority interrupt.
29957  
29958 \emph on
29959 name
29960 \emph default
29961  is the function name to use.
29962 \end_layout
29963
29964 \begin_layout List
29965 \labelwidthstring 00.00.0000
29966 DEF_HANDLER(sig,handler) define a handler for signal 
29967 \emph on
29968 sig.
29969 \end_layout
29970
29971 \begin_layout List
29972 \labelwidthstring 00.00.0000
29973 END_DEF end the declaration of the dispatch table.
29974 \end_layout
29975
29976 \begin_layout Standard
29977 Additionally there are two more macros to simplify the declaration of the
29978  signal handler:
29979 \end_layout
29980
29981 \begin_layout List
29982 \labelwidthstring 00.00.0000
29983
29984 \series medium
29985 SIGHANDLER(handler)
29986 \series default
29987  this declares the function prototype for the 
29988 \emph on
29989 handler
29990 \emph default
29991  function.
29992 \end_layout
29993
29994 \begin_layout List
29995 \labelwidthstring 00.00.0000
29996 SIGHANDLERNAKED(handler) same as SIGHANDLER() but declares a naked function.
29997 \end_layout
29998
29999 \begin_layout Standard
30000 An example of using the macros above is shown below:
30001 \end_layout
30002
30003 \begin_layout LyX-Code
30004 #include <pic18fregs.h>
30005 \end_layout
30006
30007 \begin_layout LyX-Code
30008 #include <signal.h>
30009 \newline
30010
30011 \newline
30012 DEF_INTHIGH(high_int)
30013 \end_layout
30014
30015 \begin_layout LyX-Code
30016 DEF_HANDLER(SIG_TMR0, _tmr0_handler)
30017 \end_layout
30018
30019 \begin_layout LyX-Code
30020 DEF_HANDLER(SIG_BCOL, _bcol_handler)
30021 \end_layout
30022
30023 \begin_layout LyX-Code
30024 END_DEF
30025 \newline
30026
30027 \newline
30028 SIGHANDLER(_tmr0_handler)
30029 \end_layout
30030
30031 \begin_layout LyX-Code
30032 {
30033 \end_layout
30034
30035 \begin_layout LyX-Code
30036   /* action to be taken when timer 0 overflows */
30037 \end_layout
30038
30039 \begin_layout LyX-Code
30040 }
30041 \newline
30042
30043 \newline
30044 SIGHANDLERNAKED(_bcol_handler)
30045 \end_layout
30046
30047 \begin_layout LyX-Code
30048 {
30049 \end_layout
30050
30051 \begin_layout LyX-Code
30052   _asm
30053 \end_layout
30054
30055 \begin_layout LyX-Code
30056     /* action to be taken when bus collision occurs */
30057 \end_layout
30058
30059 \begin_layout LyX-Code
30060     retfie
30061 \end_layout
30062
30063 \begin_layout LyX-Code
30064  _endasm;
30065 \end_layout
30066
30067 \begin_layout LyX-Code
30068 }
30069 \end_layout
30070
30071 \begin_layout Standard
30072
30073 \series bold
30074 NOTES:
30075 \series default
30076  Special care should be taken when using the above scheme:
30077 \end_layout
30078
30079 \begin_layout Itemize
30080 do not place a colon (;) at the end of the DEF_* and END_DEF macros.
30081 \end_layout
30082
30083 \begin_layout Itemize
30084 when declaring SIGHANDLERNAKED handler never forget to use 
30085 \emph on
30086 retfie
30087 \emph default
30088  for proper returning.
30089 \end_layout
30090
30091 \begin_layout Subsection
30092 PIC16 Port -- Tips
30093 \end_layout
30094
30095 \begin_layout Standard
30096 Here you can find some general tips for compiling programs with SDCC/pic16.
30097 \end_layout
30098
30099 \begin_layout Subsubsection
30100 Stack size
30101 \end_layout
30102
30103 \begin_layout Standard
30104 The default stack
30105 \begin_inset LatexCommand index
30106 name "PIC16!stack"
30107
30108 \end_inset
30109
30110  size (that is 64 bytes) probably is enough for many programs.
30111  One must take care that when there are many levels of function nesting,
30112  or there is excessive usage of stack, its size should be extended.
30113  An example of such a case is the printf/sprintf family of functions.
30114  If you encounter problems like not being able to print integers, then you
30115  need to set the stack size around the maximum (256 for small stack model).
30116  The following diagram shows what happens when calling printf to print an
30117  integer:
30118 \end_layout
30119
30120 \begin_layout LyX-Code
30121 printf () --> ltoa () --> ultoa () --> divschar ()
30122 \end_layout
30123
30124 \begin_layout Standard
30125 It is should be understood that stack is easily consumed when calling complicate
30126 d functions.
30127  Using command line arguments like -
30128 \begin_inset ERT
30129 status collapsed
30130
30131 \begin_layout Standard
30132
30133
30134 \backslash
30135 /
30136 \end_layout
30137
30138 \end_inset
30139
30140 -fommit-frame-pointer might reduce stack usage by not creating unnecessery
30141  stack frames.
30142  Other ways to reduce stack usage may exist.
30143 \end_layout
30144
30145 \begin_layout Subsection
30146 Known Bugs
30147 \end_layout
30148
30149 \begin_layout Subsubsection
30150 Extended Instruction Set
30151 \end_layout
30152
30153 \begin_layout Standard
30154 The PIC16 port emits code which is incompatible with the extended instruction
30155  set available with many newer devices.
30156  Make sure to always explicitly disable it, usually using
30157 \end_layout
30158
30159 \begin_layout Standard
30160
30161 \family typewriter
30162 static __code char __at(__CONFIG4L) conf4l = /* more flags & */ _XINST_OFF_4L;
30163 \end_layout
30164
30165 \begin_layout Standard
30166 \noindent
30167 Some devices (namely 18f2455, 18f2550, 18f4455, and 18f4550) use _ENHCPU_OFF_4L
30168  instead of _XINST_OFF_4L.
30169 \end_layout
30170
30171 \begin_layout Subsubsection
30172 Regression Tests
30173 \end_layout
30174
30175 \begin_layout Standard
30176 The PIC16 port currently passes most but not all of the tests in SDCC's
30177  regression test
30178 \begin_inset LatexCommand index
30179 name "Regression test (PIC16)"
30180
30181 \end_inset
30182
30183  suite (see section 
30184 \begin_inset LatexCommand ref
30185 reference "sec:Quality-control"
30186
30187 \end_inset
30188
30189 ), thus no automatic regression tests are currently performed for the PIC16
30190  target.
30191 \end_layout
30192
30193 \begin_layout Chapter
30194 Debugging
30195 \end_layout
30196
30197 \begin_layout Standard
30198 There are several approaches to debugging your code.
30199  This chapter is meant to show your options and to give detail on some of
30200  them:
30201 \newline
30202
30203 \newline
30204 When writing your code:
30205 \end_layout
30206
30207 \begin_layout Itemize
30208 write your code with debugging in mind (avoid duplicating code, put conceptually
30209  similar variables into structs, use structured code, have strategic points
30210  within your code where all variables are consistent, ...)
30211 \end_layout
30212
30213 \begin_layout Itemize
30214 run a syntax-checking tool like splint
30215 \begin_inset LatexCommand index
30216 name "splint (syntax checking tool)"
30217
30218 \end_inset
30219
30220
30221 \begin_inset LatexCommand index
30222 name "lint (syntax checking tool)"
30223
30224 \end_inset
30225
30226  (see -
30227 \begin_inset ERT
30228 status collapsed
30229
30230 \begin_layout Standard
30231
30232
30233 \backslash
30234 /
30235 \end_layout
30236
30237 \end_inset
30238
30239 -more-pedantic 
30240 \begin_inset LatexCommand ref
30241 reference "lyx:more-pedantic-SPLINT"
30242
30243 \end_inset
30244
30245 ) over the code.
30246 \end_layout
30247
30248 \begin_layout Itemize
30249 for the high level code use a C-compiler (like f.e.
30250  GCC) to compile run and debug the code on your host.
30251  See (see -
30252 \begin_inset ERT
30253 status collapsed
30254
30255 \begin_layout Standard
30256
30257
30258 \backslash
30259 /
30260 \end_layout
30261
30262 \end_inset
30263
30264 -more-pedantic 
30265 \begin_inset LatexCommand ref
30266 reference "lyx:more-pedantic-SPLINT"
30267
30268 \end_inset
30269
30270 ) on how to handle syntax extensions like __xdata, __at(), ...
30271  
30272 \end_layout
30273
30274 \begin_layout Itemize
30275 use another C-compiler to compile code for your target.
30276  Always an option but not recommended:) And not very likely to help you.
30277  If you seriously consider walking this path you should at least occasionally
30278  check portability of your code.
30279  Most commercial compiler vendors will offer an evaluation version so you
30280  can test compile your code or snippets of your code.
30281 \end_layout
30282
30283 \begin_layout Standard
30284 Debugging on a simulator:
30285 \end_layout
30286
30287 \begin_layout Itemize
30288 there is a separate section about SDCDB (section 
30289 \begin_inset LatexCommand ref
30290 reference "cha:Debugging-with-SDCDB"
30291
30292 \end_inset
30293
30294 ) below.
30295 \end_layout
30296
30297 \begin_layout Itemize
30298 or (8051 specific) use a free open source/commercial simulator which interfaces
30299  to the AOMF
30300 \begin_inset LatexCommand index
30301 name "AOMF, AOMF51"
30302
30303 \end_inset
30304
30305  file (see 
30306 \begin_inset LatexCommand ref
30307 reference "OMF file"
30308
30309 \end_inset
30310
30311 ) optionally generated by SDCC.
30312 \end_layout
30313
30314 \begin_layout Standard
30315 Debugging On-target: 
30316 \end_layout
30317
30318 \begin_layout Itemize
30319 use a MCU port pin to serially output debug data to the RS232 port of your
30320  host.
30321  You'll probably want some level shifting device typically involving a MAX232
30322  or similar IC.
30323  If the hardware serial port of the MCU is not available search for 'Software
30324  UART' in your favourite search machine.
30325 \end_layout
30326
30327 \begin_layout Itemize
30328 use an on-target monitor.
30329  In this context a monitor is a small program which usually accepts commands
30330  via a serial line and allows to set program counter, to single step through
30331  a program and read/write memory locations.
30332  For the 8051 good examples of monitors are paulmon and cmon51 (see section
30333  
30334 \begin_inset LatexCommand ref
30335 reference "sec:Related-open-source-tools"
30336
30337 \end_inset
30338
30339 ).
30340 \end_layout
30341
30342 \begin_layout Itemize
30343 toggle MCU port pins at strategic points within your code and use an oscilloscop
30344 e.
30345  A 
30346 \emph on
30347 digital oscilloscope
30348 \emph default
30349
30350 \begin_inset LatexCommand index
30351 name "Oscilloscope"
30352
30353 \end_inset
30354
30355  with deep trace memory is really helpful especially if you have to debug
30356  a realtime application.
30357  If you need to monitor more pins than your oscilloscope provides you can
30358  sometimes get away with a small R-2R network.
30359  On a single channel oscilloscope you could f.e.
30360  monitor 2 push-pull driven pins by connecting one via a 10\InsetSpace ~
30361 k
30362 \begin_inset Formula $\Omega$
30363 \end_inset
30364
30365  resistor and the other one by a 5\InsetSpace ~
30366 k
30367 \begin_inset Formula $\Omega$
30368 \end_inset
30369
30370  resistor to the oscilloscope probe (check output drive capability of the
30371  pins you want to monitor).
30372  If you need to monitor many more pins a 
30373 \emph on
30374 logic analyzer
30375 \emph default
30376  will be handy.
30377 \end_layout
30378
30379 \begin_layout Itemize
30380 use an ICE (
30381 \emph on
30382 i
30383 \emph default
30384
30385 \emph on
30386 c
30387 \emph default
30388 ircuit 
30389 \emph on
30390 e
30391 \emph default
30392 mulator
30393 \begin_inset LatexCommand index
30394 name "ICE (in circuit emulator)"
30395
30396 \end_inset
30397
30398 ).
30399  Usually very expensive.
30400  And very nice to have too.
30401  And usually locks you (for years...) to the devices the ICE can emulate.
30402  
30403 \end_layout
30404
30405 \begin_layout Itemize
30406 use a remote debugger.
30407  In most 8-bit systems the symbol information is not available on the target,
30408  and a complete debugger is too bulky for the target system.
30409  Therefore usually a debugger on the host system connects to an on-target
30410  debugging stub which accepts only primitive commands.
30411  
30412 \newline
30413 Terms to enter into your favourite search engine could be 'remote debugging',
30414  'gdb stub' or 'inferior debugger'.
30415  (is there one?)
30416 \end_layout
30417
30418 \begin_layout Itemize
30419 use an on target hardware debugger.
30420  Some of the more modern MCUs include hardware support for setting break
30421  points and monitoring/changing variables by using dedicated hardware pins.
30422  This facility doesn't require additional code to run on the target and
30423  
30424 \emph on
30425 usually
30426 \emph default
30427  doesn't affect runtime behaviour until a breakpoint is hit.
30428  For the mcs51 most hardware debuggers use the AOMF
30429 \begin_inset LatexCommand index
30430 name "AOMF, AOMF51"
30431
30432 \end_inset
30433
30434  file (see 
30435 \begin_inset LatexCommand ref
30436 reference "OMF file"
30437
30438 \end_inset
30439
30440 ) as input file.
30441  
30442 \end_layout
30443
30444 \begin_layout Standard
30445 Last not least:
30446 \end_layout
30447
30448 \begin_layout Itemize
30449 if you are not familiar with any of the following terms you're likely to
30450  run into problems rather sooner than later: 
30451 \emph on
30452 volatile
30453 \emph default
30454
30455 \emph on
30456 atomic
30457 \emph default
30458
30459 \emph on
30460 memory map
30461 \emph default
30462
30463 \emph on
30464 overlay
30465 \emph default
30466 .
30467  As an embedded programmer you 
30468 \emph on
30469 have
30470 \emph default
30471  to know them so why not look them up 
30472 \emph on
30473 before
30474 \emph default
30475  you have problems?)
30476 \end_layout
30477
30478 \begin_layout Itemize
30479 tell someone else about your problem (actually this is a surprisingly effective
30480  means to hunt down the bug even if the listener is not familiar with your
30481  environment).
30482  As 'failure to communicate' is probably one of the job-induced deformations
30483  of an embedded programmer this is highly encouraged.
30484 \end_layout
30485
30486 \begin_layout Section
30487 Debugging with SDCDB
30488 \begin_inset LatexCommand label
30489 name "cha:Debugging-with-SDCDB"
30490
30491 \end_inset
30492
30493
30494 \begin_inset LatexCommand index
30495 name "SDCDB (debugger)"
30496
30497 \end_inset
30498
30499  
30500 \end_layout
30501
30502 \begin_layout Standard
30503 SDCC is distributed with a source level debugger
30504 \begin_inset LatexCommand index
30505 name "Debugger"
30506
30507 \end_inset
30508
30509 .
30510  The debugger uses a command line interface, the command repertoire of the
30511  debugger has been kept as close to gdb
30512 \begin_inset LatexCommand index
30513 name "gdb"
30514
30515 \end_inset
30516
30517  (the GNU debugger) as possible.
30518  The configuration and build process is part of the standard compiler installati
30519 on, which also builds and installs the debugger in the target directory
30520  specified during configuration.
30521  The debugger allows you debug BOTH at the C source and at the ASM source
30522  level.
30523 \end_layout
30524
30525 \begin_layout Subsection
30526 Compiling for Debugging
30527 \end_layout
30528
30529 \begin_layout Standard
30530 The -
30531 \begin_inset ERT
30532 status collapsed
30533
30534 \begin_layout Standard
30535
30536
30537 \backslash
30538 /
30539 \end_layout
30540
30541 \end_inset
30542
30543 -debug
30544 \begin_inset LatexCommand index
30545 name "-\\/-debug"
30546
30547 \end_inset
30548
30549  option must be specified for all files for which debug information is to
30550  be generated.
30551  The compiler generates a .adb file for each of these files.
30552  The linker creates the .cdb
30553 \begin_inset LatexCommand index
30554 name "<file>.cdb"
30555
30556 \end_inset
30557
30558  file from the .adb
30559 \begin_inset LatexCommand index
30560 name "<file>.adb"
30561
30562 \end_inset
30563
30564  files and the address information.
30565  This .cdb is used by the debugger.
30566 \end_layout
30567
30568 \begin_layout Subsection
30569 How the Debugger Works
30570 \end_layout
30571
30572 \begin_layout Standard
30573 When the -
30574 \begin_inset ERT
30575 status collapsed
30576
30577 \begin_layout Standard
30578
30579
30580 \backslash
30581 /
30582 \end_layout
30583
30584 \end_inset
30585
30586 -debug option is specified the compiler generates extra symbol information
30587  some of which are put into the assembler source and some are put into the
30588  .adb file.
30589  Then the linker creates the .cdb file from the individual .adb files with
30590  the address information for the symbols.
30591  The debugger reads the symbolic information generated by the compiler &
30592  the address information generated by the linker.
30593  It uses the SIMULATOR (Daniel's S51) to execute the program, the program
30594  execution is controlled by the debugger.
30595  When a command is issued for the debugger, it translates it into appropriate
30596  commands for the simulator.
30597  (Currently SDCDM only connects to the simulator but 
30598 \emph on
30599 newcdb
30600 \emph default
30601  at 
30602 \begin_inset LatexCommand url
30603 target "http://ec2drv.sf.net/"
30604
30605 \end_inset
30606
30607  is an effort to connect directly to the hardware.) 
30608 \end_layout
30609
30610 \begin_layout Subsection
30611 Starting the Debugger SDCDB
30612 \end_layout
30613
30614 \begin_layout Standard
30615 The debugger can be started using the following command line.
30616  (Assume the file you are debugging has the file name foo).
30617 \newline
30618
30619 \newline
30620
30621 \family sans
30622 \series bold
30623 sdcdb foo
30624 \newline
30625
30626 \family default
30627 \series default
30628
30629 \newline
30630 The debugger will look for the following files.
30631 \end_layout
30632
30633 \begin_layout Itemize
30634 foo.c - the source file.
30635 \end_layout
30636
30637 \begin_layout Itemize
30638 foo.cdb - the debugger symbol information file.
30639 \end_layout
30640
30641 \begin_layout Itemize
30642 foo.ihx - the Intel hex format
30643 \begin_inset LatexCommand index
30644 name "Intel hex format"
30645
30646 \end_inset
30647
30648  object file.
30649 \end_layout
30650
30651 \begin_layout Subsection
30652 SDCDB Command Line Options
30653 \end_layout
30654
30655 \begin_layout Itemize
30656 -
30657 \begin_inset ERT
30658 status collapsed
30659
30660 \begin_layout Standard
30661
30662
30663 \backslash
30664 /
30665 \end_layout
30666
30667 \end_inset
30668
30669 -directory=<source file directory> this option can used to specify the directory
30670  search list.
30671  The debugger will look into the directory list specified for source, cdb
30672  & ihx files.
30673  The items in the directory list must be separated by ':', e.g.
30674  if the source files can be in the directories /home/src1 and /home/src2,
30675  the -
30676 \begin_inset ERT
30677 status collapsed
30678
30679 \begin_layout Standard
30680
30681
30682 \backslash
30683 /
30684 \end_layout
30685
30686 \end_inset
30687
30688 -directory option should be -
30689 \begin_inset ERT
30690 status collapsed
30691
30692 \begin_layout Standard
30693
30694
30695 \backslash
30696 /
30697 \end_layout
30698
30699 \end_inset
30700
30701 -directory=/home/src1:/home/src2.
30702  Note there can be no spaces in the option.
30703  
30704 \end_layout
30705
30706 \begin_layout Itemize
30707 -cd <directory> - change to the <directory>.
30708 \end_layout
30709
30710 \begin_layout Itemize
30711 -fullname - used by GUI front ends.
30712 \end_layout
30713
30714 \begin_layout Itemize
30715 -cpu <cpu-type> - this argument is passed to the simulator please see the
30716  simulator docs for details.
30717 \end_layout
30718
30719 \begin_layout Itemize
30720 -X <Clock frequency > this options is passed to the simulator please see
30721  the simulator docs for details.
30722 \end_layout
30723
30724 \begin_layout Itemize
30725 -s <serial port file> passed to simulator see the simulator docs for details.
30726 \end_layout
30727
30728 \begin_layout Itemize
30729 -S <serial in,out> passed to simulator see the simulator docs for details.
30730 \end_layout
30731
30732 \begin_layout Itemize
30733 -k <port number> passed to simulator see the simulator docs for details.
30734 \end_layout
30735
30736 \begin_layout Subsection
30737 SDCDB Debugger Commands
30738 \end_layout
30739
30740 \begin_layout Standard
30741 As mentioned earlier the command interface for the debugger has been deliberatel
30742 y kept as close the GNU debugger gdb, as possible.
30743  This will help the integration with existing graphical user interfaces
30744  (like ddd, xxgdb or xemacs) existing for the GNU debugger.
30745  If you use a graphical user interface for the debugger you can skip this
30746  section.
30747 \end_layout
30748
30749 \begin_layout Subsubsection*
30750 break [line | file:line | function | file:function]
30751 \end_layout
30752
30753 \begin_layout Standard
30754 Set breakpoint at specified line or function:
30755 \newline
30756
30757 \newline
30758
30759 \family sans
30760 \series bold
30761 sdcdb>break 100 
30762 \newline
30763 sdcdb>break foo.c:100
30764 \newline
30765 sdcdb>break funcfoo
30766 \newline
30767 sdcdb>break foo.c:funcfoo
30768 \end_layout
30769
30770 \begin_layout Subsubsection*
30771 clear [line | file:line | function | file:function ]
30772 \end_layout
30773
30774 \begin_layout Standard
30775 Clear breakpoint at specified line or function:
30776 \newline
30777
30778 \newline
30779
30780 \family sans
30781 \series bold
30782 sdcdb>clear 100
30783 \newline
30784 sdcdb>clear foo.c:100
30785 \newline
30786 sdcdb>clear funcfoo
30787 \newline
30788 sdcdb>clear foo.c:funcfoo
30789 \end_layout
30790
30791 \begin_layout Subsubsection*
30792 continue
30793 \end_layout
30794
30795 \begin_layout Standard
30796 Continue program being debugged, after breakpoint.
30797 \end_layout
30798
30799 \begin_layout Subsubsection*
30800 finish
30801 \end_layout
30802
30803 \begin_layout Standard
30804 Execute till the end of the current function.
30805 \end_layout
30806
30807 \begin_layout Subsubsection*
30808 delete [n]
30809 \end_layout
30810
30811 \begin_layout Standard
30812 Delete breakpoint number 'n'.
30813  If used without any option clear ALL user defined break points.
30814 \end_layout
30815
30816 \begin_layout Subsubsection*
30817 info [break | stack | frame | registers ]
30818 \end_layout
30819
30820 \begin_layout Itemize
30821 info break - list all breakpoints
30822 \end_layout
30823
30824 \begin_layout Itemize
30825 info stack - show the function call stack.
30826 \end_layout
30827
30828 \begin_layout Itemize
30829 info frame - show information about the current execution frame.
30830 \end_layout
30831
30832 \begin_layout Itemize
30833 info registers - show content of all registers.
30834 \end_layout
30835
30836 \begin_layout Subsubsection*
30837 step
30838 \end_layout
30839
30840 \begin_layout Standard
30841 Step program until it reaches a different source line.
30842  Note: pressing <return> repeats the last command.
30843 \end_layout
30844
30845 \begin_layout Subsubsection*
30846 next
30847 \end_layout
30848
30849 \begin_layout Standard
30850 Step program, proceeding through subroutine calls.
30851 \end_layout
30852
30853 \begin_layout Subsubsection*
30854 run
30855 \end_layout
30856
30857 \begin_layout Standard
30858 Start debugged program.
30859 \end_layout
30860
30861 \begin_layout Subsubsection*
30862 ptype variable 
30863 \end_layout
30864
30865 \begin_layout Standard
30866 Print type information of the variable.
30867 \end_layout
30868
30869 \begin_layout Subsubsection*
30870 print variable
30871 \end_layout
30872
30873 \begin_layout Standard
30874 print value of variable.
30875 \end_layout
30876
30877 \begin_layout Subsubsection*
30878 file filename
30879 \end_layout
30880
30881 \begin_layout Standard
30882 load the given file name.
30883  Note this is an alternate method of loading file for debugging.
30884 \end_layout
30885
30886 \begin_layout Subsubsection*
30887 frame
30888 \end_layout
30889
30890 \begin_layout Standard
30891 print information about current frame.
30892 \end_layout
30893
30894 \begin_layout Subsubsection*
30895 set srcmode
30896 \end_layout
30897
30898 \begin_layout Standard
30899 Toggle between C source & assembly source.
30900 \end_layout
30901
30902 \begin_layout Subsubsection*
30903 ! simulator command
30904 \end_layout
30905
30906 \begin_layout Standard
30907 Send the string following '!' to the simulator, the simulator response is
30908  displayed.
30909  Note the debugger does not interpret the command being sent to the simulator,
30910  so if a command like 'go' is sent the debugger can loose its execution
30911  context and may display incorrect values.
30912 \end_layout
30913
30914 \begin_layout Subsubsection*
30915 quit
30916 \end_layout
30917
30918 \begin_layout Standard
30919 "Watch me now.
30920  Iam going Down.
30921  My name is Bobby Brown"
30922 \end_layout
30923
30924 \begin_layout Subsection
30925 Interfacing SDCDB with DDD
30926 \end_layout
30927
30928 \begin_layout Standard
30929 \begin_inset Note Note
30930 status collapsed
30931
30932 \begin_layout Standard
30933 The screenshot was converted from png to eps with: 
30934 \begin_inset Quotes sld
30935 \end_inset
30936
30937 bmeps -c -e8f -p3 ddd_example.png >ddd_example.eps
30938 \begin_inset Quotes srd
30939 \end_inset
30940
30941  which produces a pretty compact eps file which is free from compression
30942  artifacts.
30943 \end_layout
30944
30945 \begin_layout Standard
30946 The screenshot was included in sdccman.lyx cvs version 1.120 but later removed
30947  as this broke the build system on Sourceforge (pdf-file was broken.
30948  pdflatex does not accept eps files).
30949 \end_layout
30950
30951 \end_inset
30952
30953
30954 \end_layout
30955
30956 \begin_layout Standard
30957 The 
30958 \emph on
30959 p
30960 \emph default
30961 ortable 
30962 \emph on
30963 n
30964 \emph default
30965 etwork 
30966 \emph on
30967 g
30968 \emph default
30969 raphics File 
30970 \size footnotesize
30971
30972 \begin_inset LatexCommand url
30973 target "http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/doc/figures/ddd_example.png"
30974
30975 \end_inset
30976
30977
30978 \size default
30979  shows a screenshot of a debugging session with DDD
30980 \begin_inset LatexCommand index
30981 name "DDD (debugger)"
30982
30983 \end_inset
30984
30985  (Unix only) on a simulated 8032.
30986  The debugging session might not run as smoothly as the screenshot suggests.
30987  The debugger allows setting of breakpoints, displaying and changing variables,
30988  single stepping through C and assembler code.
30989  
30990 \newline
30991 The source was compiled with 
30992 \family sans
30993 \series bold
30994
30995 \newline
30996
30997 \newline
30998 sdcc -
30999 \family default
31000 \series default
31001
31002 \begin_inset ERT
31003 status collapsed
31004
31005 \begin_layout Standard
31006
31007
31008 \backslash
31009 /
31010 \end_layout
31011
31012 \end_inset
31013
31014
31015 \family sans
31016 \series bold
31017 -debug ddd_example.c
31018 \family default
31019 \series default
31020  
31021 \family sans
31022 \series bold
31023
31024 \newline
31025
31026 \family default
31027 \series default
31028
31029 \newline
31030 and DDD was invoked with 
31031 \family sans
31032 \series bold
31033
31034 \newline
31035
31036 \newline
31037 ddd -debugger "sdcdb -cpu 8032 ddd_example"
31038 \end_layout
31039
31040 \begin_layout Standard
31041 \begin_inset Note Note
31042 status open
31043
31044 \begin_layout Standard
31045 Check that the double quotes or an apostrophe within the command line survive
31046  the LyX tool chain.
31047  Previously the apostrophes got slanted in the PDF output so a cut and paste
31048  did not work.
31049 \end_layout
31050
31051 \end_inset
31052
31053
31054 \end_layout
31055
31056 \begin_layout Subsection
31057 Interfacing SDCDB with XEmacs
31058 \begin_inset LatexCommand index
31059 name "XEmacs"
31060
31061 \end_inset
31062
31063
31064 \begin_inset LatexCommand index
31065 name "Emacs"
31066
31067 \end_inset
31068
31069
31070 \end_layout
31071
31072 \begin_layout Standard
31073 Two files (in emacs lisp) are provided for the interfacing with XEmacs,
31074  sdcdb.el and sdcdbsrc.el.
31075  These two files can be found in the $(prefix)/bin directory after the installat
31076 ion is complete.
31077  These files need to be loaded into XEmacs for the interface to work.
31078  This can be done at XEmacs startup time by inserting the following into
31079  your '.xemacs' file (which can be found in your HOME directory): 
31080 \newline
31081
31082 \newline
31083
31084 \family typewriter
31085 (load-file sdcdbsrc.el)
31086 \family default
31087  
31088 \newline
31089
31090 \newline
31091 .xemacs is a lisp file so the () around the command is REQUIRED.
31092  The files can also be loaded dynamically while XEmacs is running, set the
31093  environment variable 'EMACSLOADPATH' to the installation bin directory
31094  (<installdir>/bin), then enter the following command ESC-x load-file sdcdbsrc.
31095  To start the interface enter the following command: 
31096 \newline
31097
31098 \newline
31099
31100 \family sans
31101 \series bold
31102 ESC-x sdcdbsrc
31103 \family default
31104 \series default
31105
31106 \newline
31107
31108 \newline
31109 You will prompted to enter the file name to be debugged.
31110  
31111 \newline
31112
31113 \newline
31114 The command line options that are passed to the simulator directly are
31115  bound to default values in the file sdcdbsrc.el.
31116  The variables are listed below, these values maybe changed as required.
31117 \end_layout
31118
31119 \begin_layout Itemize
31120 sdcdbsrc-cpu-type '51
31121 \end_layout
31122
31123 \begin_layout Itemize
31124 sdcdbsrc-frequency '11059200
31125 \end_layout
31126
31127 \begin_layout Itemize
31128 sdcdbsrc-serial nil
31129 \end_layout
31130
31131 \begin_layout Standard
31132 The following is a list of key mapping for the debugger interface.
31133 \end_layout
31134
31135 \begin_layout Standard
31136 \InsetSpace ~
31137
31138 \family typewriter
31139
31140 \newline
31141 ;;\InsetSpace ~
31142 Current Listing :: 
31143 \newline
31144 ;;key\InsetSpace ~
31145 \InsetSpace ~
31146 \InsetSpace ~
31147 \InsetSpace ~
31148 \InsetSpace ~
31149 \InsetSpace ~
31150 \InsetSpace ~
31151 \InsetSpace ~
31152 \InsetSpace ~
31153 \InsetSpace ~
31154 \InsetSpace ~
31155 \InsetSpace ~
31156 \InsetSpace ~
31157 \InsetSpace ~
31158 binding\InsetSpace ~
31159 \InsetSpace ~
31160 \InsetSpace ~
31161 \InsetSpace ~
31162 \InsetSpace ~
31163 \InsetSpace ~
31164 \InsetSpace ~
31165 \InsetSpace ~
31166 \InsetSpace ~
31167 \InsetSpace ~
31168 \InsetSpace ~
31169 \InsetSpace ~
31170 \InsetSpace ~
31171 \InsetSpace ~
31172 \InsetSpace ~
31173 \InsetSpace ~
31174 \InsetSpace ~
31175 \InsetSpace ~
31176 \InsetSpace ~
31177 \InsetSpace ~
31178 \InsetSpace ~
31179 \InsetSpace ~
31180 Comment 
31181 \newline
31182 ;;---\InsetSpace ~
31183 \InsetSpace ~
31184 \InsetSpace ~
31185 \InsetSpace ~
31186 \InsetSpace ~
31187 \InsetSpace ~
31188 \InsetSpace ~
31189 \InsetSpace ~
31190 \InsetSpace ~
31191 \InsetSpace ~
31192 \InsetSpace ~
31193 \InsetSpace ~
31194 \InsetSpace ~
31195 \InsetSpace ~
31196 -------\InsetSpace ~
31197 \InsetSpace ~
31198 \InsetSpace ~
31199 \InsetSpace ~
31200 \InsetSpace ~
31201 \InsetSpace ~
31202 \InsetSpace ~
31203 \InsetSpace ~
31204 \InsetSpace ~
31205 \InsetSpace ~
31206 \InsetSpace ~
31207 \InsetSpace ~
31208 \InsetSpace ~
31209 \InsetSpace ~
31210 \InsetSpace ~
31211 \InsetSpace ~
31212 \InsetSpace ~
31213 \InsetSpace ~
31214 \InsetSpace ~
31215 \InsetSpace ~
31216 \InsetSpace ~
31217 \InsetSpace ~
31218 -------
31219 \newline
31220 ;; 
31221 \newline
31222 ;;\InsetSpace ~
31223 n\InsetSpace ~
31224 \InsetSpace ~
31225 \InsetSpace ~
31226 \InsetSpace ~
31227 \InsetSpace ~
31228 \InsetSpace ~
31229 \InsetSpace ~
31230 \InsetSpace ~
31231 \InsetSpace ~
31232 \InsetSpace ~
31233 \InsetSpace ~
31234 \InsetSpace ~
31235 \InsetSpace ~
31236 \InsetSpace ~
31237 \InsetSpace ~
31238 sdcdb-next-fro
31239 m-src\InsetSpace ~
31240 \InsetSpace ~
31241 \InsetSpace ~
31242 \InsetSpace ~
31243 \InsetSpace ~
31244 \InsetSpace ~
31245 \InsetSpace ~
31246 \InsetSpace ~
31247 \InsetSpace ~
31248 \InsetSpace ~
31249 SDCDB next command 
31250 \newline
31251 ;;\InsetSpace ~
31252 b\InsetSpace ~
31253 \InsetSpace ~
31254 \InsetSpace ~
31255 \InsetSpace ~
31256 \InsetSpace ~
31257 \InsetSpace ~
31258 \InsetSpace ~
31259 \InsetSpace ~
31260 \InsetSpace ~
31261 \InsetSpace ~
31262 \InsetSpace ~
31263 \InsetSpace ~
31264 \InsetSpace ~
31265 \InsetSpace ~
31266 \InsetSpace ~
31267 sdcdb-back-from-src\InsetSpace ~
31268 \InsetSpace ~
31269 \InsetSpace ~
31270 \InsetSpace ~
31271 \InsetSpace ~
31272 \InsetSpace ~
31273 \InsetSpace ~
31274 \InsetSpace ~
31275 \InsetSpace ~
31276 \InsetSpace ~
31277 SDCDB back command 
31278 \newline
31279 ;;\InsetSpace ~
31280 c\InsetSpace ~
31281 \InsetSpace ~
31282 \InsetSpace ~
31283 \InsetSpace ~
31284 \InsetSpace ~
31285 \InsetSpace ~
31286 \InsetSpace ~
31287 \InsetSpace ~
31288 \InsetSpace ~
31289 \InsetSpace ~
31290 \InsetSpace ~
31291 \InsetSpace ~
31292 \InsetSpace ~
31293 \InsetSpace ~
31294 \InsetSpace ~
31295 sdcdb-cont-f
31296 rom-src\InsetSpace ~
31297 \InsetSpace ~
31298 \InsetSpace ~
31299 \InsetSpace ~
31300 \InsetSpace ~
31301 \InsetSpace ~
31302 \InsetSpace ~
31303 \InsetSpace ~
31304 \InsetSpace ~
31305 \InsetSpace ~
31306 SDCDB continue command
31307 \newline
31308 ;;\InsetSpace ~
31309 s\InsetSpace ~
31310 \InsetSpace ~
31311 \InsetSpace ~
31312 \InsetSpace ~
31313 \InsetSpace ~
31314 \InsetSpace ~
31315 \InsetSpace ~
31316 \InsetSpace ~
31317 \InsetSpace ~
31318 \InsetSpace ~
31319 \InsetSpace ~
31320 \InsetSpace ~
31321 \InsetSpace ~
31322 \InsetSpace ~
31323 \InsetSpace ~
31324 sdcdb-step-from-src\InsetSpace ~
31325 \InsetSpace ~
31326 \InsetSpace ~
31327 \InsetSpace ~
31328 \InsetSpace ~
31329 \InsetSpace ~
31330 \InsetSpace ~
31331 \InsetSpace ~
31332 \InsetSpace ~
31333 \InsetSpace ~
31334 SDCDB step command 
31335 \newline
31336 ;;\InsetSpace ~
31337 ?\InsetSpace ~
31338 \InsetSpace ~
31339 \InsetSpace ~
31340 \InsetSpace ~
31341 \InsetSpace ~
31342 \InsetSpace ~
31343 \InsetSpace ~
31344 \InsetSpace ~
31345 \InsetSpace ~
31346 \InsetSpace ~
31347 \InsetSpace ~
31348 \InsetSpace ~
31349 \InsetSpace ~
31350 \InsetSpace ~
31351 \InsetSpace ~
31352 sdcdb-w
31353 hatis-c-sexp\InsetSpace ~
31354 \InsetSpace ~
31355 \InsetSpace ~
31356 \InsetSpace ~
31357 \InsetSpace ~
31358 \InsetSpace ~
31359 \InsetSpace ~
31360 \InsetSpace ~
31361 \InsetSpace ~
31362 \InsetSpace ~
31363 SDCDB ptypecommand for data at 
31364 \newline
31365 ;;\InsetSpace ~
31366 \InsetSpace ~
31367 \InsetSpace ~
31368 \InsetSpace ~
31369 \InsetSpace ~
31370 \InsetSpace ~
31371 \InsetSpace ~
31372 \InsetSpace ~
31373 \InsetSpace ~
31374 \InsetSpace ~
31375 \InsetSpace ~
31376 \InsetSpace ~
31377 \InsetSpace ~
31378 \InsetSpace ~
31379 \InsetSpace ~
31380 \InsetSpace ~
31381 \InsetSpace ~
31382 \InsetSpace ~
31383 \InsetSpace ~
31384 \InsetSpace ~
31385 \InsetSpace ~
31386 \InsetSpace ~
31387 \InsetSpace ~
31388 \InsetSpace ~
31389 \InsetSpace ~
31390 \InsetSpace ~
31391 \InsetSpace ~
31392 \InsetSpace ~
31393 \InsetSpace ~
31394 \InsetSpace ~
31395 \InsetSpace ~
31396 \InsetSpace ~
31397 \InsetSpace ~
31398 \InsetSpace ~
31399 \InsetSpace ~
31400 \InsetSpace ~
31401 \InsetSpace ~
31402 \InsetSpace ~
31403 \InsetSpace ~
31404 \InsetSpace ~
31405 \InsetSpace ~
31406 \InsetSpace ~
31407 \InsetSpace ~
31408 \InsetSpace ~
31409 \InsetSpace ~
31410 \InsetSpace ~
31411 \InsetSpace ~
31412 buffer point 
31413 \newline
31414 ;;\InsetSpace ~
31415 x\InsetSpace ~
31416 \InsetSpace ~
31417 \InsetSpace ~
31418 \InsetSpace ~
31419 \InsetSpace ~
31420 \InsetSpace ~
31421 \InsetSpace ~
31422 \InsetSpace ~
31423 \InsetSpace ~
31424 \InsetSpace ~
31425 \InsetSpace ~
31426 \InsetSpace ~
31427 \InsetSpace ~
31428 \InsetSpace ~
31429 \InsetSpace ~
31430 sdcdbsrc-delete\InsetSpace ~
31431 \InsetSpace ~
31432 \InsetSpace ~
31433 \InsetSpace ~
31434 \InsetSpace ~
31435 \InsetSpace ~
31436 \InsetSpace ~
31437 \InsetSpace ~
31438 \InsetSpace ~
31439 \InsetSpace ~
31440 \InsetSpace ~
31441 \InsetSpace ~
31442 \InsetSpace ~
31443 \InsetSpace ~
31444 SDCD
31445 B Delete all breakpoints if no arg 
31446 \newline
31447 ;;\InsetSpace ~
31448 \InsetSpace ~
31449 \InsetSpace ~
31450 \InsetSpace ~
31451 \InsetSpace ~
31452 \InsetSpace ~
31453 \InsetSpace ~
31454 \InsetSpace ~
31455 \InsetSpace ~
31456 \InsetSpace ~
31457 \InsetSpace ~
31458 \InsetSpace ~
31459 \InsetSpace ~
31460 \InsetSpace ~
31461 \InsetSpace ~
31462 \InsetSpace ~
31463 \InsetSpace ~
31464 \InsetSpace ~
31465 \InsetSpace ~
31466 \InsetSpace ~
31467 \InsetSpace ~
31468 \InsetSpace ~
31469 \InsetSpace ~
31470 \InsetSpace ~
31471 \InsetSpace ~
31472 \InsetSpace ~
31473 \InsetSpace ~
31474 \InsetSpace ~
31475 \InsetSpace ~
31476 \InsetSpace ~
31477 \InsetSpace ~
31478 \InsetSpace ~
31479 \InsetSpace ~
31480 \InsetSpace ~
31481 \InsetSpace ~
31482 \InsetSpace ~
31483 \InsetSpace ~
31484 \InsetSpace ~
31485 \InsetSpace ~
31486 \InsetSpace ~
31487 \InsetSpace ~
31488 \InsetSpace ~
31489 \InsetSpace ~
31490 \InsetSpace ~
31491 \InsetSpace ~
31492 \InsetSpace ~
31493 \InsetSpace ~
31494 given or delete arg (C-u arg x) 
31495 \newline
31496 ;;\InsetSpace ~
31497 m\InsetSpace ~
31498 \InsetSpace ~
31499 \InsetSpace ~
31500 \InsetSpace ~
31501 \InsetSpace ~
31502 \InsetSpace ~
31503 \InsetSpace ~
31504 \InsetSpace ~
31505 \InsetSpace ~
31506 \InsetSpace ~
31507 \InsetSpace ~
31508 \InsetSpace ~
31509 \InsetSpace ~
31510 \InsetSpace ~
31511 \InsetSpace ~
31512 sdcdbsrc
31513 -frame\InsetSpace ~
31514 \InsetSpace ~
31515 \InsetSpace ~
31516 \InsetSpace ~
31517 \InsetSpace ~
31518 \InsetSpace ~
31519 \InsetSpace ~
31520 \InsetSpace ~
31521 \InsetSpace ~
31522 \InsetSpace ~
31523 \InsetSpace ~
31524 \InsetSpace ~
31525 \InsetSpace ~
31526 \InsetSpace ~
31527 \InsetSpace ~
31528 SDCDB Display current frame if no arg, 
31529 \newline
31530 ;;\InsetSpace ~
31531 \InsetSpace ~
31532 \InsetSpace ~
31533 \InsetSpace ~
31534 \InsetSpace ~
31535 \InsetSpace ~
31536 \InsetSpace ~
31537 \InsetSpace ~
31538 \InsetSpace ~
31539 \InsetSpace ~
31540 \InsetSpace ~
31541 \InsetSpace ~
31542 \InsetSpace ~
31543 \InsetSpace ~
31544 \InsetSpace ~
31545 \InsetSpace ~
31546 \InsetSpace ~
31547 \InsetSpace ~
31548 \InsetSpace ~
31549 \InsetSpace ~
31550 \InsetSpace ~
31551 \InsetSpace ~
31552 \InsetSpace ~
31553 \InsetSpace ~
31554 \InsetSpace ~
31555 \InsetSpace ~
31556 \InsetSpace ~
31557 \InsetSpace ~
31558 \InsetSpace ~
31559 \InsetSpace ~
31560 \InsetSpace ~
31561 \InsetSpace ~
31562 \InsetSpace ~
31563 \InsetSpace ~
31564 \InsetSpace ~
31565 \InsetSpace ~
31566 \InsetSpace ~
31567 \InsetSpace ~
31568 \InsetSpace ~
31569 \InsetSpace ~
31570 \InsetSpace ~
31571 \InsetSpace ~
31572 \InsetSpace ~
31573 \InsetSpace ~
31574 \InsetSpace ~
31575 \InsetSpace ~
31576 \InsetSpace ~
31577 given or display frame arg
31578  
31579 \newline
31580 ;;\InsetSpace ~
31581 \InsetSpace ~
31582 \InsetSpace ~
31583 \InsetSpace ~
31584 \InsetSpace ~
31585 \InsetSpace ~
31586 \InsetSpace ~
31587 \InsetSpace ~
31588 \InsetSpace ~
31589 \InsetSpace ~
31590 \InsetSpace ~
31591 \InsetSpace ~
31592 \InsetSpace ~
31593 \InsetSpace ~
31594 \InsetSpace ~
31595 \InsetSpace ~
31596 \InsetSpace ~
31597 \InsetSpace ~
31598 \InsetSpace ~
31599 \InsetSpace ~
31600 \InsetSpace ~
31601 \InsetSpace ~
31602 \InsetSpace ~
31603 \InsetSpace ~
31604 \InsetSpace ~
31605 \InsetSpace ~
31606 \InsetSpace ~
31607 \InsetSpace ~
31608 \InsetSpace ~
31609 \InsetSpace ~
31610 \InsetSpace ~
31611 \InsetSpace ~
31612 \InsetSpace ~
31613 \InsetSpace ~
31614 \InsetSpace ~
31615 \InsetSpace ~
31616 \InsetSpace ~
31617 \InsetSpace ~
31618 \InsetSpace ~
31619 \InsetSpace ~
31620 \InsetSpace ~
31621 \InsetSpace ~
31622 \InsetSpace ~
31623 \InsetSpace ~
31624 \InsetSpace ~
31625 \InsetSpace ~
31626 \InsetSpace ~
31627 buffer point 
31628 \newline
31629 ;;\InsetSpace ~
31630 !\InsetSpace ~
31631 \InsetSpace ~
31632 \InsetSpace ~
31633 \InsetSpace ~
31634 \InsetSpace ~
31635 \InsetSpace ~
31636 \InsetSpace ~
31637 \InsetSpace ~
31638 \InsetSpace ~
31639 \InsetSpace ~
31640 \InsetSpace ~
31641 \InsetSpace ~
31642 \InsetSpace ~
31643 \InsetSpace ~
31644 \InsetSpace ~
31645 sdcdbsrc-goto-sdcdb\InsetSpace ~
31646 \InsetSpace ~
31647 \InsetSpace ~
31648 \InsetSpace ~
31649 \InsetSpace ~
31650 \InsetSpace ~
31651 \InsetSpace ~
31652 \InsetSpace ~
31653 \InsetSpace ~
31654 \InsetSpace ~
31655 Goto the SDCDB output buffer 
31656 \newline
31657 ;;\InsetSpace ~
31658 p\InsetSpace ~
31659 \InsetSpace ~
31660 \InsetSpace ~
31661 \InsetSpace ~
31662 \InsetSpace ~
31663 \InsetSpace ~
31664 \InsetSpace ~
31665 \InsetSpace ~
31666 \InsetSpace ~
31667 \InsetSpace ~
31668 \InsetSpace ~
31669 \InsetSpace ~
31670 \InsetSpace ~
31671 \InsetSpace ~
31672 \InsetSpace ~
31673 sdcdb-prin
31674 t-c-sexp\InsetSpace ~
31675 \InsetSpace ~
31676 \InsetSpace ~
31677 \InsetSpace ~
31678 \InsetSpace ~
31679 \InsetSpace ~
31680 \InsetSpace ~
31681 \InsetSpace ~
31682 \InsetSpace ~
31683 \InsetSpace ~
31684 \InsetSpace ~
31685 SDCDB print command for data at 
31686 \newline
31687 ;;\InsetSpace ~
31688 \InsetSpace ~
31689 \InsetSpace ~
31690 \InsetSpace ~
31691 \InsetSpace ~
31692 \InsetSpace ~
31693 \InsetSpace ~
31694 \InsetSpace ~
31695 \InsetSpace ~
31696 \InsetSpace ~
31697 \InsetSpace ~
31698 \InsetSpace ~
31699 \InsetSpace ~
31700 \InsetSpace ~
31701 \InsetSpace ~
31702 \InsetSpace ~
31703 \InsetSpace ~
31704 \InsetSpace ~
31705 \InsetSpace ~
31706 \InsetSpace ~
31707 \InsetSpace ~
31708 \InsetSpace ~
31709 \InsetSpace ~
31710 \InsetSpace ~
31711 \InsetSpace ~
31712 \InsetSpace ~
31713 \InsetSpace ~
31714 \InsetSpace ~
31715 \InsetSpace ~
31716 \InsetSpace ~
31717 \InsetSpace ~
31718 \InsetSpace ~
31719 \InsetSpace ~
31720 \InsetSpace ~
31721 \InsetSpace ~
31722 \InsetSpace ~
31723 \InsetSpace ~
31724 \InsetSpace ~
31725 \InsetSpace ~
31726 \InsetSpace ~
31727 \InsetSpace ~
31728 \InsetSpace ~
31729 \InsetSpace ~
31730 \InsetSpace ~
31731 \InsetSpace ~
31732 \InsetSpace ~
31733 \InsetSpace ~
31734 buffer point 
31735 \newline
31736 ;;\InsetSpace ~
31737 g\InsetSpace ~
31738 \InsetSpace ~
31739 \InsetSpace ~
31740 \InsetSpace ~
31741 \InsetSpace ~
31742 \InsetSpace ~
31743 \InsetSpace ~
31744 \InsetSpace ~
31745 \InsetSpace ~
31746 \InsetSpace ~
31747 \InsetSpace ~
31748 \InsetSpace ~
31749 \InsetSpace ~
31750 \InsetSpace ~
31751 \InsetSpace ~
31752 sdcdbsrc-goto-sdcdb\InsetSpace ~
31753 \InsetSpace ~
31754 \InsetSpace ~
31755 \InsetSpace ~
31756 \InsetSpace ~
31757 \InsetSpace ~
31758 \InsetSpace ~
31759 \InsetSpace ~
31760 \InsetSpace ~
31761 \InsetSpace ~
31762 Got
31763 o the SDCDB output buffer 
31764 \newline
31765 ;;\InsetSpace ~
31766 t\InsetSpace ~
31767 \InsetSpace ~
31768 \InsetSpace ~
31769 \InsetSpace ~
31770 \InsetSpace ~
31771 \InsetSpace ~
31772 \InsetSpace ~
31773 \InsetSpace ~
31774 \InsetSpace ~
31775 \InsetSpace ~
31776 \InsetSpace ~
31777 \InsetSpace ~
31778 \InsetSpace ~
31779 \InsetSpace ~
31780 \InsetSpace ~
31781 sdcdbsrc-mode\InsetSpace ~
31782 \InsetSpace ~
31783 \InsetSpace ~
31784 \InsetSpace ~
31785 \InsetSpace ~
31786 \InsetSpace ~
31787 \InsetSpace ~
31788 \InsetSpace ~
31789 \InsetSpace ~
31790 \InsetSpace ~
31791 \InsetSpace ~
31792 \InsetSpace ~
31793 \InsetSpace ~
31794 \InsetSpace ~
31795 \InsetSpace ~
31796 \InsetSpace ~
31797 Toggles Sdcdbsrc mode (turns it
31798  off) 
31799 \newline
31800 ;; 
31801 \newline
31802 ;;\InsetSpace ~
31803 C-c\InsetSpace ~
31804 C-f\InsetSpace ~
31805 \InsetSpace ~
31806 \InsetSpace ~
31807 \InsetSpace ~
31808 \InsetSpace ~
31809 \InsetSpace ~
31810 \InsetSpace ~
31811 \InsetSpace ~
31812 \InsetSpace ~
31813 sdcdb-finish-from-src\InsetSpace ~
31814 \InsetSpace ~
31815 \InsetSpace ~
31816 \InsetSpace ~
31817 \InsetSpace ~
31818 \InsetSpace ~
31819 \InsetSpace ~
31820 \InsetSpace ~
31821 SDCDB finish command 
31822 \newline
31823 ;; 
31824 \newline
31825 ;;\InsetSpace ~
31826 C-x\InsetSpace ~
31827 SPC\InsetSpace ~
31828 \InsetSpace ~
31829 \InsetSpace ~
31830 \InsetSpace ~
31831 \InsetSpace ~
31832 \InsetSpace ~
31833 \InsetSpace ~
31834 \InsetSpace ~
31835 \InsetSpace ~
31836 sdcdb-brea
31837 k\InsetSpace ~
31838 \InsetSpace ~
31839 \InsetSpace ~
31840 \InsetSpace ~
31841 \InsetSpace ~
31842 \InsetSpace ~
31843 \InsetSpace ~
31844 \InsetSpace ~
31845 \InsetSpace ~
31846 \InsetSpace ~
31847 \InsetSpace ~
31848 \InsetSpace ~
31849 \InsetSpace ~
31850 \InsetSpace ~
31851 \InsetSpace ~
31852 \InsetSpace ~
31853 \InsetSpace ~
31854 \InsetSpace ~
31855 Set break for line with point 
31856 \newline
31857 ;;\InsetSpace ~
31858 ESC\InsetSpace ~
31859 t\InsetSpace ~
31860 \InsetSpace ~
31861 \InsetSpace ~
31862 \InsetSpace ~
31863 \InsetSpace ~
31864 \InsetSpace ~
31865 \InsetSpace ~
31866 \InsetSpace ~
31867 \InsetSpace ~
31868 \InsetSpace ~
31869 \InsetSpace ~
31870 sdcdbsrc-mode\InsetSpace ~
31871 \InsetSpace ~
31872 \InsetSpace ~
31873 \InsetSpace ~
31874 \InsetSpace ~
31875 \InsetSpace ~
31876 \InsetSpace ~
31877 \InsetSpace ~
31878 \InsetSpace ~
31879 \InsetSpace ~
31880 \InsetSpace ~
31881 \InsetSpace ~
31882 \InsetSpace ~
31883 \InsetSpace ~
31884 \InsetSpace ~
31885 \InsetSpace ~
31886 Toggle Sdcdbsrc mode 
31887 \newline
31888 ;;\InsetSpace ~
31889 ESC\InsetSpace ~
31890 m\InsetSpace ~
31891 \InsetSpace ~
31892 \InsetSpace ~
31893 \InsetSpace ~
31894 \InsetSpace ~
31895 \InsetSpace ~
31896 \InsetSpace ~
31897 \InsetSpace ~
31898 \InsetSpace ~
31899 \InsetSpace ~
31900 \InsetSpace ~
31901 sdc
31902 dbsrc-srcmode\InsetSpace ~
31903 \InsetSpace ~
31904 \InsetSpace ~
31905 \InsetSpace ~
31906 \InsetSpace ~
31907 \InsetSpace ~
31908 \InsetSpace ~
31909 \InsetSpace ~
31910 \InsetSpace ~
31911 \InsetSpace ~
31912 \InsetSpace ~
31913 \InsetSpace ~
31914 \InsetSpace ~
31915 Toggle list mode 
31916 \newline
31917 ;; 
31918 \newline
31919
31920 \family default
31921
31922 \newpage
31923
31924 \end_layout
31925
31926 \begin_layout Chapter
31927 TIPS
31928 \end_layout
31929
31930 \begin_layout Standard
31931 Here are a few guidelines that will help the compiler generate more efficient
31932  code, some of the tips are specific to this compiler others are generally
31933  good programming practice.
31934 \end_layout
31935
31936 \begin_layout Itemize
31937 Use the smallest data type to represent your data-value.
31938  If it is known in advance that the value is going to be less than 256 then
31939  use an 'unsigned char' instead of a 'short' or 'int'.
31940  Please note, that ANSI C requires both signed and unsigned chars to be
31941  promoted to 'signed int'
31942 \begin_inset LatexCommand index
31943 name "promotion to signed int"
31944
31945 \end_inset
31946
31947
31948 \begin_inset Marginal
31949 status collapsed
31950
31951 \begin_layout Standard
31952
31953 \series bold
31954 \InsetSpace ~
31955 !
31956 \end_layout
31957
31958 \end_inset
31959
31960  before doing any operation.
31961  This promotion
31962 \begin_inset LatexCommand index
31963 name "type promotion"
31964
31965 \end_inset
31966
31967
31968 \begin_inset LatexCommand label
31969 name "type promotion"
31970
31971 \end_inset
31972
31973  can be omitted, if the result is the same.
31974  The effect of the promotion rules together with the sign-extension is often
31975  surprising:
31976 \end_layout
31977
31978 \begin_deeper
31979 \begin_layout Verse
31980
31981 \family typewriter
31982 unsigned char uc = 0xfe;
31983 \newline
31984 if (uc * uc < 0) /* this is true! */
31985 \newline
31986 {
31987 \newline
31988 \InsetSpace ~
31989 \InsetSpace ~
31990 \InsetSpace ~
31991 \InsetSpace ~
31992 ....
31993 \newline
31994 }
31995 \end_layout
31996
31997 \begin_layout Standard
31998
31999 \family typewriter
32000 uc * uc
32001 \family default
32002  is evaluated as 
32003 \family typewriter
32004 (int) uc * (int) uc = (int) 0xfe * (int) 0xfe = (int) 0xfc04 = -1024
32005 \family default
32006 .
32007  
32008 \newline
32009 Another one:
32010 \end_layout
32011
32012 \begin_layout Verse
32013
32014 \family typewriter
32015 (unsigned char) -12 / (signed char) -3 = ...
32016 \end_layout
32017
32018 \begin_layout Standard
32019 No, the result is not 4:
32020 \end_layout
32021
32022 \begin_layout Verse
32023
32024 \family typewriter
32025 (int) (unsigned char) -12 / (int) (signed char) -3 =
32026 \newline
32027 (int) (unsigned char)
32028  0xf4 / (int) (signed char) 0xfd =
32029 \newline
32030 (int) 0x00f4 / (int) 0xfffd =
32031 \newline
32032 (int) 0x00f4
32033  / (int) 0xfffd =
32034 \newline
32035 (int) 244 / (int) -3 =
32036 \newline
32037 (int) -81 = (int) 0xffaf;
32038 \end_layout
32039
32040 \begin_layout Standard
32041 Don't complain, that gcc gives you a different result.
32042  gcc uses 32 bit ints, while SDCC uses 16 bit ints.
32043  Therefore the results are different.
32044 \newline
32045 From 
32046 \begin_inset Quotes sld
32047 \end_inset
32048
32049 comp.lang.c FAQ
32050 \begin_inset Quotes srd
32051 \end_inset
32052
32053 :
32054 \end_layout
32055
32056 \begin_layout Quote
32057
32058 \emph on
32059 If well-defined overflow characteristics are important and negative values
32060  are not, or if you want to steer clear of sign-extension problems when
32061  manipulating bits or bytes, use one of the corresponding unsigned types.
32062  (Beware when mixing signed and unsigned values in expressions, though.)
32063 \newline
32064 Although
32065  character types (especially unsigned char) can be used as "tiny" integers,
32066  doing so is sometimes more trouble than it's worth, due to unpredictable
32067  sign extension and increased code size.
32068 \end_layout
32069
32070 \end_deeper
32071 \begin_layout Itemize
32072 Use unsigned when it is known in advance that the value is not going to
32073  be negative.
32074  This helps especially if you are doing division or multiplication, bit-shifting
32075  or are using an array index.
32076 \end_layout
32077
32078 \begin_layout Itemize
32079 NEVER jump into a LOOP.
32080 \end_layout
32081
32082 \begin_layout Itemize
32083 Declare the variables to be local
32084 \begin_inset LatexCommand index
32085 name "local variables"
32086
32087 \end_inset
32088
32089  whenever possible, especially loop control variables (induction).
32090 \end_layout
32091
32092 \begin_layout Itemize
32093 Have a look at the assembly listing to get a 
32094 \begin_inset Quotes sld
32095 \end_inset
32096
32097 feeling
32098 \begin_inset Quotes srd
32099 \end_inset
32100
32101  for the code generation.
32102 \end_layout
32103
32104 \begin_layout Section
32105 Porting code from or to other compilers
32106 \begin_inset LatexCommand label
32107 name "sec:Porting-code-to-other-compilers"
32108
32109 \end_inset
32110
32111
32112 \end_layout
32113
32114 \begin_layout Itemize
32115 check whether endianness of the compilers differs and adapt where needed.
32116 \end_layout
32117
32118 \begin_layout Itemize
32119 check the device specific header files
32120 \begin_inset LatexCommand index
32121 name "Header files"
32122
32123 \end_inset
32124
32125
32126 \begin_inset LatexCommand index
32127 name "Include files"
32128
32129 \end_inset
32130
32131  for compiler specific syntax.
32132  Eventually include the file <compiler.h
32133 \begin_inset LatexCommand index
32134 name "compiler.h (include file)"
32135
32136 \end_inset
32137
32138
32139 \begin_inset LatexCommand url
32140 target "http://sdcc.svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/device/include/mcs51/compiler.h?view=markup"
32141
32142 \end_inset
32143
32144  to allow using common header files.
32145  (see f.e.
32146  cc2510fx.h 
32147 \begin_inset LatexCommand url
32148 target "http://sdcc.svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/device/include/mcs51/cc2510fx.h?view=markup"
32149
32150 \end_inset
32151
32152 ).
32153 \end_layout
32154
32155 \begin_layout Itemize
32156 check whether the startup code contains the correct initialization (watchdog,
32157  peripherals).
32158 \end_layout
32159
32160 \begin_layout Itemize
32161 check whether the sizes of short, int, long match.
32162 \end_layout
32163
32164 \begin_layout Itemize
32165 check if some 16 or 32 bit hardware registers require a specific addressing
32166  order (least significant or most significant byte first) and adapt if needed
32167  (
32168 \emph on
32169 first
32170 \emph default
32171  and 
32172 \emph on
32173 last
32174 \emph default
32175  relate to time and not to lower/upper memory location here, so this is
32176  
32177 \emph on
32178 not
32179 \emph default
32180  the same as endianness).
32181 \end_layout
32182
32183 \begin_layout Itemize
32184 check whether the keyword 
32185 \emph on
32186 volatile
32187 \emph default
32188  is used where needed.
32189  The compilers might differ in their optimization characteristics (as different
32190  versions of the same compiler might also use more clever optimizations
32191  this is good idea anyway).
32192  See section 
32193 \begin_inset LatexCommand ref
32194 reference "sub:Common-interrupt-pitfall-volatile"
32195
32196 \end_inset
32197
32198 .
32199 \end_layout
32200
32201 \begin_layout Itemize
32202 check that the compilers are not told to suppress warnings.
32203 \end_layout
32204
32205 \begin_layout Itemize
32206 check and convert compiler specific extensions (interrupts, memory areas,
32207  pragmas etc.).
32208 \end_layout
32209
32210 \begin_layout Itemize
32211 check for differences in type promotion.
32212  Especially check for math operations on 
32213 \family typewriter
32214 char
32215 \family default
32216  or 
32217 \family typewriter
32218 unsigned char
32219 \family default
32220  variables.
32221  For the sake of C99 compatibility SDCC will probably promote these to 
32222 \family typewriter
32223 int
32224 \family default
32225  more often than other compilers.
32226  Eventually insert explicit casts to 
32227 \family typewriter
32228 (char)
32229 \family default
32230  or 
32231 \family typewriter
32232 (unsigned char)
32233 \family default
32234 .
32235  Also check that the ~\InsetSpace ~
32236 operator
32237 \begin_inset LatexCommand index
32238 name "\\~\\/ Operator"
32239
32240 \end_inset
32241
32242  is not used on 
32243 \family typewriter
32244 bit
32245 \begin_inset LatexCommand index
32246 name "bit"
32247
32248 \end_inset
32249
32250
32251 \family default
32252  variables, use the !\InsetSpace ~
32253 operator instead.
32254  See sections 
32255 \begin_inset LatexCommand ref
32256 reference "type promotion"
32257
32258 \end_inset
32259
32260  and 
32261 \begin_inset LatexCommand ref
32262 reference "sec:Compatibility-with-previous"
32263
32264 \end_inset
32265
32266 .
32267 \end_layout
32268
32269 \begin_layout Itemize
32270 check the assembly code generated for interrupt routines (f.e.
32271  for calls to possibly non-reentrant library functions).
32272 \end_layout
32273
32274 \begin_layout Itemize
32275 check whether timing loops result in proper timing (or preferably consider
32276  a rewrite of the code with timer based delays instead).
32277 \end_layout
32278
32279 \begin_layout Itemize
32280 check for differences in printf parameters (some compilers push (va_arg
32281 \begin_inset LatexCommand index
32282 name "vararg, va\\_arg"
32283
32284 \end_inset
32285
32286 ) char variables as 
32287 \family typewriter
32288 int
32289 \family default
32290  others push them as 
32291 \family typewriter
32292 char
32293 \family default
32294 .
32295  See section 
32296 \begin_inset LatexCommand ref
32297 reference "sec:Compatibility-with-previous"
32298
32299 \end_inset
32300
32301 ).
32302 \end_layout
32303
32304 \begin_layout Itemize
32305 check the resulting memory map
32306 \begin_inset LatexCommand index
32307 name "Memory map"
32308
32309 \end_inset
32310
32311 .
32312  Usage of different memory spaces: code, stack, data (for mcs51/ds390 additional
32313 ly idata, pdata, xdata).
32314  Eventually check if unexpected library functions are included.
32315 \end_layout
32316
32317 \begin_layout Section
32318 Tools
32319 \begin_inset LatexCommand index
32320 name "Tools"
32321
32322 \end_inset
32323
32324  included in the distribution
32325 \end_layout
32326
32327 \begin_layout Standard
32328 \align left
32329 \begin_inset Tabular
32330 <lyxtabular version="3" rows="12" columns="3">
32331 <features>
32332 <column alignment="left" valignment="top" leftline="true" width="0pt">
32333 <column alignment="left" valignment="top" leftline="true" width="0pt">
32334 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0pt">
32335 <row topline="true" bottomline="true">
32336 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32337 \begin_inset Text
32338
32339 \begin_layout Standard
32340
32341 \series bold
32342 Name
32343 \end_layout
32344
32345 \end_inset
32346 </cell>
32347 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32348 \begin_inset Text
32349
32350 \begin_layout Standard
32351
32352 \series bold
32353 Purpose
32354 \end_layout
32355
32356 \end_inset
32357 </cell>
32358 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32359 \begin_inset Text
32360
32361 \begin_layout Standard
32362
32363 \series bold
32364 Directory
32365 \end_layout
32366
32367 \end_inset
32368 </cell>
32369 </row>
32370 <row topline="true">
32371 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32372 \begin_inset Text
32373
32374 \begin_layout Standard
32375 uCsim
32376 \begin_inset LatexCommand index
32377 name "uCsim"
32378
32379 \end_inset
32380
32381
32382 \end_layout
32383
32384 \end_inset
32385 </cell>
32386 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32387 \begin_inset Text
32388
32389 \begin_layout Standard
32390 Simulator for various architectures
32391 \end_layout
32392
32393 \end_inset
32394 </cell>
32395 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32396 \begin_inset Text
32397
32398 \begin_layout Standard
32399 sdcc/sim/ucsim
32400 \end_layout
32401
32402 \end_inset
32403 </cell>
32404 </row>
32405 <row topline="true">
32406 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32407 \begin_inset Text
32408
32409 \begin_layout Standard
32410 keil2sdcc.pl
32411 \end_layout
32412
32413 \end_inset
32414 </cell>
32415 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32416 \begin_inset Text
32417
32418 \begin_layout Standard
32419 header file
32420 \begin_inset LatexCommand index
32421 name "Header files"
32422
32423 \end_inset
32424
32425
32426 \begin_inset LatexCommand index
32427 name "Include files"
32428
32429 \end_inset
32430
32431  conversion
32432 \end_layout
32433
32434 \end_inset
32435 </cell>
32436 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32437 \begin_inset Text
32438
32439 \begin_layout Standard
32440 sdcc/support/scripts
32441 \end_layout
32442
32443 \end_inset
32444 </cell>
32445 </row>
32446 <row topline="true">
32447 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32448 \begin_inset Text
32449
32450 \begin_layout Standard
32451 mh2h.c
32452 \end_layout
32453
32454 \end_inset
32455 </cell>
32456 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32457 \begin_inset Text
32458
32459 \begin_layout Standard
32460 header file conversion
32461 \end_layout
32462
32463 \end_inset
32464 </cell>
32465 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32466 \begin_inset Text
32467
32468 \begin_layout Standard
32469 sdcc/support/scripts
32470 \end_layout
32471
32472 \end_inset
32473 </cell>
32474 </row>
32475 <row topline="true">
32476 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32477 \begin_inset Text
32478
32479 \begin_layout Standard
32480 as-gbz80
32481 \end_layout
32482
32483 \end_inset
32484 </cell>
32485 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32486 \begin_inset Text
32487
32488 \begin_layout Standard
32489 Assembler
32490 \end_layout
32491
32492 \end_inset
32493 </cell>
32494 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32495 \begin_inset Text
32496
32497 \begin_layout Standard
32498
32499 \family roman
32500 \series medium
32501 \shape up
32502 \size normal
32503 \emph off
32504 \bar no
32505 \noun off
32506 \color none
32507 sdcc/bin
32508 \end_layout
32509
32510 \end_inset
32511 </cell>
32512 </row>
32513 <row topline="true">
32514 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32515 \begin_inset Text
32516
32517 \begin_layout Standard
32518 as-z80
32519 \end_layout
32520
32521 \end_inset
32522 </cell>
32523 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32524 \begin_inset Text
32525
32526 \begin_layout Standard
32527 Assembler
32528 \end_layout
32529
32530 \end_inset
32531 </cell>
32532 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32533 \begin_inset Text
32534
32535 \begin_layout Standard
32536
32537 \family roman
32538 \series medium
32539 \shape up
32540 \size normal
32541 \emph off
32542 \bar no
32543 \noun off
32544 \color none
32545 sdcc/bin
32546 \end_layout
32547
32548 \end_inset
32549 </cell>
32550 </row>
32551 <row topline="true">
32552 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32553 \begin_inset Text
32554
32555 \begin_layout Standard
32556 asx8051
32557 \end_layout
32558
32559 \end_inset
32560 </cell>
32561 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32562 \begin_inset Text
32563
32564 \begin_layout Standard
32565 Assembler
32566 \end_layout
32567
32568 \end_inset
32569 </cell>
32570 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32571 \begin_inset Text
32572
32573 \begin_layout Standard
32574
32575 \family roman
32576 \series medium
32577 \shape up
32578 \size normal
32579 \emph off
32580 \bar no
32581 \noun off
32582 \color none
32583 sdcc/bin
32584 \end_layout
32585
32586 \end_inset
32587 </cell>
32588 </row>
32589 <row topline="true">
32590 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32591 \begin_inset Text
32592
32593 \begin_layout Standard
32594 SDCDB
32595 \end_layout
32596
32597 \end_inset
32598 </cell>
32599 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32600 \begin_inset Text
32601
32602 \begin_layout Standard
32603 Simulator
32604 \end_layout
32605
32606 \end_inset
32607 </cell>
32608 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32609 \begin_inset Text
32610
32611 \begin_layout Standard
32612
32613 \family roman
32614 \series medium
32615 \shape up
32616 \size normal
32617 \emph off
32618 \bar no
32619 \noun off
32620 \color none
32621 sdcc/bin
32622 \end_layout
32623
32624 \end_inset
32625 </cell>
32626 </row>
32627 <row topline="true">
32628 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32629 \begin_inset Text
32630
32631 \begin_layout Standard
32632 aslink
32633 \end_layout
32634
32635 \end_inset
32636 </cell>
32637 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32638 \begin_inset Text
32639
32640 \begin_layout Standard
32641 Linker
32642 \end_layout
32643
32644 \end_inset
32645 </cell>
32646 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32647 \begin_inset Text
32648
32649 \begin_layout Standard
32650
32651 \family roman
32652 \series medium
32653 \shape up
32654 \size normal
32655 \emph off
32656 \bar no
32657 \noun off
32658 \color none
32659 sdcc/bin
32660 \end_layout
32661
32662 \end_inset
32663 </cell>
32664 </row>
32665 <row topline="true">
32666 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32667 \begin_inset Text
32668
32669 \begin_layout Standard
32670 link-z80
32671 \end_layout
32672
32673 \end_inset
32674 </cell>
32675 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32676 \begin_inset Text
32677
32678 \begin_layout Standard
32679 Linker
32680 \end_layout
32681
32682 \end_inset
32683 </cell>
32684 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32685 \begin_inset Text
32686
32687 \begin_layout Standard
32688
32689 \family roman
32690 \series medium
32691 \shape up
32692 \size normal
32693 \emph off
32694 \bar no
32695 \noun off
32696 \color none
32697 sdcc/bin
32698 \end_layout
32699
32700 \end_inset
32701 </cell>
32702 </row>
32703 <row topline="true">
32704 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32705 \begin_inset Text
32706
32707 \begin_layout Standard
32708 link-gbz80
32709 \end_layout
32710
32711 \end_inset
32712 </cell>
32713 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32714 \begin_inset Text
32715
32716 \begin_layout Standard
32717 Linker
32718 \end_layout
32719
32720 \end_inset
32721 </cell>
32722 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32723 \begin_inset Text
32724
32725 \begin_layout Standard
32726
32727 \family roman
32728 \series medium
32729 \shape up
32730 \size normal
32731 \emph off
32732 \bar no
32733 \noun off
32734 \color none
32735 sdcc/bin
32736 \end_layout
32737
32738 \end_inset
32739 </cell>
32740 </row>
32741 <row topline="true" bottomline="true">
32742 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32743 \begin_inset Text
32744
32745 \begin_layout Standard
32746 packihx
32747 \end_layout
32748
32749 \end_inset
32750 </cell>
32751 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32752 \begin_inset Text
32753
32754 \begin_layout Standard
32755 Intel Hex packer 
32756 \begin_inset LatexCommand index
32757 name "packihx (tool)"
32758
32759 \end_inset
32760
32761
32762 \end_layout
32763
32764 \end_inset
32765 </cell>
32766 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32767 \begin_inset Text
32768
32769 \begin_layout Standard
32770
32771 \family roman
32772 \series medium
32773 \shape up
32774 \size normal
32775 \emph off
32776 \bar no
32777 \noun off
32778 \color none
32779 sdcc/bin
32780 \end_layout
32781
32782 \end_inset
32783 </cell>
32784 </row>
32785 </lyxtabular>
32786
32787 \end_inset
32788
32789
32790 \newline
32791
32792 \end_layout
32793
32794 \begin_layout Section
32795 Documentation
32796 \begin_inset LatexCommand index
32797 name "Documentation"
32798
32799 \end_inset
32800
32801  included in the distribution
32802 \end_layout
32803
32804 \begin_layout Standard
32805 \align left
32806 \begin_inset Tabular
32807 <lyxtabular version="3" rows="10" columns="2">
32808 <features>
32809 <column alignment="block" valignment="top" leftline="true" width="40col%">
32810 <column alignment="block" valignment="top" leftline="true" rightline="true" width="60col%">
32811 <row topline="true" bottomline="true" endhead="true">
32812 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32813 \begin_inset Text
32814
32815 \begin_layout Standard
32816
32817 \series bold
32818 Subject / Title
32819 \end_layout
32820
32821 \end_inset
32822 </cell>
32823 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32824 \begin_inset Text
32825
32826 \begin_layout Standard
32827
32828 \series bold
32829 Filename / Where to get
32830 \end_layout
32831
32832 \end_inset
32833 </cell>
32834 </row>
32835 <row topline="true">
32836 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32837 \begin_inset Text
32838
32839 \begin_layout Standard
32840 SDCC Compiler User Guide
32841 \end_layout
32842
32843 \end_inset
32844 </cell>
32845 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32846 \begin_inset Text
32847
32848 \begin_layout Standard
32849 You're reading it right now 
32850 \emph on
32851 \InsetSpace ~
32852 \InsetSpace ~
32853 \InsetSpace ~
32854
32855 \hfill
32856 online at:
32857 \emph default
32858
32859 \newline
32860
32861 \begin_inset LatexCommand url
32862 target "http://sdcc.sourceforge.net/doc/sdccman.pdf"
32863
32864 \end_inset
32865
32866
32867 \end_layout
32868
32869 \end_inset
32870 </cell>
32871 </row>
32872 <row topline="true">
32873 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32874 \begin_inset Text
32875
32876 \begin_layout Standard
32877 Changelog of SDCC
32878 \end_layout
32879
32880 \end_inset
32881 </cell>
32882 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32883 \begin_inset Text
32884
32885 \begin_layout Standard
32886 sdcc/Changelog 
32887 \emph on
32888 \InsetSpace ~
32889 \InsetSpace ~
32890 \InsetSpace ~
32891
32892 \hfill
32893 online at:
32894 \emph default
32895
32896 \newline
32897
32898 \begin_inset LatexCommand url
32899 target "http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/ChangeLog"
32900
32901 \end_inset
32902
32903
32904 \end_layout
32905
32906 \end_inset
32907 </cell>
32908 </row>
32909 <row topline="true">
32910 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32911 \begin_inset Text
32912
32913 \begin_layout Standard
32914 ASXXXX
32915 \begin_inset LatexCommand index
32916 name "asXXXX (as-gbz80, as-hc08, asx8051, as-z80)"
32917
32918 \end_inset
32919
32920
32921 \begin_inset LatexCommand index
32922 name "Assembler documentation"
32923
32924 \end_inset
32925
32926  Assemblers and
32927 \newline
32928 ASLINK
32929 \begin_inset LatexCommand index
32930 name "aslink"
32931
32932 \end_inset
32933
32934
32935 \begin_inset LatexCommand index
32936 name "Linker documentation"
32937
32938 \end_inset
32939
32940  Relocating Linker
32941 \end_layout
32942
32943 \end_inset
32944 </cell>
32945 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32946 \begin_inset Text
32947
32948 \begin_layout Standard
32949 sdcc/as/doc/asxhtm.html 
32950 \emph on
32951 \InsetSpace ~
32952 \InsetSpace ~
32953 \InsetSpace ~
32954
32955 \hfill
32956 online at:
32957 \emph default
32958
32959 \newline
32960
32961 \begin_inset LatexCommand url
32962 target "http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/as/doc/asxhtm.html"
32963
32964 \end_inset
32965
32966
32967 \end_layout
32968
32969 \end_inset
32970 </cell>
32971 </row>
32972 <row topline="true">
32973 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32974 \begin_inset Text
32975
32976 \begin_layout Standard
32977 SDCC regression test
32978 \begin_inset LatexCommand index
32979 name "Regression test"
32980
32981 \end_inset
32982
32983
32984 \end_layout
32985
32986 \end_inset
32987 </cell>
32988 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32989 \begin_inset Text
32990
32991 \begin_layout Standard
32992 sdcc/doc/test_suite_spec.pdf 
32993 \emph on
32994 \InsetSpace ~
32995 \InsetSpace ~
32996 \InsetSpace ~
32997
32998 \hfill
32999 online at:
33000 \emph default
33001
33002 \newline
33003
33004 \begin_inset LatexCommand url
33005 target "http://sdcc.sourceforge.net/doc/test_suite_spec.pdf"
33006
33007 \end_inset
33008
33009
33010 \end_layout
33011
33012 \end_inset
33013 </cell>
33014 </row>
33015 <row topline="true">
33016 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33017 \begin_inset Text
33018
33019 \begin_layout Standard
33020 Various notes
33021 \end_layout
33022
33023 \end_inset
33024 </cell>
33025 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33026 \begin_inset Text
33027
33028 \begin_layout Standard
33029 sdcc/doc/* 
33030 \emph on
33031 \InsetSpace ~
33032 \InsetSpace ~
33033 \InsetSpace ~
33034
33035 \hfill
33036 online at:
33037 \emph default
33038
33039 \newline
33040
33041 \begin_inset LatexCommand url
33042 target "http://sdcc.svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/doc/"
33043
33044 \end_inset
33045
33046
33047 \end_layout
33048
33049 \end_inset
33050 </cell>
33051 </row>
33052 <row topline="true">
33053 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33054 \begin_inset Text
33055
33056 \begin_layout Standard
33057 Notes on debugging with SDCDB
33058 \begin_inset LatexCommand index
33059 name "SDCDB (debugger)"
33060
33061 \end_inset
33062
33063
33064 \end_layout
33065
33066 \end_inset
33067 </cell>
33068 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33069 \begin_inset Text
33070
33071 \begin_layout Standard
33072 sdcc/debugger/README 
33073 \emph on
33074 \InsetSpace ~
33075 \InsetSpace ~
33076 \InsetSpace ~
33077
33078 \hfill
33079 online at
33080 \emph default
33081 :
33082 \newline
33083
33084 \begin_inset LatexCommand url
33085 target "http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/debugger/README"
33086
33087 \end_inset
33088
33089
33090 \end_layout
33091
33092 \end_inset
33093 </cell>
33094 </row>
33095 <row topline="true">
33096 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33097 \begin_inset Text
33098
33099 \begin_layout Standard
33100 uCsim
33101 \begin_inset LatexCommand index
33102 name "uCsim"
33103
33104 \end_inset
33105
33106  Software simulator for microcontrollers
33107 \end_layout
33108
33109 \end_inset
33110 </cell>
33111 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33112 \begin_inset Text
33113
33114 \begin_layout Standard
33115
33116 \family roman
33117 \series medium
33118 \shape up
33119 \size normal
33120 \emph off
33121 \bar no
33122 \noun off
33123 \color none
33124 sdcc/sim/ucsim/doc
33125 \family default
33126 \series default
33127 \shape default
33128 \size default
33129 \emph default
33130 \bar default
33131 \noun default
33132 /index.html 
33133 \emph on
33134 \InsetSpace ~
33135 \InsetSpace ~
33136 \InsetSpace ~
33137
33138 \hfill
33139 online at:
33140 \emph default
33141
33142 \newline
33143
33144 \begin_inset LatexCommand url
33145 target "http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/sim/ucsim/doc/index.html"
33146
33147 \end_inset
33148
33149
33150 \end_layout
33151
33152 \end_inset
33153 </cell>
33154 </row>
33155 <row topline="true">
33156 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33157 \begin_inset Text
33158
33159 \begin_layout Standard
33160 Temporary notes on the pic16
33161 \begin_inset LatexCommand index
33162 name "PIC16"
33163
33164 \end_inset
33165
33166  port
33167 \end_layout
33168
33169 \end_inset
33170 </cell>
33171 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33172 \begin_inset Text
33173
33174 \begin_layout Standard
33175 sdcc/src/pic16/NOTES 
33176 \emph on
33177 \InsetSpace ~
33178 \InsetSpace ~
33179 \InsetSpace ~
33180
33181 \hfill
33182 online at:
33183 \newline
33184
33185 \emph default
33186
33187 \begin_inset LatexCommand url
33188 target "http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/src/pic16/NOTES"
33189
33190 \end_inset
33191
33192
33193 \end_layout
33194
33195 \end_inset
33196 </cell>
33197 </row>
33198 <row topline="true" bottomline="true">
33199 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33200 \begin_inset Text
33201
33202 \begin_layout Standard
33203 SDCC internal documentation (debugging file format)
33204 \end_layout
33205
33206 \end_inset
33207 </cell>
33208 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33209 \begin_inset Text
33210
33211 \begin_layout Standard
33212 sdcc/doc/
33213 \family roman
33214 \series medium
33215 \shape up
33216 \size normal
33217 \emph off
33218 \bar no
33219 \noun off
33220 \color none
33221 cdbfileformat.pd
33222 \family default
33223 \series default
33224 \shape default
33225 \size default
33226 \emph default
33227 \bar default
33228 \noun default
33229
33230 \emph on
33231 \InsetSpace ~
33232 \InsetSpace ~
33233 \InsetSpace ~
33234
33235 \hfill
33236 online at:
33237 \emph default
33238
33239 \newline
33240
33241 \begin_inset LatexCommand url
33242 target "http://sdcc.sourceforge.net/doc/cdbfileformat.pdf"
33243
33244 \end_inset
33245
33246
33247 \end_layout
33248
33249 \end_inset
33250 </cell>
33251 </row>
33252 </lyxtabular>
33253
33254 \end_inset
33255
33256
33257 \newline
33258
33259 \end_layout
33260
33261 \begin_layout Section
33262 Related open source tools
33263 \begin_inset LatexCommand label
33264 name "sec:Related-open-source-tools"
33265
33266 \end_inset
33267
33268
33269 \begin_inset LatexCommand index
33270 name "Related tools"
33271
33272 \end_inset
33273
33274
33275 \end_layout
33276
33277 \begin_layout Standard
33278 \align left
33279 \begin_inset Tabular
33280 <lyxtabular version="3" rows="16" columns="3">
33281 <features>
33282 <column alignment="left" valignment="top" leftline="true" width="0pt">
33283 <column alignment="block" valignment="top" leftline="true" width="30line%">
33284 <column alignment="left" valignment="top" leftline="true" rightline="true" width="40col%">
33285 <row topline="true" bottomline="true">
33286 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33287 \begin_inset Text
33288
33289 \begin_layout Standard
33290
33291 \series bold
33292 Name
33293 \end_layout
33294
33295 \end_inset
33296 </cell>
33297 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33298 \begin_inset Text
33299
33300 \begin_layout Standard
33301
33302 \series bold
33303 Purpose
33304 \end_layout
33305
33306 \end_inset
33307 </cell>
33308 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33309 \begin_inset Text
33310
33311 \begin_layout Standard
33312
33313 \series bold
33314 Where to get
33315 \end_layout
33316
33317 \end_inset
33318 </cell>
33319 </row>
33320 <row topline="true">
33321 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33322 \begin_inset Text
33323
33324 \begin_layout Standard
33325 gpsim
33326 \begin_inset LatexCommand index
33327 name "gpsim (pic simulator)"
33328
33329 \end_inset
33330
33331
33332 \end_layout
33333
33334 \end_inset
33335 </cell>
33336 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33337 \begin_inset Text
33338
33339 \begin_layout Standard
33340 PIC simulator
33341 \end_layout
33342
33343 \end_inset
33344 </cell>
33345 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33346 \begin_inset Text
33347
33348 \begin_layout Standard
33349 \begin_inset LatexCommand url
33350 target "http://www.dattalo.com/gnupic/gpsim.html"
33351
33352 \end_inset
33353
33354
33355 \end_layout
33356
33357 \end_inset
33358 </cell>
33359 </row>
33360 <row topline="true">
33361 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33362 \begin_inset Text
33363
33364 \begin_layout Standard
33365 gputils
33366 \begin_inset LatexCommand index
33367 name "gputils (pic tools)"
33368
33369 \end_inset
33370
33371
33372 \end_layout
33373
33374 \end_inset
33375 </cell>
33376 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33377 \begin_inset Text
33378
33379 \begin_layout Standard
33380 GNU PIC utilities
33381 \end_layout
33382
33383 \end_inset
33384 </cell>
33385 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33386 \begin_inset Text
33387
33388 \begin_layout Standard
33389 \begin_inset LatexCommand url
33390 target "http://sourceforge.net/projects/gputils"
33391
33392 \end_inset
33393
33394
33395 \end_layout
33396
33397 \end_inset
33398 </cell>
33399 </row>
33400 <row topline="true">
33401 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33402 \begin_inset Text
33403
33404 \begin_layout Standard
33405 flP5
33406 \end_layout
33407
33408 \end_inset
33409 </cell>
33410 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33411 \begin_inset Text
33412
33413 \begin_layout Standard
33414 PIC programmer
33415 \end_layout
33416
33417 \end_inset
33418 </cell>
33419 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33420 \begin_inset Text
33421
33422 \begin_layout Standard
33423 \begin_inset LatexCommand url
33424 target "http://freshmeat.net/projects/flp5/"
33425
33426 \end_inset
33427
33428
33429 \end_layout
33430
33431 \end_inset
33432 </cell>
33433 </row>
33434 <row topline="true">
33435 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33436 \begin_inset Text
33437
33438 \begin_layout Standard
33439 ec2drv/newcdb
33440 \end_layout
33441
33442 \end_inset
33443 </cell>
33444 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33445 \begin_inset Text
33446
33447 \begin_layout Standard
33448 Tools for Silicon Laboratories JTAG debug adapter, partly based on SDCDB
33449  (Unix only)
33450 \end_layout
33451
33452 \end_inset
33453 </cell>
33454 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33455 \begin_inset Text
33456
33457 \begin_layout Standard
33458 \begin_inset LatexCommand url
33459 target "http://sourceforge.net/projects/ec2drv"
33460
33461 \end_inset
33462
33463
33464 \end_layout
33465
33466 \end_inset
33467 </cell>
33468 </row>
33469 <row topline="true">
33470 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33471 \begin_inset Text
33472
33473 \begin_layout Standard
33474 indent
33475 \begin_inset LatexCommand index
33476 name "indent (source formatting tool)"
33477
33478 \end_inset
33479
33480
33481 \end_layout
33482
33483 \end_inset
33484 </cell>
33485 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33486 \begin_inset Text
33487
33488 \begin_layout Standard
33489 Formats C source - Master of the white spaces
33490 \end_layout
33491
33492 \end_inset
33493 </cell>
33494 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33495 \begin_inset Text
33496
33497 \begin_layout Standard
33498 \begin_inset LatexCommand url
33499 target "http://directory.fsf.org/GNU/indent.html"
33500
33501 \end_inset
33502
33503
33504 \end_layout
33505
33506 \end_inset
33507 </cell>
33508 </row>
33509 <row topline="true">
33510 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33511 \begin_inset Text
33512
33513 \begin_layout Standard
33514 srecord
33515 \begin_inset LatexCommand index
33516 name "srecord (bin, hex, ... tool)"
33517
33518 \end_inset
33519
33520
33521 \end_layout
33522
33523 \end_inset
33524 </cell>
33525 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33526 \begin_inset Text
33527
33528 \begin_layout Standard
33529 Object file conversion, checksumming, ...
33530 \end_layout
33531
33532 \end_inset
33533 </cell>
33534 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33535 \begin_inset Text
33536
33537 \begin_layout Standard
33538 \begin_inset LatexCommand url
33539 target "http://sourceforge.net/projects/srecord"
33540
33541 \end_inset
33542
33543
33544 \end_layout
33545
33546 \end_inset
33547 </cell>
33548 </row>
33549 <row topline="true">
33550 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33551 \begin_inset Text
33552
33553 \begin_layout Standard
33554 objdump
33555 \begin_inset LatexCommand index
33556 name "objdump (tool)"
33557
33558 \end_inset
33559
33560
33561 \end_layout
33562
33563 \end_inset
33564 </cell>
33565 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33566 \begin_inset Text
33567
33568 \begin_layout Standard
33569 Object file conversion, ...
33570 \end_layout
33571
33572 \end_inset
33573 </cell>
33574 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33575 \begin_inset Text
33576
33577 \begin_layout Standard
33578 Part of binutils (should be there anyway)
33579 \end_layout
33580
33581 \end_inset
33582 </cell>
33583 </row>
33584 <row topline="true">
33585 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33586 \begin_inset Text
33587
33588 \begin_layout Standard
33589 cmon51
33590 \end_layout
33591
33592 \end_inset
33593 </cell>
33594 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33595 \begin_inset Text
33596
33597 \begin_layout Standard
33598 8051 monitor (hex up-/download, single step, disassemble)
33599 \end_layout
33600
33601 \end_inset
33602 </cell>
33603 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33604 \begin_inset Text
33605
33606 \begin_layout Standard
33607 \begin_inset LatexCommand url
33608 target "http://sourceforge.net/projects/cmon51"
33609
33610 \end_inset
33611
33612
33613 \end_layout
33614
33615 \end_inset
33616 </cell>
33617 </row>
33618 <row topline="true">
33619 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33620 \begin_inset Text
33621
33622 \begin_layout Standard
33623 doxygen
33624 \begin_inset LatexCommand index
33625 name "doxygen (source documentation tool)"
33626
33627 \end_inset
33628
33629
33630 \end_layout
33631
33632 \end_inset
33633 </cell>
33634 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33635 \begin_inset Text
33636
33637 \begin_layout Standard
33638 Source code documentation system
33639 \end_layout
33640
33641 \end_inset
33642 </cell>
33643 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33644 \begin_inset Text
33645
33646 \begin_layout Standard
33647 \begin_inset LatexCommand url
33648 target "http://www.doxygen.org"
33649
33650 \end_inset
33651
33652
33653 \end_layout
33654
33655 \end_inset
33656 </cell>
33657 </row>
33658 <row topline="true">
33659 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33660 \begin_inset Text
33661
33662 \begin_layout Standard
33663 kdevelop
33664 \end_layout
33665
33666 \end_inset
33667 </cell>
33668 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33669 \begin_inset Text
33670
33671 \begin_layout Standard
33672 IDE (has anyone tried integrating SDCC & SDCDB? Unix only)
33673 \end_layout
33674
33675 \end_inset
33676 </cell>
33677 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33678 \begin_inset Text
33679
33680 \begin_layout Standard
33681 \begin_inset LatexCommand url
33682 target "http://www.kdevelop.org"
33683
33684 \end_inset
33685
33686
33687 \end_layout
33688
33689 \end_inset
33690 </cell>
33691 </row>
33692 <row topline="true">
33693 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33694 \begin_inset Text
33695
33696 \begin_layout Standard
33697 paulmon
33698 \end_layout
33699
33700 \end_inset
33701 </cell>
33702 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33703 \begin_inset Text
33704
33705 \begin_layout Standard
33706 8051 monitor (hex up-/download, single step, disassemble)
33707 \end_layout
33708
33709 \end_inset
33710 </cell>
33711 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33712 \begin_inset Text
33713
33714 \begin_layout Standard
33715 \begin_inset LatexCommand url
33716 target "http://www.pjrc.com/tech/8051/paulmon2.html"
33717
33718 \end_inset
33719
33720
33721 \end_layout
33722
33723 \end_inset
33724 </cell>
33725 </row>
33726 <row topline="true">
33727 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33728 \begin_inset Text
33729
33730 \begin_layout Standard
33731 splint
33732 \begin_inset LatexCommand index
33733 name "splint (syntax checking tool)"
33734
33735 \end_inset
33736
33737
33738 \end_layout
33739
33740 \end_inset
33741 </cell>
33742 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33743 \begin_inset Text
33744
33745 \begin_layout Standard
33746 Statically checks c sources (see 
33747 \begin_inset LatexCommand ref
33748 reference "lyx:more-pedantic-SPLINT"
33749
33750 \end_inset
33751
33752 )
33753 \end_layout
33754
33755 \end_inset
33756 </cell>
33757 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33758 \begin_inset Text
33759
33760 \begin_layout Standard
33761 \begin_inset LatexCommand url
33762 target "http://www.splint.org"
33763
33764 \end_inset
33765
33766
33767 \end_layout
33768
33769 \end_inset
33770 </cell>
33771 </row>
33772 <row topline="true" bottomline="true">
33773 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33774 \begin_inset Text
33775
33776 \begin_layout Standard
33777 ddd
33778 \begin_inset LatexCommand index
33779 name "DDD (debugger)"
33780
33781 \end_inset
33782
33783
33784 \end_layout
33785
33786 \end_inset
33787 </cell>
33788 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33789 \begin_inset Text
33790
33791 \begin_layout Standard
33792 Debugger, serves nicely as GUI to SDCDB
33793 \begin_inset LatexCommand index
33794 name "SDCDB (debugger)"
33795
33796 \end_inset
33797
33798  (Unix only)
33799 \end_layout
33800
33801 \end_inset
33802 </cell>
33803 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33804 \begin_inset Text
33805
33806 \begin_layout Standard
33807 \begin_inset LatexCommand url
33808 target "http://www.gnu.org/software/ddd/"
33809
33810 \end_inset
33811
33812
33813 \end_layout
33814
33815 \end_inset
33816 </cell>
33817 </row>
33818 <row bottomline="true">
33819 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33820 \begin_inset Text
33821
33822 \begin_layout Standard
33823 d52
33824 \begin_inset LatexCommand index
33825 name "d52"
33826
33827 \end_inset
33828
33829
33830 \begin_inset LatexCommand index
33831 name "d52 (disassembler)"
33832
33833 \end_inset
33834
33835
33836 \end_layout
33837
33838 \end_inset
33839 </cell>
33840 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33841 \begin_inset Text
33842
33843 \begin_layout Standard
33844 Disassembler, can count instruction cycles
33845 \begin_inset LatexCommand index
33846 name "instruction cycles (count)"
33847
33848 \end_inset
33849
33850 , use with options -pnd
33851 \end_layout
33852
33853 \end_inset
33854 </cell>
33855 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33856 \begin_inset Text
33857
33858 \begin_layout Standard
33859 \begin_inset LatexCommand url
33860 target "http://www.8052.com/users/disasm/"
33861
33862 \end_inset
33863
33864
33865 \end_layout
33866
33867 \end_inset
33868 </cell>
33869 </row>
33870 <row bottomline="true">
33871 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33872 \begin_inset Text
33873
33874 \begin_layout Standard
33875 cmake
33876 \begin_inset LatexCommand index
33877 name "cmake"
33878
33879 \end_inset
33880
33881
33882 \end_layout
33883
33884 \end_inset
33885 </cell>
33886 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33887 \begin_inset Text
33888
33889 \begin_layout Standard
33890 Cross platform build system, generates Makefiles
33891 \begin_inset LatexCommand index
33892 name "Makefile"
33893
33894 \end_inset
33895
33896  and project workspaces
33897 \begin_inset LatexCommand index
33898 name "project workspace"
33899
33900 \end_inset
33901
33902
33903 \end_layout
33904
33905 \end_inset
33906 </cell>
33907 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33908 \begin_inset Text
33909
33910 \begin_layout Standard
33911 \begin_inset LatexCommand url
33912 target "http://www.cmake.org"
33913
33914 \end_inset
33915
33916  \InsetSpace ~
33917 \InsetSpace ~
33918 \InsetSpace ~
33919 \InsetSpace ~
33920 and a dedicated wiki entry: 
33921 \begin_inset LatexCommand url
33922 target "http://www.cmake.org/Wiki/CmakeSdcc"
33923
33924 \end_inset
33925
33926
33927 \end_layout
33928
33929 \end_inset
33930 </cell>
33931 </row>
33932 </lyxtabular>
33933
33934 \end_inset
33935
33936
33937 \newline
33938
33939 \end_layout
33940
33941 \begin_layout Section
33942 Related documentation / recommended reading
33943 \end_layout
33944
33945 \begin_layout Standard
33946 \align left
33947 \begin_inset Tabular
33948 <lyxtabular version="3" rows="7" columns="3">
33949 <features>
33950 <column alignment="left" valignment="top" leftline="true" width="0pt">
33951 <column alignment="left" valignment="top" leftline="true" width="0">
33952 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0pt">
33953 <row topline="true" bottomline="true">
33954 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33955 \begin_inset Text
33956
33957 \begin_layout Standard
33958
33959 \series bold
33960 Name
33961 \end_layout
33962
33963 \end_inset
33964 </cell>
33965 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33966 \begin_inset Text
33967
33968 \begin_layout Standard
33969
33970 \series bold
33971 Subject / Title
33972 \end_layout
33973
33974 \end_inset
33975 </cell>
33976 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33977 \begin_inset Text
33978
33979 \begin_layout Standard
33980
33981 \series bold
33982 Where to get
33983 \end_layout
33984
33985 \end_inset
33986 </cell>
33987 </row>
33988 <row topline="true">
33989 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33990 \begin_inset Text
33991
33992 \begin_layout Standard
33993
33994 \family roman
33995 \series medium
33996 \shape up
33997 \size normal
33998 \emph off
33999 \bar no
34000 \noun off
34001 \color none
34002 c-refcard.pdf
34003 \end_layout
34004
34005 \end_inset
34006 </cell>
34007 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34008 \begin_inset Text
34009
34010 \begin_layout Standard
34011 C Reference Card
34012 \begin_inset LatexCommand index
34013 name "C Reference card"
34014
34015 \end_inset
34016
34017 , 2 pages
34018 \end_layout
34019
34020 \end_inset
34021 </cell>
34022 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34023 \begin_inset Text
34024
34025 \begin_layout Standard
34026 \begin_inset LatexCommand url
34027 target "http://refcards.com/refcards/c/index.html"
34028
34029 \end_inset
34030
34031
34032 \end_layout
34033
34034 \end_inset
34035 </cell>
34036 </row>
34037 <row topline="true">
34038 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34039 \begin_inset Text
34040
34041 \begin_layout Standard
34042 c-faq
34043 \end_layout
34044
34045 \end_inset
34046 </cell>
34047 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34048 \begin_inset Text
34049
34050 \begin_layout Standard
34051 C-FAQ
34052 \begin_inset LatexCommand index
34053 name "C FAQ"
34054
34055 \end_inset
34056
34057
34058 \end_layout
34059
34060 \end_inset
34061 </cell>
34062 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34063 \begin_inset Text
34064
34065 \begin_layout Standard
34066 \begin_inset LatexCommand url
34067 target "http://www.c-faq.com"
34068
34069 \end_inset
34070
34071
34072 \end_layout
34073
34074 \end_inset
34075 </cell>
34076 </row>
34077 <row topline="true">
34078 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34079 \begin_inset Text
34080
34081 \begin_layout Standard
34082 ISO/IEC 9899:TC2
34083 \end_layout
34084
34085 \end_inset
34086 </cell>
34087 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34088 \begin_inset Text
34089
34090 \begin_layout Standard
34091 \begin_inset Quotes sld
34092 \end_inset
34093
34094 C-Standard
34095 \begin_inset Quotes srd
34096 \end_inset
34097
34098
34099 \end_layout
34100
34101 \end_inset
34102 </cell>
34103 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34104 \begin_inset Text
34105
34106 \begin_layout Standard
34107
34108 \size footnotesize
34109 \begin_inset LatexCommand url
34110 target "http://www.open-std.org/jtc1/sc22/wg14/www/standards.html#9899"
34111
34112 \end_inset
34113
34114
34115 \end_layout
34116
34117 \end_inset
34118 </cell>
34119 </row>
34120 <row topline="true">
34121 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34122 \begin_inset Text
34123
34124 \begin_layout Standard
34125 ISO/IEC DTR 18037
34126 \end_layout
34127
34128 \end_inset
34129 </cell>
34130 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34131 \begin_inset Text
34132
34133 \begin_layout Standard
34134 \begin_inset Quotes sld
34135 \end_inset
34136
34137 Extensions for Embedded C
34138 \begin_inset Quotes srd
34139 \end_inset
34140
34141
34142 \end_layout
34143
34144 \end_inset
34145 </cell>
34146 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34147 \begin_inset Text
34148
34149 \begin_layout Standard
34150
34151 \size footnotesize
34152 \begin_inset LatexCommand url
34153 target "http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1021.pdf"
34154
34155 \end_inset
34156
34157
34158 \end_layout
34159
34160 \end_inset
34161 </cell>
34162 </row>
34163 <row topline="true">
34164 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34165 \begin_inset Text
34166
34167 \begin_layout Standard
34168
34169 \end_layout
34170
34171 \end_inset
34172 </cell>
34173 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34174 \begin_inset Text
34175
34176 \begin_layout Standard
34177 Latest datasheet of target CPU
34178 \end_layout
34179
34180 \end_inset
34181 </cell>
34182 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34183 \begin_inset Text
34184
34185 \begin_layout Standard
34186 vendor
34187 \end_layout
34188
34189 \end_inset
34190 </cell>
34191 </row>
34192 <row topline="true" bottomline="true">
34193 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34194 \begin_inset Text
34195
34196 \begin_layout Standard
34197
34198 \end_layout
34199
34200 \end_inset
34201 </cell>
34202 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34203 \begin_inset Text
34204
34205 \begin_layout Standard
34206 Revision history of datasheet
34207 \end_layout
34208
34209 \end_inset
34210 </cell>
34211 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34212 \begin_inset Text
34213
34214 \begin_layout Standard
34215 vendor
34216 \end_layout
34217
34218 \end_inset
34219 </cell>
34220 </row>
34221 </lyxtabular>
34222
34223 \end_inset
34224
34225
34226 \newline
34227
34228 \end_layout
34229
34230 \begin_layout Section
34231 Application notes specifically for SDCC
34232 \end_layout
34233
34234 \begin_layout Standard
34235 SDCC makes no claims about the completeness of this list and about up-to-datenes
34236 s or correctness of the application notes
34237 \begin_inset LatexCommand index
34238 name "Application notes"
34239
34240 \end_inset
34241
34242 .
34243 \end_layout
34244
34245 \begin_layout Standard
34246 \align left
34247
34248 \size footnotesize
34249 \begin_inset Tabular
34250 <lyxtabular version="3" rows="7" columns="3">
34251 <features>
34252 <column alignment="block" valignment="top" leftline="true" width="17col%">
34253 <column alignment="block" valignment="top" leftline="true" width="27col%">
34254 <column alignment="block" valignment="top" leftline="true" rightline="true" width="57col%">
34255 <row topline="true" bottomline="true">
34256 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34257 \begin_inset Text
34258
34259 \begin_layout Standard
34260
34261 \series bold
34262 \size footnotesize
34263 Vendor
34264 \end_layout
34265
34266 \end_inset
34267 </cell>
34268 <cell alignment="left" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
34269 \begin_inset Text
34270
34271 \begin_layout Standard
34272
34273 \series bold
34274 \size footnotesize
34275 Subject / Title
34276 \end_layout
34277
34278 \end_inset
34279 </cell>
34280 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34281 \begin_inset Text
34282
34283 \begin_layout Standard
34284
34285 \series bold
34286 \size footnotesize
34287 Where to get
34288 \end_layout
34289
34290 \end_inset
34291 </cell>
34292 </row>
34293 <row topline="true">
34294 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34295 \begin_inset Text
34296
34297 \begin_layout Standard
34298
34299 \size footnotesize
34300 Maxim / Dallas
34301 \end_layout
34302
34303 \end_inset
34304 </cell>
34305 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34306 \begin_inset Text
34307
34308 \begin_layout Standard
34309
34310 \size footnotesize
34311 Using the SDCC Compiler for the DS80C400
34312 \begin_inset LatexCommand index
34313 name "DS80C400"
34314
34315 \end_inset
34316
34317
34318 \end_layout
34319
34320 \end_inset
34321 </cell>
34322 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34323 \begin_inset Text
34324
34325 \begin_layout Standard
34326
34327 \size footnotesize
34328 \begin_inset LatexCommand url
34329 target "http://pdfserv.maxim-ic.com/en/an/AN3346.pdf"
34330
34331 \end_inset
34332
34333
34334 \end_layout
34335
34336 \end_inset
34337 </cell>
34338 </row>
34339 <row topline="true">
34340 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34341 \begin_inset Text
34342
34343 \begin_layout Standard
34344
34345 \size footnotesize
34346 Maxim / Dallas
34347 \end_layout
34348
34349 \end_inset
34350 </cell>
34351 <cell multicolumn="1" alignment="left" valignment="top" topline="true" leftline="true" usebox="none" width="30line%">
34352 \begin_inset Text
34353
34354 \begin_layout Standard
34355
34356 \size footnotesize
34357 Using the Free SDCC C Compiler to Develop Firmware for the DS89C420/430/440/450
34358 \begin_inset LatexCommand index
34359 name "DS89C4x0"
34360
34361 \end_inset
34362
34363  Family of Microcontrollers
34364 \end_layout
34365
34366 \end_inset
34367 </cell>
34368 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34369 \begin_inset Text
34370
34371 \begin_layout Standard
34372
34373 \size footnotesize
34374 \begin_inset LatexCommand url
34375 target "http://pdfserv.maxim-ic.com/en/an/AN3477.pdf"
34376
34377 \end_inset
34378
34379
34380 \end_layout
34381
34382 \end_inset
34383 </cell>
34384 </row>
34385 <row topline="true">
34386 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34387 \begin_inset Text
34388
34389 \begin_layout Standard
34390
34391 \size footnotesize
34392 Silicon Laboratories / Cygnal
34393 \end_layout
34394
34395 \end_inset
34396 </cell>
34397 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34398 \begin_inset Text
34399
34400 \begin_layout Standard
34401
34402 \size footnotesize
34403 Integrating SDCC 8051 Tools Into The Silicon Labs IDE
34404 \begin_inset LatexCommand index
34405 name "IDE"
34406
34407 \end_inset
34408
34409
34410 \end_layout
34411
34412 \end_inset
34413 </cell>
34414 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34415 \begin_inset Text
34416
34417 \begin_layout Standard
34418
34419 \size footnotesize
34420 \begin_inset LatexCommand url
34421 target "http://www.silabs.com/public/documents/tpub_doc/anote/Microcontrollers/en/an198.pdf"
34422
34423 \end_inset
34424
34425
34426 \end_layout
34427
34428 \end_inset
34429 </cell>
34430 </row>
34431 <row topline="true">
34432 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34433 \begin_inset Text
34434
34435 \begin_layout Standard
34436
34437 \size footnotesize
34438 Ramtron / Goal Semiconductor
34439 \end_layout
34440
34441 \end_inset
34442 </cell>
34443 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34444 \begin_inset Text
34445
34446 \begin_layout Standard
34447
34448 \size footnotesize
34449 Interfacing SDCC to Syn and Textpad
34450 \end_layout
34451
34452 \end_inset
34453 </cell>
34454 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34455 \begin_inset Text
34456
34457 \begin_layout Standard
34458
34459 \size footnotesize
34460 \begin_inset LatexCommand url
34461 target "http://www.ramtron.com/doc/Products/Microcontroller/Support_Tools.asp"
34462
34463 \end_inset
34464
34465
34466 \end_layout
34467
34468 \end_inset
34469 </cell>
34470 </row>
34471 <row topline="true">
34472 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34473 \begin_inset Text
34474
34475 \begin_layout Standard
34476
34477 \size footnotesize
34478 Ramtron / Goal Semiconductor
34479 \end_layout
34480
34481 \end_inset
34482 </cell>
34483 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34484 \begin_inset Text
34485
34486 \begin_layout Standard
34487
34488 \size footnotesize
34489 Installing and Configuring SDCC and Crimson Editor 
34490 \end_layout
34491
34492 \end_inset
34493 </cell>
34494 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34495 \begin_inset Text
34496
34497 \begin_layout Standard
34498
34499 \size footnotesize
34500 \begin_inset LatexCommand url
34501 target "http://www.ramtron.com/doc/Products/Microcontroller/Support_Tools.asp"
34502
34503 \end_inset
34504
34505
34506 \end_layout
34507
34508 \end_inset
34509 </cell>
34510 </row>
34511 <row topline="true" bottomline="true">
34512 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34513 \begin_inset Text
34514
34515 \begin_layout Standard
34516
34517 \size footnotesize
34518 Texas Instruments
34519 \end_layout
34520
34521 \end_inset
34522 </cell>
34523 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34524 \begin_inset Text
34525
34526 \begin_layout Standard
34527
34528 \size footnotesize
34529 MSC12xx Programming with SDCC
34530 \end_layout
34531
34532 \end_inset
34533 </cell>
34534 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34535 \begin_inset Text
34536
34537 \begin_layout Standard
34538
34539 \size footnotesize
34540 \begin_inset LatexCommand url
34541 target "http://focus.ti.com/general/docs/lit/getliterature.tsp?literatureNumber=sbaa109&fileType=pdf"
34542
34543 \end_inset
34544
34545
34546 \end_layout
34547
34548 \end_inset
34549 </cell>
34550 </row>
34551 </lyxtabular>
34552
34553 \end_inset
34554
34555
34556 \end_layout
34557
34558 \begin_layout Section
34559 Some Questions
34560 \end_layout
34561
34562 \begin_layout Standard
34563 Some questions answered, some pointers given - it might be time to in turn
34564  ask 
34565 \emph on
34566 you
34567 \emph default
34568  some questions: 
34569 \end_layout
34570
34571 \begin_layout Itemize
34572 can you solve your project with the selected microcontroller? Would you
34573  find out early or rather late that your target is too small/slow/whatever?
34574  Can you switch to a slightly better device if it doesn't fit?
34575 \end_layout
34576
34577 \begin_layout Itemize
34578 should you solve the problem with an 8 bit CPU? Or would a 16/32 bit CPU
34579  and/or another programming language be more adequate? Would an operating
34580  system on the target device help?
34581 \end_layout
34582
34583 \begin_layout Itemize
34584 if you solved the problem, will the marketing department be happy?
34585 \end_layout
34586
34587 \begin_layout Itemize
34588 if the marketing department is happy, will customers be happy?
34589 \end_layout
34590
34591 \begin_layout Itemize
34592 if you're the project manager, marketing department and maybe even the customer
34593  in one person, have you tried to see the project from the outside?
34594 \end_layout
34595
34596 \begin_layout Itemize
34597 is the project done if you think it is done? Or is just that other interface/pro
34598 tocol/feature/configuration/option missing? How about website, manual(s),
34599  internationali(z|s)ation, packaging, labels, 2nd source for components,
34600  electromagnetic compatability/interference, documentation for production,
34601  production test software, update mechanism, patent issues?
34602 \end_layout
34603
34604 \begin_layout Itemize
34605 is your project adequately positioned in that magic triangle: fame, fortune,
34606  fun?
34607 \end_layout
34608
34609 \begin_layout Standard
34610 Maybe not all answers to these questions are known and some answers may
34611  even be 
34612 \emph on
34613 no
34614 \emph default
34615 , nevertheless knowing these questions may help you to avoid burnout
34616 \begin_inset Foot
34617 status open
34618
34619 \begin_layout Standard
34620 burnout is bad for electronic devices, programmers and motorcycle tyres
34621 \end_layout
34622
34623 \end_inset
34624
34625 .
34626  Chances are you didn't want to hear some of them...
34627 \end_layout
34628
34629 \begin_layout Chapter
34630 Support
34631 \begin_inset LatexCommand index
34632 name "Support"
34633
34634 \end_inset
34635
34636
34637 \end_layout
34638
34639 \begin_layout Standard
34640 SDCC has grown to be a large project.
34641  The compiler alone (without the preprocessor, assembler and linker) is
34642  well over 150,000 lines of code (blank stripped).
34643  The open source nature of this project is a key to its continued growth
34644  and support.
34645  You gain the benefit and support of many active software developers and
34646  end users.
34647  Is SDCC perfect? No, that's why we need your help.
34648  The developers take pride in fixing reported bugs.
34649  You can help by reporting the bugs and helping other SDCC users.
34650  There are lots of ways to contribute, and we encourage you to take part
34651  in making SDCC a great software package.
34652  
34653 \end_layout
34654
34655 \begin_layout Standard
34656 The SDCC project is hosted on the SDCC sourceforge site at 
34657 \begin_inset LatexCommand htmlurl
34658 target "http://sourceforge.net/projects/sdcc"
34659
34660 \end_inset
34661
34662 .
34663  You'll find the complete set of mailing lists
34664 \begin_inset LatexCommand index
34665 name "Mailing list(s)"
34666
34667 \end_inset
34668
34669 , forums, bug reporting system, patch submission
34670 \begin_inset LatexCommand index
34671 name "Patch submission"
34672
34673 \end_inset
34674
34675  system, download
34676 \begin_inset LatexCommand index
34677 name "download"
34678
34679 \end_inset
34680
34681  area and Subversion code repository
34682 \begin_inset LatexCommand index
34683 name "Subversion code repository"
34684
34685 \end_inset
34686
34687  there.
34688 \end_layout
34689
34690 \begin_layout Section
34691 Reporting Bugs
34692 \begin_inset LatexCommand index
34693 name "Bug reporting"
34694
34695 \end_inset
34696
34697
34698 \begin_inset LatexCommand index
34699 name "Reporting bugs"
34700
34701 \end_inset
34702
34703
34704 \end_layout
34705
34706 \begin_layout Standard
34707 The recommended way of reporting bugs is using the infrastructure of the
34708  sourceforge site.
34709  You can follow the status of bug reports there and have an overview about
34710  the known bugs.
34711 \end_layout
34712
34713 \begin_layout Standard
34714 Bug reports are automatically forwarded to the developer mailing list and
34715  will be fixed ASAP.
34716  When reporting a bug, it is very useful to include a small test program
34717  (the smaller the better) which reproduces the problem.
34718  If you can isolate the problem by looking at the generated assembly code,
34719  this can be very helpful.
34720  Compiling your program with the -
34721 \begin_inset ERT
34722 status collapsed
34723
34724 \begin_layout Standard
34725
34726
34727 \backslash
34728 /
34729 \end_layout
34730
34731 \end_inset
34732
34733 -dumpall
34734 \begin_inset LatexCommand index
34735 name "-\\/-dumpall"
34736
34737 \end_inset
34738
34739  option can sometimes be useful in locating optimization problems.
34740  When reporting a bug please make sure you:
34741 \end_layout
34742
34743 \begin_layout Enumerate
34744 Attach the code you are compiling with SDCC.
34745  
34746 \end_layout
34747
34748 \begin_layout Enumerate
34749 Specify the exact command you use to run SDCC, or attach your Makefile.
34750  
34751 \end_layout
34752
34753 \begin_layout Enumerate
34754 Specify the SDCC version (type "
34755 \family sans
34756 \series bold
34757 sdcc -v
34758 \family default
34759 \series default
34760 "), your platform, and operating system.
34761  
34762 \end_layout
34763
34764 \begin_layout Enumerate
34765 Provide an exact copy of any error message or incorrect output.
34766  
34767 \end_layout
34768
34769 \begin_layout Enumerate
34770 Put something meaningful in the subject of your message.
34771 \end_layout
34772
34773 \begin_layout Standard
34774 Please attempt to include these 5 important parts, as applicable, in all
34775  requests for support or when reporting any problems or bugs with SDCC.
34776  Though this will make your message lengthy, it will greatly improve your
34777  chance that SDCC users and developers will be able to help you.
34778  Some SDCC developers are frustrated by bug reports without code provided
34779  that they can use to reproduce and ultimately fix the problem, so please
34780  be sure to provide sample code if you are reporting a bug! 
34781 \end_layout
34782
34783 \begin_layout Standard
34784 Please have a short check that you are using a recent version of SDCC and
34785  the bug is not yet known.
34786  This is the link for reporting bugs: 
34787 \begin_inset LatexCommand htmlurl
34788 target "http://sourceforge.net/tracker/?group_id=599&atid=100599"
34789
34790 \end_inset
34791
34792 .
34793  With SDCC on average having more than 200 downloads
34794 \begin_inset LatexCommand index
34795 name "download"
34796
34797 \end_inset
34798
34799  on sourceforge per day
34800 \begin_inset Foot
34801 status open
34802
34803 \begin_layout Standard
34804 220 daily downloads on average Jan-Sept 2006 and about 150 daily downloads
34805  between 2002 and 2005.
34806  This does not include other methods of distribution.
34807 \end_layout
34808
34809 \end_inset
34810
34811  there must be some users.
34812  So it's not exactly easy to find a new bug.
34813  If you find one we need it: 
34814 \emph on
34815 reporting bugs is good
34816 \emph default
34817 .
34818 \end_layout
34819
34820 \begin_layout Section
34821 Requesting Features
34822 \begin_inset LatexCommand label
34823 name "sub:Requesting-Features"
34824
34825 \end_inset
34826
34827
34828 \begin_inset LatexCommand index
34829 name "Feature request"
34830
34831 \end_inset
34832
34833
34834 \begin_inset LatexCommand index
34835 name "Requesting features"
34836
34837 \end_inset
34838
34839
34840 \end_layout
34841
34842 \begin_layout Standard
34843 Like bug reports feature requests are forwarded to the developer mailing
34844  list.
34845  This is the link for requesting features: 
34846 \begin_inset LatexCommand htmlurl
34847 target "http://sourceforge.net/tracker/?group_id=599&atid=350599"
34848
34849 \end_inset
34850
34851 .
34852 \end_layout
34853
34854 \begin_layout Section
34855 Submitting patches
34856 \end_layout
34857
34858 \begin_layout Standard
34859 Like bug reports contributed patches are forwarded to the developer mailing
34860  list.
34861  This is the link for submitting patches
34862 \begin_inset LatexCommand index
34863 name "Patch submission"
34864
34865 \end_inset
34866
34867
34868 \begin_inset LatexCommand url
34869 target "http://sourceforge.net/tracker/?group_id=599&atid=300599"
34870
34871 \end_inset
34872
34873 .
34874 \end_layout
34875
34876 \begin_layout Standard
34877 You need to specify some parameters to the 
34878 \family typewriter
34879 diff
34880 \family default
34881  command for the patches to be useful.
34882  If you modified more than one file a patch created f.e.
34883  with 
34884 \family sans
34885 \series bold
34886
34887 \begin_inset Quotes sld
34888 \end_inset
34889
34890 diff -Naur unmodified_directory modified_directory >my_changes.patch
34891 \begin_inset Quotes srd
34892 \end_inset
34893
34894
34895 \family default
34896 \series default
34897  will be fine, otherwise 
34898 \family sans
34899 \series bold
34900
34901 \begin_inset Quotes sld
34902 \end_inset
34903
34904 diff -u sourcefile.c.orig sourcefile.c >my_changes.patch
34905 \begin_inset Quotes srd
34906 \end_inset
34907
34908
34909 \family default
34910 \series default
34911  will do.
34912 \end_layout
34913
34914 \begin_layout Section
34915 Getting Help
34916 \end_layout
34917
34918 \begin_layout Standard
34919 These links should take you directly to the 
34920 \begin_inset LatexCommand url
34921 name "Mailing lists"
34922 target "http://sourceforge.net/mail/?group_id=599"
34923
34924 \end_inset
34925
34926
34927 \begin_inset Foot
34928 status open
34929
34930 \begin_layout Standard
34931 Traffic on sdcc-devel and sdcc-user is about 100 mails/month each not counting
34932  automated messages (mid 2003)
34933 \end_layout
34934
34935 \end_inset
34936
34937  and the 
34938 \begin_inset LatexCommand url
34939 name "Forums"
34940 target "http://sourceforge.net/forum/?group_id=599"
34941
34942 \end_inset
34943
34944 , lists
34945 \begin_inset LatexCommand index
34946 name "Mailing list(s)"
34947
34948 \end_inset
34949
34950  and forums are archived and searchable so if you are lucky someone already
34951  had a similar problem.
34952  While mails to the lists themselves are delivered promptly their web front
34953  end on sourceforge sometimes shows a severe time lag (up to several weeks),
34954  if you're seriously using SDCC please consider subscribing to the lists.
34955 \end_layout
34956
34957 \begin_layout Section
34958 ChangeLog
34959 \end_layout
34960
34961 \begin_layout Standard
34962 You can follow the status of the Subversion version
34963 \begin_inset LatexCommand index
34964 name "version"
34965
34966 \end_inset
34967
34968  of SDCC by watching the Changelog
34969 \begin_inset LatexCommand index
34970 name "Changelog"
34971
34972 \end_inset
34973
34974  in the Subversion repository
34975 \size footnotesize
34976  
34977 \begin_inset LatexCommand htmlurl
34978 target "http://sdcc.svn.sourceforge.net/viewcvs.cgi/*checkout*/sdcc/trunk/sdcc/ChangeLog"
34979
34980 \end_inset
34981
34982 .
34983 \end_layout
34984
34985 \begin_layout Section
34986 Subversion Source Code Repository
34987 \end_layout
34988
34989 \begin_layout Standard
34990 The output of 
34991 \family sans
34992 \series bold
34993 sdcc -
34994 \family default
34995
34996 \begin_inset ERT
34997 status open
34998
34999 \begin_layout Standard
35000
35001
35002 \backslash
35003 /
35004 \end_layout
35005
35006 \end_inset
35007
35008
35009 \family sans
35010 -version
35011 \family default
35012 \series default
35013  or the filenames of the snapshot versions of SDCC include date and its
35014  Subversion
35015 \begin_inset LatexCommand index
35016 name "Subversion code repository"
35017
35018 \end_inset
35019
35020  number.
35021  Subversion allows to download the source of recent or previous versions
35022  
35023 \begin_inset LatexCommand url
35024 target "http://sourceforge.net/svn/?group_id=599"
35025
35026 \end_inset
35027
35028  (by number or by date).
35029  An on-line source code browser and detailled instructions are also available
35030  there.
35031  SDCC versions starting from 1999 up to now are available (currently the
35032  versions prior to the conversion from cvs
35033 \begin_inset LatexCommand index
35034 name "cvs|see{Subversion}"
35035
35036 \end_inset
35037
35038  to Subversion (April 2006) are either by accessible by Subversion or by
35039  cvs).
35040 \end_layout
35041
35042 \begin_layout Section
35043 Release policy
35044 \begin_inset LatexCommand index
35045 name "Release policy"
35046
35047 \end_inset
35048
35049
35050 \end_layout
35051
35052 \begin_layout Standard
35053 Historically there often were long delays between official releases and
35054  the sourceforge download area tends to get not updated at all.
35055  Excuses in the past might have referred to problems with live range analysis,
35056  but as this was fixed a while ago, the current problem is that another
35057  excuse has to be found.
35058  Kidding aside, we have to get better there! On the other hand there are
35059  daily snapshots available at 
35060 \begin_inset LatexCommand htmlurl
35061 name "snap"
35062 target "http://sdcc.sourceforge.net/snap.php"
35063
35064 \end_inset
35065
35066 , and you can always build the very last version (hopefully with many bugs
35067  fixed, and features added) from the source code available at 
35068 \begin_inset LatexCommand htmlurl
35069 name "Source"
35070 target "http://sdcc.sourceforge.net/snap.php#Source"
35071
35072 \end_inset
35073
35074 .
35075  The SDCC Wiki
35076 \begin_inset LatexCommand index
35077 name "wiki"
35078
35079 \end_inset
35080
35081
35082 \begin_inset LatexCommand index
35083 name "SDCC Wiki"
35084
35085 \end_inset
35086
35087  at 
35088 \begin_inset LatexCommand url
35089 target "http://sdcc.wiki.sourceforge.net/"
35090
35091 \end_inset
35092
35093  also holds some information about past and future releases.
35094 \end_layout
35095
35096 \begin_layout Section
35097 Examples
35098 \begin_inset LatexCommand index
35099 name "Examples"
35100
35101 \end_inset
35102
35103
35104 \end_layout
35105
35106 \begin_layout Standard
35107 You'll find some small examples in the directory 
35108 \emph on
35109 sdcc/device/examples/.
35110
35111 \emph default
35112  More examples and libraries are available at 
35113 \emph on
35114 The SDCC Open Knowledge Resource 
35115 \begin_inset LatexCommand url
35116 target "http://sdccokr.dl9sec.de/"
35117
35118 \end_inset
35119
35120
35121 \emph default
35122  web site or at 
35123 \begin_inset LatexCommand url
35124 target "http://www.pjrc.com/tech/8051/"
35125
35126 \end_inset
35127
35128 .
35129 \end_layout
35130
35131 \begin_layout Standard
35132 \begin_inset Note Note
35133 status collapsed
35134
35135 \begin_layout Standard
35136 I did insert a reference to Paul's web site here although it seems rather
35137  dedicated to a specific 8032 board (I think it's okay because it f.e.
35138  shows LCD/Harddisc interface and has a free 8051 monitor.
35139  Independent 8032 board vendors face hard competition of heavily subsidized
35140  development boards anyway).
35141 \end_layout
35142
35143 \begin_layout Standard
35144 Maybe we should include some links to real world applications.
35145  Preferably pointer to pointers (one for each architecture) so this stays
35146  manageable here?
35147 \end_layout
35148
35149 \end_inset
35150
35151
35152 \end_layout
35153
35154 \begin_layout Section
35155 Quality control
35156 \begin_inset LatexCommand label
35157 name "sec:Quality-control"
35158
35159 \end_inset
35160
35161
35162 \begin_inset LatexCommand index
35163 name "Quality control"
35164
35165 \end_inset
35166
35167
35168 \end_layout
35169
35170 \begin_layout Standard
35171 The compiler is passed through snaphot build compile and build checks.
35172  The so called 
35173 \shape italic
35174 regression tests
35175 \shape default
35176
35177 \begin_inset LatexCommand index
35178 name "Regression test"
35179
35180 \end_inset
35181
35182  check that SDCC itself compiles flawlessly on several host platforms (i386,
35183  Opteron, 64 bit Alpha, ppc64, Mac OS X on ppc and i386, Solaris on Sparc)
35184  and checks the quality of the code generated by SDCC by running the code
35185  for several target platforms through simulators.
35186  The regression test suite comprises more than 100 files which expand to
35187  more than 500 test cases which include more than 4500 tests.
35188  The results of these tests are published daily on SDCC's snapshot page
35189  (click on the red or green symbols on the right side of 
35190 \begin_inset LatexCommand url
35191 target "http://sdcc.sourceforge.net/snap.php"
35192
35193 \end_inset
35194
35195 ).
35196 \end_layout
35197
35198 \begin_layout Standard
35199 There is a separate document 
35200 \shape italic
35201 test_suite.pdf 
35202 \begin_inset LatexCommand index
35203 name "Test suite"
35204
35205 \end_inset
35206
35207
35208 \shape default
35209  
35210 \begin_inset LatexCommand url
35211 target "http://sdcc.sourceforge.net/doc/test_suite_spec.pdf"
35212
35213 \end_inset
35214
35215  about the regression test suite.
35216 \end_layout
35217
35218 \begin_layout Standard
35219 You'll find the test code in the directory 
35220 \shape italic
35221 sdcc/support/regression
35222 \shape default
35223 .
35224  You can run these tests manually by running 
35225 \family sans
35226 make
35227 \family default
35228  in this directory (or f.e.
35229  
35230 \family sans
35231 \series bold
35232
35233 \begin_inset Quotes sld
35234 \end_inset
35235
35236 make test-mcs51
35237 \begin_inset Quotes srd
35238 \end_inset
35239
35240
35241 \family default
35242 \series default
35243  if you don't want to run the complete tests).
35244  The test code might also be interesting if you want to look for examples
35245 \begin_inset LatexCommand index
35246 name "Examples"
35247
35248 \end_inset
35249
35250  checking corner cases of SDCC or if you plan to submit patches
35251 \begin_inset LatexCommand index
35252 name "Patch submission"
35253
35254 \end_inset
35255
35256 .
35257 \end_layout
35258
35259 \begin_layout Standard
35260 The PIC14 port uses a different set of regression tests 
35261 \begin_inset LatexCommand index
35262 name "Regression test (PIC14)"
35263
35264 \end_inset
35265
35266 , you'll find them in the directory 
35267 \shape italic
35268 sdcc/src/regression
35269 \shape default
35270 .
35271 \end_layout
35272
35273 \begin_layout Section
35274 Use of SDCC in Education
35275 \end_layout
35276
35277 \begin_layout Standard
35278 In short: 
35279 \emph on
35280 highly
35281 \emph default
35282  encouraged
35283 \begin_inset Foot
35284 status open
35285
35286 \begin_layout Standard
35287 the phrase "use in education" might evoke the association "
35288 \emph on
35289 only
35290 \emph default
35291  fit for use in education".
35292  This connotation is not intended but nevertheless risked as the licensing
35293  of SDCC makes it difficult to offer educational discounts
35294 \end_layout
35295
35296 \end_inset
35297
35298 .
35299  If your rationales are to:
35300 \end_layout
35301
35302 \begin_layout Enumerate
35303 give students a chance to understand the 
35304 \emph on
35305 complete
35306 \emph default
35307  steps of code generation
35308 \end_layout
35309
35310 \begin_layout Enumerate
35311 have a curriculum that can be extended for years.
35312  Then you could use an fpga board as target and your curriculum will seamlessly
35313  extend from logic synthesis (
35314 \begin_inset LatexCommand url
35315 name "http://www.opencores.org"
35316 target "opencores.org"
35317
35318 \end_inset
35319
35320
35321 \begin_inset LatexCommand url
35322 name "Oregano"
35323 target "http://www.oregano.at/ip/ip01.htm"
35324
35325 \end_inset
35326
35327 ), over assembly programming, to C to FPGA compilers (
35328 \begin_inset LatexCommand url
35329 name "FPGAC"
35330 target "http://sf.net/projects/fpgac"
35331
35332 \end_inset
35333
35334 ) and to C.
35335 \end_layout
35336
35337 \begin_layout Enumerate
35338 be able to insert excursions about skills like using a revision control
35339  system, submitting/applying patches, using a type-setting (as opposed to
35340  word-processing) engine LyX/LaTeX, using 
35341 \begin_inset LatexCommand url
35342 name "SourceForge"
35343 target "http://www.sf.net"
35344
35345 \end_inset
35346
35347 , following some 
35348 \begin_inset LatexCommand url
35349 name "netiquette"
35350 target "http://en.wikipedia.org/wiki/Netiquette"
35351
35352 \end_inset
35353
35354 , understanding BSD/LGPL/GPL/Proprietary licensing, growth models of Open
35355  Source Software, CPU simulation, compiler regression tests
35356 \begin_inset LatexCommand index
35357 name "Regression test"
35358
35359 \end_inset
35360
35361 .
35362  
35363 \newline
35364 And if there should be a shortage of ideas then you can always point students
35365  to the ever-growing feature request list 
35366 \begin_inset LatexCommand htmlurl
35367 target "http://sourceforge.net/tracker/?group_id=599&atid=350599"
35368
35369 \end_inset
35370
35371 .
35372 \end_layout
35373
35374 \begin_layout Enumerate
35375 not tie students to a specific host platform and instead allow them to use
35376  a host platform of 
35377 \emph on
35378 their
35379 \emph default
35380  choice (among them Alpha, i386, i386_64, Mac OS X, Mips, Sparc, Windows
35381  and eventually 
35382 \begin_inset LatexCommand url
35383 name "OLPC"
35384 target "http://www.laptop.org"
35385
35386 \end_inset
35387
35388 )
35389 \end_layout
35390
35391 \begin_layout Enumerate
35392 not encourage students to use illegal copies of educational software
35393 \end_layout
35394
35395 \begin_layout Enumerate
35396 be immune to licensing/availability/price changes of the chosen tool chain
35397 \end_layout
35398
35399 \begin_layout Enumerate
35400 be able to change to a new target platform without having to adopt a new
35401  tool chain
35402 \end_layout
35403
35404 \begin_layout Enumerate
35405 have complete control over and insight into the tool chain
35406 \end_layout
35407
35408 \begin_layout Enumerate
35409 make your students aware about the pros and cons of open source software
35410  development
35411 \end_layout
35412
35413 \begin_layout Enumerate
35414 give back to the public as you are probably at least partially publicly
35415  funded
35416 \end_layout
35417
35418 \begin_layout Enumerate
35419 give students a chance to publicly prove their skills and to possibly see
35420  a world wide impact
35421 \end_layout
35422
35423 \begin_layout Standard
35424 then SDCC is probably among the first choices.
35425  Well, probably SDCC might be the only choice.
35426 \newpage
35427
35428 \end_layout
35429
35430 \begin_layout Chapter
35431 SDCC Technical Data
35432 \end_layout
35433
35434 \begin_layout Section
35435 Optimizations
35436 \begin_inset LatexCommand index
35437 name "Optimizations"
35438
35439 \end_inset
35440
35441
35442 \end_layout
35443
35444 \begin_layout Standard
35445 SDCC performs a host of standard optimizations in addition to some MCU specific
35446  optimizations.
35447  
35448 \end_layout
35449
35450 \begin_layout Subsection
35451 Sub-expression Elimination
35452 \begin_inset LatexCommand index
35453 name "Subexpression elimination"
35454
35455 \end_inset
35456
35457
35458 \end_layout
35459
35460 \begin_layout Standard
35461 The compiler does local and 
35462 \emph on
35463 g
35464 \emph default
35465 lobal 
35466 \emph on
35467 c
35468 \emph default
35469 ommon 
35470 \emph on
35471 s
35472 \emph default
35473 ubexpression 
35474 \emph on
35475 e
35476 \emph default
35477 limination, e.g.: 
35478 \end_layout
35479
35480 \begin_layout Verse
35481
35482 \family typewriter
35483 i = x + y + 1; 
35484 \newline
35485 j = x + y;
35486 \end_layout
35487
35488 \begin_layout Standard
35489 will be translated to
35490 \end_layout
35491
35492 \begin_layout Verse
35493
35494 \family typewriter
35495 iTemp = x + y; 
35496 \newline
35497 i = iTemp + 1; 
35498 \newline
35499 j = iTemp;
35500 \end_layout
35501
35502 \begin_layout Standard
35503 Some subexpressions are not as obvious as the above example, e.g.:
35504 \end_layout
35505
35506 \begin_layout Verse
35507
35508 \family typewriter
35509 a->b[i].c = 10; 
35510 \newline
35511 a->b[i].d = 11;
35512 \end_layout
35513
35514 \begin_layout Standard
35515 In this case the address arithmetic a->b[i] will be computed only once;
35516  the equivalent code in C would be.
35517 \end_layout
35518
35519 \begin_layout Verse
35520
35521 \family typewriter
35522 iTemp = a->b[i]; 
35523 \newline
35524 iTemp.c = 10; 
35525 \newline
35526 iTemp.d = 11;
35527 \end_layout
35528
35529 \begin_layout Standard
35530 The compiler will try to keep these temporary variables in registers.
35531 \end_layout
35532
35533 \begin_layout Subsection
35534 Dead-Code Elimination
35535 \begin_inset LatexCommand index
35536 name "Dead-code elimination"
35537
35538 \end_inset
35539
35540
35541 \end_layout
35542
35543 \begin_layout Verse
35544
35545 \family typewriter
35546 int global;
35547 \newline
35548
35549 \newline
35550 void f () { 
35551 \newline
35552 \InsetSpace ~
35553 \InsetSpace ~
35554 int i; 
35555 \newline
35556 \InsetSpace ~
35557 \InsetSpace ~
35558 i = 1; \InsetSpace ~
35559 \InsetSpace ~
35560 \InsetSpace ~
35561 \InsetSpace ~
35562 \InsetSpace ~
35563 /* dead store */ 
35564 \newline
35565 \InsetSpace ~
35566 \InsetSpace ~
35567 global = 1;\InsetSpace ~
35568 /* dead
35569  store */ 
35570 \newline
35571 \InsetSpace ~
35572 \InsetSpace ~
35573 global = 2; 
35574 \newline
35575 \InsetSpace ~
35576 \InsetSpace ~
35577 return; 
35578 \newline
35579 \InsetSpace ~
35580 \InsetSpace ~
35581 global = 3;\InsetSpace ~
35582 /* unreachable */ 
35583 \newline
35584 }
35585 \end_layout
35586
35587 \begin_layout Standard
35588 will be changed to
35589 \end_layout
35590
35591 \begin_layout Verse
35592
35593 \family typewriter
35594 int global;
35595 \newline
35596
35597 \newline
35598 void f () {
35599 \newline
35600 \InsetSpace ~
35601 \InsetSpace ~
35602 global = 2; 
35603 \newline
35604 }
35605 \end_layout
35606
35607 \begin_layout Subsection
35608 Copy-Propagation
35609 \begin_inset LatexCommand index
35610 name "Copy propagation"
35611
35612 \end_inset
35613
35614
35615 \end_layout
35616
35617 \begin_layout Verse
35618
35619 \family typewriter
35620 int f() { 
35621 \newline
35622 \InsetSpace ~
35623 \InsetSpace ~
35624 int i, j; 
35625 \newline
35626 \InsetSpace ~
35627 \InsetSpace ~
35628 i = 10; 
35629 \newline
35630 \InsetSpace ~
35631 \InsetSpace ~
35632 j = i; 
35633 \newline
35634 \InsetSpace ~
35635 \InsetSpace ~
35636 return j; 
35637 \newline
35638 }
35639 \end_layout
35640
35641 \begin_layout Standard
35642 will be changed to 
35643 \end_layout
35644
35645 \begin_layout Verse
35646
35647 \family typewriter
35648 int f() { 
35649 \newline
35650 \InsetSpace ~
35651 \InsetSpace ~
35652 int i, j; 
35653 \newline
35654 \InsetSpace ~
35655 \InsetSpace ~
35656 i = 10; 
35657 \newline
35658 \InsetSpace ~
35659 \InsetSpace ~
35660 j = 10; 
35661 \newline
35662 \InsetSpace ~
35663 \InsetSpace ~
35664 return 10; 
35665 \newline
35666 }
35667 \end_layout
35668
35669 \begin_layout Standard
35670 Note: the dead stores created by this copy propagation will be eliminated
35671  by dead-code elimination.
35672 \end_layout
35673
35674 \begin_layout Subsection
35675 Loop Optimizations
35676 \begin_inset LatexCommand index
35677 name "Loop optimization"
35678
35679 \end_inset
35680
35681
35682 \begin_inset LatexCommand label
35683 name "sub:Loop-Optimizations"
35684
35685 \end_inset
35686
35687
35688 \end_layout
35689
35690 \begin_layout Standard
35691 Two types of loop optimizations are done by SDCC 
35692 \emph on
35693 loop invariant
35694 \emph default
35695  lifting and 
35696 \emph on
35697 strength reduction
35698 \emph default
35699  of loop induction variables.
35700  In addition to the strength reduction the optimizer marks the induction
35701  variables and the register allocator tries to keep the induction variables
35702  in registers for the duration of the loop.
35703  Because of this preference of the register allocator
35704 \begin_inset LatexCommand index
35705 name "Register allocation"
35706
35707 \end_inset
35708
35709 , loop induction optimization causes an increase in register pressure, which
35710  may cause unwanted spilling of other temporary variables into the stack
35711 \begin_inset LatexCommand index
35712 name "stack"
35713
35714 \end_inset
35715
35716  / data space.
35717  The compiler will generate a warning message when it is forced to allocate
35718  extra space either on the stack or data space.
35719  If this extra space allocation is undesirable then induction optimization
35720  can be eliminated either for the entire source file (with -
35721 \begin_inset ERT
35722 status collapsed
35723
35724 \begin_layout Standard
35725
35726
35727 \backslash
35728 /
35729 \end_layout
35730
35731 \end_inset
35732
35733 -noinduction option) or for a given function only using #pragma\InsetSpace ~
35734 noinduction
35735 \begin_inset LatexCommand index
35736 name "\\#pragma noinduction"
35737
35738 \end_inset
35739
35740 .
35741 \newline
35742
35743 \newline
35744 Loop Invariant:
35745 \end_layout
35746
35747 \begin_layout Verse
35748
35749 \family typewriter
35750 for (i = 0 ; i < 100 ; i ++) 
35751 \newline
35752 \InsetSpace ~
35753 \InsetSpace ~
35754 \InsetSpace ~
35755 \InsetSpace ~
35756 f += k + l;
35757 \end_layout
35758
35759 \begin_layout Standard
35760 changed to
35761 \end_layout
35762
35763 \begin_layout Verse
35764
35765 \family typewriter
35766 itemp = k + l; 
35767 \newline
35768 for (i = 0; i < 100; i++) 
35769 \newline
35770 \InsetSpace ~
35771 \InsetSpace ~
35772 \InsetSpace ~
35773 \InsetSpace ~
35774 f += itemp;
35775 \end_layout
35776
35777 \begin_layout Standard
35778 As mentioned previously some loop invariants are not as apparent, all static
35779  address computations are also moved out of the loop.
35780 \newline
35781
35782 \newline
35783 Strength Reduction
35784 \begin_inset LatexCommand index
35785 name "Strength reduction"
35786
35787 \end_inset
35788
35789 , this optimization substitutes an expression by a cheaper expression:
35790 \end_layout
35791
35792 \begin_layout Verse
35793
35794 \family typewriter
35795 for (i=0;i < 100; i++)
35796 \newline
35797 \InsetSpace ~
35798 \InsetSpace ~
35799 \InsetSpace ~
35800 \InsetSpace ~
35801 ar[i*5] = i*3;
35802 \end_layout
35803
35804 \begin_layout Standard
35805 changed to
35806 \end_layout
35807
35808 \begin_layout Verse
35809
35810 \family typewriter
35811 itemp1 = 0; 
35812 \newline
35813 itemp2 = 0; 
35814 \newline
35815 for (i=0;i< 100;i++) { 
35816 \newline
35817 \InsetSpace ~
35818 \InsetSpace ~
35819 \InsetSpace ~
35820 \InsetSpace ~
35821 ar[itemp1] = itemp2; 
35822 \newline
35823 \InsetSpace ~
35824 \InsetSpace ~
35825 \InsetSpace ~
35826 \InsetSpace ~
35827 itemp1
35828  += 5; 
35829 \newline
35830 \InsetSpace ~
35831 \InsetSpace ~
35832 \InsetSpace ~
35833 \InsetSpace ~
35834 itemp2 += 3; 
35835 \newline
35836 }
35837 \end_layout
35838
35839 \begin_layout Standard
35840 The more expensive multiplication
35841 \begin_inset LatexCommand index
35842 name "Multiplication"
35843
35844 \end_inset
35845
35846  is changed to a less expensive addition.
35847 \end_layout
35848
35849 \begin_layout Subsection
35850 Loop Reversing
35851 \begin_inset LatexCommand index
35852 name "Loop reversing"
35853
35854 \end_inset
35855
35856
35857 \end_layout
35858
35859 \begin_layout Standard
35860 This optimization is done to reduce the overhead of checking loop boundaries
35861  for every iteration.
35862  Some simple loops can be reversed and implemented using a 
35863 \begin_inset Quotes eld
35864 \end_inset
35865
35866 decrement and jump if not zero
35867 \begin_inset Quotes erd
35868 \end_inset
35869
35870  instruction.
35871  SDCC checks for the following criterion to determine if a loop is reversible
35872  (note: more sophisticated compilers use data-dependency analysis to make
35873  this determination, SDCC uses a more simple minded analysis).
35874 \end_layout
35875
35876 \begin_layout Itemize
35877 The 'for' loop is of the form 
35878 \newline
35879
35880 \newline
35881
35882 \family typewriter
35883 for(<symbol> = <expression>; <sym> [< | <=] <expression>; [<sym>++ | <sym>
35884  += 1])
35885 \newline
35886 \InsetSpace ~
35887 \InsetSpace ~
35888 \InsetSpace ~
35889 \InsetSpace ~
35890 <for body>
35891 \end_layout
35892
35893 \begin_layout Itemize
35894 The <for body> does not contain 
35895 \begin_inset Quotes eld
35896 \end_inset
35897
35898 continue
35899 \begin_inset Quotes erd
35900 \end_inset
35901
35902  or 'break
35903 \begin_inset Quotes erd
35904 \end_inset
35905
35906 .
35907 \end_layout
35908
35909 \begin_layout Itemize
35910 All goto's are contained within the loop.
35911 \end_layout
35912
35913 \begin_layout Itemize
35914 No function calls within the loop.
35915 \end_layout
35916
35917 \begin_layout Itemize
35918 The loop control variable <sym> is not assigned any value within the loop
35919 \end_layout
35920
35921 \begin_layout Itemize
35922 The loop control variable does NOT participate in any arithmetic operation
35923  within the loop.
35924 \end_layout
35925
35926 \begin_layout Itemize
35927 There are NO switch statements in the loop.
35928 \end_layout
35929
35930 \begin_layout Subsection
35931 Algebraic Simplifications
35932 \end_layout
35933
35934 \begin_layout Standard
35935 SDCC does numerous algebraic simplifications, the following is a small sub-set
35936  of these optimizations.
35937 \end_layout
35938
35939 \begin_layout Verse
35940
35941 \family typewriter
35942 i = j + 0;\InsetSpace ~
35943 \InsetSpace ~
35944 \InsetSpace ~
35945 \InsetSpace ~
35946  /* changed to: */\InsetSpace ~
35947 \InsetSpace ~
35948 \InsetSpace ~
35949 \InsetSpace ~
35950  i = j; 
35951 \newline
35952 i /= 2;\InsetSpace ~
35953 \InsetSpace ~
35954 \InsetSpace ~
35955 \InsetSpace ~
35956 \InsetSpace ~
35957 \InsetSpace ~
35958 \InsetSpace ~
35959  /* changed to: */\InsetSpace ~
35960 \InsetSpace ~
35961 \InsetSpace ~
35962 \InsetSpace ~
35963  i >>= 1; 
35964 \newline
35965 i
35966  = j - j;\InsetSpace ~
35967 \InsetSpace ~
35968 \InsetSpace ~
35969 \InsetSpace ~
35970  /* changed to: */\InsetSpace ~
35971 \InsetSpace ~
35972 \InsetSpace ~
35973 \InsetSpace ~
35974  i = 0; 
35975 \newline
35976 i = j / 1;\InsetSpace ~
35977 \InsetSpace ~
35978 \InsetSpace ~
35979 \InsetSpace ~
35980  /* changed to: */\InsetSpace ~
35981 \InsetSpace ~
35982 \InsetSpace ~
35983 \InsetSpace ~
35984  i = j;
35985 \end_layout
35986
35987 \begin_layout Standard
35988 Note the subexpressions
35989 \begin_inset LatexCommand index
35990 name "Subexpression"
35991
35992 \end_inset
35993
35994  given above are generally introduced by macro expansions or as a result
35995  of copy/constant propagation.
35996 \end_layout
35997
35998 \begin_layout Subsection
35999 'switch' Statements
36000 \begin_inset LatexCommand label
36001 name "sub:'switch'-Statements"
36002
36003 \end_inset
36004
36005
36006 \begin_inset LatexCommand index
36007 name "switch statement"
36008
36009 \end_inset
36010
36011
36012 \end_layout
36013
36014 \begin_layout Standard
36015 SDCC can optimize switch statements to jump tables
36016 \begin_inset LatexCommand index
36017 name "jump tables"
36018
36019 \end_inset
36020
36021 .
36022  It makes the decision based on an estimate of the generated code size.
36023  SDCC is quite liberal in the requirements for jump table generation: 
36024 \end_layout
36025
36026 \begin_layout Itemize
36027 The labels need not be in order, and the starting number need not be one
36028  or zero, the case labels are in numerical sequence or not too many case
36029  labels are missing.
36030 \end_layout
36031
36032 \begin_deeper
36033 \begin_layout Verse
36034
36035 \family typewriter
36036 switch(i) {\InsetSpace ~
36037 \InsetSpace ~
36038 \InsetSpace ~
36039 \InsetSpace ~
36040 \InsetSpace ~
36041 \InsetSpace ~
36042 \InsetSpace ~
36043 \InsetSpace ~
36044 \InsetSpace ~
36045 \InsetSpace ~
36046 \InsetSpace ~
36047 \InsetSpace ~
36048 \InsetSpace ~
36049 \InsetSpace ~
36050 \InsetSpace ~
36051 \InsetSpace ~
36052 \InsetSpace ~
36053 \InsetSpace ~
36054 \InsetSpace ~
36055 \InsetSpace ~
36056 \InsetSpace ~
36057 \InsetSpace ~
36058 \InsetSpace ~
36059 \InsetSpace ~
36060 \InsetSpace ~
36061 \InsetSpace ~
36062 switch (i) { 
36063 \newline
36064 \InsetSpace ~
36065 \InsetSpace ~
36066 \InsetSpace ~
36067 case 4: ...\InsetSpace ~
36068 \InsetSpace ~
36069 \InsetSpace ~
36070 \InsetSpace ~
36071 \InsetSpace ~
36072 \InsetSpace ~
36073 \InsetSpace ~
36074 \InsetSpace ~
36075 \InsetSpace ~
36076 \InsetSpace ~
36077 \InsetSpace ~
36078 \InsetSpace ~
36079 \InsetSpace ~
36080 \InsetSpace ~
36081 \InsetSpace ~
36082 \InsetSpace ~
36083 \InsetSpace ~
36084 \InsetSpace ~
36085 \InsetSpace ~
36086 \InsetSpace ~
36087 \InsetSpace ~
36088 \InsetSpace ~
36089 \InsetSpace ~
36090 \InsetSpace ~
36091 \InsetSpace ~
36092 \InsetSpace ~
36093 case 0: ...
36094  
36095 \newline
36096 \InsetSpace ~
36097 \InsetSpace ~
36098 \InsetSpace ~
36099 case 5: ...\InsetSpace ~
36100 \InsetSpace ~
36101 \InsetSpace ~
36102 \InsetSpace ~
36103 \InsetSpace ~
36104 \InsetSpace ~
36105 \InsetSpace ~
36106 \InsetSpace ~
36107 \InsetSpace ~
36108 \InsetSpace ~
36109 \InsetSpace ~
36110 \InsetSpace ~
36111 \InsetSpace ~
36112 \InsetSpace ~
36113 \InsetSpace ~
36114 \InsetSpace ~
36115 \InsetSpace ~
36116 \InsetSpace ~
36117 \InsetSpace ~
36118 \InsetSpace ~
36119 \InsetSpace ~
36120 \InsetSpace ~
36121 \InsetSpace ~
36122 \InsetSpace ~
36123 \InsetSpace ~
36124 \InsetSpace ~
36125 case 1: ...
36126  
36127 \newline
36128 \InsetSpace ~
36129 \InsetSpace ~
36130 \InsetSpace ~
36131 case 3: ...\InsetSpace ~
36132 \InsetSpace ~
36133 \InsetSpace ~
36134 \InsetSpace ~
36135 \InsetSpace ~
36136 \InsetSpace ~
36137 \InsetSpace ~
36138 \InsetSpace ~
36139 \InsetSpace ~
36140 \InsetSpace ~
36141 \InsetSpace ~
36142 \InsetSpace ~
36143 \InsetSpace ~
36144 \InsetSpace ~
36145 \InsetSpace ~
36146 \InsetSpace ~
36147 \InsetSpace ~
36148 \InsetSpace ~
36149 \InsetSpace ~
36150 \InsetSpace ~
36151 \InsetSpace ~
36152 \InsetSpace ~
36153 \InsetSpace ~
36154 \InsetSpace ~
36155 \InsetSpace ~
36156 \InsetSpace ~
36157
36158 \newline
36159 \InsetSpace ~
36160 \InsetSpace ~
36161 \InsetSpace ~
36162 case 6: ...\InsetSpace ~
36163 \InsetSpace ~
36164 \InsetSpace ~
36165 \InsetSpace ~
36166 \InsetSpace ~
36167 \InsetSpace ~
36168 \InsetSpace ~
36169 \InsetSpace ~
36170 \InsetSpace ~
36171 \InsetSpace ~
36172 \InsetSpace ~
36173 \InsetSpace ~
36174 \InsetSpace ~
36175 \InsetSpace ~
36176 \InsetSpace ~
36177 \InsetSpace ~
36178 \InsetSpace ~
36179 \InsetSpace ~
36180 \InsetSpace ~
36181 \InsetSpace ~
36182 \InsetSpace ~
36183 \InsetSpace ~
36184 \InsetSpace ~
36185 \InsetSpace ~
36186 \InsetSpace ~
36187 \InsetSpace ~
36188 case 3: ...
36189  
36190 \newline
36191 \InsetSpace ~
36192 \InsetSpace ~
36193 \InsetSpace ~
36194 case 7: ...\InsetSpace ~
36195 \InsetSpace ~
36196 \InsetSpace ~
36197 \InsetSpace ~
36198 \InsetSpace ~
36199 \InsetSpace ~
36200 \InsetSpace ~
36201 \InsetSpace ~
36202 \InsetSpace ~
36203 \InsetSpace ~
36204 \InsetSpace ~
36205 \InsetSpace ~
36206 \InsetSpace ~
36207 \InsetSpace ~
36208 \InsetSpace ~
36209 \InsetSpace ~
36210 \InsetSpace ~
36211 \InsetSpace ~
36212 \InsetSpace ~
36213 \InsetSpace ~
36214 \InsetSpace ~
36215 \InsetSpace ~
36216 \InsetSpace ~
36217 \InsetSpace ~
36218 \InsetSpace ~
36219 \InsetSpace ~
36220 case 4: ...
36221  
36222 \newline
36223 \InsetSpace ~
36224 \InsetSpace ~
36225 \InsetSpace ~
36226 case 8: ...\InsetSpace ~
36227 \InsetSpace ~
36228 \InsetSpace ~
36229 \InsetSpace ~
36230 \InsetSpace ~
36231 \InsetSpace ~
36232 \InsetSpace ~
36233 \InsetSpace ~
36234 \InsetSpace ~
36235 \InsetSpace ~
36236 \InsetSpace ~
36237 \InsetSpace ~
36238 \InsetSpace ~
36239 \InsetSpace ~
36240 \InsetSpace ~
36241 \InsetSpace ~
36242 \InsetSpace ~
36243 \InsetSpace ~
36244 \InsetSpace ~
36245 \InsetSpace ~
36246 \InsetSpace ~
36247 \InsetSpace ~
36248 \InsetSpace ~
36249 \InsetSpace ~
36250 \InsetSpace ~
36251 \InsetSpace ~
36252 case 5: ...
36253  
36254 \newline
36255 \InsetSpace ~
36256 \InsetSpace ~
36257 \InsetSpace ~
36258 case 9: ...\InsetSpace ~
36259 \InsetSpace ~
36260 \InsetSpace ~
36261 \InsetSpace ~
36262 \InsetSpace ~
36263 \InsetSpace ~
36264 \InsetSpace ~
36265 \InsetSpace ~
36266 \InsetSpace ~
36267 \InsetSpace ~
36268 \InsetSpace ~
36269 \InsetSpace ~
36270 \InsetSpace ~
36271 \InsetSpace ~
36272 \InsetSpace ~
36273 \InsetSpace ~
36274 \InsetSpace ~
36275 \InsetSpace ~
36276 \InsetSpace ~
36277 \InsetSpace ~
36278 \InsetSpace ~
36279 \InsetSpace ~
36280 \InsetSpace ~
36281 \InsetSpace ~
36282 \InsetSpace ~
36283 \InsetSpace ~
36284 case 6: ...
36285  
36286 \newline
36287 \InsetSpace ~
36288 \InsetSpace ~
36289 \InsetSpace ~
36290 case 10: ...\InsetSpace ~
36291 \InsetSpace ~
36292 \InsetSpace ~
36293 \InsetSpace ~
36294 \InsetSpace ~
36295 \InsetSpace ~
36296 \InsetSpace ~
36297 \InsetSpace ~
36298 \InsetSpace ~
36299 \InsetSpace ~
36300 \InsetSpace ~
36301 \InsetSpace ~
36302 \InsetSpace ~
36303 \InsetSpace ~
36304 \InsetSpace ~
36305 \InsetSpace ~
36306 \InsetSpace ~
36307 \InsetSpace ~
36308 \InsetSpace ~
36309 \InsetSpace ~
36310 \InsetSpace ~
36311 \InsetSpace ~
36312 \InsetSpace ~
36313 \InsetSpace ~
36314 \InsetSpace ~
36315 case 7: ...
36316  
36317 \newline
36318 \InsetSpace ~
36319 \InsetSpace ~
36320 \InsetSpace ~
36321 case 11: ...\InsetSpace ~
36322 \InsetSpace ~
36323 \InsetSpace ~
36324 \InsetSpace ~
36325 \InsetSpace ~
36326 \InsetSpace ~
36327 \InsetSpace ~
36328 \InsetSpace ~
36329 \InsetSpace ~
36330 \InsetSpace ~
36331 \InsetSpace ~
36332 \InsetSpace ~
36333 \InsetSpace ~
36334 \InsetSpace ~
36335 \InsetSpace ~
36336 \InsetSpace ~
36337 \InsetSpace ~
36338 \InsetSpace ~
36339 \InsetSpace ~
36340 \InsetSpace ~
36341 \InsetSpace ~
36342 \InsetSpace ~
36343 \InsetSpace ~
36344 \InsetSpace ~
36345 \InsetSpace ~
36346 case 8: ...
36347  
36348 \newline
36349 }\InsetSpace ~
36350 \InsetSpace ~
36351 \InsetSpace ~
36352 \InsetSpace ~
36353 \InsetSpace ~
36354 \InsetSpace ~
36355 \InsetSpace ~
36356 \InsetSpace ~
36357 \InsetSpace ~
36358 \InsetSpace ~
36359 \InsetSpace ~
36360 \InsetSpace ~
36361 \InsetSpace ~
36362 \InsetSpace ~
36363 \InsetSpace ~
36364 \InsetSpace ~
36365 \InsetSpace ~
36366 \InsetSpace ~
36367 \InsetSpace ~
36368 \InsetSpace ~
36369 \InsetSpace ~
36370 \InsetSpace ~
36371 \InsetSpace ~
36372 \InsetSpace ~
36373 \InsetSpace ~
36374 \InsetSpace ~
36375 \InsetSpace ~
36376 \InsetSpace ~
36377 \InsetSpace ~
36378 \InsetSpace ~
36379 \InsetSpace ~
36380 \InsetSpace ~
36381 \InsetSpace ~
36382 \InsetSpace ~
36383 \InsetSpace ~
36384 \InsetSpace ~
36385 }
36386 \end_layout
36387
36388 \begin_layout Standard
36389 Both the above switch statements will be implemented using a jump-table.
36390  The example to the right side is slightly more efficient as the check for
36391  the lower boundary of the jump-table is not needed.
36392 \end_layout
36393
36394 \end_deeper
36395 \begin_layout Itemize
36396 The number of case labels is not larger than supported by the target architectur
36397 e.
36398 \end_layout
36399
36400 \begin_layout Itemize
36401 If the case labels are not in numerical sequence ('gaps' between cases)
36402  SDCC checks whether a jump table with additionally inserted dummy cases
36403  is still attractive.
36404  
36405 \end_layout
36406
36407 \begin_layout Itemize
36408 If the starting number is not zero and a check for the lower boundary of
36409  the jump-table can thus be eliminated SDCC might insert dummy cases 0,
36410  ...
36411  .
36412 \end_layout
36413
36414 \begin_layout Standard
36415 Switch statements which have large gaps in the numeric sequence or those
36416  that have too many case labels can be split into more than one switch statement
36417  for efficient code generation, e.g.:
36418 \end_layout
36419
36420 \begin_layout Verse
36421
36422 \family typewriter
36423 switch (i) { 
36424 \newline
36425 \InsetSpace ~
36426 \InsetSpace ~
36427 case 1: ...
36428  
36429 \newline
36430 \InsetSpace ~
36431 \InsetSpace ~
36432 case 2: ...
36433  
36434 \newline
36435 \InsetSpace ~
36436 \InsetSpace ~
36437 case 3: ...
36438  
36439 \newline
36440 \InsetSpace ~
36441 \InsetSpace ~
36442 case 4: ...
36443  
36444 \newline
36445 \InsetSpace ~
36446 \InsetSpace ~
36447 case 5: ...
36448  
36449 \newline
36450 \InsetSpace ~
36451 \InsetSpace ~
36452 case 6: ...
36453  
36454 \newline
36455 \InsetSpace ~
36456 \InsetSpace ~
36457 case 7: ...
36458  
36459 \newline
36460 \InsetSpace ~
36461 \InsetSpace ~
36462 case 101: ...
36463  
36464 \newline
36465 \InsetSpace ~
36466 \InsetSpace ~
36467 case 102: ...
36468  
36469 \newline
36470 \InsetSpace ~
36471 \InsetSpace ~
36472 case 103: ...
36473  
36474 \newline
36475 \InsetSpace ~
36476 \InsetSpace ~
36477 case 104: ...
36478  
36479 \newline
36480 \InsetSpace ~
36481 \InsetSpace ~
36482 case 105: ...
36483  
36484 \newline
36485 \InsetSpace ~
36486 \InsetSpace ~
36487 case 106: ...
36488  
36489 \newline
36490 \InsetSpace ~
36491 \InsetSpace ~
36492 case 107: ...
36493  
36494 \newline
36495 }
36496 \end_layout
36497
36498 \begin_layout Standard
36499 If the above switch statement is broken down into two switch statements
36500 \end_layout
36501
36502 \begin_layout Verse
36503
36504 \family typewriter
36505 switch (i) { 
36506 \newline
36507 \InsetSpace ~
36508 \InsetSpace ~
36509 case 1: ...
36510  
36511 \newline
36512 \InsetSpace ~
36513 \InsetSpace ~
36514 case 2: ...
36515  
36516 \newline
36517 \InsetSpace ~
36518 \InsetSpace ~
36519 case 3: ...
36520  
36521 \newline
36522 \InsetSpace ~
36523 \InsetSpace ~
36524 case 4: ...
36525  
36526 \newline
36527 \InsetSpace ~
36528 \InsetSpace ~
36529 case 5: ...
36530  
36531 \newline
36532 \InsetSpace ~
36533 \InsetSpace ~
36534 case 6: ...
36535  
36536 \newline
36537 \InsetSpace ~
36538 \InsetSpace ~
36539 case 7: ...
36540  
36541 \newline
36542 }
36543 \end_layout
36544
36545 \begin_layout Standard
36546 and
36547 \end_layout
36548
36549 \begin_layout Verse
36550
36551 \family typewriter
36552 switch (i) { 
36553 \newline
36554 \InsetSpace ~
36555 \InsetSpace ~
36556 case 101: ...
36557  
36558 \newline
36559 \InsetSpace ~
36560 \InsetSpace ~
36561 case 102: ...
36562  
36563 \newline
36564 \InsetSpace ~
36565 \InsetSpace ~
36566 case 103: ...
36567  
36568 \newline
36569 \InsetSpace ~
36570 \InsetSpace ~
36571 case 104: ...
36572  
36573 \newline
36574 \InsetSpace ~
36575 \InsetSpace ~
36576 case 105: ...
36577  
36578 \newline
36579 \InsetSpace ~
36580 \InsetSpace ~
36581 case 106: ...
36582  
36583 \newline
36584 \InsetSpace ~
36585 \InsetSpace ~
36586 case 107: ...
36587  
36588 \newline
36589 }
36590 \end_layout
36591
36592 \begin_layout Standard
36593 then both the switch statements will be implemented using jump-tables whereas
36594  the unmodified switch statement will not be.
36595 \end_layout
36596
36597 \begin_layout Standard
36598 \begin_inset Note Note
36599 status collapsed
36600
36601 \begin_layout Standard
36602 There might be reasons which SDCC cannot know about to either favour or
36603  not favour jump tables.
36604  If the target system has to be as quick for the last switch case as for
36605  the first (pro jump table), or if the switch argument is known to be zero
36606  in the majority of the cases (contra jump table).
36607 \end_layout
36608
36609 \end_inset
36610
36611
36612 \end_layout
36613
36614 \begin_layout Standard
36615 The pragma nojtbound
36616 \begin_inset LatexCommand index
36617 name "\\#pragma nojtbound"
36618
36619 \end_inset
36620
36621  can be used to turn off checking the 
36622 \emph on
36623 j
36624 \emph default
36625 ump 
36626 \emph on
36627 t
36628 \emph default
36629 able 
36630 \emph on
36631 bound
36632 \emph default
36633 aries.
36634  It has no effect if a default label is supplied.
36635  Use of this pragma is dangerous: if the switch
36636 \begin_inset LatexCommand index
36637 name "switch statement"
36638
36639 \end_inset
36640
36641  argument is not matched by a case statement the processor will happily
36642  jump into Nirvana.
36643 \end_layout
36644
36645 \begin_layout Subsection
36646 Bit-shifting Operations
36647 \begin_inset LatexCommand index
36648 name "Bit shifting"
36649
36650 \end_inset
36651
36652 .
36653 \end_layout
36654
36655 \begin_layout Standard
36656 Bit shifting is one of the most frequently used operation in embedded programmin
36657 g.
36658  SDCC tries to implement bit-shift operations in the most efficient way
36659  possible, e.g.:
36660 \end_layout
36661
36662 \begin_layout Verse
36663
36664 \family typewriter
36665 unsigned char i;
36666 \newline
36667 ...
36668  
36669 \newline
36670 i >>= 4; 
36671 \newline
36672 ...
36673 \end_layout
36674
36675 \begin_layout Standard
36676 generates the following code:
36677 \end_layout
36678
36679 \begin_layout Verse
36680
36681 \family typewriter
36682 mov\InsetSpace ~
36683  a,_i 
36684 \newline
36685 swap a 
36686 \newline
36687 anl\InsetSpace ~
36688  a,#0x0f 
36689 \newline
36690 mov\InsetSpace ~
36691  _i,a
36692 \end_layout
36693
36694 \begin_layout Standard
36695 In general SDCC will never setup a loop if the shift count is known.
36696  Another example:
36697 \end_layout
36698
36699 \begin_layout Verse
36700
36701 \family typewriter
36702 unsigned int i; 
36703 \newline
36704 ...
36705  
36706 \newline
36707 i >>= 9; 
36708 \newline
36709 ...
36710 \end_layout
36711
36712 \begin_layout Standard
36713 will generate:
36714 \end_layout
36715
36716 \begin_layout Verse
36717
36718 \family typewriter
36719 mov\InsetSpace ~
36720 \InsetSpace ~
36721 a,(_i + 1) 
36722 \newline
36723 mov\InsetSpace ~
36724 \InsetSpace ~
36725 (_i + 1),#0x00 
36726 \newline
36727 clr\InsetSpace ~
36728 \InsetSpace ~
36729
36730 \newline
36731 rrc\InsetSpace ~
36732 \InsetSpace ~
36733
36734 \newline
36735 mov\InsetSpace ~
36736 \InsetSpace ~
36737 _i,a
36738 \end_layout
36739
36740 \begin_layout Subsection
36741 Bit-rotation
36742 \begin_inset LatexCommand index
36743 name "Bit rotation"
36744
36745 \end_inset
36746
36747
36748 \end_layout
36749
36750 \begin_layout Standard
36751 A special case of the bit-shift operation is bit rotation
36752 \begin_inset LatexCommand index
36753 name "rotating bits"
36754
36755 \end_inset
36756
36757 , SDCC recognizes the following expression to be a left bit-rotation:
36758 \end_layout
36759
36760 \begin_layout Verse
36761
36762 \family typewriter
36763 \series bold
36764 unsigned
36765 \series default
36766 \InsetSpace ~
36767 \InsetSpace ~
36768 char i;\InsetSpace ~
36769 \InsetSpace ~
36770 \InsetSpace ~
36771 \InsetSpace ~
36772 \InsetSpace ~
36773 \InsetSpace ~
36774 \InsetSpace ~
36775 \InsetSpace ~
36776 \InsetSpace ~
36777 \InsetSpace ~
36778 \InsetSpace ~
36779 /* unsigned is needed for rotation */ 
36780 \newline
36781 ...
36782  
36783 \newline
36784 i = ((i << 1) | (i >> 7));
36785 \family default
36786  
36787 \newline
36788
36789 \family typewriter
36790 ...
36791 \end_layout
36792
36793 \begin_layout Standard
36794 will generate the following code:
36795 \end_layout
36796
36797 \begin_layout Verse
36798
36799 \family typewriter
36800 mov\InsetSpace ~
36801 \InsetSpace ~
36802 a,_i 
36803 \newline
36804 rl\InsetSpace ~
36805 \InsetSpace ~
36806 \InsetSpace ~
36807
36808 \newline
36809 mov\InsetSpace ~
36810 \InsetSpace ~
36811 _i,a
36812 \end_layout
36813
36814 \begin_layout Standard
36815 SDCC uses pattern matching on the parse tree to determine this operation.Variatio
36816 ns of this case will also be recognized as bit-rotation, i.e.: 
36817 \end_layout
36818
36819 \begin_layout Verse
36820
36821 \family typewriter
36822 i = ((i >> 7) | (i << 1)); /* left-bit rotation */
36823 \end_layout
36824
36825 \begin_layout Subsection
36826 Nibble and Byte Swapping
36827 \end_layout
36828
36829 \begin_layout Standard
36830 Other special cases of the bit-shift operations are nibble or byte swapping
36831 \begin_inset LatexCommand index
36832 name "swapping nibbles/bytes"
36833
36834 \end_inset
36835
36836 , SDCC recognizes the following expressions:
36837 \end_layout
36838
36839 \begin_layout Verse
36840
36841 \family typewriter
36842 \series bold
36843 unsigned
36844 \series default
36845 \InsetSpace ~
36846 \InsetSpace ~
36847 char i; 
36848 \newline
36849
36850 \series bold
36851 unsigned
36852 \series default
36853 \InsetSpace ~
36854 \InsetSpace ~
36855 int j; 
36856 \newline
36857 ...
36858  
36859 \newline
36860 i = ((i << 4) | (i >> 4));
36861 \family default
36862  
36863 \newline
36864
36865 \family typewriter
36866 j = ((j << 8) | (j >> 8)); 
36867 \end_layout
36868
36869 \begin_layout Standard
36870 and generates a swap instruction for the nibble swapping
36871 \begin_inset LatexCommand index
36872 name "Nibble swapping"
36873
36874 \end_inset
36875
36876  or move instructions for the byte swapping
36877 \begin_inset LatexCommand index
36878 name "Byte swapping"
36879
36880 \end_inset
36881
36882 .
36883  The 
36884 \begin_inset Quotes sld
36885 \end_inset
36886
36887 j
36888 \begin_inset Quotes srd
36889 \end_inset
36890
36891  example can be used to convert from little to big-endian or vice versa.
36892  If you want to change the endianness of a 
36893 \emph on
36894 signed
36895 \emph default
36896  integer you have to cast to 
36897 \family typewriter
36898 (unsigned int)
36899 \family default
36900  first.
36901 \end_layout
36902
36903 \begin_layout Standard
36904 Note that SDCC stores numbers in little-endian
36905 \begin_inset Foot
36906 status open
36907
36908 \begin_layout Standard
36909 Usually 8-bit processors don't care much about endianness.
36910  This is not the case for the standard 8051 which only has an instruction
36911  to increment its 
36912 \emph on
36913 dptr
36914 \emph default
36915
36916 \begin_inset LatexCommand index
36917 name "DPTR"
36918
36919 \end_inset
36920
36921 -datapointer so little-endian is the more efficient byte order.
36922 \end_layout
36923
36924 \end_inset
36925
36926
36927 \begin_inset LatexCommand index
36928 name "little-endian"
36929
36930 \end_inset
36931
36932
36933 \begin_inset LatexCommand index
36934 name "Endianness"
36935
36936 \end_inset
36937
36938  format (i.e.
36939  lowest order first).
36940 \end_layout
36941
36942 \begin_layout Subsection
36943 Highest Order Bit
36944 \begin_inset LatexCommand index
36945 name "Highest Order Bit"
36946
36947 \end_inset
36948
36949  / Any Order Bit
36950 \begin_inset LatexCommand index
36951 name "Any Order Bit"
36952
36953 \end_inset
36954
36955
36956 \end_layout
36957
36958 \begin_layout Standard
36959 It is frequently required to obtain the highest order bit of an integral
36960  type (long, int, short or char types).
36961  Also obtaining any other order bit is not uncommon.
36962  SDCC recognizes the following expressions to yield the highest order bit
36963  and generates optimized code for it, e.g.:
36964 \end_layout
36965
36966 \begin_layout Verse
36967
36968 \family typewriter
36969 unsigned int gint; 
36970 \newline
36971
36972 \newline
36973 foo () { 
36974 \newline
36975 \InsetSpace ~
36976 \InsetSpace ~
36977 unsigned char hob1, aob1; 
36978 \newline
36979 \InsetSpace ~
36980 \InsetSpace ~
36981 bit hob2, hob3, aob2,
36982  aob3; 
36983 \newline
36984 \InsetSpace ~
36985 \InsetSpace ~
36986 ...
36987  
36988 \newline
36989 \InsetSpace ~
36990 \InsetSpace ~
36991 hob1 = (gint >> 15) & 1; 
36992 \newline
36993 \InsetSpace ~
36994 \InsetSpace ~
36995 hob2 = (gint >> 15) & 1; 
36996 \newline
36997 \InsetSpace ~
36998 \InsetSpace ~
36999 hob3 = gint & 0x8000;
37000  
37001 \newline
37002 \InsetSpace ~
37003 \InsetSpace ~
37004 aob1 = (gint >> 9) & 1; 
37005 \newline
37006 \InsetSpace ~
37007 \InsetSpace ~
37008 aob2 = (gint >> 8) & 1; 
37009 \newline
37010 \InsetSpace ~
37011 \InsetSpace ~
37012 aob3 = gint & 0x0800; 
37013 \newline
37014 \InsetSpace ~
37015 \InsetSpace ~
37016 ..
37017  
37018 \newline
37019 }
37020 \end_layout
37021
37022 \begin_layout Standard
37023 will generate the following code:
37024 \end_layout
37025
37026 \begin_layout Verse
37027
37028 \family typewriter
37029 \InsetSpace ~
37030 \InsetSpace ~
37031 \InsetSpace ~
37032 \InsetSpace ~
37033 \InsetSpace ~
37034 \InsetSpace ~
37035 \InsetSpace ~
37036 \InsetSpace ~
37037 \InsetSpace ~
37038 \InsetSpace ~
37039 \InsetSpace ~
37040 \InsetSpace ~
37041 \InsetSpace ~
37042 \InsetSpace ~
37043 \InsetSpace ~
37044 \InsetSpace ~
37045 \InsetSpace ~
37046 \InsetSpace ~
37047 \InsetSpace ~
37048 \InsetSpace ~
37049 \InsetSpace ~
37050 \InsetSpace ~
37051 \InsetSpace ~
37052 \InsetSpace ~
37053 \InsetSpace ~
37054  61 ;\InsetSpace ~
37055  hob.c 7 
37056 \newline
37057 000A E5*01\InsetSpace ~
37058 \InsetSpace ~
37059 \InsetSpace ~
37060 \InsetSpace ~
37061 \InsetSpace ~
37062 \InsetSpace ~
37063 \InsetSpace ~
37064 \InsetSpace ~
37065 \InsetSpace ~
37066 \InsetSpace ~
37067 \InsetSpace ~
37068 \InsetSpace ~
37069 \InsetSpace ~
37070 \InsetSpace ~
37071 \InsetSpace ~
37072  62\InsetSpace ~
37073 \InsetSpace ~
37074 \InsetSpace ~
37075 \InsetSpace ~
37076 \InsetSpace ~
37077 \InsetSpace ~
37078 \InsetSpace ~
37079 \InsetSpace ~
37080  mov\InsetSpace ~
37081 \InsetSpace ~
37082  a,(_gint + 1) 
37083 \newline
37084 000C 23\InsetSpace ~
37085 \InsetSpace ~
37086 \InsetSpace ~
37087 \InsetSpace ~
37088 \InsetSpace ~
37089 \InsetSpace ~
37090 \InsetSpace ~
37091 \InsetSpace ~
37092 \InsetSpace ~
37093 \InsetSpace ~
37094 \InsetSpace ~
37095 \InsetSpace ~
37096 \InsetSpace ~
37097 \InsetSpace ~
37098 \InsetSpace ~
37099 \InsetSpace ~
37100 \InsetSpace ~
37101 \InsetSpace ~
37102  63\InsetSpace ~
37103 \InsetSpace ~
37104 \InsetSpace ~
37105 \InsetSpace ~
37106 \InsetSpace ~
37107 \InsetSpace ~
37108 \InsetSpace ~
37109 \InsetSpace ~
37110  rl\InsetSpace ~
37111 \InsetSpace ~
37112 \InsetSpace ~
37113  a 
37114 \newline
37115 000D 54 01\InsetSpace ~
37116 \InsetSpace ~
37117 \InsetSpace ~
37118 \InsetSpace ~
37119 \InsetSpace ~
37120 \InsetSpace ~
37121 \InsetSpace ~
37122 \InsetSpace ~
37123 \InsetSpace ~
37124 \InsetSpace ~
37125 \InsetSpace ~
37126 \InsetSpace ~
37127 \InsetSpace ~
37128 \InsetSpace ~
37129 \InsetSpace ~
37130
37131  64\InsetSpace ~
37132 \InsetSpace ~
37133 \InsetSpace ~
37134 \InsetSpace ~
37135 \InsetSpace ~
37136 \InsetSpace ~
37137 \InsetSpace ~
37138 \InsetSpace ~
37139  anl\InsetSpace ~
37140 \InsetSpace ~
37141  a,#0x01 
37142 \newline
37143 000F F5*02\InsetSpace ~
37144 \InsetSpace ~
37145 \InsetSpace ~
37146 \InsetSpace ~
37147 \InsetSpace ~
37148 \InsetSpace ~
37149 \InsetSpace ~
37150 \InsetSpace ~
37151 \InsetSpace ~
37152 \InsetSpace ~
37153 \InsetSpace ~
37154 \InsetSpace ~
37155 \InsetSpace ~
37156 \InsetSpace ~
37157 \InsetSpace ~
37158  65\InsetSpace ~
37159 \InsetSpace ~
37160 \InsetSpace ~
37161 \InsetSpace ~
37162 \InsetSpace ~
37163 \InsetSpace ~
37164 \InsetSpace ~
37165 \InsetSpace ~
37166  mov\InsetSpace ~
37167 \InsetSpace ~
37168  _foo_hob1_1_1,a 
37169 \newline
37170 \InsetSpace ~
37171 \InsetSpace ~
37172 \InsetSpace ~
37173 \InsetSpace ~
37174 \InsetSpace ~
37175 \InsetSpace ~
37176 \InsetSpace ~
37177 \InsetSpace ~
37178 \InsetSpace ~
37179 \InsetSpace ~
37180 \InsetSpace ~
37181 \InsetSpace ~
37182 \InsetSpace ~
37183 \InsetSpace ~
37184 \InsetSpace ~
37185 \InsetSpace ~
37186 \InsetSpace ~
37187 \InsetSpace ~
37188 \InsetSpace ~
37189 \InsetSpace ~
37190 \InsetSpace ~
37191 \InsetSpace ~
37192 \InsetSpace ~
37193 \InsetSpace ~
37194 \InsetSpace ~
37195  66 ;\InsetSpace ~
37196  hob.c 8 
37197 \newline
37198 0011 E5*01\InsetSpace ~
37199 \InsetSpace ~
37200 \InsetSpace ~
37201 \InsetSpace ~
37202 \InsetSpace ~
37203 \InsetSpace ~
37204 \InsetSpace ~
37205 \InsetSpace ~
37206 \InsetSpace ~
37207 \InsetSpace ~
37208 \InsetSpace ~
37209 \InsetSpace ~
37210 \InsetSpace ~
37211 \InsetSpace ~
37212 \InsetSpace ~
37213
37214  67\InsetSpace ~
37215 \InsetSpace ~
37216 \InsetSpace ~
37217 \InsetSpace ~
37218 \InsetSpace ~
37219 \InsetSpace ~
37220 \InsetSpace ~
37221 \InsetSpace ~
37222  mov\InsetSpace ~
37223 \InsetSpace ~
37224  a,(_gint + 1) 
37225 \newline
37226 0013 33\InsetSpace ~
37227 \InsetSpace ~
37228 \InsetSpace ~
37229 \InsetSpace ~
37230 \InsetSpace ~
37231 \InsetSpace ~
37232 \InsetSpace ~
37233 \InsetSpace ~
37234 \InsetSpace ~
37235 \InsetSpace ~
37236 \InsetSpace ~
37237 \InsetSpace ~
37238 \InsetSpace ~
37239 \InsetSpace ~
37240 \InsetSpace ~
37241 \InsetSpace ~
37242 \InsetSpace ~
37243 \InsetSpace ~
37244  68\InsetSpace ~
37245 \InsetSpace ~
37246 \InsetSpace ~
37247 \InsetSpace ~
37248 \InsetSpace ~
37249 \InsetSpace ~
37250 \InsetSpace ~
37251 \InsetSpace ~
37252  rlc\InsetSpace ~
37253 \InsetSpace ~
37254  a 
37255 \newline
37256 0014 92*00\InsetSpace ~
37257 \InsetSpace ~
37258 \InsetSpace ~
37259 \InsetSpace ~
37260 \InsetSpace ~
37261 \InsetSpace ~
37262 \InsetSpace ~
37263 \InsetSpace ~
37264 \InsetSpace ~
37265 \InsetSpace ~
37266 \InsetSpace ~
37267 \InsetSpace ~
37268 \InsetSpace ~
37269 \InsetSpace ~
37270 \InsetSpace ~
37271  69\InsetSpace ~
37272 \InsetSpace ~
37273 \InsetSpace ~
37274 \InsetSpace ~
37275 \InsetSpace ~
37276 \InsetSpace ~
37277 \InsetSpace ~
37278 \InsetSpace ~
37279  mov\InsetSpace ~
37280 \InsetSpace ~
37281  _foo_hob2_1_1,c
37282  
37283 \newline
37284 \InsetSpace ~
37285 \InsetSpace ~
37286 \InsetSpace ~
37287 \InsetSpace ~
37288 \InsetSpace ~
37289 \InsetSpace ~
37290 \InsetSpace ~
37291 \InsetSpace ~
37292 \InsetSpace ~
37293 \InsetSpace ~
37294 \InsetSpace ~
37295 \InsetSpace ~
37296 \InsetSpace ~
37297 \InsetSpace ~
37298 \InsetSpace ~
37299 \InsetSpace ~
37300 \InsetSpace ~
37301 \InsetSpace ~
37302 \InsetSpace ~
37303 \InsetSpace ~
37304 \InsetSpace ~
37305 \InsetSpace ~
37306 \InsetSpace ~
37307 \InsetSpace ~
37308 \InsetSpace ~
37309  66 ;\InsetSpace ~
37310  hob.c 9 
37311 \newline
37312 0016 E5*01\InsetSpace ~
37313 \InsetSpace ~
37314 \InsetSpace ~
37315 \InsetSpace ~
37316 \InsetSpace ~
37317 \InsetSpace ~
37318 \InsetSpace ~
37319 \InsetSpace ~
37320 \InsetSpace ~
37321 \InsetSpace ~
37322 \InsetSpace ~
37323 \InsetSpace ~
37324 \InsetSpace ~
37325 \InsetSpace ~
37326 \InsetSpace ~
37327  67\InsetSpace ~
37328 \InsetSpace ~
37329 \InsetSpace ~
37330 \InsetSpace ~
37331 \InsetSpace ~
37332 \InsetSpace ~
37333 \InsetSpace ~
37334 \InsetSpace ~
37335  mov\InsetSpace ~
37336 \InsetSpace ~
37337  a,(_gint + 1) 
37338 \newline
37339 0018 33\InsetSpace ~
37340 \InsetSpace ~
37341 \InsetSpace ~
37342 \InsetSpace ~
37343 \InsetSpace ~
37344 \InsetSpace ~
37345 \InsetSpace ~
37346 \InsetSpace ~
37347 \InsetSpace ~
37348 \InsetSpace ~
37349 \InsetSpace ~
37350 \InsetSpace ~
37351 \InsetSpace ~
37352 \InsetSpace ~
37353 \InsetSpace ~
37354 \InsetSpace ~
37355 \InsetSpace ~
37356 \InsetSpace ~
37357  68\InsetSpace ~
37358 \InsetSpace ~
37359 \InsetSpace ~
37360 \InsetSpace ~
37361 \InsetSpace ~
37362 \InsetSpace ~
37363 \InsetSpace ~
37364 \InsetSpace ~
37365  rlc\InsetSpace ~
37366 \InsetSpace ~
37367  a 
37368 \newline
37369 0019 92*01\InsetSpace ~
37370 \InsetSpace ~
37371 \InsetSpace ~
37372 \InsetSpace ~
37373 \InsetSpace ~
37374 \InsetSpace ~
37375 \InsetSpace ~
37376 \InsetSpace ~
37377 \InsetSpace ~
37378 \InsetSpace ~
37379 \InsetSpace ~
37380 \InsetSpace ~
37381 \InsetSpace ~
37382 \InsetSpace ~
37383 \InsetSpace ~
37384
37385  69\InsetSpace ~
37386 \InsetSpace ~
37387 \InsetSpace ~
37388 \InsetSpace ~
37389 \InsetSpace ~
37390 \InsetSpace ~
37391 \InsetSpace ~
37392 \InsetSpace ~
37393  mov\InsetSpace ~
37394 \InsetSpace ~
37395  _foo_hob3_1_1,c 
37396 \newline
37397 \InsetSpace ~
37398 \InsetSpace ~
37399 \InsetSpace ~
37400 \InsetSpace ~
37401 \InsetSpace ~
37402 \InsetSpace ~
37403 \InsetSpace ~
37404 \InsetSpace ~
37405 \InsetSpace ~
37406 \InsetSpace ~
37407 \InsetSpace ~
37408 \InsetSpace ~
37409 \InsetSpace ~
37410 \InsetSpace ~
37411 \InsetSpace ~
37412 \InsetSpace ~
37413 \InsetSpace ~
37414 \InsetSpace ~
37415 \InsetSpace ~
37416 \InsetSpace ~
37417 \InsetSpace ~
37418 \InsetSpace ~
37419 \InsetSpace ~
37420 \InsetSpace ~
37421 \InsetSpace ~
37422  70 ;\InsetSpace ~
37423  hob.c 10 
37424 \newline
37425 001B E5*01\InsetSpace ~
37426 \InsetSpace ~
37427 \InsetSpace ~
37428 \InsetSpace ~
37429 \InsetSpace ~
37430 \InsetSpace ~
37431 \InsetSpace ~
37432 \InsetSpace ~
37433 \InsetSpace ~
37434 \InsetSpace ~
37435 \InsetSpace ~
37436 \InsetSpace ~
37437 \InsetSpace ~
37438 \InsetSpace ~
37439 \InsetSpace ~
37440  71\InsetSpace ~
37441 \InsetSpace ~
37442 \InsetSpace ~
37443 \InsetSpace ~
37444 \InsetSpace ~
37445 \InsetSpace ~
37446 \InsetSpace ~
37447 \InsetSpace ~
37448  mov\InsetSpace ~
37449 \InsetSpace ~
37450  a,(_gint + 1) 
37451 \newline
37452 001D
37453  03\InsetSpace ~
37454 \InsetSpace ~
37455 \InsetSpace ~
37456 \InsetSpace ~
37457 \InsetSpace ~
37458 \InsetSpace ~
37459 \InsetSpace ~
37460 \InsetSpace ~
37461 \InsetSpace ~
37462 \InsetSpace ~
37463 \InsetSpace ~
37464 \InsetSpace ~
37465 \InsetSpace ~
37466 \InsetSpace ~
37467 \InsetSpace ~
37468 \InsetSpace ~
37469 \InsetSpace ~
37470 \InsetSpace ~
37471  72\InsetSpace ~
37472 \InsetSpace ~
37473 \InsetSpace ~
37474 \InsetSpace ~
37475 \InsetSpace ~
37476 \InsetSpace ~
37477 \InsetSpace ~
37478 \InsetSpace ~
37479  rr\InsetSpace ~
37480 \InsetSpace ~
37481 \InsetSpace ~
37482  a 
37483 \newline
37484 001E 54 01\InsetSpace ~
37485 \InsetSpace ~
37486 \InsetSpace ~
37487 \InsetSpace ~
37488 \InsetSpace ~
37489 \InsetSpace ~
37490 \InsetSpace ~
37491 \InsetSpace ~
37492 \InsetSpace ~
37493 \InsetSpace ~
37494 \InsetSpace ~
37495 \InsetSpace ~
37496 \InsetSpace ~
37497 \InsetSpace ~
37498 \InsetSpace ~
37499  73\InsetSpace ~
37500 \InsetSpace ~
37501 \InsetSpace ~
37502 \InsetSpace ~
37503 \InsetSpace ~
37504 \InsetSpace ~
37505 \InsetSpace ~
37506 \InsetSpace ~
37507  anl\InsetSpace ~
37508 \InsetSpace ~
37509  a,#0x01 
37510 \newline
37511 0020 F5*03\InsetSpace ~
37512 \InsetSpace ~
37513 \InsetSpace ~
37514 \InsetSpace ~
37515 \InsetSpace ~
37516 \InsetSpace ~
37517 \InsetSpace ~
37518 \InsetSpace ~
37519 \InsetSpace ~
37520 \InsetSpace ~
37521 \InsetSpace ~
37522 \InsetSpace ~
37523 \InsetSpace ~
37524 \InsetSpace ~
37525 \InsetSpace ~
37526  74\InsetSpace ~
37527 \InsetSpace ~
37528 \InsetSpace ~
37529 \InsetSpace ~
37530 \InsetSpace ~
37531 \InsetSpace ~
37532 \InsetSpace ~
37533 \InsetSpace ~
37534  mov\InsetSpace ~
37535 \InsetSpace ~
37536  _foo_aob1_1_1,a
37537  
37538 \newline
37539 \InsetSpace ~
37540 \InsetSpace ~
37541 \InsetSpace ~
37542 \InsetSpace ~
37543 \InsetSpace ~
37544 \InsetSpace ~
37545 \InsetSpace ~
37546 \InsetSpace ~
37547 \InsetSpace ~
37548 \InsetSpace ~
37549 \InsetSpace ~
37550 \InsetSpace ~
37551 \InsetSpace ~
37552 \InsetSpace ~
37553 \InsetSpace ~
37554 \InsetSpace ~
37555 \InsetSpace ~
37556 \InsetSpace ~
37557 \InsetSpace ~
37558 \InsetSpace ~
37559 \InsetSpace ~
37560 \InsetSpace ~
37561 \InsetSpace ~
37562 \InsetSpace ~
37563 \InsetSpace ~
37564  75 ;\InsetSpace ~
37565  hob.c 11 
37566 \newline
37567 0022 E5*01\InsetSpace ~
37568 \InsetSpace ~
37569 \InsetSpace ~
37570 \InsetSpace ~
37571 \InsetSpace ~
37572 \InsetSpace ~
37573 \InsetSpace ~
37574 \InsetSpace ~
37575 \InsetSpace ~
37576 \InsetSpace ~
37577 \InsetSpace ~
37578 \InsetSpace ~
37579 \InsetSpace ~
37580 \InsetSpace ~
37581 \InsetSpace ~
37582  76\InsetSpace ~
37583 \InsetSpace ~
37584 \InsetSpace ~
37585 \InsetSpace ~
37586 \InsetSpace ~
37587 \InsetSpace ~
37588 \InsetSpace ~
37589 \InsetSpace ~
37590  mov\InsetSpace ~
37591 \InsetSpace ~
37592  a,(_gint + 1) 
37593 \newline
37594 0024 13\InsetSpace ~
37595 \InsetSpace ~
37596 \InsetSpace ~
37597 \InsetSpace ~
37598 \InsetSpace ~
37599 \InsetSpace ~
37600 \InsetSpace ~
37601 \InsetSpace ~
37602 \InsetSpace ~
37603 \InsetSpace ~
37604 \InsetSpace ~
37605 \InsetSpace ~
37606 \InsetSpace ~
37607 \InsetSpace ~
37608 \InsetSpace ~
37609 \InsetSpace ~
37610 \InsetSpace ~
37611 \InsetSpace ~
37612  77\InsetSpace ~
37613 \InsetSpace ~
37614 \InsetSpace ~
37615 \InsetSpace ~
37616 \InsetSpace ~
37617 \InsetSpace ~
37618 \InsetSpace ~
37619 \InsetSpace ~
37620  rrc\InsetSpace ~
37621 \InsetSpace ~
37622  a 
37623 \newline
37624 0025 92*02\InsetSpace ~
37625 \InsetSpace ~
37626 \InsetSpace ~
37627 \InsetSpace ~
37628 \InsetSpace ~
37629 \InsetSpace ~
37630 \InsetSpace ~
37631 \InsetSpace ~
37632 \InsetSpace ~
37633 \InsetSpace ~
37634 \InsetSpace ~
37635 \InsetSpace ~
37636 \InsetSpace ~
37637 \InsetSpace ~
37638 \InsetSpace ~
37639
37640  78\InsetSpace ~
37641 \InsetSpace ~
37642 \InsetSpace ~
37643 \InsetSpace ~
37644 \InsetSpace ~
37645 \InsetSpace ~
37646 \InsetSpace ~
37647 \InsetSpace ~
37648  mov\InsetSpace ~
37649 \InsetSpace ~
37650  _foo_aob2_1_1,c 
37651 \newline
37652 \InsetSpace ~
37653 \InsetSpace ~
37654 \InsetSpace ~
37655 \InsetSpace ~
37656 \InsetSpace ~
37657 \InsetSpace ~
37658 \InsetSpace ~
37659 \InsetSpace ~
37660 \InsetSpace ~
37661 \InsetSpace ~
37662 \InsetSpace ~
37663 \InsetSpace ~
37664 \InsetSpace ~
37665 \InsetSpace ~
37666 \InsetSpace ~
37667 \InsetSpace ~
37668 \InsetSpace ~
37669 \InsetSpace ~
37670 \InsetSpace ~
37671 \InsetSpace ~
37672 \InsetSpace ~
37673 \InsetSpace ~
37674 \InsetSpace ~
37675 \InsetSpace ~
37676 \InsetSpace ~
37677  79 ;\InsetSpace ~
37678  hob.c 12 
37679 \newline
37680 0027 E5*01\InsetSpace ~
37681 \InsetSpace ~
37682 \InsetSpace ~
37683 \InsetSpace ~
37684 \InsetSpace ~
37685 \InsetSpace ~
37686 \InsetSpace ~
37687 \InsetSpace ~
37688 \InsetSpace ~
37689 \InsetSpace ~
37690 \InsetSpace ~
37691 \InsetSpace ~
37692 \InsetSpace ~
37693 \InsetSpace ~
37694 \InsetSpace ~
37695  80\InsetSpace ~
37696 \InsetSpace ~
37697 \InsetSpace ~
37698 \InsetSpace ~
37699 \InsetSpace ~
37700 \InsetSpace ~
37701 \InsetSpace ~
37702 \InsetSpace ~
37703  mov\InsetSpace ~
37704 \InsetSpace ~
37705  a,(_gint + 1) 
37706 \newline
37707 0029
37708  A2 E3\InsetSpace ~
37709 \InsetSpace ~
37710 \InsetSpace ~
37711 \InsetSpace ~
37712 \InsetSpace ~
37713 \InsetSpace ~
37714 \InsetSpace ~
37715 \InsetSpace ~
37716 \InsetSpace ~
37717 \InsetSpace ~
37718 \InsetSpace ~
37719 \InsetSpace ~
37720 \InsetSpace ~
37721 \InsetSpace ~
37722 \InsetSpace ~
37723  81\InsetSpace ~
37724 \InsetSpace ~
37725 \InsetSpace ~
37726 \InsetSpace ~
37727 \InsetSpace ~
37728 \InsetSpace ~
37729 \InsetSpace ~
37730 \InsetSpace ~
37731  mov\InsetSpace ~
37732 \InsetSpace ~
37733  c,acc[3] 
37734 \newline
37735 002B 92*03\InsetSpace ~
37736 \InsetSpace ~
37737 \InsetSpace ~
37738 \InsetSpace ~
37739 \InsetSpace ~
37740 \InsetSpace ~
37741 \InsetSpace ~
37742 \InsetSpace ~
37743 \InsetSpace ~
37744 \InsetSpace ~
37745 \InsetSpace ~
37746 \InsetSpace ~
37747 \InsetSpace ~
37748 \InsetSpace ~
37749 \InsetSpace ~
37750  82\InsetSpace ~
37751 \InsetSpace ~
37752 \InsetSpace ~
37753 \InsetSpace ~
37754 \InsetSpace ~
37755 \InsetSpace ~
37756 \InsetSpace ~
37757 \InsetSpace ~
37758  mov\InsetSpace ~
37759 \InsetSpace ~
37760  _foo_aob3_1_1,c 
37761 \end_layout
37762
37763 \begin_layout Standard
37764 Other variations of these cases however will 
37765 \emph on
37766 not
37767 \emph default
37768  be recognized.
37769  They are standard C expressions, so I heartily recommend these be the only
37770  way to get the highest order bit, (it is portable).
37771  Of course it will be recognized even if it is embedded in other expressions,
37772  e.g.:
37773 \end_layout
37774
37775 \begin_layout Verse
37776
37777 \family typewriter
37778 xyz = gint + ((gint >> 15) & 1);
37779 \end_layout
37780
37781 \begin_layout Standard
37782 will still be recognized.
37783 \end_layout
37784
37785 \begin_layout Subsection
37786 Higher Order Byte
37787 \begin_inset LatexCommand index
37788 name "Higher Order Byte"
37789
37790 \end_inset
37791
37792  / Higher Order Word
37793 \begin_inset LatexCommand index
37794 name "Higher Order Word"
37795
37796 \end_inset
37797
37798
37799 \end_layout
37800
37801 \begin_layout Standard
37802 It is also frequently required to obtain a higher order byte or word of
37803  a larger integral type (long, int or short types).
37804  SDCC recognizes the following expressions to yield the higher order byte
37805  or word and generates optimized code for it, e.g.:
37806 \end_layout
37807
37808 \begin_layout Verse
37809
37810 \family typewriter
37811 unsigned int gint; 
37812 \newline
37813 unsigned long int glong; 
37814 \newline
37815
37816 \newline
37817 foo () { 
37818 \newline
37819 \InsetSpace ~
37820 \InsetSpace ~
37821 unsigned char hob1,
37822  hob2; 
37823 \newline
37824 \InsetSpace ~
37825 \InsetSpace ~
37826 unsigned int how1, how2; 
37827 \newline
37828 \InsetSpace ~
37829 \InsetSpace ~
37830 ...
37831  
37832 \newline
37833 \InsetSpace ~
37834 \InsetSpace ~
37835 hob1 = (gint >> 8) & 0xFF; 
37836 \newline
37837 \InsetSpace ~
37838 \InsetSpace ~
37839 hob2 = glong >> 24; 
37840 \newline
37841 \InsetSpace ~
37842 \InsetSpace ~
37843 how1 = (glong >> 16) & 0xFFFF;
37844  
37845 \newline
37846 \InsetSpace ~
37847 \InsetSpace ~
37848 how2 = glong >> 8; 
37849 \newline
37850 \InsetSpace ~
37851 \InsetSpace ~
37852 ..
37853  
37854 \newline
37855 }
37856 \end_layout
37857
37858 \begin_layout Standard
37859 will generate the following code:
37860 \end_layout
37861
37862 \begin_layout Verse
37863
37864 \family typewriter
37865 \InsetSpace ~
37866 \InsetSpace ~
37867 \InsetSpace ~
37868 \InsetSpace ~
37869 \InsetSpace ~
37870 \InsetSpace ~
37871 \InsetSpace ~
37872 \InsetSpace ~
37873 \InsetSpace ~
37874 \InsetSpace ~
37875 \InsetSpace ~
37876 \InsetSpace ~
37877 \InsetSpace ~
37878 \InsetSpace ~
37879 \InsetSpace ~
37880 \InsetSpace ~
37881 \InsetSpace ~
37882 \InsetSpace ~
37883 \InsetSpace ~
37884 \InsetSpace ~
37885 \InsetSpace ~
37886 \InsetSpace ~
37887 \InsetSpace ~
37888 \InsetSpace ~
37889 \InsetSpace ~
37890  91 ;\InsetSpace ~
37891  hob.c 15 
37892 \newline
37893 0037 85*01*06\InsetSpace ~
37894 \InsetSpace ~
37895 \InsetSpace ~
37896 \InsetSpace ~
37897 \InsetSpace ~
37898 \InsetSpace ~
37899 \InsetSpace ~
37900 \InsetSpace ~
37901 \InsetSpace ~
37902 \InsetSpace ~
37903 \InsetSpace ~
37904 \InsetSpace ~
37905  92\InsetSpace ~
37906 \InsetSpace ~
37907 \InsetSpace ~
37908 \InsetSpace ~
37909 \InsetSpace ~
37910 \InsetSpace ~
37911 \InsetSpace ~
37912 \InsetSpace ~
37913  mov\InsetSpace ~
37914 \InsetSpace ~
37915  _foo_hob1_1_1,(_gint + 1) 
37916 \newline
37917 \InsetSpace ~
37918 \InsetSpace ~
37919 \InsetSpace ~
37920 \InsetSpace ~
37921 \InsetSpace ~
37922 \InsetSpace ~
37923 \InsetSpace ~
37924 \InsetSpace ~
37925 \InsetSpace ~
37926 \InsetSpace ~
37927 \InsetSpace ~
37928 \InsetSpace ~
37929 \InsetSpace ~
37930 \InsetSpace ~
37931 \InsetSpace ~
37932 \InsetSpace ~
37933 \InsetSpace ~
37934 \InsetSpace ~
37935 \InsetSpace ~
37936 \InsetSpace ~
37937 \InsetSpace ~
37938 \InsetSpace ~
37939 \InsetSpace ~
37940 \InsetSpace ~
37941 \InsetSpace ~
37942  93 ;\InsetSpace ~
37943  hob.c
37944  16 
37945 \newline
37946 003A 85*05*07\InsetSpace ~
37947 \InsetSpace ~
37948 \InsetSpace ~
37949 \InsetSpace ~
37950 \InsetSpace ~
37951 \InsetSpace ~
37952 \InsetSpace ~
37953 \InsetSpace ~
37954 \InsetSpace ~
37955 \InsetSpace ~
37956 \InsetSpace ~
37957 \InsetSpace ~
37958  94\InsetSpace ~
37959 \InsetSpace ~
37960 \InsetSpace ~
37961 \InsetSpace ~
37962 \InsetSpace ~
37963 \InsetSpace ~
37964 \InsetSpace ~
37965 \InsetSpace ~
37966  mov\InsetSpace ~
37967 \InsetSpace ~
37968  _foo_hob2_1_1,(_glong + 3) 
37969 \newline
37970 \InsetSpace ~
37971 \InsetSpace ~
37972 \InsetSpace ~
37973 \InsetSpace ~
37974 \InsetSpace ~
37975 \InsetSpace ~
37976 \InsetSpace ~
37977 \InsetSpace ~
37978 \InsetSpace ~
37979 \InsetSpace ~
37980 \InsetSpace ~
37981 \InsetSpace ~
37982 \InsetSpace ~
37983 \InsetSpace ~
37984 \InsetSpace ~
37985 \InsetSpace ~
37986 \InsetSpace ~
37987 \InsetSpace ~
37988 \InsetSpace ~
37989 \InsetSpace ~
37990 \InsetSpace ~
37991 \InsetSpace ~
37992 \InsetSpace ~
37993 \InsetSpace ~
37994 \InsetSpace ~
37995  95 ;\InsetSpace ~
37996  hob.c 17 
37997 \newline
37998 003D 85*04*08\InsetSpace ~
37999 \InsetSpace ~
38000 \InsetSpace ~
38001 \InsetSpace ~
38002 \InsetSpace ~
38003 \InsetSpace ~
38004 \InsetSpace ~
38005 \InsetSpace ~
38006 \InsetSpace ~
38007 \InsetSpace ~
38008 \InsetSpace ~
38009 \InsetSpace ~
38010
38011  96\InsetSpace ~
38012 \InsetSpace ~
38013 \InsetSpace ~
38014 \InsetSpace ~
38015 \InsetSpace ~
38016 \InsetSpace ~
38017 \InsetSpace ~
38018 \InsetSpace ~
38019  mov\InsetSpace ~
38020 \InsetSpace ~
38021  _foo_how1_1_1,(_glong + 2) 
38022 \newline
38023 0040 85*05*09\InsetSpace ~
38024 \InsetSpace ~
38025 \InsetSpace ~
38026 \InsetSpace ~
38027 \InsetSpace ~
38028 \InsetSpace ~
38029 \InsetSpace ~
38030 \InsetSpace ~
38031 \InsetSpace ~
38032 \InsetSpace ~
38033 \InsetSpace ~
38034 \InsetSpace ~
38035  97\InsetSpace ~
38036 \InsetSpace ~
38037 \InsetSpace ~
38038 \InsetSpace ~
38039 \InsetSpace ~
38040 \InsetSpace ~
38041 \InsetSpace ~
38042 \InsetSpace ~
38043  mov\InsetSpace ~
38044 \InsetSpace ~
38045  (_foo_how1_1_1 +
38046  1),(_glong + 3) 
38047 \newline
38048 0043 85*03*0A\InsetSpace ~
38049 \InsetSpace ~
38050 \InsetSpace ~
38051 \InsetSpace ~
38052 \InsetSpace ~
38053 \InsetSpace ~
38054 \InsetSpace ~
38055 \InsetSpace ~
38056 \InsetSpace ~
38057 \InsetSpace ~
38058 \InsetSpace ~
38059 \InsetSpace ~
38060  98\InsetSpace ~
38061 \InsetSpace ~
38062 \InsetSpace ~
38063 \InsetSpace ~
38064 \InsetSpace ~
38065 \InsetSpace ~
38066 \InsetSpace ~
38067 \InsetSpace ~
38068  mov\InsetSpace ~
38069 \InsetSpace ~
38070  _foo_how2_1_1,(_glong + 1) 
38071 \newline
38072 0046 85*04*0B\InsetSpace ~
38073 \InsetSpace ~
38074 \InsetSpace ~
38075 \InsetSpace ~
38076 \InsetSpace ~
38077 \InsetSpace ~
38078 \InsetSpace ~
38079 \InsetSpace ~
38080 \InsetSpace ~
38081 \InsetSpace ~
38082 \InsetSpace ~
38083 \InsetSpace ~
38084
38085  99\InsetSpace ~
38086 \InsetSpace ~
38087 \InsetSpace ~
38088 \InsetSpace ~
38089 \InsetSpace ~
38090 \InsetSpace ~
38091 \InsetSpace ~
38092 \InsetSpace ~
38093  mov\InsetSpace ~
38094 \InsetSpace ~
38095  (_foo_how2_1_1 + 1),(_glong + 2) 
38096 \end_layout
38097
38098 \begin_layout Standard
38099 Again, variations of these cases may 
38100 \emph on
38101 not
38102 \emph default
38103  be recognized.
38104  They are standard C expressions, so I heartily recommend these be the only
38105  way to get the higher order byte/word, (it is portable).
38106  Of course it will be recognized even if it is embedded in other expressions,
38107  e.g.:
38108 \end_layout
38109
38110 \begin_layout Verse
38111
38112 \family typewriter
38113 xyz = gint + ((gint >> 8) & 0xFF);
38114 \end_layout
38115
38116 \begin_layout Standard
38117 will still be recognized.
38118 \end_layout
38119
38120 \begin_layout Subsection
38121 Peephole Optimizer
38122 \begin_inset LatexCommand label
38123 name "sub:Peephole-Optimizer"
38124
38125 \end_inset
38126
38127
38128 \begin_inset LatexCommand index
38129 name "Peephole optimizer"
38130
38131 \end_inset
38132
38133
38134 \end_layout
38135
38136 \begin_layout Standard
38137 The compiler uses a rule based, pattern matching and re-writing mechanism
38138  for peep-hole optimization.
38139  It is inspired by 
38140 \emph on
38141 copt
38142 \emph default
38143  a peep-hole optimizer by Christopher W.
38144  Fraser (cwfraser\InsetSpace ~
38145 @\InsetSpace ~
38146 microsoft.com).
38147  A default set of rules are compiled into the compiler, additional rules
38148  may be added with the 
38149 \emph on
38150 -
38151 \begin_inset ERT
38152 status collapsed
38153
38154 \begin_layout Standard
38155
38156
38157 \backslash
38158 /
38159 \end_layout
38160
38161 \end_inset
38162
38163 -peep-file
38164 \begin_inset LatexCommand index
38165 name "-\\/-peep-file"
38166
38167 \end_inset
38168
38169  <filename>
38170 \emph default
38171  option.
38172  The rule language is best illustrated with examples.
38173 \end_layout
38174
38175 \begin_layout Verse
38176
38177 \family typewriter
38178 replace { 
38179 \newline
38180 \InsetSpace ~
38181 \InsetSpace ~
38182 mov %1,a 
38183 \newline
38184 \InsetSpace ~
38185 \InsetSpace ~
38186 mov a,%1
38187 \newline
38188 } by {
38189 \newline
38190 \InsetSpace ~
38191 \InsetSpace ~
38192 mov %1,a
38193 \newline
38194 }
38195 \end_layout
38196
38197 \begin_layout Standard
38198 The above rule will change the following assembly
38199 \begin_inset LatexCommand index
38200 name "Assembler routines"
38201
38202 \end_inset
38203
38204  sequence:
38205 \end_layout
38206
38207 \begin_layout Verse
38208
38209 \family typewriter
38210 mov r1,a 
38211 \newline
38212 mov a,r1
38213 \end_layout
38214
38215 \begin_layout Standard
38216 to
38217 \end_layout
38218
38219 \begin_layout Verse
38220
38221 \family typewriter
38222 mov r1,a
38223 \end_layout
38224
38225 \begin_layout Standard
38226 Note: All occurrences of a 
38227 \emph on
38228 %n
38229 \emph default
38230  (pattern variable) must denote the same string.
38231  With the above rule, the assembly sequence:
38232 \end_layout
38233
38234 \begin_layout Verse
38235
38236 \family typewriter
38237 mov r1,a 
38238 \newline
38239 mov a,r2
38240 \end_layout
38241
38242 \begin_layout Standard
38243 will remain unmodified.
38244 \newline
38245
38246 \newline
38247 Other special case optimizations may be added by the
38248  user (via 
38249 \emph on
38250 -
38251 \begin_inset ERT
38252 status collapsed
38253
38254 \begin_layout Standard
38255
38256
38257 \backslash
38258 /
38259 \end_layout
38260
38261 \end_inset
38262
38263 -peep-file option
38264 \emph default
38265 ).
38266  E.g.
38267  some variants of the 8051 MCU
38268 \begin_inset LatexCommand index
38269 name "MCS51 variants"
38270
38271 \end_inset
38272
38273  allow only 
38274 \family typewriter
38275 ajmp
38276 \family default
38277  and 
38278 \family typewriter
38279 acall
38280 \family default
38281 .
38282  The following two rules will change all 
38283 \family typewriter
38284 ljmp
38285 \family default
38286  and 
38287 \family typewriter
38288 lcall
38289 \family default
38290  to 
38291 \family typewriter
38292 ajmp
38293 \family default
38294  and 
38295 \family typewriter
38296 acall
38297 \end_layout
38298
38299 \begin_layout Verse
38300
38301 \family typewriter
38302 replace { lcall %1 } by { acall %1 } 
38303 \newline
38304 replace { ljmp %1 } by { ajmp %1 }
38305 \end_layout
38306
38307 \begin_layout Standard
38308 (NOTE: from version 2.7.3 on, you can use option -
38309 \emph on
38310
38311 \begin_inset ERT
38312 status collapsed
38313
38314 \begin_layout Standard
38315
38316
38317 \backslash
38318 /
38319 \end_layout
38320
38321 \end_inset
38322
38323
38324 \emph default
38325 -acall-ajmp
38326 \begin_inset LatexCommand index
38327 name "-\\/-acall-ajmp"
38328
38329 \end_inset
38330
38331 , which also takes care of aligning the interrupt vectors properly.)
38332 \newline
38333
38334 \end_layout
38335
38336 \begin_layout Standard
38337 The 
38338 \emph on
38339 inline-assembler code
38340 \emph default
38341  is also passed through the peep hole optimizer, thus the peephole optimizer
38342  can also be used as an assembly level macro expander.
38343  The rules themselves are MCU dependent whereas the rule language infra-structur
38344 e is MCU independent.
38345  Peephole optimization rules for other MCU can be easily programmed using
38346  the rule language.
38347 \newline
38348
38349 \newline
38350 The syntax for a rule is as follows:
38351 \end_layout
38352
38353 \begin_layout Verse
38354
38355 \family typewriter
38356 rule := replace [ restart ] '{' <assembly sequence> '
38357 \backslash
38358 n' 
38359 \newline
38360 \InsetSpace ~
38361  \InsetSpace ~
38362  \InsetSpace ~
38363  \InsetSpace ~
38364  \InsetSpace ~
38365  \InsetSpace ~
38366  \InsetSpace ~
38367  \InsetSpace ~
38368  \InsetSpace ~
38369  \InsetSpace ~
38370  \InsetSpace ~
38371  \InsetSpace ~
38372  \InsetSpace ~
38373  \InsetSpace ~
38374  '}' by '{' '
38375 \backslash
38376 n' 
38377 \newline
38378 \InsetSpace ~
38379  \InsetSpace ~
38380  \InsetSpace ~
38381  \InsetSpace ~
38382  \InsetSpace ~
38383  \InsetSpace ~
38384  \InsetSpace ~
38385  \InsetSpace ~
38386  \InsetSpace ~
38387  \InsetSpace ~
38388  \InsetSpace ~
38389  \InsetSpace ~
38390  \InsetSpace ~
38391  \InsetSpace ~
38392  \InsetSpace ~
38393  \InsetSpace ~
38394  <assembly sequence> '
38395 \backslash
38396 n' 
38397 \newline
38398 \InsetSpace ~
38399  \InsetSpace ~
38400  \InsetSpace ~
38401  \InsetSpace ~
38402  \InsetSpace ~
38403  \InsetSpace ~
38404  \InsetSpace ~
38405  \InsetSpace ~
38406  \InsetSpace ~
38407  \InsetSpace ~
38408  \InsetSpace ~
38409  \InsetSpace ~
38410  \InsetSpace ~
38411  \InsetSpace ~
38412  '}' [if <functionName> ] '
38413 \backslash
38414 n' 
38415 \end_layout
38416
38417 \begin_layout Standard
38418 <assembly sequence> := assembly instruction (each instruction including
38419  labels must be on a separate line).
38420 \newline
38421
38422 \newline
38423 The optimizer will apply to the rules
38424  one by one from the top in the sequence of their appearance, it will terminate
38425  when all rules are exhausted.
38426  If the 'restart' option is specified, then the optimizer will start matching
38427  the rules again from the top, this option for a rule is expensive (performance)
38428 , it is intended to be used in situations where a transformation will trigger
38429  the same rule again.
38430  An example of this (not a good one, it has side effects) is the following
38431  rule:
38432 \end_layout
38433
38434 \begin_layout Verse
38435
38436 \family typewriter
38437 replace restart { 
38438 \newline
38439 \InsetSpace ~
38440 \InsetSpace ~
38441 pop %1 
38442 \newline
38443 \InsetSpace ~
38444 \InsetSpace ~
38445 push %1 } by { 
38446 \newline
38447 \InsetSpace ~
38448 \InsetSpace ~
38449 ; nop 
38450 \newline
38451 }
38452 \end_layout
38453
38454 \begin_layout Standard
38455 Note that the replace pattern cannot be a blank, but can be a comment line.
38456  Without the 'restart' option only the innermost 'pop' 'push' pair would
38457  be eliminated, i.e.:
38458 \end_layout
38459
38460 \begin_layout Verse
38461
38462 \family typewriter
38463 pop ar1 
38464 \newline
38465 pop ar2 
38466 \newline
38467 push ar2 
38468 \newline
38469 push ar1
38470 \end_layout
38471
38472 \begin_layout Standard
38473 would result in:
38474 \end_layout
38475
38476 \begin_layout Verse
38477
38478 \family typewriter
38479 pop ar1 
38480 \newline
38481 ; nop 
38482 \newline
38483 push ar1
38484 \end_layout
38485
38486 \begin_layout Standard
38487
38488 \emph on
38489 with
38490 \emph default
38491  the restart option the rule will be applied again to the resulting code
38492  and then all the pop-push pairs will be eliminated to yield:
38493 \end_layout
38494
38495 \begin_layout Verse
38496
38497 \family typewriter
38498 ; nop 
38499 \newline
38500 ; nop
38501 \end_layout
38502
38503 \begin_layout Standard
38504 A conditional function can be attached to a rule.
38505  Attaching rules are somewhat more involved, let me illustrate this with
38506  an example.
38507 \end_layout
38508
38509 \begin_layout Verse
38510
38511 \family typewriter
38512 replace { 
38513 \newline
38514 \InsetSpace ~
38515  \InsetSpace ~
38516  \InsetSpace ~
38517 ljmp %5 
38518 \newline
38519 %2:
38520 \newline
38521 } by { 
38522 \newline
38523 \InsetSpace ~
38524  \InsetSpace ~
38525  \InsetSpace ~
38526 sjmp %5 
38527 \newline
38528 %2:
38529 \newline
38530 } if labelInRange
38531 \end_layout
38532
38533 \begin_layout Standard
38534 The optimizer does a look-up of a function name table defined in function
38535  
38536 \emph on
38537 callFuncByName
38538 \emph default
38539  in the source file SDCCpeeph.c, with the name 
38540 \emph on
38541 labelInRange
38542 \emph default
38543 .
38544  If it finds a corresponding entry the function is called.
38545  Note there can be no parameters specified for these functions, in this
38546  case the use of 
38547 \emph on
38548 %5
38549 \emph default
38550  is crucial, since the function 
38551 \emph on
38552 labelInRange
38553 \emph default
38554  expects to find the label in that particular variable (the hash table containin
38555 g the variable bindings is passed as a parameter).
38556  If you want to code more such functions, take a close look at the function
38557  labelInRange and the calling mechanism in source file SDCCpeeph.c.
38558  Currently implemented are 
38559 \emph on
38560 labelInRange, labelRefCount, labelIsReturnOnly, operandsNotSame, xramMovcOption,
38561  24bitMode, portIsDS390, 24bitModeAndPortDS390
38562 \emph default
38563  and 
38564 \emph on
38565 notVolatile
38566 \emph default
38567 .
38568 \end_layout
38569
38570 \begin_layout Standard
38571 I know this whole thing is a little kludgey, but maybe some day we will
38572  have some better means.
38573  If you are looking at this file, you will see the default rules that are
38574  compiled into the compiler, you can add your own rules in the default set
38575  there if you get tired of specifying the -
38576 \begin_inset ERT
38577 status collapsed
38578
38579 \begin_layout Standard
38580
38581
38582 \backslash
38583 /
38584 \end_layout
38585
38586 \end_inset
38587
38588 -peep-file option.
38589 \end_layout
38590
38591 \begin_layout Section
38592 ANSI-Compliance
38593 \begin_inset LatexCommand index
38594 name "ANSI-compliance"
38595
38596 \end_inset
38597
38598
38599 \begin_inset LatexCommand label
38600 name "sub:ANSI-Compliance"
38601
38602 \end_inset
38603
38604
38605 \end_layout
38606
38607 \begin_layout Standard
38608 The latest publicly available version of the standard 
38609 \emph on
38610 ISO/IEC 9899 - Programming languages - C
38611 \emph default
38612  should be available at: 
38613 \begin_inset LatexCommand url
38614 target "http://www.open-std.org/jtc1/sc22/wg14/www/standards.html#9899"
38615
38616 \end_inset
38617
38618 .
38619 \newline
38620
38621 \end_layout
38622
38623 \begin_layout Standard
38624 Deviations from the compliance:
38625 \end_layout
38626
38627 \begin_layout Itemize
38628 functions are not reentrant
38629 \begin_inset LatexCommand index
38630 name "reentrant"
38631
38632 \end_inset
38633
38634  unless explicitly declared as such or the 
38635 \series bold
38636 -
38637 \begin_inset ERT
38638 status collapsed
38639
38640 \begin_layout Standard
38641
38642
38643 \backslash
38644 /
38645 \end_layout
38646
38647 \end_inset
38648
38649 -stack-auto
38650 \begin_inset LatexCommand index
38651 name "-\\/-stack-auto"
38652
38653 \end_inset
38654
38655
38656 \series default
38657  command line option is specified.
38658 \end_layout
38659
38660 \begin_layout Itemize
38661 structures
38662 \begin_inset LatexCommand index
38663 name "struct"
38664
38665 \end_inset
38666
38667  and unions
38668 \begin_inset LatexCommand index
38669 name "union"
38670
38671 \end_inset
38672
38673  cannot be assigned values directly, cannot be passed as function parameters
38674  or assigned to each other and cannot be a return value
38675 \begin_inset LatexCommand index
38676 name "return value"
38677
38678 \end_inset
38679
38680  from a function, e.g.:
38681 \end_layout
38682
38683 \begin_deeper
38684 \begin_layout Verse
38685
38686 \family typewriter
38687 struct s { ...
38688  }; 
38689 \newline
38690 struct s s1, s2; 
38691 \newline
38692 foo() 
38693 \newline
38694
38695 \newline
38696 \InsetSpace ~
38697 \InsetSpace ~
38698 \InsetSpace ~
38699 \InsetSpace ~
38700 ...
38701  
38702 \newline
38703 \InsetSpace ~
38704 \InsetSpace ~
38705 \InsetSpace ~
38706 \InsetSpace ~
38707 s1 = s2 ; /* is invalid in SDCC although allowed in ANSI */ 
38708 \newline
38709 \InsetSpace ~
38710 \InsetSpace ~
38711 \InsetSpace ~
38712 \InsetSpace ~
38713 ...
38714  
38715 \newline
38716 }
38717 \newline
38718
38719 \series bold
38720 struct
38721 \family default
38722 \series default
38723  
38724 \family typewriter
38725 s foo1 (
38726 \series bold
38727 struct
38728 \family default
38729 \series default
38730  
38731 \family typewriter
38732 s parms) /* invalid in SDCC although allowed in ANSI */
38733 \newline
38734
38735 \newline
38736 \InsetSpace ~
38737 \InsetSpace ~
38738 \InsetSpace ~
38739 \InsetSpace ~
38740 struct s rets;
38741  
38742 \newline
38743 \InsetSpace ~
38744 \InsetSpace ~
38745 \InsetSpace ~
38746 \InsetSpace ~
38747 ...
38748  
38749 \newline
38750 \InsetSpace ~
38751 \InsetSpace ~
38752 \InsetSpace ~
38753 \InsetSpace ~
38754 return rets; /* is invalid in SDCC although allowed in ANSI */ 
38755 \newline
38756 }
38757 \end_layout
38758
38759 \end_deeper
38760 \begin_layout Itemize
38761 initialization of structure arrays must be fully braced.
38762 \end_layout
38763
38764 \begin_deeper
38765 \begin_layout Verse
38766
38767 \family typewriter
38768 struct s { char x } a[] = {1, 2};\InsetSpace ~
38769 \InsetSpace ~
38770 \InsetSpace ~
38771 \InsetSpace ~
38772 \InsetSpace ~
38773 /* invalid in SDCC */
38774 \newline
38775 struct s { char x
38776  } a[] = {{1}, {2}}; /* OK */
38777 \end_layout
38778
38779 \end_deeper
38780 \begin_layout Itemize
38781 'long long
38782 \begin_inset LatexCommand index
38783 name "long long (not supported)"
38784
38785 \end_inset
38786
38787 ' (64 bit integers
38788 \begin_inset LatexCommand index
38789 name "int (64 bit) (not supported)"
38790
38791 \end_inset
38792
38793 ) not supported.
38794 \end_layout
38795
38796 \begin_layout Itemize
38797 'double
38798 \begin_inset LatexCommand index
38799 name "double (not supported)"
38800
38801 \end_inset
38802
38803 ' precision floating point 
38804 \begin_inset LatexCommand index
38805 name "Floating point support"
38806
38807 \end_inset
38808
38809 not supported.
38810 \end_layout
38811
38812 \begin_layout Itemize
38813 Old K&R style
38814 \begin_inset LatexCommand index
38815 name "K\\&R style"
38816
38817 \end_inset
38818
38819  function declarations are NOT allowed.
38820 \end_layout
38821
38822 \begin_deeper
38823 \begin_layout Verse
38824
38825 \family typewriter
38826 foo(i,j) /* this old style of function declarations */ 
38827 \newline
38828 int i,j; /* is valid
38829  in ANSI but not valid in SDCC */ 
38830 \newline
38831
38832 \newline
38833 \InsetSpace ~
38834 \InsetSpace ~
38835 \InsetSpace ~
38836 \InsetSpace ~
38837 ...
38838  
38839 \newline
38840 }
38841 \end_layout
38842
38843 \end_deeper
38844 \begin_layout Itemize
38845 Most enhancements in C99 are not supported, e.g.:
38846 \end_layout
38847
38848 \begin_deeper
38849 \begin_layout Verse
38850
38851 \family typewriter
38852 for (
38853 \series bold
38854 int
38855 \family default
38856 \series default
38857  
38858 \family typewriter
38859 i=0; i<10; i++) /* is invalid in SDCC although allowed in C99 */
38860 \end_layout
38861
38862 \end_deeper
38863 \begin_layout Itemize
38864 But some have been added recently in SDCC 2.7.0.
38865  They must be considered alpha quality however.
38866 \end_layout
38867
38868 \begin_deeper
38869 \begin_layout Verse
38870
38871 \family typewriter
38872 \series bold
38873 inline
38874 \begin_inset LatexCommand index
38875 name "inline (not supported)"
38876
38877 \end_inset
38878
38879
38880 \family default
38881 \series default
38882  
38883 \family typewriter
38884 int increment (int a) { return a+1; } /* inlines the increment without function
38885  call overhead */
38886 \newline
38887 int *
38888 \family default
38889  
38890 \family typewriter
38891 \series bold
38892 restrict
38893 \begin_inset LatexCommand index
38894 name "inline (not supported)"
38895
38896 \end_inset
38897
38898
38899 \family default
38900 \series default
38901  
38902 \family typewriter
38903 p; /* accepted but ignored */
38904 \end_layout
38905
38906 \end_deeper
38907 \begin_layout Itemize
38908 Certain words that are valid identifiers in the standard may be reserved
38909  words in SDCC unless the 
38910 \series bold
38911 -
38912 \begin_inset ERT
38913 status collapsed
38914
38915 \begin_layout Standard
38916
38917
38918 \backslash
38919 /
38920 \end_layout
38921
38922 \end_inset
38923
38924 -std-c89
38925 \begin_inset LatexCommand index
38926 name "-\\/-std-c89"
38927
38928 \end_inset
38929
38930
38931 \series default
38932  or 
38933 \series bold
38934 -
38935 \begin_inset ERT
38936 status collapsed
38937
38938 \begin_layout Standard
38939
38940
38941 \backslash
38942 /
38943 \end_layout
38944
38945 \end_inset
38946
38947 -std-c99
38948 \begin_inset LatexCommand index
38949 name "-\\/-std-c99"
38950
38951 \end_inset
38952
38953
38954 \series default
38955  command line options are used.
38956  These may include (depending on the selected processor): 'at', 'banked',
38957  'bit', 'code', 'critical', 'data', 'eeprom', 'far', 'flash', 'idata', 'interrup
38958 t', 'near', 'nonbanked', 'pdata', 'reentrant', 'sbit', 'sfr', 'shadowregs',
38959  'sram', 'using', 'wparam', 'xdata', '_overlay', '_asm', '_endasm', and
38960  '_naked'.
38961  Compliant equivalents of these keywords are always available in a form
38962  that begin with two underscores
38963 \begin_inset LatexCommand index
38964 name "\\_\\_ (prefix for extended keywords)"
38965
38966 \end_inset
38967
38968 , f.e.
38969  '__data' instead of 'data'.
38970 \end_layout
38971
38972 \begin_layout Itemize
38973 Integer promotion of variable arguments is not performed if the argument
38974  is explicitly taypecasted unless the 
38975 \series bold
38976 -
38977 \begin_inset ERT
38978 status collapsed
38979
38980 \begin_layout Standard
38981
38982
38983 \backslash
38984 /
38985 \end_layout
38986
38987 \end_inset
38988
38989 -std-c89
38990 \begin_inset LatexCommand index
38991 name "-\\/-std-c89"
38992
38993 \end_inset
38994
38995
38996 \series default
38997  or 
38998 \series bold
38999 -
39000 \begin_inset ERT
39001 status collapsed
39002
39003 \begin_layout Standard
39004
39005
39006 \backslash
39007 /
39008 \end_layout
39009
39010 \end_inset
39011
39012 -std-c99
39013 \begin_inset LatexCommand index
39014 name "-\\/-std-c99"
39015
39016 \end_inset
39017
39018
39019 \series default
39020  command line options are used.
39021 \end_layout
39022
39023 \begin_deeper
39024 \begin_layout Verse
39025
39026 \family typewriter
39027 void vararg_func (char *str, ...) { str; }
39028 \newline
39029
39030 \newline
39031 void main (void)
39032 \newline
39033 {
39034 \newline
39035 \InsetSpace ~
39036 \InsetSpace ~
39037 char c = 10;
39038 \newline
39039
39040 \newline
39041 \InsetSpace ~
39042 \InsetSpace ~
39043 /* argument
39044  u is promoted to int before
39045 \newline
39046 \InsetSpace ~
39047 \InsetSpace ~
39048 \InsetSpace ~
39049 * passing to function */
39050 \newline
39051 \InsetSpace ~
39052 \InsetSpace ~
39053 vararg_func ("%c", c);
39054 \newline
39055
39056 \newline
39057 \InsetSpace ~
39058 \InsetSpace ~
39059 /*
39060  argument u is not promoted to int,
39061 \newline
39062 \InsetSpace ~
39063 \InsetSpace ~
39064 \InsetSpace ~
39065 * it is passed as char to function
39066 \newline
39067 \InsetSpace ~
39068 \InsetSpace ~
39069 \InsetSpace ~
39070 * if
39071  --std-cXX is not defined;
39072 \newline
39073 \InsetSpace ~
39074 \InsetSpace ~
39075 \InsetSpace ~
39076 * is promoted to int before passing
39077 \newline
39078 \InsetSpace ~
39079 \InsetSpace ~
39080 \InsetSpace ~
39081 * to function
39082  if --std-cXX is defined */
39083 \newline
39084 \InsetSpace ~
39085 \InsetSpace ~
39086 vararg_func ("%bc", (char)u);
39087 \newline
39088 }
39089 \end_layout
39090
39091 \end_deeper
39092 \begin_layout Section
39093 Cyclomatic Complexity
39094 \begin_inset LatexCommand index
39095 name "Cyclomatic complexity"
39096
39097 \end_inset
39098
39099
39100 \end_layout
39101
39102 \begin_layout Standard
39103 Cyclomatic complexity of a function is defined as the number of independent
39104  paths the program can take during execution of the function.
39105  This is an important number since it defines the number test cases you
39106  have to generate to validate the function.
39107  The accepted industry standard for complexity number is 10, if the cyclomatic
39108  complexity reported by SDCC exceeds 10 you should think about simplification
39109  of the function logic.
39110  Note that the complexity level is not related to the number of lines of
39111  code in a function.
39112  Large functions can have low complexity, and small functions can have large
39113  complexity levels.
39114  
39115 \newline
39116
39117 \newline
39118 SDCC uses the following formula to compute the complexity:
39119 \newline
39120
39121 \end_layout
39122
39123 \begin_layout Standard
39124 complexity = (number of edges in control flow graph) - (number of nodes
39125  in control flow graph) + 2;
39126 \newline
39127
39128 \newline
39129 Having said that the industry standard is 10,
39130  you should be aware that in some cases it be may unavoidable to have a
39131  complexity level of less than 10.
39132  For example if you have switch statement with more than 10 case labels,
39133  each case label adds one to the complexity level.
39134  The complexity level is by no means an absolute measure of the algorithmic
39135  complexity of the function, it does however provide a good starting point
39136  for which functions you might look at for further optimization.
39137 \end_layout
39138
39139 \begin_layout Section
39140 Retargetting for other Processors
39141 \end_layout
39142
39143 \begin_layout Standard
39144 The issues for retargetting the compiler are far too numerous to be covered
39145  by this document.
39146  What follows is a brief description of each of the seven phases of the
39147  compiler and its MCU dependency.
39148 \end_layout
39149
39150 \begin_layout Itemize
39151 Parsing the source and building the annotated parse tree.
39152  This phase is largely MCU independent (except for the language extensions).
39153  Syntax & semantic checks are also done in this phase, along with some initial
39154  optimizations like back patching labels and the pattern matching optimizations
39155  like bit-rotation etc.
39156 \end_layout
39157
39158 \begin_layout Itemize
39159 The second phase involves generating an intermediate code which can be easy
39160  manipulated during the later phases.
39161  This phase is entirely MCU independent.
39162  The intermediate code generation assumes the target machine has unlimited
39163  number of registers, and designates them with the name iTemp.
39164  The compiler can be made to dump a human readable form of the code generated
39165  by using the -
39166 \begin_inset ERT
39167 status collapsed
39168
39169 \begin_layout Standard
39170
39171
39172 \backslash
39173 /
39174 \end_layout
39175
39176 \end_inset
39177
39178 -dumpraw option.
39179 \end_layout
39180
39181 \begin_layout Itemize
39182 This phase does the bulk of the standard optimizations and is also MCU independe
39183 nt.
39184  This phase can be broken down into several sub-phases:
39185 \newline
39186
39187 \newline
39188 Break down intermediate
39189  code (iCode) into basic blocks.
39190 \newline
39191 Do control flow & data flow analysis on the
39192  basic blocks.
39193 \newline
39194 Do local common subexpression elimination, then global subexpressio
39195 n elimination
39196 \newline
39197 Dead code elimination
39198 \newline
39199 Loop optimizations
39200 \newline
39201 If loop optimizations
39202  caused any changes then do 'global subexpression elimination' and 'dead
39203  code elimination' again.
39204 \end_layout
39205
39206 \begin_layout Itemize
39207 This phase determines the live-ranges; by live range I mean those iTemp
39208  variables defined by the compiler that still survive after all the optimization
39209 s.
39210  Live range analysis
39211 \begin_inset LatexCommand index
39212 name "Live range analysis"
39213
39214 \end_inset
39215
39216  is essential for register allocation, since these computation determines
39217  which of these iTemps will be assigned to registers, and for how long.
39218 \end_layout
39219
39220 \begin_layout Itemize
39221 Phase five is register allocation.
39222  There are two parts to this process.
39223 \newline
39224
39225 \newline
39226 The first part I call 'register packing'
39227  (for lack of a better term).
39228  In this case several MCU specific expression folding is done to reduce
39229  register pressure.
39230 \newline
39231
39232 \newline
39233 The second part is more MCU independent and deals with
39234  allocating registers to the remaining live ranges.
39235  A lot of MCU specific code does creep into this phase because of the limited
39236  number of index registers available in the 8051.
39237 \end_layout
39238
39239 \begin_layout Itemize
39240 The Code generation phase is (unhappily), entirely MCU dependent and very
39241  little (if any at all) of this code can be reused for other MCU.
39242  However the scheme for allocating a homogenized assembler operand for each
39243  iCode operand may be reused.
39244 \end_layout
39245
39246 \begin_layout Itemize
39247 As mentioned in the optimization section the peep-hole optimizer is rule
39248  based system, which can reprogrammed for other MCUs.
39249 \end_layout
39250
39251 \begin_layout Standard
39252 More information is available on SDCC Wiki
39253 \begin_inset LatexCommand index
39254 name "wiki"
39255
39256 \end_inset
39257
39258  (preliminary link 
39259 \begin_inset LatexCommand url
39260 target "http://sdcc.wiki.sourceforge.net/SDCC+internals+and+porting"
39261
39262 \end_inset
39263
39264 ) and in the thread 
39265 \begin_inset LatexCommand url
39266 target "http://sf.net/mailarchive/message.php?msg_id=13954144"
39267
39268 \end_inset
39269
39270  .
39271 \end_layout
39272
39273 \begin_layout Chapter
39274 Compiler internals
39275 \begin_inset LatexCommand index
39276 name "Compiler internals"
39277
39278 \end_inset
39279
39280
39281 \end_layout
39282
39283 \begin_layout Section
39284 The anatomy of the compiler
39285 \begin_inset LatexCommand label
39286 name "sub:The-anatomy-of"
39287
39288 \end_inset
39289
39290
39291 \end_layout
39292
39293 \begin_layout Standard
39294
39295 \shape italic
39296 This is an excerpt from an article published in Circuit Cellar Magazine
39297  in
39298 \shape default
39299  
39300 \series bold
39301 \shape italic
39302 August 2000
39303 \series default
39304 .
39305  It's a little outdated (the compiler is much more efficient now and user/develo
39306 per friendly), but pretty well exposes the guts of it all.
39307 \shape default
39308
39309 \newline
39310
39311 \newline
39312 The current version of SDCC can generate code for Intel 8051 and Z80 MCU.
39313  It is fairly easy to retarget for other 8-bit MCU.
39314  Here we take a look at some of the internals of the compiler.
39315  
39316 \end_layout
39317
39318 \begin_layout Paragraph*
39319 Parsing
39320 \begin_inset LatexCommand index
39321 name "Parsing"
39322
39323 \end_inset
39324
39325  
39326 \end_layout
39327
39328 \begin_layout Standard
39329 Parsing the input source file and creating an AST (Annotated Syntax Tree
39330 \begin_inset LatexCommand index
39331 name "Annotated syntax tree"
39332
39333 \end_inset
39334
39335 ).
39336  This phase also involves propagating types (annotating each node of the
39337  parse tree with type information) and semantic analysis.
39338  There are some MCU specific parsing rules.
39339  For example the storage classes, the extended storage classes are MCU specific
39340  while there may be a xdata storage class for 8051 there is no such storage
39341  class for z80 or Atmel AVR.
39342  SDCC allows MCU specific storage class extensions, i.e.
39343  xdata will be treated as a storage class specifier when parsing 8051 C
39344  code but will be treated as a C identifier when parsing z80 or ATMEL AVR
39345  C code.
39346 \end_layout
39347
39348 \begin_layout Paragraph*
39349 Generating iCode
39350 \begin_inset LatexCommand index
39351 name "iCode"
39352
39353 \end_inset
39354
39355
39356 \end_layout
39357
39358 \begin_layout Standard
39359 Intermediate code generation.
39360  In this phase the AST is broken down into three-operand form (iCode).
39361  These three operand forms are represented as doubly linked lists.
39362  ICode is the term given to the intermediate form generated by the compiler.
39363  ICode example section shows some examples of iCode generated for some simple
39364  C source functions.
39365 \end_layout
39366
39367 \begin_layout Paragraph*
39368 Optimizations
39369 \begin_inset LatexCommand index
39370 name "Optimizations"
39371
39372 \end_inset
39373
39374 .
39375 \end_layout
39376
39377 \begin_layout Standard
39378 Bulk of the target independent optimizations is performed in this phase.
39379  The optimizations include constant propagation, common sub-expression eliminati
39380 on, loop invariant code movement, strength reduction of loop induction variables
39381  and dead-code elimination.
39382 \end_layout
39383
39384 \begin_layout Paragraph*
39385 Live range analysis
39386 \begin_inset LatexCommand index
39387 name "Live range analysis"
39388
39389 \end_inset
39390
39391
39392 \end_layout
39393
39394 \begin_layout Standard
39395 During intermediate code generation phase, the compiler assumes the target
39396  machine has infinite number of registers and generates a lot of temporary
39397  variables.
39398  The live range computation determines the lifetime of each of these compiler-ge
39399 nerated temporaries.
39400  A picture speaks a thousand words.
39401  ICode example sections show the live range annotations for each of the
39402  operand.
39403  It is important to note here, each iCode is assigned a number in the order
39404  of its execution in the function.
39405  The live ranges are computed in terms of these numbers.
39406  The from number is the number of the iCode which first defines the operand
39407  and the to number signifies the iCode which uses this operand last.
39408 \end_layout
39409
39410 \begin_layout Paragraph*
39411 Register Allocation
39412 \begin_inset LatexCommand index
39413 name "Register allocation"
39414
39415 \end_inset
39416
39417
39418 \end_layout
39419
39420 \begin_layout Standard
39421 The register allocation determines the type and number of registers needed
39422  by each operand.
39423  In most MCUs only a few registers can be used for indirect addressing.
39424  In case of 8051 for example the registers R0 & R1 can be used to indirectly
39425  address the internal ram and DPTR to indirectly address the external ram.
39426  The compiler will try to allocate the appropriate register to pointer variables
39427  if it can.
39428  ICode example section shows the operands annotated with the registers assigned
39429  to them.
39430  The compiler will try to keep operands in registers as much as possible;
39431  there are several schemes the compiler uses to do achieve this.
39432  When the compiler runs out of registers the compiler will check to see
39433  if there are any live operands which is not used or defined in the current
39434  basic block being processed, if there are any found then it will push that
39435  operand and use the registers in this block, the operand will then be popped
39436  at the end of the basic block.
39437  
39438 \end_layout
39439
39440 \begin_layout Standard
39441 There are other MCU specific considerations in this phase.
39442  Some MCUs have an accumulator; very short-lived operands could be assigned
39443  to the accumulator instead of a general-purpose register.
39444 \end_layout
39445
39446 \begin_layout Paragraph*
39447 Code generation
39448 \end_layout
39449
39450 \begin_layout Standard
39451 Figure II gives a table of iCode
39452 \begin_inset LatexCommand index
39453 name "iCode"
39454
39455 \end_inset
39456
39457  operations supported by the compiler.
39458  The code generation involves translating these operations into corresponding
39459  assembly code for the processor.
39460  This sounds overly simple but that is the essence of code generation.
39461  Some of the iCode operations are generated on a MCU specific manner for
39462  example, the z80 port does not use registers to pass parameters so the
39463  SEND and RECV iCode operations will not be generated, and it also does
39464  not support JUMPTABLES.
39465  
39466 \newline
39467
39468 \end_layout
39469
39470 \begin_layout Standard
39471
39472 \size footnotesize
39473 Figure II 
39474 \begin_inset Tabular
39475 <lyxtabular version="3" rows="39" columns="4">
39476 <features islongtable="true" headBottomDL="true">
39477 <column alignment="block" valignment="top" leftline="true" width="13col%">
39478 <column alignment="left" valignment="top" leftline="true" width="13col%">
39479 <column alignment="block" valignment="top" leftline="true" width="22col%">
39480 <column alignment="block" valignment="top" leftline="true" rightline="true" width="40col%">
39481 <row topline="true" bottomline="true" endhead="true">
39482 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39483 \begin_inset Text
39484
39485 \begin_layout Standard
39486
39487 \series bold
39488 iCode
39489 \series default
39490
39491 \begin_inset LatexCommand index
39492 name "iCode"
39493
39494 \end_inset
39495
39496
39497 \end_layout
39498
39499 \end_inset
39500 </cell>
39501 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39502 \begin_inset Text
39503
39504 \begin_layout Standard
39505
39506 \series bold
39507 Operands
39508 \end_layout
39509
39510 \end_inset
39511 </cell>
39512 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39513 \begin_inset Text
39514
39515 \begin_layout Standard
39516
39517 \series bold
39518 Description
39519 \end_layout
39520
39521 \end_inset
39522 </cell>
39523 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39524 \begin_inset Text
39525
39526 \begin_layout Standard
39527
39528 \series bold
39529 C Equivalent
39530 \end_layout
39531
39532 \end_inset
39533 </cell>
39534 </row>
39535 <row topline="true">
39536 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39537 \begin_inset Text
39538
39539 \begin_layout Standard
39540
39541 \size footnotesize
39542 '!'
39543 \end_layout
39544
39545 \end_inset
39546 </cell>
39547 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39548 \begin_inset Text
39549
39550 \begin_layout Standard
39551
39552 \size footnotesize
39553 IC_LEFT() IC_RESULT()
39554 \end_layout
39555
39556 \end_inset
39557 </cell>
39558 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39559 \begin_inset Text
39560
39561 \begin_layout Standard
39562
39563 \size footnotesize
39564 NOT operation 
39565 \end_layout
39566
39567 \end_inset
39568 </cell>
39569 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39570 \begin_inset Text
39571
39572 \begin_layout Standard
39573
39574 \size footnotesize
39575 IC_RESULT = ! IC_LEFT;
39576 \end_layout
39577
39578 \end_inset
39579 </cell>
39580 </row>
39581 <row topline="true">
39582 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39583 \begin_inset Text
39584
39585 \begin_layout Standard
39586
39587 \size footnotesize
39588 '~'
39589 \end_layout
39590
39591 \end_inset
39592 </cell>
39593 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39594 \begin_inset Text
39595
39596 \begin_layout Standard
39597
39598 \size footnotesize
39599 IC_LEFT() IC_RESULT()
39600 \end_layout
39601
39602 \end_inset
39603 </cell>
39604 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39605 \begin_inset Text
39606
39607 \begin_layout Standard
39608
39609 \size footnotesize
39610 Bitwise complement of 
39611 \end_layout
39612
39613 \end_inset
39614 </cell>
39615 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39616 \begin_inset Text
39617
39618 \begin_layout Standard
39619
39620 \size footnotesize
39621 IC_RESULT = ~IC_LEFT;
39622 \end_layout
39623
39624 \end_inset
39625 </cell>
39626 </row>
39627 <row topline="true">
39628 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39629 \begin_inset Text
39630
39631 \begin_layout Standard
39632
39633 \size footnotesize
39634 RRC
39635 \end_layout
39636
39637 \end_inset
39638 </cell>
39639 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39640 \begin_inset Text
39641
39642 \begin_layout Standard
39643
39644 \size footnotesize
39645 IC_LEFT() IC_RESULT()
39646 \end_layout
39647
39648 \end_inset
39649 </cell>
39650 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39651 \begin_inset Text
39652
39653 \begin_layout Standard
39654
39655 \size footnotesize
39656 Rotate right with carry
39657 \end_layout
39658
39659 \end_inset
39660 </cell>
39661 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39662 \begin_inset Text
39663
39664 \begin_layout Standard
39665
39666 \size footnotesize
39667 IC_RESULT = (IC_LEFT << 1) | (IC_LEFT >> (sizeof(IC_LEFT)*8-1));
39668 \end_layout
39669
39670 \end_inset
39671 </cell>
39672 </row>
39673 <row topline="true">
39674 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39675 \begin_inset Text
39676
39677 \begin_layout Standard
39678
39679 \size footnotesize
39680 RLC
39681 \end_layout
39682
39683 \end_inset
39684 </cell>
39685 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39686 \begin_inset Text
39687
39688 \begin_layout Standard
39689
39690 \size footnotesize
39691 IC_LEFT() IC_RESULT()
39692 \end_layout
39693
39694 \end_inset
39695 </cell>
39696 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39697 \begin_inset Text
39698
39699 \begin_layout Standard
39700
39701 \size footnotesize
39702 Rotate left with carry
39703 \end_layout
39704
39705 \end_inset
39706 </cell>
39707 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39708 \begin_inset Text
39709
39710 \begin_layout Standard
39711
39712 \size footnotesize
39713 IC_RESULT = (IC_LEFT << (sizeof(LC_LEFT)*8-1) ) | (IC_LEFT >> 1);
39714 \end_layout
39715
39716 \end_inset
39717 </cell>
39718 </row>
39719 <row topline="true">
39720 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39721 \begin_inset Text
39722
39723 \begin_layout Standard
39724
39725 \size footnotesize
39726 GETHBIT
39727 \end_layout
39728
39729 \end_inset
39730 </cell>
39731 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39732 \begin_inset Text
39733
39734 \begin_layout Standard
39735
39736 \size footnotesize
39737 IC_LEFT() IC_RESULT()
39738 \end_layout
39739
39740 \end_inset
39741 </cell>
39742 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39743 \begin_inset Text
39744
39745 \begin_layout Standard
39746
39747 \size footnotesize
39748 Get the highest order bit of IC_LEFT
39749 \end_layout
39750
39751 \end_inset
39752 </cell>
39753 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39754 \begin_inset Text
39755
39756 \begin_layout Standard
39757
39758 \size footnotesize
39759 IC_RESULT = (IC_LEFT >> (sizeof(IC_LEFT)*8 -1));
39760 \end_layout
39761
39762 \end_inset
39763 </cell>
39764 </row>
39765 <row topline="true">
39766 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39767 \begin_inset Text
39768
39769 \begin_layout Standard
39770
39771 \size footnotesize
39772 UNARYMINUS
39773 \end_layout
39774
39775 \end_inset
39776 </cell>
39777 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39778 \begin_inset Text
39779
39780 \begin_layout Standard
39781
39782 \size footnotesize
39783 IC_LEFT() IC_RESULT()
39784 \end_layout
39785
39786 \end_inset
39787 </cell>
39788 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39789 \begin_inset Text
39790
39791 \begin_layout Standard
39792
39793 \size footnotesize
39794 Unary minus
39795 \end_layout
39796
39797 \end_inset
39798 </cell>
39799 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39800 \begin_inset Text
39801
39802 \begin_layout Standard
39803
39804 \size footnotesize
39805 IC_RESULT = - IC_LEFT;
39806 \end_layout
39807
39808 \end_inset
39809 </cell>
39810 </row>
39811 <row topline="true">
39812 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39813 \begin_inset Text
39814
39815 \begin_layout Standard
39816
39817 \size footnotesize
39818 IPUSH
39819 \end_layout
39820
39821 \end_inset
39822 </cell>
39823 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39824 \begin_inset Text
39825
39826 \begin_layout Standard
39827
39828 \size footnotesize
39829 IC_LEFT()
39830 \end_layout
39831
39832 \end_inset
39833 </cell>
39834 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39835 \begin_inset Text
39836
39837 \begin_layout Standard
39838
39839 \size footnotesize
39840 Push the operand into stack
39841 \end_layout
39842
39843 \end_inset
39844 </cell>
39845 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39846 \begin_inset Text
39847
39848 \begin_layout Standard
39849
39850 \size footnotesize
39851 NONE
39852 \end_layout
39853
39854 \end_inset
39855 </cell>
39856 </row>
39857 <row topline="true">
39858 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39859 \begin_inset Text
39860
39861 \begin_layout Standard
39862
39863 \size footnotesize
39864 IPOP
39865 \end_layout
39866
39867 \end_inset
39868 </cell>
39869 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39870 \begin_inset Text
39871
39872 \begin_layout Standard
39873
39874 \size footnotesize
39875 IC_LEFT()
39876 \end_layout
39877
39878 \end_inset
39879 </cell>
39880 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39881 \begin_inset Text
39882
39883 \begin_layout Standard
39884
39885 \size footnotesize
39886 Pop the operand from the stack 
39887 \end_layout
39888
39889 \end_inset
39890 </cell>
39891 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39892 \begin_inset Text
39893
39894 \begin_layout Standard
39895
39896 \size footnotesize
39897 NONE
39898 \end_layout
39899
39900 \end_inset
39901 </cell>
39902 </row>
39903 <row topline="true">
39904 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39905 \begin_inset Text
39906
39907 \begin_layout Standard
39908
39909 \size footnotesize
39910 CALL
39911 \end_layout
39912
39913 \end_inset
39914 </cell>
39915 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39916 \begin_inset Text
39917
39918 \begin_layout Standard
39919
39920 \size footnotesize
39921 IC_LEFT() IC_RESULT()
39922 \end_layout
39923
39924 \end_inset
39925 </cell>
39926 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39927 \begin_inset Text
39928
39929 \begin_layout Standard
39930
39931 \size footnotesize
39932 Call the function represented by IC_LEFT 
39933 \end_layout
39934
39935 \end_inset
39936 </cell>
39937 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39938 \begin_inset Text
39939
39940 \begin_layout Standard
39941
39942 \size footnotesize
39943 IC_RESULT = IC_LEFT();
39944 \end_layout
39945
39946 \end_inset
39947 </cell>
39948 </row>
39949 <row topline="true">
39950 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39951 \begin_inset Text
39952
39953 \begin_layout Standard
39954
39955 \size footnotesize
39956 PCALL
39957 \end_layout
39958
39959 \end_inset
39960 </cell>
39961 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39962 \begin_inset Text
39963
39964 \begin_layout Standard
39965
39966 \size footnotesize
39967 IC_LEFT() IC_RESULT()
39968 \end_layout
39969
39970 \end_inset
39971 </cell>
39972 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39973 \begin_inset Text
39974
39975 \begin_layout Standard
39976
39977 \size footnotesize
39978 Call via function pointer
39979 \end_layout
39980
39981 \end_inset
39982 </cell>
39983 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39984 \begin_inset Text
39985
39986 \begin_layout Standard
39987
39988 \size footnotesize
39989 IC_RESULT = (*IC_LEFT)();
39990 \end_layout
39991
39992 \end_inset
39993 </cell>
39994 </row>
39995 <row topline="true">
39996 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39997 \begin_inset Text
39998
39999 \begin_layout Standard
40000
40001 \size footnotesize
40002 RETURN
40003 \end_layout
40004
40005 \end_inset
40006 </cell>
40007 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40008 \begin_inset Text
40009
40010 \begin_layout Standard
40011
40012 \size footnotesize
40013 IC_LEFT()
40014 \end_layout
40015
40016 \end_inset
40017 </cell>
40018 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40019 \begin_inset Text
40020
40021 \begin_layout Standard
40022
40023 \size footnotesize
40024 Return the value in operand IC_LEFT 
40025 \end_layout
40026
40027 \end_inset
40028 </cell>
40029 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40030 \begin_inset Text
40031
40032 \begin_layout Standard
40033
40034 \size footnotesize
40035 return IC_LEFT;
40036 \end_layout
40037
40038 \end_inset
40039 </cell>
40040 </row>
40041 <row topline="true">
40042 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40043 \begin_inset Text
40044
40045 \begin_layout Standard
40046
40047 \size footnotesize
40048 LABEL
40049 \end_layout
40050
40051 \end_inset
40052 </cell>
40053 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40054 \begin_inset Text
40055
40056 \begin_layout Standard
40057
40058 \size footnotesize
40059 IC_LABEL() 
40060 \end_layout
40061
40062 \end_inset
40063 </cell>
40064 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40065 \begin_inset Text
40066
40067 \begin_layout Standard
40068
40069 \size footnotesize
40070 Label
40071 \end_layout
40072
40073 \end_inset
40074 </cell>
40075 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40076 \begin_inset Text
40077
40078 \begin_layout Standard
40079
40080 \size footnotesize
40081 IC_LABEL:
40082 \end_layout
40083
40084 \end_inset
40085 </cell>
40086 </row>
40087 <row topline="true">
40088 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40089 \begin_inset Text
40090
40091 \begin_layout Standard
40092
40093 \size footnotesize
40094 GOTO
40095 \end_layout
40096
40097 \end_inset
40098 </cell>
40099 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40100 \begin_inset Text
40101
40102 \begin_layout Standard
40103
40104 \size footnotesize
40105 IC_LABEL() 
40106 \end_layout
40107
40108 \end_inset
40109 </cell>
40110 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40111 \begin_inset Text
40112
40113 \begin_layout Standard
40114
40115 \size footnotesize
40116 Goto label
40117 \end_layout
40118
40119 \end_inset
40120 </cell>
40121 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40122 \begin_inset Text
40123
40124 \begin_layout Standard
40125
40126 \size footnotesize
40127 goto IC_LABEL();
40128 \end_layout
40129
40130 \end_inset
40131 </cell>
40132 </row>
40133 <row topline="true">
40134 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40135 \begin_inset Text
40136
40137 \begin_layout Standard
40138
40139 \size footnotesize
40140 '+'
40141 \end_layout
40142
40143 \end_inset
40144 </cell>
40145 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40146 \begin_inset Text
40147
40148 \begin_layout Standard
40149
40150 \size footnotesize
40151 IC_LEFT() IC_RIGHT() IC_RESULT()
40152 \end_layout
40153
40154 \end_inset
40155 </cell>
40156 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40157 \begin_inset Text
40158
40159 \begin_layout Standard
40160
40161 \size footnotesize
40162 Addition
40163 \end_layout
40164
40165 \end_inset
40166 </cell>
40167 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40168 \begin_inset Text
40169
40170 \begin_layout Standard
40171
40172 \size footnotesize
40173 IC_RESULT = IC_LEFT + IC_RIGHT
40174 \end_layout
40175
40176 \end_inset
40177 </cell>
40178 </row>
40179 <row topline="true">
40180 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40181 \begin_inset Text
40182
40183 \begin_layout Standard
40184
40185 \size footnotesize
40186 '-'
40187 \end_layout
40188
40189 \end_inset
40190 </cell>
40191 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40192 \begin_inset Text
40193
40194 \begin_layout Standard
40195
40196 \size footnotesize
40197 IC_LEFT() IC_RIGHT() IC_RESULT()
40198 \end_layout
40199
40200 \end_inset
40201 </cell>
40202 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40203 \begin_inset Text
40204
40205 \begin_layout Standard
40206
40207 \size footnotesize
40208 Subtraction
40209 \end_layout
40210
40211 \end_inset
40212 </cell>
40213 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40214 \begin_inset Text
40215
40216 \begin_layout Standard
40217
40218 \size footnotesize
40219 IC_RESULT = IC_LEFT - IC_RIGHT 
40220 \end_layout
40221
40222 \end_inset
40223 </cell>
40224 </row>
40225 <row topline="true">
40226 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40227 \begin_inset Text
40228
40229 \begin_layout Standard
40230
40231 \size footnotesize
40232 '*'
40233 \end_layout
40234
40235 \end_inset
40236 </cell>
40237 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40238 \begin_inset Text
40239
40240 \begin_layout Standard
40241
40242 \size footnotesize
40243 IC_LEFT() IC_RIGHT() IC_RESULT()
40244 \end_layout
40245
40246 \end_inset
40247 </cell>
40248 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40249 \begin_inset Text
40250
40251 \begin_layout Standard
40252
40253 \size footnotesize
40254 Multiplication 
40255 \end_layout
40256
40257 \end_inset
40258 </cell>
40259 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40260 \begin_inset Text
40261
40262 \begin_layout Standard
40263
40264 \size footnotesize
40265 IC_RESULT = IC_LEFT * IC_RIGHT;
40266 \end_layout
40267
40268 \end_inset
40269 </cell>
40270 </row>
40271 <row topline="true">
40272 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40273 \begin_inset Text
40274
40275 \begin_layout Standard
40276
40277 \size footnotesize
40278 '/'
40279 \end_layout
40280
40281 \end_inset
40282 </cell>
40283 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40284 \begin_inset Text
40285
40286 \begin_layout Standard
40287
40288 \size footnotesize
40289 IC_LEFT() IC_RIGHT() IC_RESULT()
40290 \end_layout
40291
40292 \end_inset
40293 </cell>
40294 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40295 \begin_inset Text
40296
40297 \begin_layout Standard
40298
40299 \size footnotesize
40300 Division
40301 \end_layout
40302
40303 \end_inset
40304 </cell>
40305 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40306 \begin_inset Text
40307
40308 \begin_layout Standard
40309
40310 \size footnotesize
40311 IC_RESULT = IC_LEFT / IC_RIGHT;
40312 \end_layout
40313
40314 \end_inset
40315 </cell>
40316 </row>
40317 <row topline="true">
40318 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40319 \begin_inset Text
40320
40321 \begin_layout Standard
40322
40323 \size footnotesize
40324 '%'
40325 \end_layout
40326
40327 \end_inset
40328 </cell>
40329 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40330 \begin_inset Text
40331
40332 \begin_layout Standard
40333
40334 \size footnotesize
40335 IC_LEFT() IC_RIGHT() IC_RESULT()
40336 \end_layout
40337
40338 \end_inset
40339 </cell>
40340 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40341 \begin_inset Text
40342
40343 \begin_layout Standard
40344
40345 \size footnotesize
40346 Modulus
40347 \end_layout
40348
40349 \end_inset
40350 </cell>
40351 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40352 \begin_inset Text
40353
40354 \begin_layout Standard
40355
40356 \size footnotesize
40357 IC_RESULT = IC_LEFT % IC_RIGHT;
40358 \end_layout
40359
40360 \end_inset
40361 </cell>
40362 </row>
40363 <row topline="true">
40364 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40365 \begin_inset Text
40366
40367 \begin_layout Standard
40368
40369 \size footnotesize
40370 '<'
40371 \end_layout
40372
40373 \end_inset
40374 </cell>
40375 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40376 \begin_inset Text
40377
40378 \begin_layout Standard
40379
40380 \size footnotesize
40381 IC_LEFT() IC_RIGHT() IC_RESULT()
40382 \end_layout
40383
40384 \end_inset
40385 </cell>
40386 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40387 \begin_inset Text
40388
40389 \begin_layout Standard
40390
40391 \size footnotesize
40392 Less than
40393 \end_layout
40394
40395 \end_inset
40396 </cell>
40397 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40398 \begin_inset Text
40399
40400 \begin_layout Standard
40401
40402 \size footnotesize
40403 IC_RESULT = IC_LEFT < IC_RIGHT;
40404 \end_layout
40405
40406 \end_inset
40407 </cell>
40408 </row>
40409 <row topline="true">
40410 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40411 \begin_inset Text
40412
40413 \begin_layout Standard
40414
40415 \size footnotesize
40416 '>'
40417 \end_layout
40418
40419 \end_inset
40420 </cell>
40421 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40422 \begin_inset Text
40423
40424 \begin_layout Standard
40425
40426 \size footnotesize
40427 IC_LEFT() IC_RIGHT() IC_RESULT()
40428 \end_layout
40429
40430 \end_inset
40431 </cell>
40432 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40433 \begin_inset Text
40434
40435 \begin_layout Standard
40436
40437 \size footnotesize
40438 Greater than 
40439 \end_layout
40440
40441 \end_inset
40442 </cell>
40443 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40444 \begin_inset Text
40445
40446 \begin_layout Standard
40447
40448 \size footnotesize
40449 IC_RESULT = IC_LEFT > IC_RIGHT;
40450 \end_layout
40451
40452 \end_inset
40453 </cell>
40454 </row>
40455 <row topline="true">
40456 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40457 \begin_inset Text
40458
40459 \begin_layout Standard
40460
40461 \size footnotesize
40462 EQ_OP
40463 \end_layout
40464
40465 \end_inset
40466 </cell>
40467 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40468 \begin_inset Text
40469
40470 \begin_layout Standard
40471
40472 \size footnotesize
40473 IC_LEFT() IC_RIGHT() IC_RESULT()
40474 \end_layout
40475
40476 \end_inset
40477 </cell>
40478 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40479 \begin_inset Text
40480
40481 \begin_layout Standard
40482
40483 \size footnotesize
40484 Equal to 
40485 \end_layout
40486
40487 \end_inset
40488 </cell>
40489 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40490 \begin_inset Text
40491
40492 \begin_layout Standard
40493
40494 \size footnotesize
40495 IC_RESULT = IC_LEFT == IC_RIGHT;
40496 \end_layout
40497
40498 \end_inset
40499 </cell>
40500 </row>
40501 <row topline="true">
40502 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40503 \begin_inset Text
40504
40505 \begin_layout Standard
40506
40507 \size footnotesize
40508 AND_OP
40509 \end_layout
40510
40511 \end_inset
40512 </cell>
40513 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40514 \begin_inset Text
40515
40516 \begin_layout Standard
40517
40518 \size footnotesize
40519 IC_LEFT() IC_RIGHT() IC_RESULT() 
40520 \end_layout
40521
40522 \end_inset
40523 </cell>
40524 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40525 \begin_inset Text
40526
40527 \begin_layout Standard
40528
40529 \size footnotesize
40530 Logical and operation
40531 \end_layout
40532
40533 \end_inset
40534 </cell>
40535 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40536 \begin_inset Text
40537
40538 \begin_layout Standard
40539
40540 \size footnotesize
40541 IC_RESULT = IC_LEFT && IC_RIGHT; 
40542 \end_layout
40543
40544 \end_inset
40545 </cell>
40546 </row>
40547 <row topline="true">
40548 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40549 \begin_inset Text
40550
40551 \begin_layout Standard
40552
40553 \size footnotesize
40554 OR_OP
40555 \end_layout
40556
40557 \end_inset
40558 </cell>
40559 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40560 \begin_inset Text
40561
40562 \begin_layout Standard
40563
40564 \size footnotesize
40565 IC_LEFT() IC_RIGHT() IC_RESULT() 
40566 \end_layout
40567
40568 \end_inset
40569 </cell>
40570 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40571 \begin_inset Text
40572
40573 \begin_layout Standard
40574
40575 \size footnotesize
40576 Logical or operation 
40577 \end_layout
40578
40579 \end_inset
40580 </cell>
40581 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40582 \begin_inset Text
40583
40584 \begin_layout Standard
40585
40586 \size footnotesize
40587 IC_RESULT = IC_LEFT || IC_RIGHT; 
40588 \end_layout
40589
40590 \end_inset
40591 </cell>
40592 </row>
40593 <row topline="true">
40594 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40595 \begin_inset Text
40596
40597 \begin_layout Standard
40598
40599 \size footnotesize
40600 '^'
40601 \end_layout
40602
40603 \end_inset
40604 </cell>
40605 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40606 \begin_inset Text
40607
40608 \begin_layout Standard
40609
40610 \size footnotesize
40611 IC_LEFT() IC_RIGHT() IC_RESULT() 
40612 \end_layout
40613
40614 \end_inset
40615 </cell>
40616 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40617 \begin_inset Text
40618
40619 \begin_layout Standard
40620
40621 \size footnotesize
40622 Exclusive OR
40623 \end_layout
40624
40625 \end_inset
40626 </cell>
40627 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40628 \begin_inset Text
40629
40630 \begin_layout Standard
40631
40632 \size footnotesize
40633 IC_RESULT = IC_LEFT ^ IC_RIGHT;
40634 \end_layout
40635
40636 \end_inset
40637 </cell>
40638 </row>
40639 <row topline="true">
40640 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40641 \begin_inset Text
40642
40643 \begin_layout Standard
40644
40645 \size footnotesize
40646 '|'
40647 \end_layout
40648
40649 \end_inset
40650 </cell>
40651 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40652 \begin_inset Text
40653
40654 \begin_layout Standard
40655
40656 \size footnotesize
40657 IC_LEFT() IC_RIGHT() IC_RESULT() 
40658 \end_layout
40659
40660 \end_inset
40661 </cell>
40662 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40663 \begin_inset Text
40664
40665 \begin_layout Standard
40666
40667 \size footnotesize
40668 Bitwise OR 
40669 \end_layout
40670
40671 \end_inset
40672 </cell>
40673 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40674 \begin_inset Text
40675
40676 \begin_layout Standard
40677
40678 \size footnotesize
40679 IC_RESULT = IC_LEFT | IC_RIGHT;
40680 \end_layout
40681
40682 \end_inset
40683 </cell>
40684 </row>
40685 <row topline="true">
40686 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40687 \begin_inset Text
40688
40689 \begin_layout Standard
40690
40691 \size footnotesize
40692 BITWISEAND
40693 \end_layout
40694
40695 \end_inset
40696 </cell>
40697 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40698 \begin_inset Text
40699
40700 \begin_layout Standard
40701
40702 \size footnotesize
40703 IC_LEFT() IC_RIGHT() IC_RESULT()
40704 \end_layout
40705
40706 \end_inset
40707 </cell>
40708 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40709 \begin_inset Text
40710
40711 \begin_layout Standard
40712
40713 \size footnotesize
40714 Bitwise AND 
40715 \end_layout
40716
40717 \end_inset
40718 </cell>
40719 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40720 \begin_inset Text
40721
40722 \begin_layout Standard
40723
40724 \size footnotesize
40725 IC_RESULT = IC_LEFT & IC_RIGHT;
40726 \end_layout
40727
40728 \end_inset
40729 </cell>
40730 </row>
40731 <row topline="true">
40732 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40733 \begin_inset Text
40734
40735 \begin_layout Standard
40736
40737 \size footnotesize
40738 LEFT_OP
40739 \end_layout
40740
40741 \end_inset
40742 </cell>
40743 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40744 \begin_inset Text
40745
40746 \begin_layout Standard
40747
40748 \size footnotesize
40749 IC_LEFT() IC_RIGHT() IC_RESULT()
40750 \end_layout
40751
40752 \end_inset
40753 </cell>
40754 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40755 \begin_inset Text
40756
40757 \begin_layout Standard
40758
40759 \size footnotesize
40760 Left shift 
40761 \end_layout
40762
40763 \end_inset
40764 </cell>
40765 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40766 \begin_inset Text
40767
40768 \begin_layout Standard
40769
40770 \size footnotesize
40771 IC_RESULT = IC_LEFT << IC_RIGHT 
40772 \end_layout
40773
40774 \end_inset
40775 </cell>
40776 </row>
40777 <row topline="true">
40778 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40779 \begin_inset Text
40780
40781 \begin_layout Standard
40782
40783 \size footnotesize
40784 RIGHT_OP
40785 \end_layout
40786
40787 \end_inset
40788 </cell>
40789 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40790 \begin_inset Text
40791
40792 \begin_layout Standard
40793
40794 \size footnotesize
40795 IC_LEFT() IC_RIGHT() IC_RESULT()
40796 \end_layout
40797
40798 \end_inset
40799 </cell>
40800 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40801 \begin_inset Text
40802
40803 \begin_layout Standard
40804
40805 \size footnotesize
40806 Right shift
40807 \end_layout
40808
40809 \end_inset
40810 </cell>
40811 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40812 \begin_inset Text
40813
40814 \begin_layout Standard
40815
40816 \size footnotesize
40817 IC_RESULT = IC_LEFT >> IC_RIGHT 
40818 \end_layout
40819
40820 \end_inset
40821 </cell>
40822 </row>
40823 <row topline="true">
40824 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40825 \begin_inset Text
40826
40827 \begin_layout Standard
40828
40829 \size footnotesize
40830 GET_VALUE_
40831 \newline
40832 AT_ ADDRESS
40833 \end_layout
40834
40835 \end_inset
40836 </cell>
40837 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40838 \begin_inset Text
40839
40840 \begin_layout Standard
40841
40842 \size footnotesize
40843 IC_LEFT() IC_RESULT()
40844 \end_layout
40845
40846 \end_inset
40847 </cell>
40848 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40849 \begin_inset Text
40850
40851 \begin_layout Standard
40852
40853 \size footnotesize
40854 Indirect fetch 
40855 \end_layout
40856
40857 \end_inset
40858 </cell>
40859 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40860 \begin_inset Text
40861
40862 \begin_layout Standard
40863
40864 \size footnotesize
40865 IC_RESULT = (*IC_LEFT);
40866 \end_layout
40867
40868 \end_inset
40869 </cell>
40870 </row>
40871 <row topline="true">
40872 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40873 \begin_inset Text
40874
40875 \begin_layout Standard
40876
40877 \size footnotesize
40878 POINTER_SET
40879 \end_layout
40880
40881 \end_inset
40882 </cell>
40883 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40884 \begin_inset Text
40885
40886 \begin_layout Standard
40887
40888 \size footnotesize
40889 IC_RIGHT() IC_RESULT() 
40890 \end_layout
40891
40892 \end_inset
40893 </cell>
40894 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40895 \begin_inset Text
40896
40897 \begin_layout Standard
40898
40899 \size footnotesize
40900 Indirect set
40901 \end_layout
40902
40903 \end_inset
40904 </cell>
40905 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40906 \begin_inset Text
40907
40908 \begin_layout Standard
40909
40910 \size footnotesize
40911 (*IC_RESULT) = IC_RIGHT;
40912 \end_layout
40913
40914 \end_inset
40915 </cell>
40916 </row>
40917 <row topline="true">
40918 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40919 \begin_inset Text
40920
40921 \begin_layout Standard
40922
40923 \size footnotesize
40924 '='
40925 \end_layout
40926
40927 \end_inset
40928 </cell>
40929 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40930 \begin_inset Text
40931
40932 \begin_layout Standard
40933
40934 \size footnotesize
40935 IC_RIGHT() IC_RESULT()
40936 \end_layout
40937
40938 \end_inset
40939 </cell>
40940 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40941 \begin_inset Text
40942
40943 \begin_layout Standard
40944
40945 \size footnotesize
40946 Assignment
40947 \end_layout
40948
40949 \end_inset
40950 </cell>
40951 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40952 \begin_inset Text
40953
40954 \begin_layout Standard
40955
40956 \size footnotesize
40957 IC_RESULT = IC_RIGHT;
40958 \end_layout
40959
40960 \end_inset
40961 </cell>
40962 </row>
40963 <row topline="true">
40964 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40965 \begin_inset Text
40966
40967 \begin_layout Standard
40968
40969 \size footnotesize
40970 IFX
40971 \end_layout
40972
40973 \end_inset
40974 </cell>
40975 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40976 \begin_inset Text
40977
40978 \begin_layout Standard
40979
40980 \size footnotesize
40981 IC_COND IC_TRUE IC_LABEL
40982 \end_layout
40983
40984 \end_inset
40985 </cell>
40986 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40987 \begin_inset Text
40988
40989 \begin_layout Standard
40990
40991 \size footnotesize
40992 Conditional jump.
40993  If true label is present then jump to true label if condition is true else
40994  jump to false label if condition is false 
40995 \end_layout
40996
40997 \end_inset
40998 </cell>
40999 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
41000 \begin_inset Text
41001
41002 \begin_layout Standard
41003
41004 \size footnotesize
41005 if (IC_COND) goto IC_TRUE; 
41006 \newline
41007 \InsetSpace ~
41008 \InsetSpace ~
41009 Or 
41010 \newline
41011 If (!IC_COND) goto IC_FALSE;
41012 \end_layout
41013
41014 \end_inset
41015 </cell>
41016 </row>
41017 <row topline="true">
41018 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41019 \begin_inset Text
41020
41021 \begin_layout Standard
41022
41023 \size footnotesize
41024 ADDRESS_OF
41025 \end_layout
41026
41027 \end_inset
41028 </cell>
41029 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41030 \begin_inset Text
41031
41032 \begin_layout Standard
41033
41034 \size footnotesize
41035 IC_LEFT() IC_RESULT()
41036 \end_layout
41037
41038 \end_inset
41039 </cell>
41040 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41041 \begin_inset Text
41042
41043 \begin_layout Standard
41044
41045 \size footnotesize
41046 Address of 
41047 \end_layout
41048
41049 \end_inset
41050 </cell>
41051 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
41052 \begin_inset Text
41053
41054 \begin_layout Standard
41055
41056 \size footnotesize
41057 IC_RESULT = &IC_LEFT();
41058 \end_layout
41059
41060 \end_inset
41061 </cell>
41062 </row>
41063 <row topline="true">
41064 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41065 \begin_inset Text
41066
41067 \begin_layout Standard
41068
41069 \size footnotesize
41070 JUMPTABLE
41071 \end_layout
41072
41073 \end_inset
41074 </cell>
41075 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41076 \begin_inset Text
41077
41078 \begin_layout Standard
41079
41080 \size footnotesize
41081 IC_JTCOND IC_JTLABELS
41082 \end_layout
41083
41084 \end_inset
41085 </cell>
41086 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41087 \begin_inset Text
41088
41089 \begin_layout Standard
41090
41091 \size footnotesize
41092 Jump to list of labels depending on the value of JTCOND
41093 \end_layout
41094
41095 \end_inset
41096 </cell>
41097 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
41098 \begin_inset Text
41099
41100 \begin_layout Standard
41101
41102 \size footnotesize
41103 Switch statement
41104 \end_layout
41105
41106 \end_inset
41107 </cell>
41108 </row>
41109 <row topline="true">
41110 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41111 \begin_inset Text
41112
41113 \begin_layout Standard
41114
41115 \size footnotesize
41116 CAST
41117 \end_layout
41118
41119 \end_inset
41120 </cell>
41121 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41122 \begin_inset Text
41123
41124 \begin_layout Standard
41125
41126 \size footnotesize
41127 IC_RIGHT() IC_LEFT() IC_RESULT()
41128 \end_layout
41129
41130 \end_inset
41131 </cell>
41132 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41133 \begin_inset Text
41134
41135 \begin_layout Standard
41136
41137 \size footnotesize
41138 Cast types 
41139 \end_layout
41140
41141 \end_inset
41142 </cell>
41143 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
41144 \begin_inset Text
41145
41146 \begin_layout Standard
41147
41148 \size footnotesize
41149 IC_RESULT = (typeof IC_LEFT) IC_RIGHT;
41150 \end_layout
41151
41152 \end_inset
41153 </cell>
41154 </row>
41155 <row topline="true">
41156 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41157 \begin_inset Text
41158
41159 \begin_layout Standard
41160
41161 \size footnotesize
41162 SEND
41163 \end_layout
41164
41165 \end_inset
41166 </cell>
41167 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41168 \begin_inset Text
41169
41170 \begin_layout Standard
41171
41172 \size footnotesize
41173 IC_LEFT()
41174 \end_layout
41175
41176 \end_inset
41177 </cell>
41178 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41179 \begin_inset Text
41180
41181 \begin_layout Standard
41182
41183 \size footnotesize
41184 This is used for passing parameters in registers; 
41185 \newline
41186 move IC_LEFT to the next
41187  available parameter register.
41188 \end_layout
41189
41190 \end_inset
41191 </cell>
41192 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
41193 \begin_inset Text
41194
41195 \begin_layout Standard
41196
41197 \size footnotesize
41198 None
41199 \end_layout
41200
41201 \end_inset
41202 </cell>
41203 </row>
41204 <row topline="true">
41205 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41206 \begin_inset Text
41207
41208 \begin_layout Standard
41209
41210 \size footnotesize
41211 RECV
41212 \end_layout
41213
41214 \end_inset
41215 </cell>
41216 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41217 \begin_inset Text
41218
41219 \begin_layout Standard
41220
41221 \size footnotesize
41222 IC_RESULT()
41223 \end_layout
41224
41225 \end_inset
41226 </cell>
41227 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41228 \begin_inset Text
41229
41230 \begin_layout Standard
41231
41232 \size footnotesize
41233 This is used for receiving parameters passed in registers;
41234 \newline
41235 Move the values
41236  in the next parameter register to IC_RESULT 
41237 \end_layout
41238
41239 \end_inset
41240 </cell>
41241 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
41242 \begin_inset Text
41243
41244 \begin_layout Standard
41245
41246 \size footnotesize
41247 None
41248 \end_layout
41249
41250 \end_inset
41251 </cell>
41252 </row>
41253 <row topline="true" bottomline="true">
41254 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41255 \begin_inset Text
41256
41257 \begin_layout Standard
41258
41259 \shape slanted
41260 \size footnotesize
41261 (some more have been added)
41262 \end_layout
41263
41264 \end_inset
41265 </cell>
41266 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41267 \begin_inset Text
41268
41269 \begin_layout Standard
41270
41271 \end_layout
41272
41273 \end_inset
41274 </cell>
41275 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41276 \begin_inset Text
41277
41278 \begin_layout Standard
41279
41280 \end_layout
41281
41282 \end_inset
41283 </cell>
41284 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
41285 \begin_inset Text
41286
41287 \begin_layout Standard
41288
41289 \shape slanted
41290 \size footnotesize
41291 see f.e.
41292
41293 \shape default
41294  
41295 \family typewriter
41296 \shape slanted
41297 gen51Code()
41298 \family default
41299 \shape default
41300  
41301 \shape slanted
41302 in
41303 \shape default
41304  
41305 \family typewriter
41306 \shape slanted
41307 src/mcs51/gen.c
41308 \end_layout
41309
41310 \end_inset
41311 </cell>
41312 </row>
41313 </lyxtabular>
41314
41315 \end_inset
41316
41317
41318 \end_layout
41319
41320 \begin_layout Standard
41321 \begin_inset Note Note
41322 status collapsed
41323
41324 \begin_layout Standard
41325 In the original article Figure II was announced to be downloadable on 
41326 \shape italic
41327 Circuit Cellar
41328 \shape default
41329 's web site.
41330  ftp://ftp.circuitcellar.com/pub/Circuit_Cellar/2000/121/dutta.ZIP
41331 \end_layout
41332
41333 \end_inset
41334
41335
41336 \end_layout
41337
41338 \begin_layout Paragraph*
41339 ICode Example
41340 \begin_inset LatexCommand index
41341 name "iCode"
41342
41343 \end_inset
41344
41345
41346 \end_layout
41347
41348 \begin_layout Standard
41349 This section shows some details of iCode.
41350  The example C code does not do anything useful; it is used as an example
41351  to illustrate the intermediate code generated by the compiler.
41352 \end_layout
41353
41354 \begin_layout Verse
41355
41356 \family typewriter
41357 1.\InsetSpace ~
41358 xdata int * p;
41359 \newline
41360 2.\InsetSpace ~
41361 int gint;
41362 \newline
41363 3.\InsetSpace ~
41364 /* This function does nothing useful.
41365  It is used
41366 \newline
41367 4.\InsetSpace ~
41368 \InsetSpace ~
41369 \InsetSpace ~
41370 \InsetSpace ~
41371 for the purpose of explaining iCode */
41372 \newline
41373 5.\InsetSpace ~
41374 short function (data
41375  int *x)
41376 \newline
41377 6.\InsetSpace ~
41378 {
41379 \newline
41380 7.\InsetSpace ~
41381 \InsetSpace ~
41382 \InsetSpace ~
41383 short i=10; \InsetSpace ~
41384 \InsetSpace ~
41385 /* dead initialization eliminated */
41386 \newline
41387 8.\InsetSpace ~
41388 \InsetSpace ~
41389 \InsetSpace ~
41390 short sum=10;
41391  /* dead initialization eliminated */
41392 \newline
41393 9.\InsetSpace ~
41394 \InsetSpace ~
41395 \InsetSpace ~
41396 short mul;
41397 \newline
41398 10.\InsetSpace ~
41399 \InsetSpace ~
41400 int j ;
41401 \newline
41402 11.\InsetSpace ~
41403 \InsetSpace ~
41404 while (*x) *x++
41405  = *p++; 
41406 \newline
41407 12.\InsetSpace ~
41408 \InsetSpace ~
41409 \InsetSpace ~
41410 \InsetSpace ~
41411 sum = 0 ; 
41412 \newline
41413 13.\InsetSpace ~
41414 \InsetSpace ~
41415 mul = 0;
41416 \newline
41417 14.\InsetSpace ~
41418 \InsetSpace ~
41419 /* compiler detects i,j to be induction
41420  variables */
41421 \newline
41422 15.\InsetSpace ~
41423 \InsetSpace ~
41424 for (i = 0, j = 10 ; i < 10 ; i++, j
41425 \family default
41426 -
41427 \begin_inset ERT
41428 status collapsed
41429
41430 \begin_layout Standard
41431
41432
41433 \backslash
41434 /
41435 \end_layout
41436
41437 \end_inset
41438
41439 -
41440 \family typewriter
41441 ) {
41442 \newline
41443 16.\InsetSpace ~
41444 \InsetSpace ~
41445 \InsetSpace ~
41446 \InsetSpace ~
41447 sum += i;
41448 \newline
41449 17.\InsetSpace ~
41450 \InsetSpace ~
41451 \InsetSpace ~
41452 \InsetSpace ~
41453 mul += i * 3; \InsetSpace ~
41454 \InsetSpace ~
41455 /* this multiplication remains */
41456 \newline
41457 18.\InsetSpace ~
41458 \InsetSpace ~
41459 \InsetSpace ~
41460 \InsetSpace ~
41461 gint +=
41462  j * 3;\InsetSpace ~
41463 \InsetSpace ~
41464 /* this multiplication changed to addition */
41465 \newline
41466 19.\InsetSpace ~
41467 \InsetSpace ~
41468 }
41469 \newline
41470 20.\InsetSpace ~
41471 \InsetSpace ~
41472 return sum+mul;
41473 \newline
41474 21.\InsetSpace ~
41475 }
41476 \end_layout
41477
41478 \begin_layout Standard
41479 In addition to the operands each iCode contains information about the filename
41480  and line it corresponds to in the source file.
41481  The first field in the listing should be interpreted as follows:
41482 \newline
41483
41484 \shape italic
41485 \size footnotesize
41486 Filename(linenumber: iCode Execution sequence number : ICode hash table
41487  key : loop depth of the iCode).
41488 \shape default
41489 \size default
41490
41491 \newline
41492 Then follows the human readable form of the ICode operation.
41493  Each operand of this triplet form can be of three basic types a) compiler
41494  generated temporary b) user defined variable c) a constant value.
41495  Note that local variables and parameters are replaced by compiler generated
41496  temporaries.
41497  Live ranges
41498 \begin_inset LatexCommand index
41499 name "Live range analysis"
41500
41501 \end_inset
41502
41503  are computed only for temporaries (i.e.
41504  live ranges are not computed for global variables).
41505  Registers
41506 \begin_inset LatexCommand index
41507 name "Register allocation"
41508
41509 \end_inset
41510
41511  are allocated for temporaries only.
41512  Operands are formatted in the following manner:
41513 \newline
41514
41515 \shape italic
41516 \size footnotesize
41517 Operand Name [lr live-from : live-to ] { type information } [ registers
41518  allocated ].
41519 \shape default
41520 \size default
41521
41522 \newline
41523 As mentioned earlier the live ranges are computed in terms of the execution
41524  sequence number of the iCodes, for example 
41525 \newline
41526 the iTemp0 is live from (i.e.
41527  first defined in iCode with execution sequence number 3, and is last used
41528  in the iCode with sequence number 5).
41529  For induction variables such as iTemp21 the live range computation extends
41530  the lifetime from the start to the end of the loop.
41531 \newline
41532 The register allocator
41533  used the live range information to allocate registers, the same registers
41534  may be used for different temporaries if their live ranges do not overlap,
41535  for example r0 is allocated to both iTemp6 and to iTemp17 since their live
41536  ranges do not overlap.
41537  In addition the allocator also takes into consideration the type and usage
41538  of a temporary, for example itemp6 is a pointer to near space and is used
41539  as to fetch data from (i.e.
41540  used in GET_VALUE_AT_ADDRESS) so it is allocated a pointer register (r0).
41541  Some short lived temporaries are allocated to special registers which have
41542  meaning to the code generator e.g.
41543  iTemp13 is allocated to a pseudo register CC which tells the back end that
41544  the temporary is used only for a conditional jump the code generation makes
41545  use of this information to optimize a compare and jump ICode.
41546 \newline
41547 There are several
41548  loop optimizations
41549 \begin_inset LatexCommand index
41550 name "Loop optimization"
41551
41552 \end_inset
41553
41554  performed by the compiler.
41555  It can detect induction variables iTemp21(i) and iTemp23(j).
41556  Also note the compiler does selective strength reduction
41557 \begin_inset LatexCommand index
41558 name "Strength reduction"
41559
41560 \end_inset
41561
41562 , i.e.
41563  the multiplication of an induction variable in line 18 (gint = j * 3) is
41564  changed to addition, a new temporary iTemp17 is allocated and assigned
41565  a initial value, a constant 3 is then added for each iteration of the loop.
41566  The compiler does not change the multiplication
41567 \begin_inset LatexCommand index
41568 name "Multiplication"
41569
41570 \end_inset
41571
41572  in line 17 however since the processor does support an 8 * 8 bit multiplication.
41573 \newline
41574
41575 Note the dead code elimination
41576 \begin_inset LatexCommand index
41577 name "Dead-code elimination"
41578
41579 \end_inset
41580
41581  optimization eliminated the dead assignments in line 7 & 8 to I and sum
41582  respectively.
41583 \newline
41584
41585 \end_layout
41586
41587 \begin_layout Standard
41588
41589 \size footnotesize
41590 Sample.c (5:1:0:0) _entry($9) :
41591 \end_layout
41592
41593 \begin_layout Standard
41594
41595 \size footnotesize
41596 Sample.c(5:2:1:0) proc _function [lr0:0]{function short}
41597 \end_layout
41598
41599 \begin_layout Standard
41600
41601 \size footnotesize
41602 Sample.c(11:3:2:0) iTemp0 [lr3:5]{_near * int}[r2] = recv 
41603 \end_layout
41604
41605 \begin_layout Standard
41606
41607 \size footnotesize
41608 Sample.c(11:4:53:0) preHeaderLbl0($11) :
41609 \end_layout
41610
41611 \begin_layout Standard
41612
41613 \size footnotesize
41614 Sample.c(11:5:55:0) iTemp6 [lr5:16]{_near * int}[r0] := iTemp0 [lr3:5]{_near
41615  * int}[r2]
41616 \end_layout
41617
41618 \begin_layout Standard
41619
41620 \size footnotesize
41621 Sample.c(11:6:5:1) _whilecontinue_0($1) :
41622 \end_layout
41623
41624 \begin_layout Standard
41625
41626 \size footnotesize
41627 Sample.c(11:7:7:1) iTemp4 [lr7:8]{int}[r2 r3] = @[iTemp6 [lr5:16]{_near *
41628  int}[r0]]
41629 \end_layout
41630
41631 \begin_layout Standard
41632
41633 \size footnotesize
41634 Sample.c(11:8:8:1) if iTemp4 [lr7:8]{int}[r2 r3] == 0 goto _whilebreak_0($3)
41635 \end_layout
41636
41637 \begin_layout Standard
41638
41639 \size footnotesize
41640 Sample.c(11:9:14:1) iTemp7 [lr9:13]{_far * int}[DPTR] := _p [lr0:0]{_far
41641  * int}
41642 \end_layout
41643
41644 \begin_layout Standard
41645
41646 \size footnotesize
41647 Sample.c(11:10:15:1) _p [lr0:0]{_far * int} = _p [lr0:0]{_far * int} + 0x2
41648  {short}
41649 \end_layout
41650
41651 \begin_layout Standard
41652
41653 \size footnotesize
41654 Sample.c(11:13:18:1) iTemp10 [lr13:14]{int}[r2 r3] = @[iTemp7 [lr9:13]{_far
41655  * int}[DPTR]]
41656 \end_layout
41657
41658 \begin_layout Standard
41659
41660 \size footnotesize
41661 Sample.c(11:14:19:1) *(iTemp6 [lr5:16]{_near * int}[r0]) := iTemp10 [lr13:14]{int
41662 }[r2 r3]
41663 \end_layout
41664
41665 \begin_layout Standard
41666
41667 \size footnotesize
41668 Sample.c(11:15:12:1) iTemp6 [lr5:16]{_near * int}[r0] = iTemp6 [lr5:16]{_near
41669  * int}[r0] + 0x2 {short}
41670 \end_layout
41671
41672 \begin_layout Standard
41673
41674 \size footnotesize
41675 Sample.c(11:16:20:1) goto _whilecontinue_0($1)
41676 \end_layout
41677
41678 \begin_layout Standard
41679
41680 \size footnotesize
41681 Sample.c(11:17:21:0)_whilebreak_0($3) :
41682 \end_layout
41683
41684 \begin_layout Standard
41685
41686 \size footnotesize
41687 Sample.c(12:18:22:0) iTemp2 [lr18:40]{short}[r2] := 0x0 {short}
41688 \end_layout
41689
41690 \begin_layout Standard
41691
41692 \size footnotesize
41693 Sample.c(13:19:23:0) iTemp11 [lr19:40]{short}[r3] := 0x0 {short}
41694 \end_layout
41695
41696 \begin_layout Standard
41697
41698 \size footnotesize
41699 Sample.c(15:20:54:0)preHeaderLbl1($13) :
41700 \end_layout
41701
41702 \begin_layout Standard
41703
41704 \size footnotesize
41705 Sample.c(15:21:56:0) iTemp21 [lr21:38]{short}[r4] := 0x0 {short}
41706 \end_layout
41707
41708 \begin_layout Standard
41709
41710 \size footnotesize
41711 Sample.c(15:22:57:0) iTemp23 [lr22:38]{int}[r5 r6] := 0xa {int}
41712 \end_layout
41713
41714 \begin_layout Standard
41715
41716 \size footnotesize
41717 Sample.c(15:23:58:0) iTemp17 [lr23:38]{int}[r7 r0] := 0x1e {int}
41718 \end_layout
41719
41720 \begin_layout Standard
41721
41722 \size footnotesize
41723 Sample.c(15:24:26:1)_forcond_0($4) :
41724 \end_layout
41725
41726 \begin_layout Standard
41727
41728 \size footnotesize
41729 Sample.c(15:25:27:1) iTemp13 [lr25:26]{char}[CC] = iTemp21 [lr21:38]{short}[r4]
41730  < 0xa {short}
41731 \end_layout
41732
41733 \begin_layout Standard
41734
41735 \size footnotesize
41736 Sample.c(15:26:28:1) if iTemp13 [lr25:26]{char}[CC] == 0 goto _forbreak_0($7)
41737 \end_layout
41738
41739 \begin_layout Standard
41740
41741 \size footnotesize
41742 Sample.c(16:27:31:1) iTemp2 [lr18:40]{short}[r2] = iTemp2 [lr18:40]{short}[r2]
41743  + ITemp21 [lr21:38]{short}[r4]
41744 \end_layout
41745
41746 \begin_layout Standard
41747
41748 \size footnotesize
41749 Sample.c(17:29:33:1) iTemp15 [lr29:30]{short}[r1] = iTemp21 [lr21:38]{short}[r4]
41750  * 0x3 {short}
41751 \end_layout
41752
41753 \begin_layout Standard
41754
41755 \size footnotesize
41756 Sample.c(17:30:34:1) iTemp11 [lr19:40]{short}[r3] = iTemp11 [lr19:40]{short}[r3]
41757  + iTemp15 [lr29:30]{short}[r1]
41758 \end_layout
41759
41760 \begin_layout Standard
41761
41762 \size footnotesize
41763 Sample.c(18:32:36:1:1) iTemp17 [lr23:38]{int}[r7 r0]= iTemp17 [lr23:38]{int}[r7
41764  r0]- 0x3 {short}
41765 \end_layout
41766
41767 \begin_layout Standard
41768
41769 \size footnotesize
41770 Sample.c(18:33:37:1) _gint [lr0:0]{int} = _gint [lr0:0]{int} + iTemp17 [lr23:38]{
41771 int}[r7 r0]
41772 \end_layout
41773
41774 \begin_layout Standard
41775
41776 \size footnotesize
41777 Sample.c(15:36:42:1) iTemp21 [lr21:38]{short}[r4] = iTemp21 [lr21:38]{short}[r4]
41778  + 0x1 {short}
41779 \end_layout
41780
41781 \begin_layout Standard
41782
41783 \size footnotesize
41784 Sample.c(15:37:45:1) iTemp23 [lr22:38]{int}[r5 r6]= iTemp23 [lr22:38]{int}[r5
41785  r6]- 0x1 {short}
41786 \end_layout
41787
41788 \begin_layout Standard
41789
41790 \size footnotesize
41791 Sample.c(19:38:47:1) goto _forcond_0($4)
41792 \end_layout
41793
41794 \begin_layout Standard
41795
41796 \size footnotesize
41797 Sample.c(19:39:48:0)_forbreak_0($7) :
41798 \end_layout
41799
41800 \begin_layout Standard
41801
41802 \size footnotesize
41803 Sample.c(20:40:49:0) iTemp24 [lr40:41]{short}[DPTR] = iTemp2 [lr18:40]{short}[r2]
41804  + ITemp11 [lr19:40]{short}[r3]
41805 \end_layout
41806
41807 \begin_layout Standard
41808
41809 \size footnotesize
41810 Sample.c(20:41:50:0) ret iTemp24 [lr40:41]{short}
41811 \end_layout
41812
41813 \begin_layout Standard
41814
41815 \size footnotesize
41816 Sample.c(20:42:51:0)_return($8) :
41817 \end_layout
41818
41819 \begin_layout Standard
41820
41821 \size footnotesize
41822 Sample.c(20:43:52:0) eproc _function [lr0:0]{ ia0 re0 rm0}{function short}
41823 \size default
41824
41825 \newline
41826
41827 \newline
41828 Finally the code generated for this function:
41829 \newline
41830
41831 \end_layout
41832
41833 \begin_layout Standard
41834
41835 \size footnotesize
41836 .area DSEG (DATA)
41837 \end_layout
41838
41839 \begin_layout Standard
41840
41841 \size footnotesize
41842 _p::
41843 \end_layout
41844
41845 \begin_layout Standard
41846
41847 \size footnotesize
41848 \InsetSpace ~
41849 \InsetSpace ~
41850 .ds 2
41851 \end_layout
41852
41853 \begin_layout Standard
41854
41855 \size footnotesize
41856 _gint::
41857 \end_layout
41858
41859 \begin_layout Standard
41860
41861 \size footnotesize
41862 \InsetSpace ~
41863 \InsetSpace ~
41864 .ds 2
41865 \end_layout
41866
41867 \begin_layout Standard
41868
41869 \size footnotesize
41870 ; sample.c 5
41871 \end_layout
41872
41873 \begin_layout Standard
41874
41875 \size footnotesize
41876 ; ----------------------------------------------
41877 \end_layout
41878
41879 \begin_layout Standard
41880
41881 \size footnotesize
41882 ; function function
41883 \end_layout
41884
41885 \begin_layout Standard
41886
41887 \size footnotesize
41888 ; ----------------------------------------------
41889 \end_layout
41890
41891 \begin_layout Standard
41892
41893 \size footnotesize
41894 _function:
41895 \end_layout
41896
41897 \begin_layout Standard
41898
41899 \size footnotesize
41900 ; iTemp0 [lr3:5]{_near * int}[r2] = recv 
41901 \end_layout
41902
41903 \begin_layout Standard
41904
41905 \size footnotesize
41906 \InsetSpace ~
41907 \InsetSpace ~
41908 mov r2,dpl
41909 \end_layout
41910
41911 \begin_layout Standard
41912
41913 \size footnotesize
41914 ; iTemp6 [lr5:16]{_near * int}[r0] := iTemp0 [lr3:5]{_near * int}[r2]
41915 \end_layout
41916
41917 \begin_layout Standard
41918
41919 \size footnotesize
41920 \InsetSpace ~
41921 \InsetSpace ~
41922 mov ar0,r2
41923 \end_layout
41924
41925 \begin_layout Standard
41926
41927 \size footnotesize
41928 ;_whilecontinue_0($1) :
41929 \end_layout
41930
41931 \begin_layout Standard
41932
41933 \size footnotesize
41934 00101$:
41935 \end_layout
41936
41937 \begin_layout Standard
41938
41939 \size footnotesize
41940 ; iTemp4 [lr7:8]{int}[r2 r3] = @[iTemp6 [lr5:16]{_near * int}[r0]]
41941 \end_layout
41942
41943 \begin_layout Standard
41944
41945 \size footnotesize
41946 ; if iTemp4 [lr7:8]{int}[r2 r3] == 0 goto _whilebreak_0($3)
41947 \end_layout
41948
41949 \begin_layout Standard
41950
41951 \size footnotesize
41952 \InsetSpace ~
41953 \InsetSpace ~
41954 mov ar2,@r0
41955 \end_layout
41956
41957 \begin_layout Standard
41958
41959 \size footnotesize
41960 \InsetSpace ~
41961 \InsetSpace ~
41962 inc r0
41963 \end_layout
41964
41965 \begin_layout Standard
41966
41967 \size footnotesize
41968 \InsetSpace ~
41969 \InsetSpace ~
41970 mov ar3,@r0
41971 \end_layout
41972
41973 \begin_layout Standard
41974
41975 \size footnotesize
41976 \InsetSpace ~
41977 \InsetSpace ~
41978 dec r0
41979 \end_layout
41980
41981 \begin_layout Standard
41982
41983 \size footnotesize
41984 \InsetSpace ~
41985 \InsetSpace ~
41986 mov a,r2
41987 \end_layout
41988
41989 \begin_layout Standard
41990
41991 \size footnotesize
41992 \InsetSpace ~
41993 \InsetSpace ~
41994 orl a,r3
41995 \end_layout
41996
41997 \begin_layout Standard
41998
41999 \size footnotesize
42000 \InsetSpace ~
42001 \InsetSpace ~
42002 jz 00103$
42003 \end_layout
42004
42005 \begin_layout Standard
42006
42007 \size footnotesize
42008 00114$:
42009 \end_layout
42010
42011 \begin_layout Standard
42012
42013 \size footnotesize
42014 ; iTemp7 [lr9:13]{_far * int}[DPTR] := _p [lr0:0]{_far * int}
42015 \end_layout
42016
42017 \begin_layout Standard
42018
42019 \size footnotesize
42020 \InsetSpace ~
42021 \InsetSpace ~
42022 mov dpl,_p
42023 \end_layout
42024
42025 \begin_layout Standard
42026
42027 \size footnotesize
42028 \InsetSpace ~
42029 \InsetSpace ~
42030 mov dph,(_p + 1)
42031 \end_layout
42032
42033 \begin_layout Standard
42034
42035 \size footnotesize
42036 ; _p [lr0:0]{_far * int} = _p [lr0:0]{_far * int} + 0x2 {short}
42037 \end_layout
42038
42039 \begin_layout Standard
42040
42041 \size footnotesize
42042 \InsetSpace ~
42043 \InsetSpace ~
42044 mov a,#0x02
42045 \end_layout
42046
42047 \begin_layout Standard
42048
42049 \size footnotesize
42050 \InsetSpace ~
42051 \InsetSpace ~
42052 add a,_p
42053 \end_layout
42054
42055 \begin_layout Standard
42056
42057 \size footnotesize
42058 \InsetSpace ~
42059 \InsetSpace ~
42060 mov _p,a
42061 \end_layout
42062
42063 \begin_layout Standard
42064
42065 \size footnotesize
42066 \InsetSpace ~
42067 \InsetSpace ~
42068 clr a
42069 \end_layout
42070
42071 \begin_layout Standard
42072
42073 \size footnotesize
42074 \InsetSpace ~
42075 \InsetSpace ~
42076 addc a,(_p + 1)
42077 \end_layout
42078
42079 \begin_layout Standard
42080
42081 \size footnotesize
42082 \InsetSpace ~
42083 \InsetSpace ~
42084 mov (_p + 1),a
42085 \end_layout
42086
42087 \begin_layout Standard
42088
42089 \size footnotesize
42090 ; iTemp10 [lr13:14]{int}[r2 r3] = @[iTemp7 [lr9:13]{_far * int}[DPTR]]
42091 \end_layout
42092
42093 \begin_layout Standard
42094
42095 \size footnotesize
42096 \InsetSpace ~
42097 \InsetSpace ~
42098 movx a,@dptr
42099 \end_layout
42100
42101 \begin_layout Standard
42102
42103 \size footnotesize
42104 \InsetSpace ~
42105 \InsetSpace ~
42106 mov r2,a
42107 \end_layout
42108
42109 \begin_layout Standard
42110
42111 \size footnotesize
42112 \InsetSpace ~
42113 \InsetSpace ~
42114 inc dptr
42115 \end_layout
42116
42117 \begin_layout Standard
42118
42119 \size footnotesize
42120 \InsetSpace ~
42121 \InsetSpace ~
42122 movx a,@dptr
42123 \end_layout
42124
42125 \begin_layout Standard
42126
42127 \size footnotesize
42128 \InsetSpace ~
42129 \InsetSpace ~
42130 mov r3,a
42131 \end_layout
42132
42133 \begin_layout Standard
42134
42135 \size footnotesize
42136 ; *(iTemp6 [lr5:16]{_near * int}[r0]) := iTemp10 [lr13:14]{int}[r2 r3]
42137 \end_layout
42138
42139 \begin_layout Standard
42140
42141 \size footnotesize
42142 \InsetSpace ~
42143 \InsetSpace ~
42144 mov @r0,ar2
42145 \end_layout
42146
42147 \begin_layout Standard
42148
42149 \size footnotesize
42150 \InsetSpace ~
42151 \InsetSpace ~
42152 inc r0
42153 \end_layout
42154
42155 \begin_layout Standard
42156
42157 \size footnotesize
42158 \InsetSpace ~
42159 \InsetSpace ~
42160 mov @r0,ar3
42161 \end_layout
42162
42163 \begin_layout Standard
42164
42165 \size footnotesize
42166 ; iTemp6 [lr5:16]{_near * int}[r0] = 
42167 \end_layout
42168
42169 \begin_layout Standard
42170
42171 \size footnotesize
42172 ; iTemp6 [lr5:16]{_near * int}[r0] + 
42173 \end_layout
42174
42175 \begin_layout Standard
42176
42177 \size footnotesize
42178 ; 0x2 {short}
42179 \end_layout
42180
42181 \begin_layout Standard
42182
42183 \size footnotesize
42184 \InsetSpace ~
42185 \InsetSpace ~
42186 inc r0
42187 \end_layout
42188
42189 \begin_layout Standard
42190
42191 \size footnotesize
42192 ; goto _whilecontinue_0($1)
42193 \end_layout
42194
42195 \begin_layout Standard
42196
42197 \size footnotesize
42198 \InsetSpace ~
42199 \InsetSpace ~
42200 sjmp 00101$
42201 \end_layout
42202
42203 \begin_layout Standard
42204
42205 \size footnotesize
42206 ; _whilebreak_0($3) :
42207 \end_layout
42208
42209 \begin_layout Standard
42210
42211 \size footnotesize
42212 00103$:
42213 \end_layout
42214
42215 \begin_layout Standard
42216
42217 \size footnotesize
42218 ; iTemp2 [lr18:40]{short}[r2] := 0x0 {short}
42219 \end_layout
42220
42221 \begin_layout Standard
42222
42223 \size footnotesize
42224 \InsetSpace ~
42225 \InsetSpace ~
42226 mov r2,#0x00
42227 \end_layout
42228
42229 \begin_layout Standard
42230
42231 \size footnotesize
42232 ; iTemp11 [lr19:40]{short}[r3] := 0x0 {short}
42233 \end_layout
42234
42235 \begin_layout Standard
42236
42237 \size footnotesize
42238 \InsetSpace ~
42239 \InsetSpace ~
42240 mov r3,#0x00
42241 \end_layout
42242
42243 \begin_layout Standard
42244
42245 \size footnotesize
42246 ; iTemp21 [lr21:38]{short}[r4] := 0x0 {short}
42247 \end_layout
42248
42249 \begin_layout Standard
42250
42251 \size footnotesize
42252 \InsetSpace ~
42253 \InsetSpace ~
42254 mov r4,#0x00
42255 \end_layout
42256
42257 \begin_layout Standard
42258
42259 \size footnotesize
42260 ; iTemp23 [lr22:38]{int}[r5 r6] := 0xa {int}
42261 \end_layout
42262
42263 \begin_layout Standard
42264
42265 \size footnotesize
42266 \InsetSpace ~
42267 \InsetSpace ~
42268 mov r5,#0x0A
42269 \end_layout
42270
42271 \begin_layout Standard
42272
42273 \size footnotesize
42274 \InsetSpace ~
42275 \InsetSpace ~
42276 mov r6,#0x00
42277 \end_layout
42278
42279 \begin_layout Standard
42280
42281 \size footnotesize
42282 ; iTemp17 [lr23:38]{int}[r7 r0] := 0x1e {int}
42283 \end_layout
42284
42285 \begin_layout Standard
42286
42287 \size footnotesize
42288 \InsetSpace ~
42289 \InsetSpace ~
42290 mov r7,#0x1E
42291 \end_layout
42292
42293 \begin_layout Standard
42294
42295 \size footnotesize
42296 \InsetSpace ~
42297 \InsetSpace ~
42298 mov r0,#0x00
42299 \end_layout
42300
42301 \begin_layout Standard
42302
42303 \size footnotesize
42304 ; _forcond_0($4) :
42305 \end_layout
42306
42307 \begin_layout Standard
42308
42309 \size footnotesize
42310 00104$:
42311 \end_layout
42312
42313 \begin_layout Standard
42314
42315 \size footnotesize
42316 ; iTemp13 [lr25:26]{char}[CC] = iTemp21 [lr21:38]{short}[r4] < 0xa {short}
42317 \end_layout
42318
42319 \begin_layout Standard
42320
42321 \size footnotesize
42322 ; if iTemp13 [lr25:26]{char}[CC] == 0 goto _forbreak_0($7)
42323 \end_layout
42324
42325 \begin_layout Standard
42326
42327 \size footnotesize
42328 \InsetSpace ~
42329 \InsetSpace ~
42330 clr c
42331 \end_layout
42332
42333 \begin_layout Standard
42334
42335 \size footnotesize
42336 \InsetSpace ~
42337 \InsetSpace ~
42338 mov a,r4
42339 \end_layout
42340
42341 \begin_layout Standard
42342
42343 \size footnotesize
42344 \InsetSpace ~
42345 \InsetSpace ~
42346 xrl a,#0x80
42347 \end_layout
42348
42349 \begin_layout Standard
42350
42351 \size footnotesize
42352 \InsetSpace ~
42353 \InsetSpace ~
42354 subb a,#0x8a
42355 \end_layout
42356
42357 \begin_layout Standard
42358
42359 \size footnotesize
42360 \InsetSpace ~
42361 \InsetSpace ~
42362 jnc 00107$
42363 \end_layout
42364
42365 \begin_layout Standard
42366
42367 \size footnotesize
42368 00115$:
42369 \end_layout
42370
42371 \begin_layout Standard
42372
42373 \size footnotesize
42374 ; iTemp2 [lr18:40]{short}[r2] = iTemp2 [lr18:40]{short}[r2] + 
42375 \end_layout
42376
42377 \begin_layout Standard
42378
42379 \size footnotesize
42380 ; iTemp21 [lr21:38]{short}[r4]
42381 \end_layout
42382
42383 \begin_layout Standard
42384
42385 \size footnotesize
42386 \InsetSpace ~
42387 \InsetSpace ~
42388 mov a,r4
42389 \end_layout
42390
42391 \begin_layout Standard
42392
42393 \size footnotesize
42394 \InsetSpace ~
42395 \InsetSpace ~
42396 add a,r2
42397 \end_layout
42398
42399 \begin_layout Standard
42400
42401 \size footnotesize
42402 \InsetSpace ~
42403 \InsetSpace ~
42404 mov r2,a
42405 \end_layout
42406
42407 \begin_layout Standard
42408
42409 \size footnotesize
42410 ; iTemp15 [lr29:30]{short}[r1] = iTemp21 [lr21:38]{short}[r4] * 0x3 {short}
42411 \end_layout
42412
42413 \begin_layout Standard
42414
42415 \size footnotesize
42416 \InsetSpace ~
42417 \InsetSpace ~
42418 mov b,#0x03
42419 \end_layout
42420
42421 \begin_layout Standard
42422
42423 \size footnotesize
42424 \InsetSpace ~
42425 \InsetSpace ~
42426 mov a,r4
42427 \end_layout
42428
42429 \begin_layout Standard
42430
42431 \size footnotesize
42432 \InsetSpace ~
42433 \InsetSpace ~
42434 mul ab
42435 \end_layout
42436
42437 \begin_layout Standard
42438
42439 \size footnotesize
42440 \InsetSpace ~
42441 \InsetSpace ~
42442 mov r1,a
42443 \end_layout
42444
42445 \begin_layout Standard
42446
42447 \size footnotesize
42448 ; iTemp11 [lr19:40]{short}[r3] = iTemp11 [lr19:40]{short}[r3] + 
42449 \end_layout
42450
42451 \begin_layout Standard
42452
42453 \size footnotesize
42454 ; iTemp15 [lr29:30]{short}[r1]
42455 \end_layout
42456
42457 \begin_layout Standard
42458
42459 \size footnotesize
42460 \InsetSpace ~
42461 \InsetSpace ~
42462 add a,r3
42463 \end_layout
42464
42465 \begin_layout Standard
42466
42467 \size footnotesize
42468 \InsetSpace ~
42469 \InsetSpace ~
42470 mov r3,a
42471 \end_layout
42472
42473 \begin_layout Standard
42474
42475 \size footnotesize
42476 ; iTemp17 [lr23:38]{int}[r7 r0]= iTemp17 [lr23:38]{int}[r7 r0]- 0x3 {short}
42477 \end_layout
42478
42479 \begin_layout Standard
42480
42481 \size footnotesize
42482 \InsetSpace ~
42483 \InsetSpace ~
42484 mov a,r7
42485 \end_layout
42486
42487 \begin_layout Standard
42488
42489 \size footnotesize
42490 \InsetSpace ~
42491 \InsetSpace ~
42492 add a,#0xfd
42493 \end_layout
42494
42495 \begin_layout Standard
42496
42497 \size footnotesize
42498 \InsetSpace ~
42499 \InsetSpace ~
42500 mov r7,a
42501 \end_layout
42502
42503 \begin_layout Standard
42504
42505 \size footnotesize
42506 \InsetSpace ~
42507 \InsetSpace ~
42508 mov a,r0
42509 \end_layout
42510
42511 \begin_layout Standard
42512
42513 \size footnotesize
42514 \InsetSpace ~
42515 \InsetSpace ~
42516 addc a,#0xff
42517 \end_layout
42518
42519 \begin_layout Standard
42520
42521 \size footnotesize
42522 \InsetSpace ~
42523 \InsetSpace ~
42524 mov r0,a
42525 \end_layout
42526
42527 \begin_layout Standard
42528
42529 \size footnotesize
42530 ; _gint [lr0:0]{int} = _gint [lr0:0]{int} + iTemp17 [lr23:38]{int}[r7 r0]
42531 \end_layout
42532
42533 \begin_layout Standard
42534
42535 \size footnotesize
42536 \InsetSpace ~
42537 \InsetSpace ~
42538 mov a,r7
42539 \end_layout
42540
42541 \begin_layout Standard
42542
42543 \size footnotesize
42544 \InsetSpace ~
42545 \InsetSpace ~
42546 add a,_gint
42547 \end_layout
42548
42549 \begin_layout Standard
42550
42551 \size footnotesize
42552 \InsetSpace ~
42553 \InsetSpace ~
42554 mov _gint,a
42555 \end_layout
42556
42557 \begin_layout Standard
42558
42559 \size footnotesize
42560 \InsetSpace ~
42561 \InsetSpace ~
42562 mov a,r0
42563 \end_layout
42564
42565 \begin_layout Standard
42566
42567 \size footnotesize
42568 \InsetSpace ~
42569 \InsetSpace ~
42570 addc a,(_gint + 1)
42571 \end_layout
42572
42573 \begin_layout Standard
42574
42575 \size footnotesize
42576 \InsetSpace ~
42577 \InsetSpace ~
42578 mov (_gint + 1),a
42579 \end_layout
42580
42581 \begin_layout Standard
42582
42583 \size footnotesize
42584 ; iTemp21 [lr21:38]{short}[r4] = iTemp21 [lr21:38]{short}[r4] + 0x1 {short}
42585 \end_layout
42586
42587 \begin_layout Standard
42588
42589 \size footnotesize
42590 \InsetSpace ~
42591 \InsetSpace ~
42592 inc r4
42593 \end_layout
42594
42595 \begin_layout Standard
42596
42597 \size footnotesize
42598 ; iTemp23 [lr22:38]{int}[r5 r6]= iTemp23 [lr22:38]{int}[r5 r6]- 0x1 {short}
42599 \end_layout
42600
42601 \begin_layout Standard
42602
42603 \size footnotesize
42604 \InsetSpace ~
42605 \InsetSpace ~
42606 dec r5
42607 \end_layout
42608
42609 \begin_layout Standard
42610
42611 \size footnotesize
42612 \InsetSpace ~
42613 \InsetSpace ~
42614 cjne r5,#0xff,00104$
42615 \end_layout
42616
42617 \begin_layout Standard
42618
42619 \size footnotesize
42620 \InsetSpace ~
42621 \InsetSpace ~
42622 dec r6
42623 \end_layout
42624
42625 \begin_layout Standard
42626
42627 \size footnotesize
42628 ; goto _forcond_0($4)
42629 \end_layout
42630
42631 \begin_layout Standard
42632
42633 \size footnotesize
42634 \InsetSpace ~
42635 \InsetSpace ~
42636 sjmp 00104$
42637 \end_layout
42638
42639 \begin_layout Standard
42640
42641 \size footnotesize
42642 ; _forbreak_0($7) :
42643 \end_layout
42644
42645 \begin_layout Standard
42646
42647 \size footnotesize
42648 00107$:
42649 \end_layout
42650
42651 \begin_layout Standard
42652
42653 \size footnotesize
42654 ; ret iTemp24 [lr40:41]{short}
42655 \end_layout
42656
42657 \begin_layout Standard
42658
42659 \size footnotesize
42660 \InsetSpace ~
42661 \InsetSpace ~
42662 mov a,r3
42663 \end_layout
42664
42665 \begin_layout Standard
42666
42667 \size footnotesize
42668 \InsetSpace ~
42669 \InsetSpace ~
42670 add a,r2
42671 \end_layout
42672
42673 \begin_layout Standard
42674
42675 \size footnotesize
42676 \InsetSpace ~
42677 \InsetSpace ~
42678 mov dpl,a
42679 \end_layout
42680
42681 \begin_layout Standard
42682
42683 \size footnotesize
42684 ; _return($8) :
42685 \end_layout
42686
42687 \begin_layout Standard
42688
42689 \size footnotesize
42690 00108$:
42691 \end_layout
42692
42693 \begin_layout Standard
42694
42695 \size footnotesize
42696 \InsetSpace ~
42697 \InsetSpace ~
42698 ret
42699 \newline
42700
42701 \end_layout
42702
42703 \begin_layout Section
42704 A few words about basic block successors, predecessors and dominators
42705 \end_layout
42706
42707 \begin_layout Standard
42708 Successors are basic blocks
42709 \begin_inset LatexCommand index
42710 name "Basic blocks"
42711
42712 \end_inset
42713
42714  that might execute after this basic block.
42715 \newline
42716 Predecessors are basic blocks
42717  that might execute before reaching this basic block.
42718 \newline
42719 Dominators are basic
42720  blocks that WILL execute before reaching this basic block.
42721 \newline
42722
42723 \end_layout
42724
42725 \begin_layout Standard
42726 [basic block 1]
42727 \end_layout
42728
42729 \begin_layout Standard
42730 if (something)
42731 \end_layout
42732
42733 \begin_layout Standard
42734 \InsetSpace ~
42735 \InsetSpace ~
42736 \InsetSpace ~
42737 \InsetSpace ~
42738 [basic block 2]
42739 \end_layout
42740
42741 \begin_layout Standard
42742 else
42743 \end_layout
42744
42745 \begin_layout Standard
42746 \InsetSpace ~
42747 \InsetSpace ~
42748 \InsetSpace ~
42749 \InsetSpace ~
42750 [basic block 3]
42751 \end_layout
42752
42753 \begin_layout Standard
42754 [basic block 4]
42755 \newline
42756
42757 \end_layout
42758
42759 \begin_layout Standard
42760 a) succList of [BB2] = [BB4], of [BB3] = [BB4], of [BB1] = [BB2,BB3]
42761 \end_layout
42762
42763 \begin_layout Standard
42764 b) predList of [BB2] = [BB1], of [BB3] = [BB1], of [BB4] = [BB2,BB3]
42765 \end_layout
42766
42767 \begin_layout Standard
42768 c) domVect of [BB4] = BB1 ...
42769  here we are not sure if BB2 or BB3 was executed but we are SURE that BB1
42770  was executed.
42771 \end_layout
42772
42773 \begin_layout Chapter
42774 Acknowledgments
42775 \end_layout
42776
42777 \begin_layout Standard
42778 \begin_inset LatexCommand url
42779 target "http://sdcc.sourceforge.net/#Who"
42780
42781 \end_inset
42782
42783
42784 \newline
42785
42786 \newline
42787
42788 \emph on
42789 Thanks to all the other volunteer developers who have helped with coding,
42790  testing, web-page creation, distribution sets, etc.
42791  You know who you are :-)
42792 \emph default
42793
42794 \newline
42795
42796 \newline
42797
42798 \emph on
42799 Thanks to Sourceforge 
42800 \begin_inset LatexCommand url
42801 target "http://www.sf.net"
42802
42803 \end_inset
42804
42805  which has hosted the project since 1999 and donates significant download
42806  bandwidth.
42807 \emph default
42808
42809 \newline
42810
42811 \newline
42812
42813 \emph on
42814 Also thanks to all SDCC Distributed Compile Farm members for donating CPU
42815  cycles and bandwidth for snapshot builds.
42816 \newline
42817
42818 \end_layout
42819
42820 \begin_layout Standard
42821 This document was initially written by Sandeep Dutta
42822 \end_layout
42823
42824 \begin_layout Standard
42825 All product names mentioned herein may be trademarks
42826 \begin_inset LatexCommand index
42827 name "Trademarks"
42828
42829 \end_inset
42830
42831  of their respective companies.
42832  
42833 \end_layout
42834
42835 \begin_layout Section*
42836 Alphabetical index
42837 \end_layout
42838
42839 \begin_layout Standard
42840 To avoid confusion, the installation and building options for SDCC itself
42841  (chapter 2) are not part of the index.
42842 \end_layout
42843
42844 \begin_layout Standard
42845 \begin_inset LatexCommand printindex
42846
42847 \end_inset
42848
42849
42850 \end_layout
42851
42852 \end_body
42853 \end_document