Use 'ao-dbg' instead of 's51' to communicate with TeleMetrum
[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.1
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_CHAR_UNSIGNED
24301 \begin_inset LatexCommand index
24302 name "SDCC\\_CHAR\\_UNSIGNED"
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 -
24318 \begin_inset ERT
24319 status collapsed
24320
24321 \begin_layout Standard
24322
24323
24324 \backslash
24325 /
24326 \end_layout
24327
24328 \end_inset
24329
24330 -funsigned-char
24331 \emph default
24332  option is used
24333 \end_layout
24334
24335 \end_inset
24336 </cell>
24337 </row>
24338 <row topline="true">
24339 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24340 \begin_inset Text
24341
24342 \begin_layout Standard
24343 SDCC_STACK_TENBIT
24344 \begin_inset LatexCommand index
24345 name "SDCC\\_STACK\\_TENBIT"
24346
24347 \end_inset
24348
24349  
24350 \end_layout
24351
24352 \end_inset
24353 </cell>
24354 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24355 \begin_inset Text
24356
24357 \begin_layout Standard
24358 when 
24359 \emph on
24360 -mds390
24361 \emph default
24362  is used
24363 \end_layout
24364
24365 \end_inset
24366 </cell>
24367 </row>
24368 <row topline="true">
24369 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24370 \begin_inset Text
24371
24372 \begin_layout Standard
24373 SDCC_MODEL_FLAT24
24374 \begin_inset LatexCommand index
24375 name "SDCC\\_MODEL\\_FLAT24"
24376
24377 \end_inset
24378
24379
24380 \end_layout
24381
24382 \end_inset
24383 </cell>
24384 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24385 \begin_inset Text
24386
24387 \begin_layout Standard
24388 when 
24389 \emph on
24390 -mds390
24391 \emph default
24392  is used
24393 \end_layout
24394
24395 \end_inset
24396 </cell>
24397 </row>
24398 <row topline="true">
24399 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24400 \begin_inset Text
24401
24402 \begin_layout Standard
24403 SDCC_REVISION
24404 \begin_inset LatexCommand index
24405 name "SDCC\\_REVISION"
24406
24407 \end_inset
24408
24409
24410 \end_layout
24411
24412 \end_inset
24413 </cell>
24414 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24415 \begin_inset Text
24416
24417 \begin_layout Standard
24418 Always defined.
24419  SDCC svn revision number
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_PARMS_IN_BANK1
24431 \begin_inset LatexCommand index
24432 name "SDCC\\_PARMS\\_IN\\_BANK1"
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 -parms-in-bank1
24461 \emph default
24462  is used
24463 \end_layout
24464
24465 \end_inset
24466 </cell>
24467 </row>
24468 <row topline="true">
24469 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24470 \begin_inset Text
24471
24472 \begin_layout Standard
24473 SDCC_FLOAT_REENT
24474 \begin_inset LatexCommand index
24475 name "SDCC\\_MODEL\\_FLAT24"
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 -float-reent
24504 \emph default
24505  is used
24506 \end_layout
24507
24508 \end_inset
24509 </cell>
24510 </row>
24511 <row topline="true" bottomline="true">
24512 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24513 \begin_inset Text
24514
24515 \begin_layout Standard
24516 SDCC_INT_LONG_REENT
24517 \begin_inset LatexCommand index
24518 name "SDCC\\_INT\\_LONG\\_REENT"
24519
24520 \end_inset
24521
24522
24523 \end_layout
24524
24525 \end_inset
24526 </cell>
24527 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24528 \begin_inset Text
24529
24530 \begin_layout Standard
24531 when 
24532 \emph on
24533 -
24534 \begin_inset ERT
24535 status collapsed
24536
24537 \begin_layout Standard
24538
24539
24540 \backslash
24541 /
24542 \end_layout
24543
24544 \end_inset
24545
24546 -int-long-reent
24547 \emph default
24548  is used
24549 \end_layout
24550
24551 \end_inset
24552 </cell>
24553 </row>
24554 </lyxtabular>
24555
24556 \end_inset
24557
24558
24559 \end_layout
24560
24561 \begin_layout Chapter
24562 Notes on supported Processors
24563 \end_layout
24564
24565 \begin_layout Section
24566 MCS51 variants
24567 \begin_inset LatexCommand label
24568 name "sub:MCS51-variants"
24569
24570 \end_inset
24571
24572
24573 \begin_inset LatexCommand index
24574 name "MCS51 variants"
24575
24576 \end_inset
24577
24578
24579 \end_layout
24580
24581 \begin_layout Standard
24582 MCS51 processors are available from many vendors and come in many different
24583  flavours.
24584  While they might differ considerably in respect to Special Function Registers
24585  the core MCS51 is usually not modified or is kept compatible.
24586  
24587 \end_layout
24588
24589 \begin_layout Subsection
24590 pdata access by SFR 
24591 \end_layout
24592
24593 \begin_layout Standard
24594 With the upcome of devices with internal xdata and flash memory devices
24595  using port P2
24596 \begin_inset LatexCommand index
24597 name "P2 (mcs51 sfr)"
24598
24599 \end_inset
24600
24601  as dedicated I/O port is becoming more popular.
24602  Switching the high byte for pdata
24603 \begin_inset LatexCommand index
24604 name "pdata (mcs51, ds390 storage class)"
24605
24606 \end_inset
24607
24608  access which was formerly done by port P2 is then achieved by a Special
24609  Function Register
24610 \begin_inset LatexCommand index
24611 name "sfr"
24612
24613 \end_inset
24614
24615 .
24616  In well-established MCS51 tradition the address of this 
24617 \emph on
24618 sfr
24619 \emph default
24620  is where the chip designers decided to put it.
24621  Needless to say that they didn't agree on a common name either.
24622  So that the startup code can correctly initialize xdata variables, you
24623  should define an sfr with the name _XPAGE
24624 \family typewriter
24625
24626 \begin_inset LatexCommand index
24627 name "\\_XPAGE (mcs51)"
24628
24629 \end_inset
24630
24631
24632 \family default
24633  at the appropriate location if the default, port P2, is not used for this.
24634  Some examples are:
24635 \end_layout
24636
24637 \begin_layout Verse
24638
24639 \family typewriter
24640 __sfr __at (0x85) _XPAGE; /* Ramtron VRS51 family a.k.a.
24641  MPAGE */
24642 \end_layout
24643
24644 \begin_layout Verse
24645
24646 \family typewriter
24647 __sfr __at (0x92) _XPAGE; /* Cypress EZ-USB family, Texas Instruments (Chipcon)
24648  a.k.a.
24649  MPAGE */
24650 \end_layout
24651
24652 \begin_layout Verse
24653
24654 \family typewriter
24655 __sfr __at (0x91) _XPAGE; /* Infineon (Siemens) C500 family a.k.a.
24656  XPAGE */
24657 \end_layout
24658
24659 \begin_layout Verse
24660
24661 \family typewriter
24662 __sfr __at (0xaf) _XPAGE; /* some Silicon Labs (Cygnal) chips a.k.a.
24663  EMI0CN */
24664 \end_layout
24665
24666 \begin_layout Verse
24667
24668 \family typewriter
24669 __sfr __at (0xaa) _XPAGE; /* some Silicon Labs (Cygnal) chips a.k.a.
24670  EMI0CN */
24671 \end_layout
24672
24673 \begin_layout Standard
24674 For more exotic implementations further customizations may be needed.
24675  See section 
24676 \begin_inset LatexCommand ref
24677 reference "sub:Startup-Code"
24678
24679 \end_inset
24680
24681  for other possibilities.
24682 \end_layout
24683
24684 \begin_layout Subsection
24685 Other Features available by SFR
24686 \end_layout
24687
24688 \begin_layout Standard
24689 Some MCS51 variants offer features like Double DPTR
24690 \begin_inset LatexCommand index
24691 name "DPTR"
24692
24693 \end_inset
24694
24695 , multiple DPTR, decrementing DPTR, 16x16 Multiply.
24696  These are currently not used for the MCS51 port.
24697  If you absolutely need them you can fall back to inline assembly or submit
24698  a patch to SDCC.
24699 \end_layout
24700
24701 \begin_layout Subsection
24702 Bankswitching
24703 \end_layout
24704
24705 \begin_layout Standard
24706 Bankswitching
24707 \begin_inset LatexCommand index
24708 name "Bankswitching"
24709
24710 \end_inset
24711
24712  (a.k.a.
24713  code banking
24714 \begin_inset LatexCommand index
24715 name "code banking"
24716
24717 \end_inset
24718
24719 ) is a technique to increase the code space above the 64k limit of the 8051.
24720 \end_layout
24721
24722 \begin_layout Subsubsection
24723 Hardware
24724 \end_layout
24725
24726 \begin_layout Standard
24727 \begin_inset Tabular
24728 <lyxtabular version="3" rows="3" columns="4">
24729 <features>
24730 <column alignment="center" valignment="top" width="0">
24731 <column alignment="center" valignment="top" leftline="true" width="0">
24732 <column alignment="center" valignment="top" leftline="true" width="0">
24733 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
24734 <row topline="true" bottomline="true">
24735 <cell multicolumn="1" alignment="center" valignment="top" usebox="none">
24736 \begin_inset Text
24737
24738 \begin_layout Standard
24739 8000-FFFF
24740 \end_layout
24741
24742 \end_inset
24743 </cell>
24744 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24745 \begin_inset Text
24746
24747 \begin_layout Standard
24748 bank1
24749 \end_layout
24750
24751 \end_inset
24752 </cell>
24753 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24754 \begin_inset Text
24755
24756 \begin_layout Standard
24757 bank2
24758 \end_layout
24759
24760 \end_inset
24761 </cell>
24762 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24763 \begin_inset Text
24764
24765 \begin_layout Standard
24766 bank3
24767 \end_layout
24768
24769 \end_inset
24770 </cell>
24771 </row>
24772 <row topline="true" bottomline="true">
24773 <cell multicolumn="1" alignment="center" valignment="top" usebox="none">
24774 \begin_inset Text
24775
24776 \begin_layout Standard
24777 0000-7FFF
24778 \end_layout
24779
24780 \end_inset
24781 </cell>
24782 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24783 \begin_inset Text
24784
24785 \begin_layout Standard
24786 common
24787 \end_layout
24788
24789 \end_inset
24790 </cell>
24791 <cell multicolumn="1" alignment="center" valignment="top" usebox="none">
24792 \begin_inset Text
24793
24794 \begin_layout Standard
24795
24796 \end_layout
24797
24798 \end_inset
24799 </cell>
24800 <cell multicolumn="2" alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
24801 \begin_inset Text
24802
24803 \begin_layout Standard
24804
24805 \end_layout
24806
24807 \end_inset
24808 </cell>
24809 </row>
24810 <row>
24811 <cell multicolumn="1" alignment="center" valignment="top" usebox="none">
24812 \begin_inset Text
24813
24814 \begin_layout Standard
24815 SiLabs C8051F120 example
24816 \end_layout
24817
24818 \end_inset
24819 </cell>
24820 <cell multicolumn="2" alignment="center" valignment="top" usebox="none">
24821 \begin_inset Text
24822
24823 \begin_layout Standard
24824
24825 \end_layout
24826
24827 \end_inset
24828 </cell>
24829 <cell multicolumn="2" alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24830 \begin_inset Text
24831
24832 \begin_layout Standard
24833
24834 \end_layout
24835
24836 \end_inset
24837 </cell>
24838 <cell multicolumn="2" alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
24839 \begin_inset Text
24840
24841 \begin_layout Standard
24842
24843 \end_layout
24844
24845 \end_inset
24846 </cell>
24847 </row>
24848 </lyxtabular>
24849
24850 \end_inset
24851
24852
24853 \newline
24854
24855 \newline
24856 Usually the hardware uses some sfr (an output port or an internal sfr) to
24857  select a bank and put it in the banked area of the memory map.
24858  The selected bank usually becomes active immediately upon assignment to
24859  this sfr and when running inside a bank it will switch out this code it
24860  is currently running.
24861  Therefor you cannot jump or call directly from one bank to another and
24862  need to use a so-called trampoline in the common area.
24863  For SDCC an example trampoline is in crtbank.asm and you may need to change
24864  it to your 8051 derivative or schematic.
24865  The presented code is written for the C8051F120.
24866 \newline
24867
24868 \newline
24869 When calling a banked function
24870  SDCC will put the LSB of the functions address in register R0, the MSB
24871  in R1 and the bank in R2 and then call this trampoline 
24872 \emph on
24873 __sdcc_banked_call
24874 \emph default
24875 .
24876  The current selected bank is saved on the stack, the new bank is selected
24877  and an indirect jump is made.
24878  When the banked function returns it jumps to 
24879 \emph on
24880 __sdcc_banked_ret
24881 \emph default
24882  which restores the previous bank and returns to the caller.
24883 \end_layout
24884
24885 \begin_layout Subsubsection
24886 Software
24887 \end_layout
24888
24889 \begin_layout Standard
24890 When writing banked software using SDCC you need to use some special keywords
24891  and options.
24892  You also need to take over a bit of work from the linker.
24893 \newline
24894
24895 \newline
24896 To create a function
24897  that can be called from another bank it requires the keyword 
24898 \emph on
24899 banked
24900 \emph default
24901
24902 \begin_inset LatexCommand index
24903 name "banked"
24904
24905 \end_inset
24906
24907 .
24908  The caller must see this in the prototype of the callee and the callee
24909  needs it for a proper return.
24910  Called functions within the same bank as the caller do not need the 
24911 \emph on
24912 banked
24913 \emph default
24914  keyword nor do functions in the common area.
24915  Beware: SDCC does not know or check if functions are in the same bank.
24916  This is your responsibility!
24917 \newline
24918
24919 \newline
24920 Normally all functions you write end up in
24921  the segment CSEG.
24922  If you want a function explicitly to reside in the common area put it in
24923  segment HOME.
24924  This applies for instance to interrupt service routines as they should
24925  not be banked.
24926 \end_layout
24927
24928 \begin_layout Standard
24929 Functions that need to be in a switched bank must be put in a named segment.
24930  The name can be mostly anything up to eight characters (e.g.
24931  BANK1).
24932  To do this you either use -
24933 \begin_inset ERT
24934 status collapsed
24935
24936 \begin_layout Standard
24937
24938
24939 \backslash
24940 /
24941 \end_layout
24942
24943 \end_inset
24944
24945 -codeseg BANK1 (See 
24946 \begin_inset LatexCommand ref
24947 reference "lyx:-codeseg"
24948
24949 \end_inset
24950
24951 ) on the command line when compiling or #pragma codeseg BANK1 (See 
24952 \begin_inset LatexCommand ref
24953 reference "sec:Pragmas"
24954
24955 \end_inset
24956
24957 ) at the top of the C source file.
24958  The segment name always applies to the whole source file and generated
24959  object so functions for different banks need to be defined in different
24960  source files.
24961 \newline
24962
24963 \newline
24964 When linking your objects you need to tell the linker where
24965  to put your segments.
24966  To do this you use the following command line option to SDCC: -Wl-b BANK1=0x180
24967 00 (See 
24968 \begin_inset LatexCommand ref
24969 reference "lyx:-Wl option"
24970
24971 \end_inset
24972
24973 ).
24974  This sets the virtual start address of this segment.
24975  It sets the banknumber to 0x01 and maps the bank to 0x8000 and up.
24976  The linker will not check for overflows, again this is your responsibility.
24977 \end_layout
24978
24979 \begin_layout Standard
24980 \begin_inset VSpace bigskip
24981 \end_inset
24982
24983
24984 \end_layout
24985
24986 \begin_layout Section
24987 DS400 port
24988 \end_layout
24989
24990 \begin_layout Standard
24991 The DS80C400
24992 \begin_inset LatexCommand index
24993 name "DS80C400"
24994
24995 \end_inset
24996
24997
24998 \begin_inset LatexCommand index
24999 name "DS400"
25000
25001 \end_inset
25002
25003  microcontroller has a rich set of peripherals.
25004  In its built-in ROM library it includes functions to access some of the
25005  features, among them is a TCP stack with IP4 and IP6 support.
25006  Library headers (currently in beta status) and other files are provided
25007  at 
25008 \size footnotesize
25009
25010 \begin_inset LatexCommand url
25011 target "ftp://ftp.dalsemi.com/pub/tini/ds80c400/c_libraries/sdcc/index.html"
25012
25013 \end_inset
25014
25015 .
25016  
25017 \begin_inset VSpace bigskip
25018 \end_inset
25019
25020
25021 \end_layout
25022
25023 \begin_layout Section
25024 The Z80 and gbz80 port
25025 \end_layout
25026
25027 \begin_layout Standard
25028 SDCC can target both the Zilog Z80
25029 \begin_inset LatexCommand index
25030 name "Z80"
25031
25032 \end_inset
25033
25034  and the Nintendo Gameboy's Z80-like gbz80
25035 \begin_inset LatexCommand index
25036 name "gbz80 (GameBoy Z80)"
25037
25038 \end_inset
25039
25040 .
25041  The Z80 port is passed through the same 
25042 \emph on
25043 regressions tests
25044 \begin_inset LatexCommand index
25045 name "Regression test"
25046
25047 \end_inset
25048
25049
25050 \emph default
25051  (see section 
25052 \begin_inset LatexCommand ref
25053 reference "sec:Quality-control"
25054
25055 \end_inset
25056
25057 ) as the MCS51 and DS390 ports, so floating point support, support for long
25058  variables and bitfield support is fine.
25059  See mailing lists and forums about interrupt routines.
25060 \end_layout
25061
25062 \begin_layout Standard
25063 As always, the code is the authoritative reference - see z80/ralloc.c and
25064  z80/gen.c.
25065  The stack
25066 \begin_inset LatexCommand index
25067 name "Z80!stack"
25068
25069 \end_inset
25070
25071  frame is similar to that generated by the IAR Z80 compiler.
25072  IX is used as the base pointer, HL and IY are used as a temporary registers,
25073  and BC and DE are available for holding variables.
25074  Return values
25075 \begin_inset LatexCommand index
25076 name "Z80!return value"
25077
25078 \end_inset
25079
25080  for the Z80 port are stored in L (one byte), HL (two bytes), or DEHL (four
25081  bytes).
25082  The gbz80 port use the same set of registers for the return values, but
25083  in a different order of significance: E (one byte), DE (two bytes), or
25084  HLDE (four bytes).
25085 \begin_inset VSpace bigskip
25086 \end_inset
25087
25088
25089 \end_layout
25090
25091 \begin_layout Section
25092 The HC08 port
25093 \end_layout
25094
25095 \begin_layout Standard
25096 The port to the Freescale/Motorola HC08
25097 \begin_inset LatexCommand index
25098 name "HC08"
25099
25100 \end_inset
25101
25102  family has been added in October 2003, and is still undergoing some basic
25103  development.
25104  The code generator is complete, but the register allocation is still quite
25105  unoptimized.
25106  Some of the SDCC's standard C library functions have embedded non-HC08
25107  inline assembly and so are not yet usable.
25108 \end_layout
25109
25110 \begin_layout Standard
25111 The HC08 port passes the regression test suite (see section 
25112 \begin_inset LatexCommand ref
25113 reference "sec:Quality-control"
25114
25115 \end_inset
25116
25117 ).
25118 \begin_inset VSpace bigskip
25119 \end_inset
25120
25121
25122 \end_layout
25123
25124 \begin_layout Section
25125 The PIC14
25126 \begin_inset LatexCommand index
25127 name "PIC14"
25128
25129 \end_inset
25130
25131  port
25132 \end_layout
25133
25134 \begin_layout Standard
25135 The PIC14 port adds support for Microchip
25136 \begin_inset LatexCommand index
25137 name "Microchip"
25138
25139 \end_inset
25140
25141
25142 \begin_inset Formula $^{\text{TM}}$
25143 \end_inset
25144
25145  PIC
25146 \begin_inset LatexCommand index
25147 name "PIC14"
25148
25149 \end_inset
25150
25151
25152 \begin_inset Formula $^{\text{TM}}$
25153 \end_inset
25154
25155  MCUs with 14 bit wide instructions.
25156  This port is not yet mature and still lacks many features.
25157  However, it can work for simple code.
25158 \end_layout
25159
25160 \begin_layout Standard
25161 \noindent
25162 Currently supported devices include:
25163 \end_layout
25164
25165 \begin_layout Standard
25166 12F: 629, 635, 675, 683
25167 \end_layout
25168
25169 \begin_layout Standard
25170 16C: 432, 433
25171 \end_layout
25172
25173 \begin_layout Standard
25174 16C: 554, 557, 558
25175 \end_layout
25176
25177 \begin_layout Standard
25178 16C: 62, 620, 620a, 621, 621a, 622, 622a, 63a, 65b
25179 \end_layout
25180
25181 \begin_layout Standard
25182 16C: 71, 710, 711, 715, 717, 72, 73b, 745, 74b, 765, 770, 771, 773, 774,
25183  781, 782
25184 \end_layout
25185
25186 \begin_layout Standard
25187 16C: 925, 926
25188 \end_layout
25189
25190 \begin_layout Standard
25191 16CR: 620a, 73, 74, 76, 77
25192 \end_layout
25193
25194 \begin_layout Standard
25195 16F: 616, 627, 627a, 628, 628a, 630, 636, 639, 648, 648a, 676, 684, 685,
25196  687, 688, 689, 690
25197 \end_layout
25198
25199 \begin_layout Standard
25200 16F: 716, 72, 73, 737, 74, 747, 76, 767, 77, 777, 785
25201 \end_layout
25202
25203 \begin_layout Standard
25204 16F: 818, 819, 84, 84a, 87, 870, 871, 872, 873, 873a, 874, 874a, 876, 876a,
25205  877, 877a, 88, 886, 887
25206 \end_layout
25207
25208 \begin_layout Standard
25209 16F: 913, 914, 916, 917, 946
25210 \end_layout
25211
25212 \begin_layout Standard
25213 26HV: 626, 785
25214 \end_layout
25215
25216 \begin_layout Standard
25217 \noindent
25218 An up-to-date list of currently supported devices can be obtained via 
25219 \family typewriter
25220 sdcc -mpic14 -phelp foo.c
25221 \family default
25222  (foo.c must exist...).
25223 \end_layout
25224
25225 \begin_layout Subsection
25226 PIC Code Pages
25227 \begin_inset LatexCommand index
25228 name "code page (pic14)"
25229
25230 \end_inset
25231
25232  and Memory Banks
25233 \begin_inset LatexCommand index
25234 name "Memory bank (pic14)"
25235
25236 \end_inset
25237
25238
25239 \end_layout
25240
25241 \begin_layout Standard
25242 The linker organizes allocation for the code page and RAM banks.
25243  It does not have intimate knowledge of the code flow.
25244  It will put all the code section of a single .asm file into a single code
25245  page.
25246  In order to make use of multiple code pages, separate asm files must be
25247  used.
25248  The compiler assigns all 
25249 \emph on
25250 static
25251 \emph default
25252  functions of a single .c file into the same code page.
25253 \newline
25254
25255 \newline
25256 To get the best results,
25257  follow these guidelines:
25258 \end_layout
25259
25260 \begin_layout Enumerate
25261 Make local functions static, as non static functions require code page selection
25262  overhead.
25263 \newline
25264 Due to the way sdcc handles functions, place called functions prior
25265  to calling functions in the file wherever possible: Otherwise sdcc will
25266  insert unnecessary pagesel directives around the call, believing that the
25267  called function is externally defined.
25268 \end_layout
25269
25270 \begin_layout Enumerate
25271 For devices that have multiple code pages it is more efficient to use the
25272  same number of files as pages: Use up to 4 separate .c files for the 16F877,
25273  but only 2 files for the 16F874.
25274  This way the linker can put the code for each file into different code
25275  pages and there will be less page selection overhead.
25276 \end_layout
25277
25278 \begin_layout Enumerate
25279 And as for any 8 bit micro (especially for PIC14 as they have a very simple
25280  instruction set), use `unsigned char' wherever possible instead of `int'.
25281 \end_layout
25282
25283 \begin_layout Subsection
25284 Adding New Devices to the Port 
25285 \end_layout
25286
25287 \begin_layout Standard
25288 Adding support for a new 14
25289 \begin_inset ERT
25290 status open
25291
25292 \begin_layout Standard
25293
25294
25295 \backslash
25296 ,
25297 \end_layout
25298
25299 \end_inset
25300
25301 bit PIC MCU requires the following steps:
25302 \end_layout
25303
25304 \begin_layout Enumerate
25305 Create a new device description.
25306 \newline
25307 Each device is described in two files: pic16f*.h
25308  and pic16f*.c.
25309  These files primarily define SFRs, structs to access their bits, and symbolic
25310  configuration options.
25311  Both files can be generated from gputils' .inc files using the perl script
25312  
25313 \family typewriter
25314 support/scripts/inc2h.pl
25315 \family default
25316 .
25317  This file also contains further instructions on how to proceed.
25318 \end_layout
25319
25320 \begin_layout Enumerate
25321 Copy the .h file into SDCC's include path and either add the .c file to your
25322  project or copy it to 
25323 \family typewriter
25324 device/lib/pic/libdev
25325 \family default
25326 .
25327  Afterwards, rebuild and install the libraries.
25328 \end_layout
25329
25330 \begin_layout Enumerate
25331 Edit pic14devices.txt in SDCC's include path (
25332 \family typewriter
25333 device/include/pic/
25334 \family default
25335  in the source tree or 
25336 \family typewriter
25337 /usr/local/share/sdcc/include/pic
25338 \family default
25339  after installation).
25340 \newline
25341 You need to add a device specification here to make
25342  the memory layout (code banks, RAM, aliased memory regions, ...) known to
25343  the compiler.
25344  Probably you can copy and modify an existing entry.
25345  The file format is documented at the top of the file.
25346 \end_layout
25347
25348 \begin_layout Subsection
25349 Interrupt Code
25350 \end_layout
25351
25352 \begin_layout Standard
25353 For the interrupt function, use the keyword `__interrupt'
25354 \begin_inset LatexCommand index
25355 name "PIC14!interrupt"
25356
25357 \end_inset
25358
25359  with level number of 0 (PIC14 only has 1 interrupt so this number is only
25360  there to avoid a syntax error - it ought to be fixed).
25361  E.g.:
25362 \end_layout
25363
25364 \begin_layout Verse
25365
25366 \family typewriter
25367 void Intr(void) __interrupt 0
25368 \newline
25369 {
25370 \newline
25371 \InsetSpace ~
25372 \InsetSpace ~
25373 T0IF = 0; /* Clear timer interrupt */
25374 \newline
25375 }
25376 \end_layout
25377
25378 \begin_layout Subsection
25379 Linking and Assembling
25380 \end_layout
25381
25382 \begin_layout Standard
25383 For assembling you can use either GPUTILS'
25384 \begin_inset LatexCommand index
25385 name "gputils (pic tools)"
25386
25387 \end_inset
25388
25389  gpasm.exe or MPLAB's mpasmwin.exe.
25390  GPUTILS are available from 
25391 \begin_inset LatexCommand url
25392 target "http://sourceforge.net/projects/gputils"
25393
25394 \end_inset
25395
25396 .
25397  For linking you can use either GPUTILS' gplink or MPLAB's mplink.exe.
25398  If you use MPLAB and an interrupt function then the linker script file
25399  vectors section will need to be enlarged to link with mplink.
25400 \newline
25401
25402 \newline
25403 Here is a 
25404 \family typewriter
25405 Makefile
25406 \family default
25407  using GPUTILS:
25408 \end_layout
25409
25410 \begin_layout Verse
25411
25412 \family typewriter
25413 .c.o:
25414 \newline
25415 \InsetSpace ~
25416 \InsetSpace ~
25417 \InsetSpace ~
25418 \InsetSpace ~
25419 \InsetSpace ~
25420 \InsetSpace ~
25421 \InsetSpace ~
25422 \InsetSpace ~
25423 sdcc -V -mpic14 -p16f877 -c $< 
25424 \newline
25425
25426 \newline
25427 $(PRJ).hex: $(OBJS) 
25428 \newline
25429 \InsetSpace ~
25430 \InsetSpace ~
25431 \InsetSpace ~
25432 \InsetSpace ~
25433 \InsetSpace ~
25434 \InsetSpace ~
25435 \InsetSpace ~
25436 \InsetSpace ~
25437 gplink -m -s $(PRJ).lkr
25438  -o $(PRJ).hex $(OBJS) libsdcc.lib
25439 \end_layout
25440
25441 \begin_layout Standard
25442 Here is a 
25443 \family typewriter
25444 Makefile
25445 \family default
25446  using MPLAB:
25447 \end_layout
25448
25449 \begin_layout Verse
25450
25451 \family typewriter
25452 .c.o: 
25453 \newline
25454 \InsetSpace ~
25455 \InsetSpace ~
25456 \InsetSpace ~
25457 \InsetSpace ~
25458 \InsetSpace ~
25459 \InsetSpace ~
25460 \InsetSpace ~
25461 \InsetSpace ~
25462 sdcc -S -V -mpic14 -p16f877 $< 
25463 \newline
25464 \InsetSpace ~
25465 \InsetSpace ~
25466 \InsetSpace ~
25467 \InsetSpace ~
25468 \InsetSpace ~
25469 \InsetSpace ~
25470 \InsetSpace ~
25471 \InsetSpace ~
25472 mpasmwin /q /o $*.asm
25473 \newline
25474
25475 \newline
25476 $(PRJ).hex: $(OBJS)
25477  
25478 \newline
25479 \InsetSpace ~
25480 \InsetSpace ~
25481 \InsetSpace ~
25482 \InsetSpace ~
25483 \InsetSpace ~
25484 \InsetSpace ~
25485 \InsetSpace ~
25486 \InsetSpace ~
25487 mplink /v $(PRJ).lkr /m $(PRJ).map /o $(PRJ).hex $(OBJS) libsdcc.lib
25488 \end_layout
25489
25490 \begin_layout Standard
25491 Please note that indentations within a 
25492 \family typewriter
25493 Makefile
25494 \family default
25495  have to be done with a tabulator character.
25496 \end_layout
25497
25498 \begin_layout Subsection
25499 Command-Line Options
25500 \end_layout
25501
25502 \begin_layout Standard
25503 Besides the switches common to all SDCC backends, the PIC14 port accepts
25504  the following options (for an updated list see sdcc -
25505 \begin_inset ERT
25506 status collapsed
25507
25508 \begin_layout Standard
25509
25510
25511 \backslash
25512 /
25513 \end_layout
25514
25515 \end_inset
25516
25517 -help):
25518 \end_layout
25519
25520 \begin_layout Description
25521 -
25522 \begin_inset ERT
25523 status collapsed
25524
25525 \begin_layout Standard
25526
25527
25528 \backslash
25529 /
25530 \end_layout
25531
25532 \end_inset
25533
25534 -debug-xtra
25535 \begin_inset LatexCommand index
25536 name "PIC14!Options!-\\/-debug-extra"
25537
25538 \end_inset
25539
25540  emit debug info in assembly output
25541 \end_layout
25542
25543 \begin_layout Description
25544 -
25545 \begin_inset ERT
25546 status collapsed
25547
25548 \begin_layout Standard
25549
25550
25551 \backslash
25552 /
25553 \end_layout
25554
25555 \end_inset
25556
25557 -no-pcode-opt
25558 \begin_inset LatexCommand index
25559 name "PIC14!Options!-\\/-no-pcode-opt"
25560
25561 \end_inset
25562
25563  disable (slightly faulty) optimization on pCode
25564 \end_layout
25565
25566 \begin_layout Description
25567 -
25568 \begin_inset ERT
25569 status collapsed
25570
25571 \begin_layout Standard
25572
25573
25574 \backslash
25575 /
25576 \end_layout
25577
25578 \end_inset
25579
25580 -stack-loc
25581 \begin_inset LatexCommand index
25582 name "PIC14!Options!-\\/-stack-loc"
25583
25584 \end_inset
25585
25586  sets the lowest address of the argument passing stack (defaults to a suitably
25587  large shared databank to reduce BANKSEL overhead)
25588 \end_layout
25589
25590 \begin_layout Description
25591 -
25592 \begin_inset ERT
25593 status collapsed
25594
25595 \begin_layout Standard
25596
25597
25598 \backslash
25599 /
25600 \end_layout
25601
25602 \end_inset
25603
25604 -stack-size
25605 \begin_inset LatexCommand index
25606 name "PIC14!Options!-\\/-stack-size"
25607
25608 \end_inset
25609
25610  sets the size if the argument passing stack (default: 16, minimum: 4)
25611 \end_layout
25612
25613 \begin_layout Subsection
25614 Environment Variables
25615 \end_layout
25616
25617 \begin_layout Standard
25618 The PIC14 port recognizes the following environment variables:
25619 \end_layout
25620
25621 \begin_layout Description
25622 SDCC_PIC14_SPLIT_LOCALS If set and not empty, sdcc will allocate each temporary
25623  register (the ones called r0xNNNN) in a section of its own.
25624  By default (if this variable is unset), sdcc tries to cluster registers
25625  in sections in order to reduce the BANKSEL overhead when accessing them.
25626 \end_layout
25627
25628 \begin_layout Subsection
25629 The Library
25630 \end_layout
25631
25632 \begin_layout Standard
25633 The PIC14 library currently only contains support routines required by the
25634  compiler to implement multiplication, division, and floating point support.
25635  No libc-like replacement is available at the moment, though many of the
25636  common sdcc library sources (in 
25637 \family typewriter
25638 device/lib
25639 \family default
25640 ) should also compile with the PIC14 port.
25641 \end_layout
25642
25643 \begin_layout Subsubsection
25644 error: missing definition for symbol ``__gptrget1''
25645 \end_layout
25646
25647 \begin_layout Standard
25648 The PIC14 port uses library routines to provide more complex operations
25649  like multiplication, division/modulus and (generic) pointer dereferencing.
25650  In order to add these routines to your project, you must link with PIC14's
25651  
25652 \family typewriter
25653 libsdcc.lib
25654 \family default
25655 .
25656  For single source file projects this is done automatically, more complex
25657  projects must add 
25658 \family typewriter
25659 libsdcc.lib
25660 \family default
25661  to the linker's arguments.
25662  Make sure you also add an include path for the library (using the -I switch
25663  to the linker)!
25664 \end_layout
25665
25666 \begin_layout Subsubsection
25667 Processor mismatch in file ``XXX''.
25668 \end_layout
25669
25670 \begin_layout Standard
25671 This warning can usually be ignored due to the very good compatibility amongst
25672  14
25673 \begin_inset ERT
25674 status open
25675
25676 \begin_layout Standard
25677
25678
25679 \backslash
25680 ,
25681 \end_layout
25682
25683 \end_inset
25684
25685 bit PIC
25686 \begin_inset LatexCommand index
25687 name "PIC14"
25688
25689 \end_inset
25690
25691  devices.
25692 \end_layout
25693
25694 \begin_layout Standard
25695 You might also consider recompiling the library for your specific device
25696  by changing the ARCH=p16f877 (default target) entry in 
25697 \family typewriter
25698 device/lib/pic/Makefile.in
25699 \family default
25700  and 
25701 \family typewriter
25702 device/lib/pic/Makefile
25703 \family default
25704  to reflect your device.
25705  This might even improve performance for smaller devices as unnecessary
25706  BANKSELs might be removed.
25707 \end_layout
25708
25709 \begin_layout Subsection
25710 Known Bugs
25711 \end_layout
25712
25713 \begin_layout Subsubsection
25714 Function arguments
25715 \end_layout
25716
25717 \begin_layout Standard
25718 Functions with variable argument lists (like printf) are not yet supported.
25719  Similarly, taking the address of the first argument passed into a function
25720  does not work: It is currently passed in WREG and has no address...
25721 \end_layout
25722
25723 \begin_layout Subsubsection
25724 Regression tests fail
25725 \end_layout
25726
25727 \begin_layout Standard
25728 Though the small subset of regression tests in src/regression passes, SDCC
25729  regression test suite does not, indicating that there are still major bugs
25730  in the port.
25731  However, many smaller projects have successfully used SDCC in the past...
25732 \end_layout
25733
25734 \begin_layout Standard
25735
25736 \size footnotesize
25737
25738 \newpage
25739
25740 \end_layout
25741
25742 \begin_layout Section
25743 The PIC16
25744 \begin_inset LatexCommand index
25745 name "PIC16"
25746
25747 \end_inset
25748
25749  port
25750 \end_layout
25751
25752 \begin_layout Standard
25753 The PIC16 port adds support for Microchip
25754 \begin_inset LatexCommand index
25755 name "Microchip"
25756
25757 \end_inset
25758
25759
25760 \begin_inset Formula $^{\text{TM}}$
25761 \end_inset
25762
25763  PIC
25764 \begin_inset LatexCommand index
25765 name "PIC"
25766
25767 \end_inset
25768
25769
25770 \begin_inset Formula $^{\text{TM}}$
25771 \end_inset
25772
25773  MCUs with 16 bit wide instructions.
25774  Currently this family of microcontrollers contains the PIC18Fxxx and PIC18Fxxxx
25775 ; devices supported by the port include:
25776 \end_layout
25777
25778 \begin_layout Standard
25779 18F: 242, 248, 252, 258, 442, 448, 452, 458
25780 \end_layout
25781
25782 \begin_layout Standard
25783 18F: 1220, 1320
25784 \end_layout
25785
25786 \begin_layout Standard
25787 18F: 2220, 2221, 2320, 2321, 2331, 23k20
25788 \end_layout
25789
25790 \begin_layout Standard
25791 18F: 2410, 2420, 2423, 2431, 2450, 2455, 2480, 24j10, 24k20
25792 \end_layout
25793
25794 \begin_layout Standard
25795 18F: 2510, 2515, 2520, 2523, 2525, 2550, 2580, 2585, 25j10, 25k20
25796 \end_layout
25797
25798 \begin_layout Standard
25799 18F: 2610, 2620, 2680, 2682, 2685
25800 \end_layout
25801
25802 \begin_layout Standard
25803 18F: 4220, 4221, 4320, 4321, 4331, 43k20
25804 \end_layout
25805
25806 \begin_layout Standard
25807 18F: 4410, 4420, 4423, 4431, 4450, 4455, 4480, 44j10, 44k20
25808 \end_layout
25809
25810 \begin_layout Standard
25811 18F: 4510, 4515, 4520, 4523, 4525, 4550, 4580, 4585, 45j10, 45k20
25812 \end_layout
25813
25814 \begin_layout Standard
25815 18F: 4610, 4620, 4680, 4682, 4685, 46k20
25816 \end_layout
25817
25818 \begin_layout Standard
25819 18F: 6520, 6585, 65j50, 6620, 6680, 66j50, 66j55, 66j60, 66j65, 6720, 67j50,
25820  67j60
25821 \end_layout
25822
25823 \begin_layout Standard
25824 18F: 8520, 8585, 85j50, 8620, 8680, 86j50, 86j55, 86j60, 86j65, 8720, 87j50,
25825  87j60
25826 \end_layout
25827
25828 \begin_layout Standard
25829 18F: 96j60, 96j65, 97j60
25830 \end_layout
25831
25832 \begin_layout Standard
25833 \noindent
25834 An up-to-date list of supported devices is also available via '
25835 \family typewriter
25836 sdcc -mpic16 -plist
25837 \family default
25838 '.
25839 \end_layout
25840
25841 \begin_layout Subsection
25842 Global Options
25843 \end_layout
25844
25845 \begin_layout Standard
25846 PIC16 port supports the standard command line arguments as supposed, with
25847  the exception of certain cases that will be mentioned in the following
25848  list:
25849 \end_layout
25850
25851 \begin_layout Description
25852 -
25853 \begin_inset ERT
25854 status collapsed
25855
25856 \begin_layout Standard
25857
25858
25859 \backslash
25860 /
25861 \end_layout
25862
25863 \end_inset
25864
25865 -callee-saves
25866 \begin_inset LatexCommand index
25867 name "PIC16!Options!-\\/-callee-saves"
25868
25869 \end_inset
25870
25871  See -
25872 \begin_inset ERT
25873 status collapsed
25874
25875 \begin_layout Standard
25876
25877
25878 \backslash
25879 /
25880 \end_layout
25881
25882 \end_inset
25883
25884 -all-callee-saves
25885 \end_layout
25886
25887 \begin_layout Description
25888 -
25889 \begin_inset ERT
25890 status collapsed
25891
25892 \begin_layout Standard
25893
25894
25895 \backslash
25896 /
25897 \end_layout
25898
25899 \end_inset
25900
25901 -fommit-frame-pointer
25902 \begin_inset LatexCommand index
25903 name "PIC16!Options!-\\/-fommit-frame-pointer"
25904
25905 \end_inset
25906
25907  Frame pointer will be omitted when the function uses no local variables.
25908 \end_layout
25909
25910 \begin_layout Subsection
25911 Port Specific Options
25912 \begin_inset LatexCommand index
25913 name "Options PIC16"
25914
25915 \end_inset
25916
25917
25918 \end_layout
25919
25920 \begin_layout Standard
25921 The port specific options appear after the global options in the sdcc -
25922 \begin_inset ERT
25923 status collapsed
25924
25925 \begin_layout Standard
25926
25927
25928 \backslash
25929 /
25930 \end_layout
25931
25932 \end_inset
25933
25934 -help output.
25935 \end_layout
25936
25937 \begin_layout Subsubsection
25938 Code Generation Options
25939 \end_layout
25940
25941 \begin_layout Standard
25942 These options influence the generated assembler code.
25943 \end_layout
25944
25945 \begin_layout Description
25946 -
25947 \begin_inset ERT
25948 status collapsed
25949
25950 \begin_layout Standard
25951
25952
25953 \backslash
25954 /
25955 \end_layout
25956
25957 \end_inset
25958
25959 -pstack-model=[model] Used in conjunction with the command above.
25960  Defines the stack model to be used, valid stack models are:
25961 \end_layout
25962
25963 \begin_deeper
25964 \begin_layout List
25965 \labelwidthstring 00.00.0000
25966
25967 \emph on
25968 small
25969 \emph default
25970  Selects small stack model.
25971  8 bit stack and frame pointers.
25972  Supports 256 bytes stack size.
25973 \end_layout
25974
25975 \begin_layout List
25976 \labelwidthstring 00.00.0000
25977
25978 \emph on
25979 large
25980 \emph default
25981  Selects large stack model.
25982  16 bit stack and frame pointers.
25983  Supports 65536 bytes stack size.
25984 \end_layout
25985
25986 \end_deeper
25987 \begin_layout Description
25988 -
25989 \begin_inset ERT
25990 status collapsed
25991
25992 \begin_layout Standard
25993
25994
25995 \backslash
25996 /
25997 \end_layout
25998
25999 \end_inset
26000
26001 -pno-banksel Do not generate BANKSEL assembler directives.
26002 \end_layout
26003
26004 \begin_layout Description
26005 -
26006 \begin_inset ERT
26007 status collapsed
26008
26009 \begin_layout Standard
26010
26011
26012 \backslash
26013 /
26014 \end_layout
26015
26016 \end_inset
26017
26018 -extended Enable extended instruction set/literal offset addressing mode.
26019  Use with care!
26020 \end_layout
26021
26022 \begin_layout Subsubsection
26023 Optimization Options
26024 \end_layout
26025
26026 \begin_layout Description
26027 -
26028 \begin_inset ERT
26029 status collapsed
26030
26031 \begin_layout Standard
26032
26033
26034 \backslash
26035 /
26036 \end_layout
26037
26038 \end_inset
26039
26040 -obanksel=n Set optimization level for inserting BANKSELs.
26041 \newline
26042
26043 \end_layout
26044
26045 \begin_deeper
26046 \begin_layout List
26047 \labelwidthstring 00.00.0000
26048 0 no optimization
26049 \end_layout
26050
26051 \begin_layout List
26052 \labelwidthstring 00.00.0000
26053 1 checks previous used register and if it is the same then does not emit
26054  BANKSEL, accounts only for labels.
26055 \end_layout
26056
26057 \begin_layout List
26058 \labelwidthstring 00.00.0000
26059 2 tries to check the location of (even different) symbols and removes BANKSELs
26060  if they are in the same bank.
26061  
26062 \newline
26063
26064 \emph on
26065 Important: There might be problems if the linker script has data sections
26066  across bank borders!
26067 \end_layout
26068
26069 \end_deeper
26070 \begin_layout Description
26071 -
26072 \begin_inset ERT
26073 status collapsed
26074
26075 \begin_layout Standard
26076
26077
26078 \backslash
26079 /
26080 \end_layout
26081
26082 \end_inset
26083
26084 -denable-peeps Force the usage of peepholes.
26085  Use with care.
26086 \end_layout
26087
26088 \begin_layout Description
26089 -
26090 \begin_inset ERT
26091 status collapsed
26092
26093 \begin_layout Standard
26094
26095
26096 \backslash
26097 /
26098 \end_layout
26099
26100 \end_inset
26101
26102 -no-optimize-goto Do not use (conditional) BRA instead of GOTO.
26103 \end_layout
26104
26105 \begin_layout Description
26106 -
26107 \begin_inset ERT
26108 status collapsed
26109
26110 \begin_layout Standard
26111
26112
26113 \backslash
26114 /
26115 \end_layout
26116
26117 \end_inset
26118
26119 -optimize-cmp Try to optimize some compares.
26120 \end_layout
26121
26122 \begin_layout Description
26123 -
26124 \begin_inset ERT
26125 status collapsed
26126
26127 \begin_layout Standard
26128
26129
26130 \backslash
26131 /
26132 \end_layout
26133
26134 \end_inset
26135
26136 -optimize-df Analyze the dataflow of the generated code and improve it.
26137 \end_layout
26138
26139 \begin_layout Subsubsection
26140 Assembling Options
26141 \end_layout
26142
26143 \begin_layout Description
26144 -
26145 \begin_inset ERT
26146 status collapsed
26147
26148 \begin_layout Standard
26149
26150
26151 \backslash
26152 /
26153 \end_layout
26154
26155 \end_inset
26156
26157 -asm= Sets the full path and name of an external assembler to call.
26158 \end_layout
26159
26160 \begin_layout Description
26161 -
26162 \begin_inset ERT
26163 status collapsed
26164
26165 \begin_layout Standard
26166
26167
26168 \backslash
26169 /
26170 \end_layout
26171
26172 \end_inset
26173
26174 -mplab-comp MPLAB
26175 \begin_inset LatexCommand index
26176 name "PIC16!MPLAB"
26177
26178 \end_inset
26179
26180  compatibility option.
26181  Currently only suppresses special gpasm directives.
26182 \end_layout
26183
26184 \begin_layout Subsubsection
26185 Linking Options
26186 \end_layout
26187
26188 \begin_layout Description
26189 -
26190 \begin_inset ERT
26191 status collapsed
26192
26193 \begin_layout Standard
26194
26195
26196 \backslash
26197 /
26198 \end_layout
26199
26200 \end_inset
26201
26202 -link= Sets the full path and name of an external linker to call.
26203 \end_layout
26204
26205 \begin_layout Description
26206 -
26207 \begin_inset ERT
26208 status collapsed
26209
26210 \begin_layout Standard
26211
26212
26213 \backslash
26214 /
26215 \end_layout
26216
26217 \end_inset
26218
26219 -preplace-udata-with=[kword] Replaces the default udata keyword for allocating
26220  unitialized data variables with [kword].
26221  Valid keywords are: "udata_acs", "udata_shr", "udata_ovr".
26222 \end_layout
26223
26224 \begin_layout Description
26225 -
26226 \begin_inset ERT
26227 status collapsed
26228
26229 \begin_layout Standard
26230
26231
26232 \backslash
26233 /
26234 \end_layout
26235
26236 \end_inset
26237
26238 -ivt-loc=n Place the interrupt vector table at address 
26239 \emph on
26240 n
26241 \emph default
26242 .
26243  Useful for bootloaders.
26244 \end_layout
26245
26246 \begin_layout Description
26247 -
26248 \begin_inset ERT
26249 status collapsed
26250
26251 \begin_layout Standard
26252
26253
26254 \backslash
26255 /
26256 \end_layout
26257
26258 \end_inset
26259
26260 -nodefaultlibs Do not link default libraries when linking.
26261 \end_layout
26262
26263 \begin_layout Description
26264 -
26265 \begin_inset ERT
26266 status collapsed
26267
26268 \begin_layout Standard
26269
26270
26271 \backslash
26272 /
26273 \end_layout
26274
26275 \end_inset
26276
26277 -use-crt= Use a custom run-time module instead of the defaults.
26278 \end_layout
26279
26280 \begin_layout Description
26281 -
26282 \begin_inset ERT
26283 status collapsed
26284
26285 \begin_layout Standard
26286
26287
26288 \backslash
26289 /
26290 \end_layout
26291
26292 \end_inset
26293
26294 -no-crt Don't link the default run-time modules
26295 \end_layout
26296
26297 \begin_layout Subsubsection
26298 Debugging Options
26299 \end_layout
26300
26301 \begin_layout Standard
26302 Debugging options enable extra debugging information in the output files.
26303 \end_layout
26304
26305 \begin_layout Description
26306 -
26307 \begin_inset ERT
26308 status collapsed
26309
26310 \begin_layout Standard
26311
26312
26313 \backslash
26314 /
26315 \end_layout
26316
26317 \end_inset
26318
26319 -debug-xtra Similar to -
26320 \begin_inset ERT
26321 status collapsed
26322
26323 \begin_layout Standard
26324
26325
26326 \backslash
26327 /
26328 \end_layout
26329
26330 \end_inset
26331
26332 -debug
26333 \begin_inset LatexCommand index
26334 name "-\\/-debug"
26335
26336 \end_inset
26337
26338 , but dumps more information.
26339 \end_layout
26340
26341 \begin_layout Description
26342 -
26343 \begin_inset ERT
26344 status collapsed
26345
26346 \begin_layout Standard
26347
26348
26349 \backslash
26350 /
26351 \end_layout
26352
26353 \end_inset
26354
26355 -debug-ralloc Force register allocator to dump <source>.d file with debugging
26356  information.
26357  <source> is the name of the file being compiled.
26358 \end_layout
26359
26360 \begin_layout Description
26361 -
26362 \begin_inset ERT
26363 status collapsed
26364
26365 \begin_layout Standard
26366
26367
26368 \backslash
26369 /
26370 \end_layout
26371
26372 \end_inset
26373
26374 -pcode-verbose Enable pcode debugging information in translation.
26375 \end_layout
26376
26377 \begin_layout Description
26378 -
26379 \begin_inset ERT
26380 status collapsed
26381
26382 \begin_layout Standard
26383
26384
26385 \backslash
26386 /
26387 \end_layout
26388
26389 \end_inset
26390
26391 -calltree Dump call tree in .calltree file.
26392 \end_layout
26393
26394 \begin_layout Description
26395 -
26396 \begin_inset ERT
26397 status collapsed
26398
26399 \begin_layout Standard
26400
26401
26402 \backslash
26403 /
26404 \end_layout
26405
26406 \end_inset
26407
26408 -gstack Trace push/pops for stack pointer overflow.
26409 \end_layout
26410
26411 \begin_layout Subsection
26412 Environment Variables
26413 \end_layout
26414
26415 \begin_layout Standard
26416 There is a number of environmental variables that can be used when running
26417  SDCC to enable certain optimizations or force a specific program behaviour.
26418  these variables are primarily for debugging purposes so they can be enabled/dis
26419 abled at will.
26420 \end_layout
26421
26422 \begin_layout Standard
26423 Currently there is only two such variables available:
26424 \end_layout
26425
26426 \begin_layout Description
26427 OPTIMIZE_BITFIELD_POINTER_GET When this variable exists, reading of structure
26428  bitfields is optimized by directly loading FSR0 with the address of the
26429  bitfield structure.
26430  Normally SDCC will cast the bitfield structure to a bitfield pointer and
26431  then load FSR0.
26432  This step saves data ram and code space for functions that make heavy use
26433  of bitfields.
26434  (i.e., 80 bytes of code space are saved when compiling malloc.c with this
26435  option).
26436  
26437 \end_layout
26438
26439 \begin_layout Description
26440 NO_REG_OPT Do not perform pCode registers optimization.
26441  This should be used for debugging purposes.
26442  If bugs in the pcode optimizer are found, users can benefit from temporarily
26443  disabling the optimizer until the bug is fixed.
26444 \end_layout
26445
26446 \begin_layout Subsection
26447 Preprocessor Macros
26448 \end_layout
26449
26450 \begin_layout Standard
26451 PIC16
26452 \begin_inset LatexCommand index
26453 name "PIC16"
26454
26455 \end_inset
26456
26457  port defines the following preprocessor macros while translating a source.
26458 \end_layout
26459
26460 \begin_layout Standard
26461 \align center
26462 \begin_inset Tabular
26463 <lyxtabular version="3" rows="6" columns="2">
26464 <features>
26465 <column alignment="center" valignment="top" leftline="true" width="0">
26466 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26467 <row topline="true" bottomline="true">
26468 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26469 \begin_inset Text
26470
26471 \begin_layout Standard
26472 Macro
26473 \end_layout
26474
26475 \end_inset
26476 </cell>
26477 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26478 \begin_inset Text
26479
26480 \begin_layout Standard
26481 Description
26482 \end_layout
26483
26484 \end_inset
26485 </cell>
26486 </row>
26487 <row topline="true">
26488 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26489 \begin_inset Text
26490
26491 \begin_layout Standard
26492 SDCC_pic16
26493 \end_layout
26494
26495 \end_inset
26496 </cell>
26497 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26498 \begin_inset Text
26499
26500 \begin_layout Standard
26501 Port identification
26502 \end_layout
26503
26504 \end_inset
26505 </cell>
26506 </row>
26507 <row topline="true">
26508 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26509 \begin_inset Text
26510
26511 \begin_layout Standard
26512 _
26513 \begin_inset ERT
26514 status collapsed
26515
26516 \begin_layout Standard
26517
26518
26519 \backslash
26520 /
26521 \end_layout
26522
26523 \end_inset
26524
26525 _pic16
26526 \end_layout
26527
26528 \end_inset
26529 </cell>
26530 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26531 \begin_inset Text
26532
26533 \begin_layout Standard
26534 Port identification (same as above)
26535 \end_layout
26536
26537 \end_inset
26538 </cell>
26539 </row>
26540 <row topline="true">
26541 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26542 \begin_inset Text
26543
26544 \begin_layout Standard
26545 pic18fxxxx
26546 \end_layout
26547
26548 \end_inset
26549 </cell>
26550 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26551 \begin_inset Text
26552
26553 \begin_layout Standard
26554 MCU Identification.
26555  
26556 \emph on
26557 xxxx
26558 \emph default
26559  is the microcontrol identification number, i.e.
26560  452, 6620, etc
26561 \end_layout
26562
26563 \end_inset
26564 </cell>
26565 </row>
26566 <row topline="true">
26567 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26568 \begin_inset Text
26569
26570 \begin_layout Standard
26571 _
26572 \begin_inset ERT
26573 status collapsed
26574
26575 \begin_layout Standard
26576
26577
26578 \backslash
26579 /
26580 \end_layout
26581
26582 \end_inset
26583
26584 _18Fxxxx
26585 \end_layout
26586
26587 \end_inset
26588 </cell>
26589 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26590 \begin_inset Text
26591
26592 \begin_layout Standard
26593 MCU Identification (same as above)
26594 \end_layout
26595
26596 \end_inset
26597 </cell>
26598 </row>
26599 <row topline="true" bottomline="true">
26600 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26601 \begin_inset Text
26602
26603 \begin_layout Standard
26604 STACK_MODEL_nnn
26605 \end_layout
26606
26607 \end_inset
26608 </cell>
26609 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26610 \begin_inset Text
26611
26612 \begin_layout Standard
26613 nnn = SMALL or LARGE respectively according to the stack model used
26614 \end_layout
26615
26616 \end_inset
26617 </cell>
26618 </row>
26619 </lyxtabular>
26620
26621 \end_inset
26622
26623
26624 \end_layout
26625
26626 \begin_layout Standard
26627 \noindent
26628 In addition the following macros are defined when calling assembler:
26629 \end_layout
26630
26631 \begin_layout Standard
26632 \align center
26633 \begin_inset Tabular
26634 <lyxtabular version="3" rows="4" columns="2">
26635 <features>
26636 <column alignment="center" valignment="top" leftline="true" width="0">
26637 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26638 <row topline="true" bottomline="true">
26639 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26640 \begin_inset Text
26641
26642 \begin_layout Standard
26643 Macro
26644 \end_layout
26645
26646 \end_inset
26647 </cell>
26648 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26649 \begin_inset Text
26650
26651 \begin_layout Standard
26652 Description
26653 \end_layout
26654
26655 \end_inset
26656 </cell>
26657 </row>
26658 <row topline="true">
26659 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26660 \begin_inset Text
26661
26662 \begin_layout Standard
26663 __18Fxxxx
26664 \end_layout
26665
26666 \end_inset
26667 </cell>
26668 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26669 \begin_inset Text
26670
26671 \begin_layout Standard
26672 MCU Identification.
26673  
26674 \emph on
26675 xxxx
26676 \emph default
26677  is the microcontrol identification number, i.e.
26678  452, 6620, etc
26679 \end_layout
26680
26681 \end_inset
26682 </cell>
26683 </row>
26684 <row topline="true">
26685 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26686 \begin_inset Text
26687
26688 \begin_layout Standard
26689 SDCC_MODEL_nnn
26690 \end_layout
26691
26692 \end_inset
26693 </cell>
26694 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26695 \begin_inset Text
26696
26697 \begin_layout Standard
26698 nnn = SMALL or LARGE respectively according to the memory model used for
26699  SDCC
26700 \end_layout
26701
26702 \end_inset
26703 </cell>
26704 </row>
26705 <row topline="true" bottomline="true">
26706 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26707 \begin_inset Text
26708
26709 \begin_layout Standard
26710 STACK_MODEL_nnn
26711 \end_layout
26712
26713 \end_inset
26714 </cell>
26715 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26716 \begin_inset Text
26717
26718 \begin_layout Standard
26719 nnn = SMALL or LARGE respectively according to the stack model used
26720 \end_layout
26721
26722 \end_inset
26723 </cell>
26724 </row>
26725 </lyxtabular>
26726
26727 \end_inset
26728
26729
26730 \end_layout
26731
26732 \begin_layout Subsection
26733 Directories
26734 \end_layout
26735
26736 \begin_layout Standard
26737 PIC16
26738 \begin_inset LatexCommand index
26739 name "PIC16"
26740
26741 \end_inset
26742
26743  port uses the following directories for searching header files and libraries.
26744 \end_layout
26745
26746 \begin_layout Standard
26747 \align center
26748 \begin_inset Tabular
26749 <lyxtabular version="3" rows="3" columns="4">
26750 <features>
26751 <column alignment="center" valignment="top" leftline="true" width="0">
26752 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26753 <column alignment="center" valignment="top" width="0">
26754 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
26755 <row topline="true" bottomline="true">
26756 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26757 \begin_inset Text
26758
26759 \begin_layout Standard
26760 Directory
26761 \end_layout
26762
26763 \end_inset
26764 </cell>
26765 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26766 \begin_inset Text
26767
26768 \begin_layout Standard
26769 Description
26770 \end_layout
26771
26772 \end_inset
26773 </cell>
26774 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26775 \begin_inset Text
26776
26777 \begin_layout Standard
26778 Target
26779 \end_layout
26780
26781 \end_inset
26782 </cell>
26783 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26784 \begin_inset Text
26785
26786 \begin_layout Standard
26787 Command prefix
26788 \end_layout
26789
26790 \end_inset
26791 </cell>
26792 </row>
26793 <row topline="true">
26794 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26795 \begin_inset Text
26796
26797 \begin_layout Standard
26798 PREFIX/sdcc/include/pic16
26799 \end_layout
26800
26801 \end_inset
26802 </cell>
26803 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26804 \begin_inset Text
26805
26806 \begin_layout Standard
26807 PIC16 specific headers
26808 \end_layout
26809
26810 \end_inset
26811 </cell>
26812 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26813 \begin_inset Text
26814
26815 \begin_layout Standard
26816 Compiler
26817 \end_layout
26818
26819 \end_inset
26820 </cell>
26821 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26822 \begin_inset Text
26823
26824 \begin_layout Standard
26825 -I
26826 \end_layout
26827
26828 \end_inset
26829 </cell>
26830 </row>
26831 <row topline="true" bottomline="true">
26832 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
26833 \begin_inset Text
26834
26835 \begin_layout Standard
26836 PREFIX/sdcc/lib/pic16
26837 \end_layout
26838
26839 \end_inset
26840 </cell>
26841 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26842 \begin_inset Text
26843
26844 \begin_layout Standard
26845 PIC16 specific libraries
26846 \end_layout
26847
26848 \end_inset
26849 </cell>
26850 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26851 \begin_inset Text
26852
26853 \begin_layout Standard
26854 Linker
26855 \end_layout
26856
26857 \end_inset
26858 </cell>
26859 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
26860 \begin_inset Text
26861
26862 \begin_layout Standard
26863 -L
26864 \end_layout
26865
26866 \end_inset
26867 </cell>
26868 </row>
26869 </lyxtabular>
26870
26871 \end_inset
26872
26873
26874 \end_layout
26875
26876 \begin_layout Subsection
26877 Pragmas
26878 \begin_inset LatexCommand label
26879 name "sub:PIC16_Pragmas"
26880
26881 \end_inset
26882
26883
26884 \end_layout
26885
26886 \begin_layout Standard
26887 The PIC16
26888 \begin_inset LatexCommand index
26889 name "PIC16"
26890
26891 \end_inset
26892
26893  port currently supports the following pragmas:
26894 \end_layout
26895
26896 \begin_layout Description
26897 stack
26898 \begin_inset LatexCommand index
26899 name "PIC16!Pragmas!\\#pragma stack"
26900
26901 \end_inset
26902
26903  This forces the code generator to initialize the stack & frame pointers
26904  at a specific address.
26905  This is an ad hoc solution for cases where no STACK directive is available
26906  in the linker script or gplink is not instructed to create a stack section.
26907 \newline
26908 The
26909  stack pragma should be used only once in a project.
26910  Multiple pragmas may result in indeterminate behaviour of the program.
26911 \begin_inset Foot
26912 status open
26913
26914 \begin_layout Standard
26915 The old format (ie.
26916  #pragma stack 0x5ff) is deprecated and will cause the stack pointer to
26917  cross page boundaries (or even exceed the available data RAM) and crash
26918  the program.
26919  Make sure that stack does not cross page boundaries when using the SMALL
26920  stack model.
26921 \end_layout
26922
26923 \end_inset
26924
26925
26926 \newline
26927 The format is as follows:
26928 \newline
26929
26930 \end_layout
26931
26932 \begin_layout LyX-Code
26933 #pragma stack bottom_address [stack_size]
26934 \newline
26935
26936 \end_layout
26937
26938 \begin_layout Standard
26939
26940 \emph on
26941 bottom_address
26942 \emph default
26943  is the lower bound of the stack section.
26944  The stack pointer initially will point at address (bottom_address+stack_size-1).
26945 \end_layout
26946
26947 \begin_layout LyX-Code
26948 Example:
26949 \end_layout
26950
26951 \begin_layout LyX-Code
26952
26953 \end_layout
26954
26955 \begin_layout LyX-Code
26956 /* initializes stack of 100 bytes at RAM address 0x200 */
26957 \end_layout
26958
26959 \begin_layout LyX-Code
26960 #pragma stack 0x200 100
26961 \end_layout
26962
26963 \begin_layout Standard
26964 If the stack_size field is omitted then a stack is created with the default
26965  size of 64.
26966  This size might be enough for most programs, but its not enough for operations
26967  with deep function nesting or excessive stack usage.
26968 \end_layout
26969
26970 \begin_layout Description
26971 code
26972 \begin_inset LatexCommand index
26973 name "PIC16!Pragmas!\\#pragma code"
26974
26975 \end_inset
26976
26977  Force a function to a static FLASH address.
26978 \end_layout
26979
26980 \begin_layout LyX-Code
26981 Example:
26982 \end_layout
26983
26984 \begin_layout LyX-Code
26985
26986 \end_layout
26987
26988 \begin_layout LyX-Code
26989 /* place function test_func at 0x4000 */
26990 \end_layout
26991
26992 \begin_layout LyX-Code
26993 #pragma code test_func 0x4000
26994 \end_layout
26995
26996 \begin_layout LyX-Code
26997
26998 \end_layout
26999
27000 \begin_layout Description
27001 library instructs the linker to use a library module.
27002 \newline
27003 Usage:
27004 \end_layout
27005
27006 \begin_layout LyX-Code
27007 #pragma library module_name
27008 \end_layout
27009
27010 \begin_layout Standard
27011
27012 \emph on
27013 module_name
27014 \emph default
27015  can be any library or object file (including its path).
27016  Note that there are four reserved keywords which have special meaning.
27017  These are:
27018 \end_layout
27019
27020 \begin_layout Standard
27021 \align center
27022 \begin_inset Tabular
27023 <lyxtabular version="3" rows="6" columns="3">
27024 <features>
27025 <column alignment="center" valignment="top" leftline="true" width="0">
27026 <column alignment="block" valignment="top" leftline="true" width="20page%">
27027 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0">
27028 <row topline="true" bottomline="true">
27029 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27030 \begin_inset Text
27031
27032 \begin_layout Standard
27033 Keyword
27034 \end_layout
27035
27036 \end_inset
27037 </cell>
27038 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27039 \begin_inset Text
27040
27041 \begin_layout Standard
27042 Description
27043 \end_layout
27044
27045 \end_inset
27046 </cell>
27047 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27048 \begin_inset Text
27049
27050 \begin_layout Standard
27051 Module to link
27052 \end_layout
27053
27054 \end_inset
27055 </cell>
27056 </row>
27057 <row topline="true">
27058 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27059 \begin_inset Text
27060
27061 \begin_layout Standard
27062
27063 \series bold
27064 ignore
27065 \end_layout
27066
27067 \end_inset
27068 </cell>
27069 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27070 \begin_inset Text
27071
27072 \begin_layout Standard
27073 ignore all library pragmas
27074 \end_layout
27075
27076 \end_inset
27077 </cell>
27078 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27079 \begin_inset Text
27080
27081 \begin_layout Standard
27082
27083 \emph on
27084 (none)
27085 \end_layout
27086
27087 \end_inset
27088 </cell>
27089 </row>
27090 <row topline="true">
27091 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27092 \begin_inset Text
27093
27094 \begin_layout Standard
27095
27096 \series bold
27097 c
27098 \end_layout
27099
27100 \end_inset
27101 </cell>
27102 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27103 \begin_inset Text
27104
27105 \begin_layout Standard
27106 link the C library
27107 \end_layout
27108
27109 \end_inset
27110 </cell>
27111 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27112 \begin_inset Text
27113
27114 \begin_layout Standard
27115
27116 \emph on
27117 libc18f
27118 \emph default
27119 .lib
27120 \end_layout
27121
27122 \end_inset
27123 </cell>
27124 </row>
27125 <row topline="true">
27126 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27127 \begin_inset Text
27128
27129 \begin_layout Standard
27130
27131 \series bold
27132 math
27133 \end_layout
27134
27135 \end_inset
27136 </cell>
27137 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27138 \begin_inset Text
27139
27140 \begin_layout Standard
27141 link the Math libarary
27142 \end_layout
27143
27144 \end_inset
27145 </cell>
27146 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27147 \begin_inset Text
27148
27149 \begin_layout Standard
27150
27151 \emph on
27152 libm18f
27153 \emph default
27154 .lib
27155 \end_layout
27156
27157 \end_inset
27158 </cell>
27159 </row>
27160 <row topline="true">
27161 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27162 \begin_inset Text
27163
27164 \begin_layout Standard
27165
27166 \series bold
27167 io
27168 \end_layout
27169
27170 \end_inset
27171 </cell>
27172 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27173 \begin_inset Text
27174
27175 \begin_layout Standard
27176 link the I/O library
27177 \end_layout
27178
27179 \end_inset
27180 </cell>
27181 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27182 \begin_inset Text
27183
27184 \begin_layout Standard
27185
27186 \emph on
27187 libio18f*
27188 \emph default
27189 .lib
27190 \end_layout
27191
27192 \end_inset
27193 </cell>
27194 </row>
27195 <row topline="true" bottomline="true">
27196 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27197 \begin_inset Text
27198
27199 \begin_layout Standard
27200
27201 \series bold
27202 debug
27203 \end_layout
27204
27205 \end_inset
27206 </cell>
27207 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27208 \begin_inset Text
27209
27210 \begin_layout Standard
27211 link the debug library
27212 \end_layout
27213
27214 \end_inset
27215 </cell>
27216 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27217 \begin_inset Text
27218
27219 \begin_layout Standard
27220
27221 \emph on
27222 libdebug
27223 \emph default
27224 .lib
27225 \end_layout
27226
27227 \end_inset
27228 </cell>
27229 </row>
27230 </lyxtabular>
27231
27232 \end_inset
27233
27234
27235 \newline
27236 * is the device number, i.e.
27237  452 for PIC18F452 MCU.
27238 \end_layout
27239
27240 \begin_layout Standard
27241 \noindent
27242 This feature allows for linking with specific libraries without having to
27243  explicit name them in the command line.
27244  Note that the 
27245 \noun on
27246 ignore
27247 \noun default
27248  keyword will reject all modules specified by the library pragma.
27249 \end_layout
27250
27251 \begin_layout Description
27252 udata The pragma udata instructs the compiler to emit code so that linker
27253  will place a variable at a specific memory bank.
27254 \end_layout
27255
27256 \begin_layout LyX-Code
27257 Example:
27258 \end_layout
27259
27260 \begin_layout LyX-Code
27261
27262 \end_layout
27263
27264 \begin_layout LyX-Code
27265 /* places variable foo at bank2 */
27266 \end_layout
27267
27268 \begin_layout LyX-Code
27269 #pragma udata bank2 foo
27270 \end_layout
27271
27272 \begin_layout LyX-Code
27273 char foo;
27274 \end_layout
27275
27276 \begin_layout Standard
27277 In order for this pragma to work extra SECTION directives should be added
27278  in the .lkr script.
27279  In the following example a sample .lkr file is shown:
27280 \end_layout
27281
27282 \begin_layout LyX-Code
27283
27284 \end_layout
27285
27286 \begin_layout LyX-Code
27287 // Sample linker script for the PIC18F452 processor
27288 \end_layout
27289
27290 \begin_layout LyX-Code
27291 LIBPATH .
27292 \end_layout
27293
27294 \begin_layout LyX-Code
27295 CODEPAGE   NAME=vectors    START=0x0            END=0x29           PROTECTED
27296 \end_layout
27297
27298 \begin_layout LyX-Code
27299 CODEPAGE   NAME=page       START=0x2A           END=0x7FFF
27300 \end_layout
27301
27302 \begin_layout LyX-Code
27303 CODEPAGE   NAME=idlocs     START=0x200000       END=0x200007       PROTECTED
27304 \end_layout
27305
27306 \begin_layout LyX-Code
27307 CODEPAGE   NAME=config     START=0x300000       END=0x30000D       PROTECTED
27308 \end_layout
27309
27310 \begin_layout LyX-Code
27311 CODEPAGE   NAME=devid      START=0x3FFFFE       END=0x3FFFFF       PROTECTED
27312 \end_layout
27313
27314 \begin_layout LyX-Code
27315 CODEPAGE   NAME=eedata     START=0xF00000       END=0xF000FF       PROTECTED
27316 \end_layout
27317
27318 \begin_layout LyX-Code
27319 ACCESSBANK NAME=accessram  START=0x0            END=0x7F
27320 \end_layout
27321
27322 \begin_layout LyX-Code
27323
27324 \end_layout
27325
27326 \begin_layout LyX-Code
27327 DATABANK   NAME=gpr0       START=0x80           END=0xFF
27328 \end_layout
27329
27330 \begin_layout LyX-Code
27331 DATABANK   NAME=gpr1       START=0x100          END=0x1FF
27332 \end_layout
27333
27334 \begin_layout LyX-Code
27335 DATABANK   NAME=gpr2       START=0x200          END=0x2FF
27336 \end_layout
27337
27338 \begin_layout LyX-Code
27339 DATABANK   NAME=gpr3       START=0x300          END=0x3FF
27340 \end_layout
27341
27342 \begin_layout LyX-Code
27343 DATABANK   NAME=gpr4       START=0x400          END=0x4FF
27344 \end_layout
27345
27346 \begin_layout LyX-Code
27347 DATABANK   NAME=gpr5       START=0x500          END=0x5FF
27348 \end_layout
27349
27350 \begin_layout LyX-Code
27351 ACCESSBANK NAME=accesssfr  START=0xF80          END=0xFFF          PROTECTED
27352 \end_layout
27353
27354 \begin_layout LyX-Code
27355
27356 \end_layout
27357
27358 \begin_layout LyX-Code
27359 SECTION    NAME=CONFIG     ROM=config
27360 \end_layout
27361
27362 \begin_layout LyX-Code
27363
27364 \end_layout
27365
27366 \begin_layout LyX-Code
27367 SECTION    NAME=bank0      RAM=gpr0       # these SECTION directives
27368 \end_layout
27369
27370 \begin_layout LyX-Code
27371 SECTION    NAME=bank1      RAM=gpr1       # should be added to link
27372 \end_layout
27373
27374 \begin_layout LyX-Code
27375 SECTION    NAME=bank2      RAM=gpr2       # section name 'bank?' with
27376 \end_layout
27377
27378 \begin_layout LyX-Code
27379 SECTION    NAME=bank3      RAM=gpr3       # a specific DATABANK name
27380 \end_layout
27381
27382 \begin_layout LyX-Code
27383 SECTION    NAME=bank4      RAM=gpr4
27384 \end_layout
27385
27386 \begin_layout LyX-Code
27387 SECTION    NAME=bank5      RAM=gpr5
27388 \end_layout
27389
27390 \begin_layout Standard
27391 The linker will recognise the section name set in the pragma statement and
27392  will position the variable at the memory bank set with the RAM field at
27393  the SECTION line in the linker script file.
27394 \end_layout
27395
27396 \begin_layout Subsection
27397 Header Files
27398 \begin_inset LatexCommand label
27399 name "sub:PIC16_Header-Files"
27400
27401 \end_inset
27402
27403
27404 \end_layout
27405
27406 \begin_layout Standard
27407 There is one main header file
27408 \begin_inset LatexCommand index
27409 name "PIC16!Header files"
27410
27411 \end_inset
27412
27413  that can be included to the source files using the pic16
27414 \begin_inset LatexCommand index
27415 name "PIC16"
27416
27417 \end_inset
27418
27419  port.
27420  That file is the 
27421 \series bold
27422 pic18fregs.h
27423 \series default
27424 .
27425  This header file contains the definitions for the processor special registers,
27426  so it is necessary if the source accesses them.
27427  It can be included by adding the following line in the beginning of the
27428  file:
27429 \end_layout
27430
27431 \begin_layout LyX-Code
27432 #include <pic18fregs.h>
27433 \end_layout
27434
27435 \begin_layout Standard
27436 The specific microcontroller is selected within the pic18fregs.h automatically,
27437  so the same source can be used with a variety of devices.
27438 \end_layout
27439
27440 \begin_layout Subsection
27441 Libraries
27442 \begin_inset LatexCommand label
27443 name "sub:pic16Libraries"
27444
27445 \end_inset
27446
27447
27448 \end_layout
27449
27450 \begin_layout Standard
27451 The libraries
27452 \begin_inset LatexCommand index
27453 name "PIC16!Libraries"
27454
27455 \end_inset
27456
27457  that PIC16
27458 \begin_inset LatexCommand index
27459 name "PIC16"
27460
27461 \end_inset
27462
27463  port depends on are the microcontroller device libraries which contain
27464  the symbol definitions for the microcontroller special function registers.
27465  These libraries have the format pic18fxxxx.lib, where 
27466 \emph on
27467 xxxx
27468 \emph default
27469  is the microcontroller identification number.
27470  The specific library is selected automatically by the compiler at link
27471  stage according to the selected device.
27472 \end_layout
27473
27474 \begin_layout Standard
27475 \noindent
27476 Libraries are created with gplib which is part of the gputils package 
27477 \begin_inset LatexCommand url
27478 target "http://sourceforge.net/projects/gputils"
27479
27480 \end_inset
27481
27482 .
27483 \end_layout
27484
27485 \begin_layout Subsubsection*
27486 Building the libraries
27487 \end_layout
27488
27489 \begin_layout Standard
27490 Before using SDCC/pic16 there are some libraries that need to be compiled.
27491  This process is done automatically if gputils are found at SDCC's compile
27492  time.
27493  Should you require to rebuild the pic16 libraries manually (e.g.
27494  in order to enable output of float values
27495 \begin_inset LatexCommand index
27496 name "Floating point support"
27497
27498 \end_inset
27499
27500  via 
27501 \family typewriter
27502 printf()
27503 \family default
27504 , see below), these are the steps required to do so under Linux or Mac OS
27505  X (cygwin might work as well, but is untested):
27506 \end_layout
27507
27508 \begin_layout LyX-Code
27509 cd device/lib/pic16
27510 \end_layout
27511
27512 \begin_layout LyX-Code
27513 ./configure.gnu
27514 \end_layout
27515
27516 \begin_layout LyX-Code
27517 cd ..
27518 \end_layout
27519
27520 \begin_layout LyX-Code
27521 make model-pic16
27522 \end_layout
27523
27524 \begin_layout LyX-Code
27525 su -c 'make install'     # install the libraries, you need the root password
27526 \end_layout
27527
27528 \begin_layout LyX-Code
27529 cd ../..
27530 \end_layout
27531
27532 \begin_layout Standard
27533 If you need to install the headers too, do:
27534 \end_layout
27535
27536 \begin_layout LyX-Code
27537 cd device/include
27538 \end_layout
27539
27540 \begin_layout LyX-Code
27541 su -c 'make install'     # install the headers, you need the root password
27542 \end_layout
27543
27544 \begin_layout Subsubsection*
27545 Output of float values via printf()
27546 \end_layout
27547
27548 \begin_layout Standard
27549 The library is normally built without support for displaying float values,
27550  only <NO FLOAT>
27551 \begin_inset LatexCommand index
27552 name "<NO FLOAT>"
27553
27554 \end_inset
27555
27556
27557 \begin_inset LatexCommand index
27558 name "printf floating point support"
27559
27560 \end_inset
27561
27562  will appear instead of the value.
27563  To change this, rebuild the library as stated above, but call 
27564 \family typewriter
27565 ./configure.gnu --enable-floats 
27566 \family default
27567 instead of just 
27568 \family typewriter
27569 ./configure.gnu
27570 \family default
27571 .
27572  Also make sure that at least 
27573 \family typewriter
27574 libc/stdio/vfprintf.c
27575 \family default
27576  is actually recompiled, e.g.
27577  by 
27578 \family typewriter
27579 touch
27580 \family default
27581 ing it after the 
27582 \family typewriter
27583 configure
27584 \family default
27585  run or deleting its 
27586 \family typewriter
27587 .o
27588 \family default
27589  file.
27590 \end_layout
27591
27592 \begin_layout Standard
27593 The more common appraoch of compiling 
27594 \family typewriter
27595 vfprintf.c
27596 \family default
27597  manually with 
27598 \family typewriter
27599 -DUSE_FLOATS=1
27600 \family default
27601  should also work, but is untested.
27602 \end_layout
27603
27604 \begin_layout Subsection
27605 Adding New Devices to the Port
27606 \end_layout
27607
27608 \begin_layout Standard
27609 Adding support for a new 16
27610 \begin_inset ERT
27611 status collapsed
27612
27613 \begin_layout Standard
27614
27615
27616 \backslash
27617 ,
27618 \end_layout
27619
27620 \end_inset
27621
27622 bit PIC MCU requires the following steps:
27623 \end_layout
27624
27625 \begin_layout Enumerate
27626 Create picDEVICE.c and picDEVICE.h from pDEVICE.inc using
27627 \newline
27628
27629 \family typewriter
27630 perl /path/to/sdcc/support/scripts/inc2h-pic16.pl /path/to/gputils/header/pDEVICE.
27631 inc
27632 \end_layout
27633
27634 \begin_layout Enumerate
27635
27636 \family typewriter
27637 mv picDEVICE.h /path/to/sdcc/device/include/pic16
27638 \end_layout
27639
27640 \begin_layout Enumerate
27641
27642 \family typewriter
27643 mv picDEVICE.c /path/to/sdcc/device/lib/pic16/libdev
27644 \end_layout
27645
27646 \begin_layout Enumerate
27647 Add DEVICE to 
27648 \family typewriter
27649 /path/to/sdcc/device/lib/pic16/pics.all
27650 \family default
27651
27652 \newline
27653 Note: No 18f prefix here!
27654 \end_layout
27655
27656 \begin_layout Enumerate
27657 Edit 
27658 \family typewriter
27659 /path/to/sdcc/device/include/pic16/adc.h
27660 \newline
27661
27662 \family default
27663 Add the new devices to the correct ADC style class (depending on the number
27664  of ADC channels).
27665 \newline
27666 Do not touch 
27667 \family typewriter
27668 adc.h
27669 \family default
27670  if the device does not offer any ADC at all.
27671 \end_layout
27672
27673 \begin_layout Enumerate
27674 Edit 
27675 \family typewriter
27676 /path/to/sdcc/device/include/pic16/pic18fregs.h
27677 \family default
27678
27679 \newline
27680 The file format is self-explanatory, just add
27681 \newline
27682
27683 \family typewriter
27684 #elif defined(picDEVICE)
27685 \newline
27686 #
27687 \begin_inset ERT
27688 status collapsed
27689
27690 \begin_layout Standard
27691
27692
27693 \backslash
27694  
27695 \backslash
27696  
27697 \end_layout
27698
27699 \end_inset
27700
27701 include <picDEVICE.h>
27702 \family default
27703
27704 \newline
27705 at the right place (keep the file sorted, please).
27706 \end_layout
27707
27708 \begin_layout Enumerate
27709 Edit 
27710 \family typewriter
27711 /path/to/sdcc/device/include/pic16devices.txt
27712 \newline
27713
27714 \family default
27715 Copy and modify an existing entry or create a new one and insert it at the
27716  correct place (keep the file sorted, please).
27717 \end_layout
27718
27719 \begin_layout Enumerate
27720 Add the device to 
27721 \family typewriter
27722 /path/to/sdcc/device/lib/pic16/libdev/Makefile.am
27723 \family default
27724
27725 \newline
27726 Copy an existing entry and adjust the device name.
27727 \end_layout
27728
27729 \begin_layout Enumerate
27730 Add the device to 
27731 \family typewriter
27732 /path/to/sdcc/device/lib/pic16/libio/Makefile.am
27733 \family default
27734
27735 \newline
27736 Copy the record from the 18f2220 and adjust the device name.
27737 \newline
27738 If the new device
27739  does not offer ADC, I
27740 \begin_inset Formula $^{\text{2}}$
27741 \end_inset
27742
27743 C, and/or (E)USART functionality as assumed by the library, remove the lines
27744  with references to 
27745 \family typewriter
27746 adc/*.c
27747 \family default
27748
27749 \family typewriter
27750 usart/*.c
27751 \family default
27752 , or 
27753 \family typewriter
27754 usart/*.c
27755 \family default
27756 , respectively.
27757 \end_layout
27758
27759 \begin_layout Enumerate
27760 Update 
27761 \family typewriter
27762 libdev/Makefile.in
27763 \family default
27764  and 
27765 \family typewriter
27766 libio/Makefile.in
27767 \family default
27768  using
27769 \newline
27770
27771 \family typewriter
27772 ./bootstrap.sh
27773 \family default
27774
27775 \newline
27776 in 
27777 \family typewriter
27778 /path/to/sdcc/device/lib/pic16
27779 \family default
27780 .
27781 \end_layout
27782
27783 \begin_layout Enumerate
27784 Recompile the pic16 libraries as described in 
27785 \begin_inset LatexCommand ref
27786 reference "sub:pic16Libraries"
27787
27788 \end_inset
27789
27790 .
27791 \end_layout
27792
27793 \begin_layout Subsection
27794 Memory Models
27795 \end_layout
27796
27797 \begin_layout Standard
27798 The following memory models are supported by the PIC16 port:
27799 \end_layout
27800
27801 \begin_layout Itemize
27802 small model
27803 \end_layout
27804
27805 \begin_layout Itemize
27806 large model
27807 \end_layout
27808
27809 \begin_layout Standard
27810 Memory model affects the default size of pointers within the source.
27811  The sizes are shown in the next table:
27812 \end_layout
27813
27814 \begin_layout Standard
27815 \align center
27816 \begin_inset Tabular
27817 <lyxtabular version="3" rows="3" columns="3">
27818 <features>
27819 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
27820 <column alignment="center" valignment="top" leftline="true" width="0">
27821 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
27822 <row topline="true" bottomline="true">
27823 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27824 \begin_inset Text
27825
27826 \begin_layout Standard
27827 Pointer sizes according to memory model
27828 \end_layout
27829
27830 \end_inset
27831 </cell>
27832 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27833 \begin_inset Text
27834
27835 \begin_layout Standard
27836 small model
27837 \end_layout
27838
27839 \end_inset
27840 </cell>
27841 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27842 \begin_inset Text
27843
27844 \begin_layout Standard
27845 large model
27846 \end_layout
27847
27848 \end_inset
27849 </cell>
27850 </row>
27851 <row topline="true" bottomline="true">
27852 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27853 \begin_inset Text
27854
27855 \begin_layout Standard
27856 code pointers
27857 \end_layout
27858
27859 \end_inset
27860 </cell>
27861 <cell multicolumn="1" alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27862 \begin_inset Text
27863
27864 \begin_layout Standard
27865 16-bits
27866 \end_layout
27867
27868 \end_inset
27869 </cell>
27870 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27871 \begin_inset Text
27872
27873 \begin_layout Standard
27874 24-bits
27875 \end_layout
27876
27877 \end_inset
27878 </cell>
27879 </row>
27880 <row topline="true" bottomline="true">
27881 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
27882 \begin_inset Text
27883
27884 \begin_layout Standard
27885 data pointers
27886 \end_layout
27887
27888 \end_inset
27889 </cell>
27890 <cell multicolumn="1" alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
27891 \begin_inset Text
27892
27893 \begin_layout Standard
27894 16-bits
27895 \end_layout
27896
27897 \end_inset
27898 </cell>
27899 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
27900 \begin_inset Text
27901
27902 \begin_layout Standard
27903 16-bits
27904 \end_layout
27905
27906 \end_inset
27907 </cell>
27908 </row>
27909 </lyxtabular>
27910
27911 \end_inset
27912
27913
27914 \end_layout
27915
27916 \begin_layout Standard
27917 It is advisable that all sources within a project are compiled with the
27918  same memory model.
27919  If one wants to override the default memory model, this can be done by
27920  declaring a pointer as 
27921 \series bold
27922 far
27923 \series default
27924  or 
27925 \series bold
27926 near
27927 \series default
27928 .
27929  Far selects large memory model's pointers, while near selects small memory
27930  model's pointers.
27931 \end_layout
27932
27933 \begin_layout Standard
27934 The standard device libraries (see 
27935 \begin_inset LatexCommand ref
27936 reference "sub:PIC16_Header-Files"
27937
27938 \end_inset
27939
27940 ) contain no reference to pointers, so they can be used with both memory
27941  models.
27942 \end_layout
27943
27944 \begin_layout Subsection
27945 Stack
27946 \end_layout
27947
27948 \begin_layout Standard
27949 The stack
27950 \begin_inset LatexCommand index
27951 name "PIC16!stack"
27952
27953 \end_inset
27954
27955  implementation for the PIC16 port uses two indirect registers, FSR1 and
27956  FSR2.
27957 \end_layout
27958
27959 \begin_layout Description
27960 FSR1 is assigned as stack pointer
27961 \end_layout
27962
27963 \begin_layout Description
27964 FSR2 is assigned as frame pointer
27965 \end_layout
27966
27967 \begin_layout Standard
27968 The following stack models are supported by the PIC16 port
27969 \end_layout
27970
27971 \begin_layout Itemize
27972
27973 \noun on
27974 small
27975 \noun default
27976  model
27977 \end_layout
27978
27979 \begin_layout Itemize
27980
27981 \noun on
27982 large
27983 \noun default
27984  model
27985 \end_layout
27986
27987 \begin_layout Standard
27988
27989 \noun on
27990 Small
27991 \noun default
27992  model means that only the FSRxL byte is used to access stack and frame,
27993  while 
27994 \emph on
27995 \noun on
27996 large
27997 \emph default
27998 \noun default
27999  uses both FSRxL and FSRxH registers.
28000  The following table shows the stack/frame pointers sizes according to stack
28001  model and the maximum space they can address:
28002 \end_layout
28003
28004 \begin_layout Standard
28005 \align center
28006 \begin_inset Tabular
28007 <lyxtabular version="3" rows="3" columns="3">
28008 <features>
28009 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
28010 <column alignment="center" valignment="top" leftline="true" width="0">
28011 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
28012 <row topline="true" bottomline="true">
28013 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28014 \begin_inset Text
28015
28016 \begin_layout Standard
28017 Stack & Frame pointer sizes according to stack model
28018 \end_layout
28019
28020 \end_inset
28021 </cell>
28022 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28023 \begin_inset Text
28024
28025 \begin_layout Standard
28026 small
28027 \end_layout
28028
28029 \end_inset
28030 </cell>
28031 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28032 \begin_inset Text
28033
28034 \begin_layout Standard
28035 large
28036 \end_layout
28037
28038 \end_inset
28039 </cell>
28040 </row>
28041 <row topline="true">
28042 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28043 \begin_inset Text
28044
28045 \begin_layout Standard
28046 Stack pointer FSR1
28047 \end_layout
28048
28049 \end_inset
28050 </cell>
28051 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28052 \begin_inset Text
28053
28054 \begin_layout Standard
28055 8-bits
28056 \end_layout
28057
28058 \end_inset
28059 </cell>
28060 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28061 \begin_inset Text
28062
28063 \begin_layout Standard
28064 16-bits
28065 \end_layout
28066
28067 \end_inset
28068 </cell>
28069 </row>
28070 <row topline="true" bottomline="true">
28071 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28072 \begin_inset Text
28073
28074 \begin_layout Standard
28075 Frame pointer FSR2
28076 \end_layout
28077
28078 \end_inset
28079 </cell>
28080 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28081 \begin_inset Text
28082
28083 \begin_layout Standard
28084 8-bits
28085 \end_layout
28086
28087 \end_inset
28088 </cell>
28089 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28090 \begin_inset Text
28091
28092 \begin_layout Standard
28093 16-bits
28094 \end_layout
28095
28096 \end_inset
28097 </cell>
28098 </row>
28099 </lyxtabular>
28100
28101 \end_inset
28102
28103
28104 \end_layout
28105
28106 \begin_layout Standard
28107 \noindent
28108
28109 \noun on
28110 Large 
28111 \noun default
28112 stack model is currently not working properly throughout the code generator.
28113  So its use is not advised.
28114  Also there are some other points that need special care:
28115 \newline
28116
28117 \end_layout
28118
28119 \begin_layout Enumerate
28120 Do not create stack sections with size more than one physical bank (that
28121  is 256 bytes)
28122 \end_layout
28123
28124 \begin_layout Enumerate
28125 Stack sections should no cross physical bank limits (i.e.
28126  #pragma stack 0x50 0x100)
28127 \end_layout
28128
28129 \begin_layout Standard
28130 These limitations are caused by the fact that only FSRxL is modified when
28131  using SMALL stack model, so no more than 256 bytes of stack can be used.
28132  This problem will disappear after LARGE model is fully implemented.
28133 \end_layout
28134
28135 \begin_layout Subsection
28136 Functions
28137 \end_layout
28138
28139 \begin_layout Standard
28140 In addition to the standard SDCC function keywords, PIC16
28141 \begin_inset LatexCommand index
28142 name "PIC16"
28143
28144 \end_inset
28145
28146  port makes available two more:
28147 \end_layout
28148
28149 \begin_layout Description
28150 wparam
28151 \begin_inset LatexCommand index
28152 name "PIC16!wparam"
28153
28154 \end_inset
28155
28156  Use the WREG to pass one byte of the first function argument.
28157  This improves speed but you may not use this for functions with arguments
28158  that are called via function pointers, otherwise the first byte of the
28159  first parameter will get lost.
28160  Usage:
28161 \end_layout
28162
28163 \begin_layout LyX-Code
28164 void func_wparam(int a) wparam
28165 \end_layout
28166
28167 \begin_layout LyX-Code
28168 {
28169 \end_layout
28170
28171 \begin_layout LyX-Code
28172     /* WREG hold the lower part of a */
28173 \end_layout
28174
28175 \begin_layout LyX-Code
28176     /* the high part of a is stored in FSR2+2 (or +3 for large stack model)
28177  */
28178 \end_layout
28179
28180 \begin_layout LyX-Code
28181 ...
28182 \end_layout
28183
28184 \begin_layout LyX-Code
28185 }
28186 \end_layout
28187
28188 \begin_layout Description
28189 shadowregs
28190 \begin_inset LatexCommand index
28191 name "PIC16!shadowregs"
28192
28193 \end_inset
28194
28195  When entering/exiting an ISR, it is possible to take advantage of the PIC18F
28196  hardware shadow registers which hold the values of WREG, STATUS and BSR
28197  registers.
28198  This can be done by adding the keyword 
28199 \emph on
28200 shadowregs
28201 \emph default
28202  before the 
28203 \emph on
28204 interrupt
28205 \emph default
28206  keyword in the function's header.
28207 \end_layout
28208
28209 \begin_layout LyX-Code
28210 void isr_shadow(void) shadowregs interrupt 1
28211 \end_layout
28212
28213 \begin_layout LyX-Code
28214 {
28215 \end_layout
28216
28217 \begin_layout LyX-Code
28218 ...
28219 \end_layout
28220
28221 \begin_layout LyX-Code
28222 }
28223 \end_layout
28224
28225 \begin_layout Standard
28226
28227 \emph on
28228 shadowregs
28229 \emph default
28230  instructs the code generator not to store/restore WREG, STATUS, BSR when
28231  entering/exiting the ISR.
28232 \end_layout
28233
28234 \begin_layout Subsection
28235 Function return values
28236 \end_layout
28237
28238 \begin_layout Standard
28239 Return values from functions are placed to the appropriate registers following
28240  a modified Microchip policy optimized for SDCC.
28241  The following table shows these registers:
28242 \end_layout
28243
28244 \begin_layout Standard
28245 \align center
28246 \begin_inset Tabular
28247 <lyxtabular version="3" rows="6" columns="2">
28248 <features>
28249 <column alignment="center" valignment="top" leftline="true" width="0">
28250 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
28251 <row topline="true" bottomline="true">
28252 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28253 \begin_inset Text
28254
28255 \begin_layout Standard
28256 size
28257 \end_layout
28258
28259 \end_inset
28260 </cell>
28261 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28262 \begin_inset Text
28263
28264 \begin_layout Standard
28265 destination register
28266 \end_layout
28267
28268 \end_inset
28269 </cell>
28270 </row>
28271 <row topline="true">
28272 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28273 \begin_inset Text
28274
28275 \begin_layout Standard
28276 8 bits
28277 \end_layout
28278
28279 \end_inset
28280 </cell>
28281 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28282 \begin_inset Text
28283
28284 \begin_layout Standard
28285 WREG
28286 \end_layout
28287
28288 \end_inset
28289 </cell>
28290 </row>
28291 <row topline="true">
28292 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28293 \begin_inset Text
28294
28295 \begin_layout Standard
28296 16 bits
28297 \end_layout
28298
28299 \end_inset
28300 </cell>
28301 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28302 \begin_inset Text
28303
28304 \begin_layout Standard
28305 PRODL:WREG
28306 \end_layout
28307
28308 \end_inset
28309 </cell>
28310 </row>
28311 <row topline="true">
28312 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28313 \begin_inset Text
28314
28315 \begin_layout Standard
28316 24 bits
28317 \end_layout
28318
28319 \end_inset
28320 </cell>
28321 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28322 \begin_inset Text
28323
28324 \begin_layout Standard
28325 PRODH:PRODL:WREG
28326 \end_layout
28327
28328 \end_inset
28329 </cell>
28330 </row>
28331 <row topline="true">
28332 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28333 \begin_inset Text
28334
28335 \begin_layout Standard
28336 32 bits
28337 \end_layout
28338
28339 \end_inset
28340 </cell>
28341 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28342 \begin_inset Text
28343
28344 \begin_layout Standard
28345 FSR0L:PRODH:PRODL:WREG
28346 \end_layout
28347
28348 \end_inset
28349 </cell>
28350 </row>
28351 <row topline="true" bottomline="true">
28352 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28353 \begin_inset Text
28354
28355 \begin_layout Standard
28356 >32 bits
28357 \end_layout
28358
28359 \end_inset
28360 </cell>
28361 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28362 \begin_inset Text
28363
28364 \begin_layout Standard
28365 on stack, FSR0 points to the beginning
28366 \end_layout
28367
28368 \end_inset
28369 </cell>
28370 </row>
28371 </lyxtabular>
28372
28373 \end_inset
28374
28375
28376 \end_layout
28377
28378 \begin_layout Subsection
28379 Interrupts
28380 \end_layout
28381
28382 \begin_layout Standard
28383 An interrupt
28384 \begin_inset LatexCommand index
28385 name "PIC16!interrupt"
28386
28387 \end_inset
28388
28389  service routine (ISR) is declared using the 
28390 \emph on
28391 interrupt
28392 \emph default
28393  keyword.
28394 \end_layout
28395
28396 \begin_layout LyX-Code
28397 void isr(void) interrupt 
28398 \emph on
28399 n
28400 \end_layout
28401
28402 \begin_layout LyX-Code
28403 {
28404 \end_layout
28405
28406 \begin_layout LyX-Code
28407 ...
28408 \end_layout
28409
28410 \begin_layout LyX-Code
28411 }
28412 \end_layout
28413
28414 \begin_layout Standard
28415
28416 \emph on
28417 n
28418 \emph default
28419  is the interrupt number, which for PIC18F devices can be:
28420 \end_layout
28421
28422 \begin_layout Standard
28423 \align center
28424 \begin_inset Tabular
28425 <lyxtabular version="3" rows="4" columns="3">
28426 <features>
28427 <column alignment="center" valignment="top" leftline="true" width="0">
28428 <column alignment="center" valignment="top" leftline="true" width="0">
28429 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
28430 <row topline="true" bottomline="true">
28431 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28432 \begin_inset Text
28433
28434 \begin_layout Standard
28435
28436 \emph on
28437 n
28438 \end_layout
28439
28440 \end_inset
28441 </cell>
28442 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28443 \begin_inset Text
28444
28445 \begin_layout Standard
28446 Interrupt Vector
28447 \end_layout
28448
28449 \end_inset
28450 </cell>
28451 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28452 \begin_inset Text
28453
28454 \begin_layout Standard
28455 Interrupt Vector Address
28456 \end_layout
28457
28458 \end_inset
28459 </cell>
28460 </row>
28461 <row topline="true">
28462 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28463 \begin_inset Text
28464
28465 \begin_layout Standard
28466 0
28467 \end_layout
28468
28469 \end_inset
28470 </cell>
28471 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28472 \begin_inset Text
28473
28474 \begin_layout Standard
28475 RESET vector
28476 \end_layout
28477
28478 \end_inset
28479 </cell>
28480 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28481 \begin_inset Text
28482
28483 \begin_layout Standard
28484 0x000000
28485 \end_layout
28486
28487 \end_inset
28488 </cell>
28489 </row>
28490 <row topline="true">
28491 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28492 \begin_inset Text
28493
28494 \begin_layout Standard
28495
28496 \family roman
28497 \series medium
28498 \shape up
28499 \size normal
28500 \emph off
28501 \bar no
28502 \noun off
28503 \color none
28504 1
28505 \end_layout
28506
28507 \end_inset
28508 </cell>
28509 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28510 \begin_inset Text
28511
28512 \begin_layout Standard
28513
28514 \family roman
28515 \series medium
28516 \shape up
28517 \size normal
28518 \emph off
28519 \bar no
28520 \noun off
28521 \color none
28522 HIGH priority interrupts
28523 \end_layout
28524
28525 \end_inset
28526 </cell>
28527 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28528 \begin_inset Text
28529
28530 \begin_layout Standard
28531 0x000008
28532 \end_layout
28533
28534 \end_inset
28535 </cell>
28536 </row>
28537 <row topline="true" bottomline="true">
28538 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28539 \begin_inset Text
28540
28541 \begin_layout Standard
28542 2
28543 \end_layout
28544
28545 \end_inset
28546 </cell>
28547 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28548 \begin_inset Text
28549
28550 \begin_layout Standard
28551 LOW priority interrupts
28552 \end_layout
28553
28554 \end_inset
28555 </cell>
28556 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28557 \begin_inset Text
28558
28559 \begin_layout Standard
28560 0x000018
28561 \end_layout
28562
28563 \end_inset
28564 </cell>
28565 </row>
28566 </lyxtabular>
28567
28568 \end_inset
28569
28570
28571 \end_layout
28572
28573 \begin_layout Standard
28574 When generating assembly code for ISR the code generator places a 
28575 \noun on
28576 goto 
28577 \noun default
28578 instruction at the 
28579 \emph on
28580 Interrupt Vector Address
28581 \emph default
28582  which points at the generated ISR.
28583  This single GOTO instruction is part of an automatically generated 
28584 \emph on
28585 interrupt entry point
28586 \emph default
28587  function.
28588  The actuall ISR code is placed as normally would in the code space.
28589  Upon interrupt request, the GOTO instruction is executed which jumps to
28590  the ISR code.
28591  When declaring interrupt functions as _naked this GOTO instruction is 
28592 \series bold
28593 not
28594 \series default
28595  generated.
28596  The whole interrupt functions is therefore placed at the Interrupt Vector
28597  Address of the specific interrupt.
28598  This is not a problem for the LOW priority interrupts, but it is a problem
28599  for the RESET and the HIGH priority interrupts because code may be written
28600  at the next interrupt's vector address and cause indeterminate program
28601  behaviour if that interrupt is raised.
28602 \begin_inset Foot
28603 status open
28604
28605 \begin_layout Standard
28606 This is not a problem when
28607 \end_layout
28608
28609 \begin_layout Enumerate
28610 this is a HIGH interrupt ISR and LOW interrupts are 
28611 \emph on
28612 disabled
28613 \emph default
28614  or not used.
28615 \end_layout
28616
28617 \begin_layout Enumerate
28618 when the ISR is small enough not to reach the next interrupt's vector address.
28619 \end_layout
28620
28621 \end_inset
28622
28623
28624 \end_layout
28625
28626 \begin_layout Standard
28627
28628 \emph on
28629 n
28630 \emph default
28631  may be omitted.
28632  This way a function is generated similar to an ISR, but it is not assigned
28633  to any interrupt.
28634 \end_layout
28635
28636 \begin_layout Standard
28637 When entering an interrupt, currently the PIC16
28638 \begin_inset LatexCommand index
28639 name "PIC16"
28640
28641 \end_inset
28642
28643  port automatically saves the following registers:
28644 \end_layout
28645
28646 \begin_layout Itemize
28647 WREG
28648 \end_layout
28649
28650 \begin_layout Itemize
28651 STATUS
28652 \end_layout
28653
28654 \begin_layout Itemize
28655 BSR
28656 \end_layout
28657
28658 \begin_layout Itemize
28659 PROD (PRODL and PRODH)
28660 \end_layout
28661
28662 \begin_layout Itemize
28663 FSR0 (FSR0L and FSR0H)
28664 \end_layout
28665
28666 \begin_layout Standard
28667 These registers are restored upon return from the interrupt routine.
28668 \begin_inset Foot
28669 status open
28670
28671 \begin_layout Standard
28672 NOTE that when the _naked attribute is specified for an interrupt routine,
28673  then NO registers are stored or restored.
28674 \end_layout
28675
28676 \end_inset
28677
28678
28679 \end_layout
28680
28681 \begin_layout Subsection
28682 Generic Pointers
28683 \end_layout
28684
28685 \begin_layout Standard
28686 Generic pointers are implemented in PIC16 port as 3-byte (24-bit) types.
28687  There are 3 types of generic pointers currently implemented data, code
28688  and eeprom pointers.
28689  They are differentiated by the value of the 7th and 6th bits of the upper
28690  byte:
28691 \end_layout
28692
28693 \begin_layout Standard
28694 \align center
28695 \begin_inset Tabular
28696 <lyxtabular version="3" rows="5" columns="5">
28697 <features>
28698 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
28699 <column alignment="center" valignment="top" width="0">
28700 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
28701 <column alignment="center" valignment="top" width="0">
28702 <column alignment="left" valignment="top" rightline="true" width="0">
28703 <row topline="true" bottomline="true">
28704 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28705 \begin_inset Text
28706
28707 \begin_layout Standard
28708 pointer type
28709 \end_layout
28710
28711 \end_inset
28712 </cell>
28713 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28714 \begin_inset Text
28715
28716 \begin_layout Standard
28717 7th bit
28718 \end_layout
28719
28720 \end_inset
28721 </cell>
28722 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28723 \begin_inset Text
28724
28725 \begin_layout Standard
28726 6th bit
28727 \end_layout
28728
28729 \end_inset
28730 </cell>
28731 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28732 \begin_inset Text
28733
28734 \begin_layout Standard
28735 rest of the pointer
28736 \end_layout
28737
28738 \end_inset
28739 </cell>
28740 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28741 \begin_inset Text
28742
28743 \begin_layout Standard
28744 description
28745 \end_layout
28746
28747 \end_inset
28748 </cell>
28749 </row>
28750 <row topline="true" bottomline="true">
28751 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28752 \begin_inset Text
28753
28754 \begin_layout Standard
28755 data 
28756 \end_layout
28757
28758 \end_inset
28759 </cell>
28760 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28761 \begin_inset Text
28762
28763 \begin_layout Standard
28764 1
28765 \end_layout
28766
28767 \end_inset
28768 </cell>
28769 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28770 \begin_inset Text
28771
28772 \begin_layout Standard
28773 0
28774 \end_layout
28775
28776 \end_inset
28777 </cell>
28778 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28779 \begin_inset Text
28780
28781 \begin_layout Standard
28782
28783 \family typewriter
28784 \shape slanted
28785 \emph on
28786 uuuuuu uuuuxxxx xxxxxxxx
28787 \end_layout
28788
28789 \end_inset
28790 </cell>
28791 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28792 \begin_inset Text
28793
28794 \begin_layout Standard
28795 a 12-bit data pointer in data RAM memory
28796 \end_layout
28797
28798 \end_inset
28799 </cell>
28800 </row>
28801 <row bottomline="true">
28802 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28803 \begin_inset Text
28804
28805 \begin_layout Standard
28806 code
28807 \end_layout
28808
28809 \end_inset
28810 </cell>
28811 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28812 \begin_inset Text
28813
28814 \begin_layout Standard
28815 0
28816 \end_layout
28817
28818 \end_inset
28819 </cell>
28820 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28821 \begin_inset Text
28822
28823 \begin_layout Standard
28824 0
28825 \end_layout
28826
28827 \end_inset
28828 </cell>
28829 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28830 \begin_inset Text
28831
28832 \begin_layout Standard
28833
28834 \family typewriter
28835 \shape slanted
28836 \emph on
28837 uxxxxx xxxxxxxx xxxxxxxx
28838 \end_layout
28839
28840 \end_inset
28841 </cell>
28842 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28843 \begin_inset Text
28844
28845 \begin_layout Standard
28846 a 21-bit code pointer in FLASH memory
28847 \end_layout
28848
28849 \end_inset
28850 </cell>
28851 </row>
28852 <row bottomline="true">
28853 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28854 \begin_inset Text
28855
28856 \begin_layout Standard
28857 eeprom
28858 \end_layout
28859
28860 \end_inset
28861 </cell>
28862 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28863 \begin_inset Text
28864
28865 \begin_layout Standard
28866 0
28867 \end_layout
28868
28869 \end_inset
28870 </cell>
28871 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28872 \begin_inset Text
28873
28874 \begin_layout Standard
28875 1
28876 \end_layout
28877
28878 \end_inset
28879 </cell>
28880 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28881 \begin_inset Text
28882
28883 \begin_layout Standard
28884
28885 \family typewriter
28886 \shape slanted
28887 \emph on
28888 uuuuuu uuuuuuxx xxxxxxxx
28889 \end_layout
28890
28891 \end_inset
28892 </cell>
28893 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28894 \begin_inset Text
28895
28896 \begin_layout Standard
28897 a 10-bit eeprom pointer in EEPROM memory
28898 \end_layout
28899
28900 \end_inset
28901 </cell>
28902 </row>
28903 <row bottomline="true">
28904 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28905 \begin_inset Text
28906
28907 \begin_layout Standard
28908 (unimplemented)
28909 \end_layout
28910
28911 \end_inset
28912 </cell>
28913 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
28914 \begin_inset Text
28915
28916 \begin_layout Standard
28917 1
28918 \end_layout
28919
28920 \end_inset
28921 </cell>
28922 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28923 \begin_inset Text
28924
28925 \begin_layout Standard
28926 1
28927 \end_layout
28928
28929 \end_inset
28930 </cell>
28931 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28932 \begin_inset Text
28933
28934 \begin_layout Standard
28935
28936 \family typewriter
28937 \shape slanted
28938 \emph on
28939 xxxxxx xxxxxxxx xxxxxxxx
28940 \end_layout
28941
28942 \end_inset
28943 </cell>
28944 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
28945 \begin_inset Text
28946
28947 \begin_layout Standard
28948 unimplemented pointer type
28949 \end_layout
28950
28951 \end_inset
28952 </cell>
28953 </row>
28954 </lyxtabular>
28955
28956 \end_inset
28957
28958
28959 \end_layout
28960
28961 \begin_layout Standard
28962 \noindent
28963 Generic pointer are read and written with a set of library functions which
28964  read/write 1, 2, 3, 4 bytes.
28965 \end_layout
28966
28967 \begin_layout Subsection
28968 PIC16 C Libraries
28969 \end_layout
28970
28971 \begin_layout Subsubsection
28972 Standard I/O Streams
28973 \end_layout
28974
28975 \begin_layout Standard
28976 In the 
28977 \emph on
28978 stdio.h
28979 \emph default
28980  the type FILE is defined as:
28981 \end_layout
28982
28983 \begin_layout LyX-Code
28984 typedef char * FILE;
28985 \end_layout
28986
28987 \begin_layout Standard
28988 This type is the stream type implemented I/O in the PIC18F devices.
28989  Also the standard input and output streams are declared in stdio.h:
28990 \end_layout
28991
28992 \begin_layout LyX-Code
28993 extern FILE * stdin;
28994 \end_layout
28995
28996 \begin_layout LyX-Code
28997 extern FILE * stdout;
28998 \end_layout
28999
29000 \begin_layout Standard
29001 The FILE type is actually a generic pointer which defines one more type
29002  of generic pointers, the 
29003 \emph on
29004 stream
29005 \emph default
29006  pointer.
29007  This new type has the format:
29008 \end_layout
29009
29010 \begin_layout Standard
29011 \noindent
29012 \align center
29013 \begin_inset Tabular
29014 <lyxtabular version="3" rows="2" columns="7">
29015 <features>
29016 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
29017 <column alignment="center" valignment="top" width="0">
29018 <column alignment="center" valignment="top" leftline="true" width="0">
29019 <column alignment="center" valignment="top" leftline="true" width="0">
29020 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
29021 <column alignment="center" valignment="top" width="0">
29022 <column alignment="left" valignment="top" rightline="true" width="0">
29023 <row topline="true" bottomline="true">
29024 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29025 \begin_inset Text
29026
29027 \begin_layout Standard
29028 pointer type
29029 \end_layout
29030
29031 \end_inset
29032 </cell>
29033 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29034 \begin_inset Text
29035
29036 \begin_layout Standard
29037 <7:6>
29038 \end_layout
29039
29040 \end_inset
29041 </cell>
29042 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29043 \begin_inset Text
29044
29045 \begin_layout Standard
29046 <5>
29047 \end_layout
29048
29049 \end_inset
29050 </cell>
29051 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29052 \begin_inset Text
29053
29054 \begin_layout Standard
29055 <4>
29056 \end_layout
29057
29058 \end_inset
29059 </cell>
29060 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29061 \begin_inset Text
29062
29063 \begin_layout Standard
29064 <3:0>
29065 \end_layout
29066
29067 \end_inset
29068 </cell>
29069 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29070 \begin_inset Text
29071
29072 \begin_layout Standard
29073 rest of the pointer
29074 \end_layout
29075
29076 \end_inset
29077 </cell>
29078 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29079 \begin_inset Text
29080
29081 \begin_layout Standard
29082 descrption
29083 \end_layout
29084
29085 \end_inset
29086 </cell>
29087 </row>
29088 <row topline="true" bottomline="true">
29089 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29090 \begin_inset Text
29091
29092 \begin_layout Standard
29093 stream
29094 \end_layout
29095
29096 \end_inset
29097 </cell>
29098 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29099 \begin_inset Text
29100
29101 \begin_layout Standard
29102 00
29103 \end_layout
29104
29105 \end_inset
29106 </cell>
29107 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29108 \begin_inset Text
29109
29110 \begin_layout Standard
29111 1
29112 \end_layout
29113
29114 \end_inset
29115 </cell>
29116 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29117 \begin_inset Text
29118
29119 \begin_layout Standard
29120 0
29121 \end_layout
29122
29123 \end_inset
29124 </cell>
29125 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29126 \begin_inset Text
29127
29128 \begin_layout Standard
29129 nnnn
29130 \end_layout
29131
29132 \end_inset
29133 </cell>
29134 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29135 \begin_inset Text
29136
29137 \begin_layout Standard
29138
29139 \family typewriter
29140 \shape slanted
29141 \emph on
29142 uuuuuuuu uuuuuuuu
29143 \end_layout
29144
29145 \end_inset
29146 </cell>
29147 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29148 \begin_inset Text
29149
29150 \begin_layout Standard
29151 upper byte high nubble is 0x2n, the rest are zeroes
29152 \end_layout
29153
29154 \end_inset
29155 </cell>
29156 </row>
29157 </lyxtabular>
29158
29159 \end_inset
29160
29161
29162 \end_layout
29163
29164 \begin_layout Standard
29165 \noindent
29166 Currently implemented there are 3 types of streams defined:
29167 \end_layout
29168
29169 \begin_layout Standard
29170 \noindent
29171 \align center
29172 \begin_inset Tabular
29173 <lyxtabular version="3" rows="4" columns="4">
29174 <features>
29175 <column alignment="center" valignment="top" leftline="true" width="0">
29176 <column alignment="center" valignment="top" leftline="true" width="0">
29177 <column alignment="center" valignment="top" leftline="true" width="0">
29178 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
29179 <row topline="true" bottomline="true">
29180 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29181 \begin_inset Text
29182
29183 \begin_layout Standard
29184 stream type
29185 \end_layout
29186
29187 \end_inset
29188 </cell>
29189 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29190 \begin_inset Text
29191
29192 \begin_layout Standard
29193 value
29194 \end_layout
29195
29196 \end_inset
29197 </cell>
29198 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29199 \begin_inset Text
29200
29201 \begin_layout Standard
29202 module
29203 \end_layout
29204
29205 \end_inset
29206 </cell>
29207 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29208 \begin_inset Text
29209
29210 \begin_layout Standard
29211 description
29212 \end_layout
29213
29214 \end_inset
29215 </cell>
29216 </row>
29217 <row topline="true">
29218 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29219 \begin_inset Text
29220
29221 \begin_layout Standard
29222 STREAM_USART
29223 \end_layout
29224
29225 \end_inset
29226 </cell>
29227 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29228 \begin_inset Text
29229
29230 \begin_layout Standard
29231
29232 \family typewriter
29233 0x200000UL
29234 \end_layout
29235
29236 \end_inset
29237 </cell>
29238 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29239 \begin_inset Text
29240
29241 \begin_layout Standard
29242 USART
29243 \end_layout
29244
29245 \end_inset
29246 </cell>
29247 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29248 \begin_inset Text
29249
29250 \begin_layout Standard
29251 Writes/Reads characters via the USART peripheral
29252 \end_layout
29253
29254 \end_inset
29255 </cell>
29256 </row>
29257 <row topline="true">
29258 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29259 \begin_inset Text
29260
29261 \begin_layout Standard
29262 STREAM_MSSP
29263 \end_layout
29264
29265 \end_inset
29266 </cell>
29267 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29268 \begin_inset Text
29269
29270 \begin_layout Standard
29271
29272 \family typewriter
29273 0x210000UL
29274 \end_layout
29275
29276 \end_inset
29277 </cell>
29278 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29279 \begin_inset Text
29280
29281 \begin_layout Standard
29282 MSSP
29283 \end_layout
29284
29285 \end_inset
29286 </cell>
29287 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29288 \begin_inset Text
29289
29290 \begin_layout Standard
29291 Writes/Reads characters via the MSSP peripheral
29292 \end_layout
29293
29294 \end_inset
29295 </cell>
29296 </row>
29297 <row topline="true" bottomline="true">
29298 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29299 \begin_inset Text
29300
29301 \begin_layout Standard
29302 STREAM_USER
29303 \end_layout
29304
29305 \end_inset
29306 </cell>
29307 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29308 \begin_inset Text
29309
29310 \begin_layout Standard
29311
29312 \family typewriter
29313 0x2f0000UL
29314 \end_layout
29315
29316 \end_inset
29317 </cell>
29318 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29319 \begin_inset Text
29320
29321 \begin_layout Standard
29322 (none)
29323 \end_layout
29324
29325 \end_inset
29326 </cell>
29327 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29328 \begin_inset Text
29329
29330 \begin_layout Standard
29331 Writes/Reads characters via used defined functions
29332 \end_layout
29333
29334 \end_inset
29335 </cell>
29336 </row>
29337 </lyxtabular>
29338
29339 \end_inset
29340
29341
29342 \end_layout
29343
29344 \begin_layout Standard
29345 \noindent
29346 The stream identifiers are declared as macros in the stdio.h header.
29347 \end_layout
29348
29349 \begin_layout Standard
29350 \noindent
29351 In the libc library there exist the functions that are used to write to
29352  each of the above streams.
29353  These are
29354 \end_layout
29355
29356 \begin_layout Description
29357 _
29358 \begin_inset ERT
29359 status collapsed
29360
29361 \begin_layout Standard
29362
29363
29364 \backslash
29365 /
29366 \end_layout
29367
29368 \end_inset
29369
29370 _stream_usart_putchar writes a character at the USART stream
29371 \end_layout
29372
29373 \begin_layout Description
29374 _
29375 \begin_inset ERT
29376 status collapsed
29377
29378 \begin_layout Standard
29379
29380
29381 \backslash
29382 /
29383 \end_layout
29384
29385 \end_inset
29386
29387 _stream_mssp_putchar writes a character at the MSSP stream
29388 \end_layout
29389
29390 \begin_layout Description
29391 putchar dummy function.
29392  This writes a character to a user specified manner.
29393 \end_layout
29394
29395 \begin_layout Standard
29396 In order to increase performance 
29397 \emph on
29398 putchar
29399 \emph default
29400  is declared in stdio.h as having its parameter in WREG (it has the wparam
29401  keyword).
29402  In stdio.h exists the macro PUTCHAR(arg) that defines the putchar function
29403  in a user-friendly way.
29404  
29405 \emph on
29406 arg
29407 \emph default
29408  is the name of the variable that holds the character to print.
29409  An example follows:
29410 \end_layout
29411
29412 \begin_layout LyX-Code
29413 #include <pic18fregs.h>
29414 \newline
29415 #include <stdio.h>
29416 \newline
29417
29418 \newline
29419 PUTCHAR( c )
29420 \end_layout
29421
29422 \begin_layout LyX-Code
29423 {
29424 \end_layout
29425
29426 \begin_layout LyX-Code
29427     PORTA = c;    /* dump character c to PORTA */
29428 \end_layout
29429
29430 \begin_layout LyX-Code
29431
29432 \newline
29433
29434 \newline
29435 void main(void)
29436 \end_layout
29437
29438 \begin_layout LyX-Code
29439 {
29440 \end_layout
29441
29442 \begin_layout LyX-Code
29443     stdout = STREAM_USER;    /* this is not necessary, since stdout points
29444 \end_layout
29445
29446 \begin_layout LyX-Code
29447                               * by default to STREAM_USER */
29448 \end_layout
29449
29450 \begin_layout LyX-Code
29451     printf (
29452 \begin_inset Quotes sld
29453 \end_inset
29454
29455 This is a printf test
29456 \backslash
29457 n
29458 \begin_inset Quotes srd
29459 \end_inset
29460
29461 );
29462 \end_layout
29463
29464 \begin_layout LyX-Code
29465 }
29466 \end_layout
29467
29468 \begin_layout LyX-Code
29469
29470 \end_layout
29471
29472 \begin_layout Subsubsection
29473 Printing functions
29474 \end_layout
29475
29476 \begin_layout Standard
29477 PIC16 contains an implementation of the printf-family of functions.
29478  There exist the following functions:
29479 \end_layout
29480
29481 \begin_layout LyX-Code
29482 extern unsigned int sprintf(char *buf, char *fmt, ...);
29483 \end_layout
29484
29485 \begin_layout LyX-Code
29486 extern unsigned int vsprintf(char *buf, char *fmt, va_list ap);
29487 \end_layout
29488
29489 \begin_layout LyX-Code
29490
29491 \end_layout
29492
29493 \begin_layout LyX-Code
29494 extern unsigned int printf(char *fmt, ...);
29495 \end_layout
29496
29497 \begin_layout LyX-Code
29498 extern unsigned int vprintf(char *fmt, va_lista ap);
29499 \end_layout
29500
29501 \begin_layout LyX-Code
29502
29503 \end_layout
29504
29505 \begin_layout LyX-Code
29506 extern unsigned int fprintf(FILE *fp, char *fmt, ...);
29507 \end_layout
29508
29509 \begin_layout LyX-Code
29510 extern unsigned int vfprintf(FILE *fp, char *fmt, va_list ap);
29511 \end_layout
29512
29513 \begin_layout Standard
29514 For sprintf and vsprintf 
29515 \emph on
29516 buf
29517 \emph default
29518  should normally be a data pointer where the resulting string will be placed.
29519  No range checking is done so the user should allocate the necessary buffer.
29520  For fprintf and vfprintf 
29521 \emph on
29522 fp
29523 \emph default
29524  should be a stream pointer (i.e.
29525  stdout, STREAM_MSSP, etc...).
29526 \end_layout
29527
29528 \begin_layout Subsubsection
29529 Signals
29530 \end_layout
29531
29532 \begin_layout Standard
29533 The PIC18F family of microcontrollers supports a number of interrupt sources.
29534  A list of these interrupts is shown in the following table:
29535 \end_layout
29536
29537 \begin_layout Standard
29538 \align center
29539 \begin_inset Tabular
29540 <lyxtabular version="3" rows="11" columns="4">
29541 <features>
29542 <column alignment="left" valignment="top" leftline="true" width="0">
29543 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
29544 <column alignment="left" valignment="top" leftline="true" width="0">
29545 <column alignment="center" valignment="top" leftline="true" rightline="true" width="0">
29546 <row topline="true" bottomline="true">
29547 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29548 \begin_inset Text
29549
29550 \begin_layout Standard
29551 signal name
29552 \end_layout
29553
29554 \end_inset
29555 </cell>
29556 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29557 \begin_inset Text
29558
29559 \begin_layout Standard
29560 description
29561 \end_layout
29562
29563 \end_inset
29564 </cell>
29565 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29566 \begin_inset Text
29567
29568 \begin_layout Standard
29569 signal name
29570 \end_layout
29571
29572 \end_inset
29573 </cell>
29574 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29575 \begin_inset Text
29576
29577 \begin_layout Standard
29578 description
29579 \end_layout
29580
29581 \end_inset
29582 </cell>
29583 </row>
29584 <row topline="true">
29585 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29586 \begin_inset Text
29587
29588 \begin_layout Standard
29589 SIG_RB
29590 \end_layout
29591
29592 \end_inset
29593 </cell>
29594 <cell multicolumn="1" alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29595 \begin_inset Text
29596
29597 \begin_layout Standard
29598 PORTB change interrupt
29599 \end_layout
29600
29601 \end_inset
29602 </cell>
29603 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29604 \begin_inset Text
29605
29606 \begin_layout Standard
29607 SIG_EE
29608 \end_layout
29609
29610 \end_inset
29611 </cell>
29612 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29613 \begin_inset Text
29614
29615 \begin_layout Standard
29616 EEPROM/FLASH write complete interrupt
29617 \end_layout
29618
29619 \end_inset
29620 </cell>
29621 </row>
29622 <row topline="true">
29623 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29624 \begin_inset Text
29625
29626 \begin_layout Standard
29627 SIG_INT0
29628 \end_layout
29629
29630 \end_inset
29631 </cell>
29632 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29633 \begin_inset Text
29634
29635 \begin_layout Standard
29636 INT0 external interrupt
29637 \end_layout
29638
29639 \end_inset
29640 </cell>
29641 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29642 \begin_inset Text
29643
29644 \begin_layout Standard
29645 SIG_BCOL
29646 \end_layout
29647
29648 \end_inset
29649 </cell>
29650 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29651 \begin_inset Text
29652
29653 \begin_layout Standard
29654 Bus collision interrupt
29655 \end_layout
29656
29657 \end_inset
29658 </cell>
29659 </row>
29660 <row topline="true">
29661 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29662 \begin_inset Text
29663
29664 \begin_layout Standard
29665 SIG_INT1
29666 \end_layout
29667
29668 \end_inset
29669 </cell>
29670 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29671 \begin_inset Text
29672
29673 \begin_layout Standard
29674 INT1 external interrupt
29675 \end_layout
29676
29677 \end_inset
29678 </cell>
29679 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29680 \begin_inset Text
29681
29682 \begin_layout Standard
29683 SIG_LVD
29684 \end_layout
29685
29686 \end_inset
29687 </cell>
29688 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29689 \begin_inset Text
29690
29691 \begin_layout Standard
29692 Low voltage detect interrupt
29693 \end_layout
29694
29695 \end_inset
29696 </cell>
29697 </row>
29698 <row topline="true">
29699 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29700 \begin_inset Text
29701
29702 \begin_layout Standard
29703 SIG_INT2
29704 \end_layout
29705
29706 \end_inset
29707 </cell>
29708 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29709 \begin_inset Text
29710
29711 \begin_layout Standard
29712 INT2 external interrupt
29713 \end_layout
29714
29715 \end_inset
29716 </cell>
29717 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29718 \begin_inset Text
29719
29720 \begin_layout Standard
29721 SIG_PSP
29722 \end_layout
29723
29724 \end_inset
29725 </cell>
29726 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29727 \begin_inset Text
29728
29729 \begin_layout Standard
29730 Parallel slave port interrupt
29731 \end_layout
29732
29733 \end_inset
29734 </cell>
29735 </row>
29736 <row topline="true">
29737 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29738 \begin_inset Text
29739
29740 \begin_layout Standard
29741 SIG_CCP1
29742 \end_layout
29743
29744 \end_inset
29745 </cell>
29746 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29747 \begin_inset Text
29748
29749 \begin_layout Standard
29750 CCP1 module interrupt
29751 \end_layout
29752
29753 \end_inset
29754 </cell>
29755 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29756 \begin_inset Text
29757
29758 \begin_layout Standard
29759 SIG_AD
29760 \end_layout
29761
29762 \end_inset
29763 </cell>
29764 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29765 \begin_inset Text
29766
29767 \begin_layout Standard
29768 AD convertion complete interrupt
29769 \end_layout
29770
29771 \end_inset
29772 </cell>
29773 </row>
29774 <row topline="true">
29775 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29776 \begin_inset Text
29777
29778 \begin_layout Standard
29779 SIG_CCP2
29780 \end_layout
29781
29782 \end_inset
29783 </cell>
29784 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29785 \begin_inset Text
29786
29787 \begin_layout Standard
29788 CCP2 module interrupt
29789 \end_layout
29790
29791 \end_inset
29792 </cell>
29793 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29794 \begin_inset Text
29795
29796 \begin_layout Standard
29797 SIG_RC
29798 \end_layout
29799
29800 \end_inset
29801 </cell>
29802 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29803 \begin_inset Text
29804
29805 \begin_layout Standard
29806 USART receive interrupt
29807 \end_layout
29808
29809 \end_inset
29810 </cell>
29811 </row>
29812 <row topline="true">
29813 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29814 \begin_inset Text
29815
29816 \begin_layout Standard
29817 SIG_TMR0
29818 \end_layout
29819
29820 \end_inset
29821 </cell>
29822 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29823 \begin_inset Text
29824
29825 \begin_layout Standard
29826 TMR0 overflow interrupt
29827 \end_layout
29828
29829 \end_inset
29830 </cell>
29831 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29832 \begin_inset Text
29833
29834 \begin_layout Standard
29835 SIG_TX
29836 \end_layout
29837
29838 \end_inset
29839 </cell>
29840 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29841 \begin_inset Text
29842
29843 \begin_layout Standard
29844 USART transmit interrupt
29845 \end_layout
29846
29847 \end_inset
29848 </cell>
29849 </row>
29850 <row topline="true">
29851 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29852 \begin_inset Text
29853
29854 \begin_layout Standard
29855 SIG_TMR1
29856 \end_layout
29857
29858 \end_inset
29859 </cell>
29860 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29861 \begin_inset Text
29862
29863 \begin_layout Standard
29864 TMR1 overflow interrupt
29865 \end_layout
29866
29867 \end_inset
29868 </cell>
29869 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29870 \begin_inset Text
29871
29872 \begin_layout Standard
29873 SIG_MSSP
29874 \end_layout
29875
29876 \end_inset
29877 </cell>
29878 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29879 \begin_inset Text
29880
29881 \begin_layout Standard
29882 SSP receive/transmit interrupt
29883 \end_layout
29884
29885 \end_inset
29886 </cell>
29887 </row>
29888 <row topline="true">
29889 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29890 \begin_inset Text
29891
29892 \begin_layout Standard
29893 SIG_TMR2
29894 \end_layout
29895
29896 \end_inset
29897 </cell>
29898 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29899 \begin_inset Text
29900
29901 \begin_layout Standard
29902 TMR2 matches PR2 interrupt
29903 \end_layout
29904
29905 \end_inset
29906 </cell>
29907 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29908 \begin_inset Text
29909
29910 \begin_layout Standard
29911
29912 \end_layout
29913
29914 \end_inset
29915 </cell>
29916 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29917 \begin_inset Text
29918
29919 \begin_layout Standard
29920
29921 \end_layout
29922
29923 \end_inset
29924 </cell>
29925 </row>
29926 <row topline="true" bottomline="true">
29927 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
29928 \begin_inset Text
29929
29930 \begin_layout Standard
29931 SIG_TMR3
29932 \end_layout
29933
29934 \end_inset
29935 </cell>
29936 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29937 \begin_inset Text
29938
29939 \begin_layout Standard
29940 TMR3 overflow interrupt
29941 \end_layout
29942
29943 \end_inset
29944 </cell>
29945 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29946 \begin_inset Text
29947
29948 \begin_layout Standard
29949
29950 \end_layout
29951
29952 \end_inset
29953 </cell>
29954 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
29955 \begin_inset Text
29956
29957 \begin_layout Standard
29958
29959 \end_layout
29960
29961 \end_inset
29962 </cell>
29963 </row>
29964 </lyxtabular>
29965
29966 \end_inset
29967
29968
29969 \end_layout
29970
29971 \begin_layout Standard
29972 \noindent
29973 The prototypes for these names are defined in the header file 
29974 \emph on
29975 signal.h
29976 \emph default
29977  .
29978 \end_layout
29979
29980 \begin_layout Standard
29981 \noindent
29982 In order to simplify signal handling, a number of macros is provided:
29983 \end_layout
29984
29985 \begin_layout List
29986 \labelwidthstring 00.00.0000
29987 DEF_INTHIGH(name) begin the definition of the interrupt dispatch table for
29988  high priority interrupts.
29989  
29990 \emph on
29991 name
29992 \emph default
29993  is the function name to use.
29994 \end_layout
29995
29996 \begin_layout List
29997 \labelwidthstring 00.00.0000
29998 DEF_INTLOW(name) begin the definition of the interrupt dispatch table fo
29999  low priority interrupt.
30000  
30001 \emph on
30002 name
30003 \emph default
30004  is the function name to use.
30005 \end_layout
30006
30007 \begin_layout List
30008 \labelwidthstring 00.00.0000
30009 DEF_HANDLER(sig,handler) define a handler for signal 
30010 \emph on
30011 sig.
30012 \end_layout
30013
30014 \begin_layout List
30015 \labelwidthstring 00.00.0000
30016 END_DEF end the declaration of the dispatch table.
30017 \end_layout
30018
30019 \begin_layout Standard
30020 Additionally there are two more macros to simplify the declaration of the
30021  signal handler:
30022 \end_layout
30023
30024 \begin_layout List
30025 \labelwidthstring 00.00.0000
30026
30027 \series medium
30028 SIGHANDLER(handler)
30029 \series default
30030  this declares the function prototype for the 
30031 \emph on
30032 handler
30033 \emph default
30034  function.
30035 \end_layout
30036
30037 \begin_layout List
30038 \labelwidthstring 00.00.0000
30039 SIGHANDLERNAKED(handler) same as SIGHANDLER() but declares a naked function.
30040 \end_layout
30041
30042 \begin_layout Standard
30043 An example of using the macros above is shown below:
30044 \end_layout
30045
30046 \begin_layout LyX-Code
30047 #include <pic18fregs.h>
30048 \end_layout
30049
30050 \begin_layout LyX-Code
30051 #include <signal.h>
30052 \newline
30053
30054 \newline
30055 DEF_INTHIGH(high_int)
30056 \end_layout
30057
30058 \begin_layout LyX-Code
30059 DEF_HANDLER(SIG_TMR0, _tmr0_handler)
30060 \end_layout
30061
30062 \begin_layout LyX-Code
30063 DEF_HANDLER(SIG_BCOL, _bcol_handler)
30064 \end_layout
30065
30066 \begin_layout LyX-Code
30067 END_DEF
30068 \newline
30069
30070 \newline
30071 SIGHANDLER(_tmr0_handler)
30072 \end_layout
30073
30074 \begin_layout LyX-Code
30075 {
30076 \end_layout
30077
30078 \begin_layout LyX-Code
30079   /* action to be taken when timer 0 overflows */
30080 \end_layout
30081
30082 \begin_layout LyX-Code
30083 }
30084 \newline
30085
30086 \newline
30087 SIGHANDLERNAKED(_bcol_handler)
30088 \end_layout
30089
30090 \begin_layout LyX-Code
30091 {
30092 \end_layout
30093
30094 \begin_layout LyX-Code
30095   _asm
30096 \end_layout
30097
30098 \begin_layout LyX-Code
30099     /* action to be taken when bus collision occurs */
30100 \end_layout
30101
30102 \begin_layout LyX-Code
30103     retfie
30104 \end_layout
30105
30106 \begin_layout LyX-Code
30107  _endasm;
30108 \end_layout
30109
30110 \begin_layout LyX-Code
30111 }
30112 \end_layout
30113
30114 \begin_layout Standard
30115
30116 \series bold
30117 NOTES:
30118 \series default
30119  Special care should be taken when using the above scheme:
30120 \end_layout
30121
30122 \begin_layout Itemize
30123 do not place a colon (;) at the end of the DEF_* and END_DEF macros.
30124 \end_layout
30125
30126 \begin_layout Itemize
30127 when declaring SIGHANDLERNAKED handler never forget to use 
30128 \emph on
30129 retfie
30130 \emph default
30131  for proper returning.
30132 \end_layout
30133
30134 \begin_layout Subsection
30135 PIC16 Port -- Tips
30136 \end_layout
30137
30138 \begin_layout Standard
30139 Here you can find some general tips for compiling programs with SDCC/pic16.
30140 \end_layout
30141
30142 \begin_layout Subsubsection
30143 Stack size
30144 \end_layout
30145
30146 \begin_layout Standard
30147 The default stack
30148 \begin_inset LatexCommand index
30149 name "PIC16!stack"
30150
30151 \end_inset
30152
30153  size (that is 64 bytes) probably is enough for many programs.
30154  One must take care that when there are many levels of function nesting,
30155  or there is excessive usage of stack, its size should be extended.
30156  An example of such a case is the printf/sprintf family of functions.
30157  If you encounter problems like not being able to print integers, then you
30158  need to set the stack size around the maximum (256 for small stack model).
30159  The following diagram shows what happens when calling printf to print an
30160  integer:
30161 \end_layout
30162
30163 \begin_layout LyX-Code
30164 printf () --> ltoa () --> ultoa () --> divschar ()
30165 \end_layout
30166
30167 \begin_layout Standard
30168 It is should be understood that stack is easily consumed when calling complicate
30169 d functions.
30170  Using command line arguments like -
30171 \begin_inset ERT
30172 status collapsed
30173
30174 \begin_layout Standard
30175
30176
30177 \backslash
30178 /
30179 \end_layout
30180
30181 \end_inset
30182
30183 -fommit-frame-pointer might reduce stack usage by not creating unnecessery
30184  stack frames.
30185  Other ways to reduce stack usage may exist.
30186 \end_layout
30187
30188 \begin_layout Subsection
30189 Known Bugs
30190 \end_layout
30191
30192 \begin_layout Subsubsection
30193 Extended Instruction Set
30194 \end_layout
30195
30196 \begin_layout Standard
30197 The PIC16 port emits code which is incompatible with the extended instruction
30198  set available with many newer devices.
30199  Make sure to always explicitly disable it, usually using
30200 \end_layout
30201
30202 \begin_layout Standard
30203
30204 \family typewriter
30205 static __code char __at(__CONFIG4L) conf4l = /* more flags & */ _XINST_OFF_4L;
30206 \end_layout
30207
30208 \begin_layout Standard
30209 \noindent
30210 Some devices (namely 18f2455, 18f2550, 18f4455, and 18f4550) use _ENHCPU_OFF_4L
30211  instead of _XINST_OFF_4L.
30212 \end_layout
30213
30214 \begin_layout Subsubsection
30215 Regression Tests
30216 \end_layout
30217
30218 \begin_layout Standard
30219 The PIC16 port currently passes most but not all of the tests in SDCC's
30220  regression test
30221 \begin_inset LatexCommand index
30222 name "Regression test (PIC16)"
30223
30224 \end_inset
30225
30226  suite (see section 
30227 \begin_inset LatexCommand ref
30228 reference "sec:Quality-control"
30229
30230 \end_inset
30231
30232 ), thus no automatic regression tests are currently performed for the PIC16
30233  target.
30234 \end_layout
30235
30236 \begin_layout Chapter
30237 Debugging
30238 \end_layout
30239
30240 \begin_layout Standard
30241 There are several approaches to debugging your code.
30242  This chapter is meant to show your options and to give detail on some of
30243  them:
30244 \newline
30245
30246 \newline
30247 When writing your code:
30248 \end_layout
30249
30250 \begin_layout Itemize
30251 write your code with debugging in mind (avoid duplicating code, put conceptually
30252  similar variables into structs, use structured code, have strategic points
30253  within your code where all variables are consistent, ...)
30254 \end_layout
30255
30256 \begin_layout Itemize
30257 run a syntax-checking tool like splint
30258 \begin_inset LatexCommand index
30259 name "splint (syntax checking tool)"
30260
30261 \end_inset
30262
30263
30264 \begin_inset LatexCommand index
30265 name "lint (syntax checking tool)"
30266
30267 \end_inset
30268
30269  (see -
30270 \begin_inset ERT
30271 status collapsed
30272
30273 \begin_layout Standard
30274
30275
30276 \backslash
30277 /
30278 \end_layout
30279
30280 \end_inset
30281
30282 -more-pedantic 
30283 \begin_inset LatexCommand ref
30284 reference "lyx:more-pedantic-SPLINT"
30285
30286 \end_inset
30287
30288 ) over the code.
30289 \end_layout
30290
30291 \begin_layout Itemize
30292 for the high level code use a C-compiler (like f.e.
30293  GCC) to compile run and debug the code on your host.
30294  See (see -
30295 \begin_inset ERT
30296 status collapsed
30297
30298 \begin_layout Standard
30299
30300
30301 \backslash
30302 /
30303 \end_layout
30304
30305 \end_inset
30306
30307 -more-pedantic 
30308 \begin_inset LatexCommand ref
30309 reference "lyx:more-pedantic-SPLINT"
30310
30311 \end_inset
30312
30313 ) on how to handle syntax extensions like __xdata, __at(), ...
30314  
30315 \end_layout
30316
30317 \begin_layout Itemize
30318 use another C-compiler to compile code for your target.
30319  Always an option but not recommended:) And not very likely to help you.
30320  If you seriously consider walking this path you should at least occasionally
30321  check portability of your code.
30322  Most commercial compiler vendors will offer an evaluation version so you
30323  can test compile your code or snippets of your code.
30324 \end_layout
30325
30326 \begin_layout Standard
30327 Debugging on a simulator:
30328 \end_layout
30329
30330 \begin_layout Itemize
30331 there is a separate section about SDCDB (section 
30332 \begin_inset LatexCommand ref
30333 reference "cha:Debugging-with-SDCDB"
30334
30335 \end_inset
30336
30337 ) below.
30338 \end_layout
30339
30340 \begin_layout Itemize
30341 or (8051 specific) use a free open source/commercial simulator which interfaces
30342  to the AOMF
30343 \begin_inset LatexCommand index
30344 name "AOMF, AOMF51"
30345
30346 \end_inset
30347
30348  file (see 
30349 \begin_inset LatexCommand ref
30350 reference "OMF file"
30351
30352 \end_inset
30353
30354 ) optionally generated by SDCC.
30355 \end_layout
30356
30357 \begin_layout Standard
30358 Debugging On-target: 
30359 \end_layout
30360
30361 \begin_layout Itemize
30362 use a MCU port pin to serially output debug data to the RS232 port of your
30363  host.
30364  You'll probably want some level shifting device typically involving a MAX232
30365  or similar IC.
30366  If the hardware serial port of the MCU is not available search for 'Software
30367  UART' in your favourite search machine.
30368 \end_layout
30369
30370 \begin_layout Itemize
30371 use an on-target monitor.
30372  In this context a monitor is a small program which usually accepts commands
30373  via a serial line and allows to set program counter, to single step through
30374  a program and read/write memory locations.
30375  For the 8051 good examples of monitors are paulmon and cmon51 (see section
30376  
30377 \begin_inset LatexCommand ref
30378 reference "sec:Related-open-source-tools"
30379
30380 \end_inset
30381
30382 ).
30383 \end_layout
30384
30385 \begin_layout Itemize
30386 toggle MCU port pins at strategic points within your code and use an oscilloscop
30387 e.
30388  A 
30389 \emph on
30390 digital oscilloscope
30391 \emph default
30392
30393 \begin_inset LatexCommand index
30394 name "Oscilloscope"
30395
30396 \end_inset
30397
30398  with deep trace memory is really helpful especially if you have to debug
30399  a realtime application.
30400  If you need to monitor more pins than your oscilloscope provides you can
30401  sometimes get away with a small R-2R network.
30402  On a single channel oscilloscope you could f.e.
30403  monitor 2 push-pull driven pins by connecting one via a 10\InsetSpace ~
30404 k
30405 \begin_inset Formula $\Omega$
30406 \end_inset
30407
30408  resistor and the other one by a 5\InsetSpace ~
30409 k
30410 \begin_inset Formula $\Omega$
30411 \end_inset
30412
30413  resistor to the oscilloscope probe (check output drive capability of the
30414  pins you want to monitor).
30415  If you need to monitor many more pins a 
30416 \emph on
30417 logic analyzer
30418 \emph default
30419  will be handy.
30420 \end_layout
30421
30422 \begin_layout Itemize
30423 use an ICE (
30424 \emph on
30425 i
30426 \emph default
30427
30428 \emph on
30429 c
30430 \emph default
30431 ircuit 
30432 \emph on
30433 e
30434 \emph default
30435 mulator
30436 \begin_inset LatexCommand index
30437 name "ICE (in circuit emulator)"
30438
30439 \end_inset
30440
30441 ).
30442  Usually very expensive.
30443  And very nice to have too.
30444  And usually locks you (for years...) to the devices the ICE can emulate.
30445  
30446 \end_layout
30447
30448 \begin_layout Itemize
30449 use a remote debugger.
30450  In most 8-bit systems the symbol information is not available on the target,
30451  and a complete debugger is too bulky for the target system.
30452  Therefore usually a debugger on the host system connects to an on-target
30453  debugging stub which accepts only primitive commands.
30454  
30455 \newline
30456 Terms to enter into your favourite search engine could be 'remote debugging',
30457  'gdb stub' or 'inferior debugger'.
30458  (is there one?)
30459 \end_layout
30460
30461 \begin_layout Itemize
30462 use an on target hardware debugger.
30463  Some of the more modern MCUs include hardware support for setting break
30464  points and monitoring/changing variables by using dedicated hardware pins.
30465  This facility doesn't require additional code to run on the target and
30466  
30467 \emph on
30468 usually
30469 \emph default
30470  doesn't affect runtime behaviour until a breakpoint is hit.
30471  For the mcs51 most hardware debuggers use the AOMF
30472 \begin_inset LatexCommand index
30473 name "AOMF, AOMF51"
30474
30475 \end_inset
30476
30477  file (see 
30478 \begin_inset LatexCommand ref
30479 reference "OMF file"
30480
30481 \end_inset
30482
30483 ) as input file.
30484  
30485 \end_layout
30486
30487 \begin_layout Standard
30488 Last not least:
30489 \end_layout
30490
30491 \begin_layout Itemize
30492 if you are not familiar with any of the following terms you're likely to
30493  run into problems rather sooner than later: 
30494 \emph on
30495 volatile
30496 \emph default
30497
30498 \emph on
30499 atomic
30500 \emph default
30501
30502 \emph on
30503 memory map
30504 \emph default
30505
30506 \emph on
30507 overlay
30508 \emph default
30509 .
30510  As an embedded programmer you 
30511 \emph on
30512 have
30513 \emph default
30514  to know them so why not look them up 
30515 \emph on
30516 before
30517 \emph default
30518  you have problems?)
30519 \end_layout
30520
30521 \begin_layout Itemize
30522 tell someone else about your problem (actually this is a surprisingly effective
30523  means to hunt down the bug even if the listener is not familiar with your
30524  environment).
30525  As 'failure to communicate' is probably one of the job-induced deformations
30526  of an embedded programmer this is highly encouraged.
30527 \end_layout
30528
30529 \begin_layout Section
30530 Debugging with SDCDB
30531 \begin_inset LatexCommand label
30532 name "cha:Debugging-with-SDCDB"
30533
30534 \end_inset
30535
30536
30537 \begin_inset LatexCommand index
30538 name "SDCDB (debugger)"
30539
30540 \end_inset
30541
30542  
30543 \end_layout
30544
30545 \begin_layout Standard
30546 SDCC is distributed with a source level debugger
30547 \begin_inset LatexCommand index
30548 name "Debugger"
30549
30550 \end_inset
30551
30552 .
30553  The debugger uses a command line interface, the command repertoire of the
30554  debugger has been kept as close to gdb
30555 \begin_inset LatexCommand index
30556 name "gdb"
30557
30558 \end_inset
30559
30560  (the GNU debugger) as possible.
30561  The configuration and build process is part of the standard compiler installati
30562 on, which also builds and installs the debugger in the target directory
30563  specified during configuration.
30564  The debugger allows you debug BOTH at the C source and at the ASM source
30565  level.
30566 \end_layout
30567
30568 \begin_layout Subsection
30569 Compiling for Debugging
30570 \end_layout
30571
30572 \begin_layout Standard
30573 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
30587 \begin_inset LatexCommand index
30588 name "-\\/-debug"
30589
30590 \end_inset
30591
30592  option must be specified for all files for which debug information is to
30593  be generated.
30594  The compiler generates a .adb file for each of these files.
30595  The linker creates the .cdb
30596 \begin_inset LatexCommand index
30597 name "<file>.cdb"
30598
30599 \end_inset
30600
30601  file from the .adb
30602 \begin_inset LatexCommand index
30603 name "<file>.adb"
30604
30605 \end_inset
30606
30607  files and the address information.
30608  This .cdb is used by the debugger.
30609 \end_layout
30610
30611 \begin_layout Subsection
30612 How the Debugger Works
30613 \end_layout
30614
30615 \begin_layout Standard
30616 When the -
30617 \begin_inset ERT
30618 status collapsed
30619
30620 \begin_layout Standard
30621
30622
30623 \backslash
30624 /
30625 \end_layout
30626
30627 \end_inset
30628
30629 -debug option is specified the compiler generates extra symbol information
30630  some of which are put into the assembler source and some are put into the
30631  .adb file.
30632  Then the linker creates the .cdb file from the individual .adb files with
30633  the address information for the symbols.
30634  The debugger reads the symbolic information generated by the compiler &
30635  the address information generated by the linker.
30636  It uses the SIMULATOR (Daniel's S51) to execute the program, the program
30637  execution is controlled by the debugger.
30638  When a command is issued for the debugger, it translates it into appropriate
30639  commands for the simulator.
30640  (Currently SDCDM only connects to the simulator but 
30641 \emph on
30642 newcdb
30643 \emph default
30644  at 
30645 \begin_inset LatexCommand url
30646 target "http://ec2drv.sf.net/"
30647
30648 \end_inset
30649
30650  is an effort to connect directly to the hardware.) 
30651 \end_layout
30652
30653 \begin_layout Subsection
30654 Starting the Debugger SDCDB
30655 \end_layout
30656
30657 \begin_layout Standard
30658 The debugger can be started using the following command line.
30659  (Assume the file you are debugging has the file name foo).
30660 \newline
30661
30662 \newline
30663
30664 \family sans
30665 \series bold
30666 sdcdb foo
30667 \newline
30668
30669 \family default
30670 \series default
30671
30672 \newline
30673 The debugger will look for the following files.
30674 \end_layout
30675
30676 \begin_layout Itemize
30677 foo.c - the source file.
30678 \end_layout
30679
30680 \begin_layout Itemize
30681 foo.cdb - the debugger symbol information file.
30682 \end_layout
30683
30684 \begin_layout Itemize
30685 foo.ihx - the Intel hex format
30686 \begin_inset LatexCommand index
30687 name "Intel hex format"
30688
30689 \end_inset
30690
30691  object file.
30692 \end_layout
30693
30694 \begin_layout Subsection
30695 SDCDB Command Line Options
30696 \end_layout
30697
30698 \begin_layout Itemize
30699 -
30700 \begin_inset ERT
30701 status collapsed
30702
30703 \begin_layout Standard
30704
30705
30706 \backslash
30707 /
30708 \end_layout
30709
30710 \end_inset
30711
30712 -directory=<source file directory> this option can used to specify the directory
30713  search list.
30714  The debugger will look into the directory list specified for source, cdb
30715  & ihx files.
30716  The items in the directory list must be separated by ':', e.g.
30717  if the source files can be in the directories /home/src1 and /home/src2,
30718  the -
30719 \begin_inset ERT
30720 status collapsed
30721
30722 \begin_layout Standard
30723
30724
30725 \backslash
30726 /
30727 \end_layout
30728
30729 \end_inset
30730
30731 -directory option should be -
30732 \begin_inset ERT
30733 status collapsed
30734
30735 \begin_layout Standard
30736
30737
30738 \backslash
30739 /
30740 \end_layout
30741
30742 \end_inset
30743
30744 -directory=/home/src1:/home/src2.
30745  Note there can be no spaces in the option.
30746  
30747 \end_layout
30748
30749 \begin_layout Itemize
30750 -cd <directory> - change to the <directory>.
30751 \end_layout
30752
30753 \begin_layout Itemize
30754 -fullname - used by GUI front ends.
30755 \end_layout
30756
30757 \begin_layout Itemize
30758 -cpu <cpu-type> - this argument is passed to the simulator please see the
30759  simulator docs for details.
30760 \end_layout
30761
30762 \begin_layout Itemize
30763 -X <Clock frequency > this options is passed to the simulator please see
30764  the simulator docs for details.
30765 \end_layout
30766
30767 \begin_layout Itemize
30768 -s <serial port file> passed to simulator see the simulator docs for details.
30769 \end_layout
30770
30771 \begin_layout Itemize
30772 -S <serial in,out> passed to simulator see the simulator docs for details.
30773 \end_layout
30774
30775 \begin_layout Itemize
30776 -k <port number> passed to simulator see the simulator docs for details.
30777 \end_layout
30778
30779 \begin_layout Subsection
30780 SDCDB Debugger Commands
30781 \end_layout
30782
30783 \begin_layout Standard
30784 As mentioned earlier the command interface for the debugger has been deliberatel
30785 y kept as close the GNU debugger gdb, as possible.
30786  This will help the integration with existing graphical user interfaces
30787  (like ddd, xxgdb or xemacs) existing for the GNU debugger.
30788  If you use a graphical user interface for the debugger you can skip this
30789  section.
30790 \end_layout
30791
30792 \begin_layout Subsubsection*
30793 break [line | file:line | function | file:function]
30794 \end_layout
30795
30796 \begin_layout Standard
30797 Set breakpoint at specified line or function:
30798 \newline
30799
30800 \newline
30801
30802 \family sans
30803 \series bold
30804 sdcdb>break 100 
30805 \newline
30806 sdcdb>break foo.c:100
30807 \newline
30808 sdcdb>break funcfoo
30809 \newline
30810 sdcdb>break foo.c:funcfoo
30811 \end_layout
30812
30813 \begin_layout Subsubsection*
30814 clear [line | file:line | function | file:function ]
30815 \end_layout
30816
30817 \begin_layout Standard
30818 Clear breakpoint at specified line or function:
30819 \newline
30820
30821 \newline
30822
30823 \family sans
30824 \series bold
30825 sdcdb>clear 100
30826 \newline
30827 sdcdb>clear foo.c:100
30828 \newline
30829 sdcdb>clear funcfoo
30830 \newline
30831 sdcdb>clear foo.c:funcfoo
30832 \end_layout
30833
30834 \begin_layout Subsubsection*
30835 continue
30836 \end_layout
30837
30838 \begin_layout Standard
30839 Continue program being debugged, after breakpoint.
30840 \end_layout
30841
30842 \begin_layout Subsubsection*
30843 finish
30844 \end_layout
30845
30846 \begin_layout Standard
30847 Execute till the end of the current function.
30848 \end_layout
30849
30850 \begin_layout Subsubsection*
30851 delete [n]
30852 \end_layout
30853
30854 \begin_layout Standard
30855 Delete breakpoint number 'n'.
30856  If used without any option clear ALL user defined break points.
30857 \end_layout
30858
30859 \begin_layout Subsubsection*
30860 info [break | stack | frame | registers ]
30861 \end_layout
30862
30863 \begin_layout Itemize
30864 info break - list all breakpoints
30865 \end_layout
30866
30867 \begin_layout Itemize
30868 info stack - show the function call stack.
30869 \end_layout
30870
30871 \begin_layout Itemize
30872 info frame - show information about the current execution frame.
30873 \end_layout
30874
30875 \begin_layout Itemize
30876 info registers - show content of all registers.
30877 \end_layout
30878
30879 \begin_layout Subsubsection*
30880 step
30881 \end_layout
30882
30883 \begin_layout Standard
30884 Step program until it reaches a different source line.
30885  Note: pressing <return> repeats the last command.
30886 \end_layout
30887
30888 \begin_layout Subsubsection*
30889 next
30890 \end_layout
30891
30892 \begin_layout Standard
30893 Step program, proceeding through subroutine calls.
30894 \end_layout
30895
30896 \begin_layout Subsubsection*
30897 run
30898 \end_layout
30899
30900 \begin_layout Standard
30901 Start debugged program.
30902 \end_layout
30903
30904 \begin_layout Subsubsection*
30905 ptype variable 
30906 \end_layout
30907
30908 \begin_layout Standard
30909 Print type information of the variable.
30910 \end_layout
30911
30912 \begin_layout Subsubsection*
30913 print variable
30914 \end_layout
30915
30916 \begin_layout Standard
30917 print value of variable.
30918 \end_layout
30919
30920 \begin_layout Subsubsection*
30921 file filename
30922 \end_layout
30923
30924 \begin_layout Standard
30925 load the given file name.
30926  Note this is an alternate method of loading file for debugging.
30927 \end_layout
30928
30929 \begin_layout Subsubsection*
30930 frame
30931 \end_layout
30932
30933 \begin_layout Standard
30934 print information about current frame.
30935 \end_layout
30936
30937 \begin_layout Subsubsection*
30938 set srcmode
30939 \end_layout
30940
30941 \begin_layout Standard
30942 Toggle between C source & assembly source.
30943 \end_layout
30944
30945 \begin_layout Subsubsection*
30946 ! simulator command
30947 \end_layout
30948
30949 \begin_layout Standard
30950 Send the string following '!' to the simulator, the simulator response is
30951  displayed.
30952  Note the debugger does not interpret the command being sent to the simulator,
30953  so if a command like 'go' is sent the debugger can loose its execution
30954  context and may display incorrect values.
30955 \end_layout
30956
30957 \begin_layout Subsubsection*
30958 quit
30959 \end_layout
30960
30961 \begin_layout Standard
30962 "Watch me now.
30963  Iam going Down.
30964  My name is Bobby Brown"
30965 \end_layout
30966
30967 \begin_layout Subsection
30968 Interfacing SDCDB with DDD
30969 \end_layout
30970
30971 \begin_layout Standard
30972 \begin_inset Note Note
30973 status collapsed
30974
30975 \begin_layout Standard
30976 The screenshot was converted from png to eps with: 
30977 \begin_inset Quotes sld
30978 \end_inset
30979
30980 bmeps -c -e8f -p3 ddd_example.png >ddd_example.eps
30981 \begin_inset Quotes srd
30982 \end_inset
30983
30984  which produces a pretty compact eps file which is free from compression
30985  artifacts.
30986 \end_layout
30987
30988 \begin_layout Standard
30989 The screenshot was included in sdccman.lyx cvs version 1.120 but later removed
30990  as this broke the build system on Sourceforge (pdf-file was broken.
30991  pdflatex does not accept eps files).
30992 \end_layout
30993
30994 \end_inset
30995
30996
30997 \end_layout
30998
30999 \begin_layout Standard
31000 The 
31001 \emph on
31002 p
31003 \emph default
31004 ortable 
31005 \emph on
31006 n
31007 \emph default
31008 etwork 
31009 \emph on
31010 g
31011 \emph default
31012 raphics File 
31013 \size footnotesize
31014
31015 \begin_inset LatexCommand url
31016 target "http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/doc/figures/ddd_example.png"
31017
31018 \end_inset
31019
31020
31021 \size default
31022  shows a screenshot of a debugging session with DDD
31023 \begin_inset LatexCommand index
31024 name "DDD (debugger)"
31025
31026 \end_inset
31027
31028  (Unix only) on a simulated 8032.
31029  The debugging session might not run as smoothly as the screenshot suggests.
31030  The debugger allows setting of breakpoints, displaying and changing variables,
31031  single stepping through C and assembler code.
31032  
31033 \newline
31034 The source was compiled with 
31035 \family sans
31036 \series bold
31037
31038 \newline
31039
31040 \newline
31041 sdcc -
31042 \family default
31043 \series default
31044
31045 \begin_inset ERT
31046 status collapsed
31047
31048 \begin_layout Standard
31049
31050
31051 \backslash
31052 /
31053 \end_layout
31054
31055 \end_inset
31056
31057
31058 \family sans
31059 \series bold
31060 -debug ddd_example.c
31061 \family default
31062 \series default
31063  
31064 \family sans
31065 \series bold
31066
31067 \newline
31068
31069 \family default
31070 \series default
31071
31072 \newline
31073 and DDD was invoked with 
31074 \family sans
31075 \series bold
31076
31077 \newline
31078
31079 \newline
31080 ddd -debugger "sdcdb -cpu 8032 ddd_example"
31081 \end_layout
31082
31083 \begin_layout Standard
31084 \begin_inset Note Note
31085 status open
31086
31087 \begin_layout Standard
31088 Check that the double quotes or an apostrophe within the command line survive
31089  the LyX tool chain.
31090  Previously the apostrophes got slanted in the PDF output so a cut and paste
31091  did not work.
31092 \end_layout
31093
31094 \end_inset
31095
31096
31097 \end_layout
31098
31099 \begin_layout Subsection
31100 Interfacing SDCDB with XEmacs
31101 \begin_inset LatexCommand index
31102 name "XEmacs"
31103
31104 \end_inset
31105
31106
31107 \begin_inset LatexCommand index
31108 name "Emacs"
31109
31110 \end_inset
31111
31112
31113 \end_layout
31114
31115 \begin_layout Standard
31116 Two files (in emacs lisp) are provided for the interfacing with XEmacs,
31117  sdcdb.el and sdcdbsrc.el.
31118  These two files can be found in the $(prefix)/bin directory after the installat
31119 ion is complete.
31120  These files need to be loaded into XEmacs for the interface to work.
31121  This can be done at XEmacs startup time by inserting the following into
31122  your '.xemacs' file (which can be found in your HOME directory): 
31123 \newline
31124
31125 \newline
31126
31127 \family typewriter
31128 (load-file sdcdbsrc.el)
31129 \family default
31130  
31131 \newline
31132
31133 \newline
31134 .xemacs is a lisp file so the () around the command is REQUIRED.
31135  The files can also be loaded dynamically while XEmacs is running, set the
31136  environment variable 'EMACSLOADPATH' to the installation bin directory
31137  (<installdir>/bin), then enter the following command ESC-x load-file sdcdbsrc.
31138  To start the interface enter the following command: 
31139 \newline
31140
31141 \newline
31142
31143 \family sans
31144 \series bold
31145 ESC-x sdcdbsrc
31146 \family default
31147 \series default
31148
31149 \newline
31150
31151 \newline
31152 You will prompted to enter the file name to be debugged.
31153  
31154 \newline
31155
31156 \newline
31157 The command line options that are passed to the simulator directly are
31158  bound to default values in the file sdcdbsrc.el.
31159  The variables are listed below, these values maybe changed as required.
31160 \end_layout
31161
31162 \begin_layout Itemize
31163 sdcdbsrc-cpu-type '51
31164 \end_layout
31165
31166 \begin_layout Itemize
31167 sdcdbsrc-frequency '11059200
31168 \end_layout
31169
31170 \begin_layout Itemize
31171 sdcdbsrc-serial nil
31172 \end_layout
31173
31174 \begin_layout Standard
31175 The following is a list of key mapping for the debugger interface.
31176 \end_layout
31177
31178 \begin_layout Standard
31179 \InsetSpace ~
31180
31181 \family typewriter
31182
31183 \newline
31184 ;;\InsetSpace ~
31185 Current Listing :: 
31186 \newline
31187 ;;key\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 binding\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 \InsetSpace ~
31219 \InsetSpace ~
31220 \InsetSpace ~
31221 \InsetSpace ~
31222 \InsetSpace ~
31223 Comment 
31224 \newline
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 \InsetSpace ~
31239 -------\InsetSpace ~
31240 \InsetSpace ~
31241 \InsetSpace ~
31242 \InsetSpace ~
31243 \InsetSpace ~
31244 \InsetSpace ~
31245 \InsetSpace ~
31246 \InsetSpace ~
31247 \InsetSpace ~
31248 \InsetSpace ~
31249 \InsetSpace ~
31250 \InsetSpace ~
31251 \InsetSpace ~
31252 \InsetSpace ~
31253 \InsetSpace ~
31254 \InsetSpace ~
31255 \InsetSpace ~
31256 \InsetSpace ~
31257 \InsetSpace ~
31258 \InsetSpace ~
31259 \InsetSpace ~
31260 \InsetSpace ~
31261 -------
31262 \newline
31263 ;; 
31264 \newline
31265 ;;\InsetSpace ~
31266 n\InsetSpace ~
31267 \InsetSpace ~
31268 \InsetSpace ~
31269 \InsetSpace ~
31270 \InsetSpace ~
31271 \InsetSpace ~
31272 \InsetSpace ~
31273 \InsetSpace ~
31274 \InsetSpace ~
31275 \InsetSpace ~
31276 \InsetSpace ~
31277 \InsetSpace ~
31278 \InsetSpace ~
31279 \InsetSpace ~
31280 \InsetSpace ~
31281 sdcdb-next-fro
31282 m-src\InsetSpace ~
31283 \InsetSpace ~
31284 \InsetSpace ~
31285 \InsetSpace ~
31286 \InsetSpace ~
31287 \InsetSpace ~
31288 \InsetSpace ~
31289 \InsetSpace ~
31290 \InsetSpace ~
31291 \InsetSpace ~
31292 SDCDB next command 
31293 \newline
31294 ;;\InsetSpace ~
31295 b\InsetSpace ~
31296 \InsetSpace ~
31297 \InsetSpace ~
31298 \InsetSpace ~
31299 \InsetSpace ~
31300 \InsetSpace ~
31301 \InsetSpace ~
31302 \InsetSpace ~
31303 \InsetSpace ~
31304 \InsetSpace ~
31305 \InsetSpace ~
31306 \InsetSpace ~
31307 \InsetSpace ~
31308 \InsetSpace ~
31309 \InsetSpace ~
31310 sdcdb-back-from-src\InsetSpace ~
31311 \InsetSpace ~
31312 \InsetSpace ~
31313 \InsetSpace ~
31314 \InsetSpace ~
31315 \InsetSpace ~
31316 \InsetSpace ~
31317 \InsetSpace ~
31318 \InsetSpace ~
31319 \InsetSpace ~
31320 SDCDB back command 
31321 \newline
31322 ;;\InsetSpace ~
31323 c\InsetSpace ~
31324 \InsetSpace ~
31325 \InsetSpace ~
31326 \InsetSpace ~
31327 \InsetSpace ~
31328 \InsetSpace ~
31329 \InsetSpace ~
31330 \InsetSpace ~
31331 \InsetSpace ~
31332 \InsetSpace ~
31333 \InsetSpace ~
31334 \InsetSpace ~
31335 \InsetSpace ~
31336 \InsetSpace ~
31337 \InsetSpace ~
31338 sdcdb-cont-f
31339 rom-src\InsetSpace ~
31340 \InsetSpace ~
31341 \InsetSpace ~
31342 \InsetSpace ~
31343 \InsetSpace ~
31344 \InsetSpace ~
31345 \InsetSpace ~
31346 \InsetSpace ~
31347 \InsetSpace ~
31348 \InsetSpace ~
31349 SDCDB continue command
31350 \newline
31351 ;;\InsetSpace ~
31352 s\InsetSpace ~
31353 \InsetSpace ~
31354 \InsetSpace ~
31355 \InsetSpace ~
31356 \InsetSpace ~
31357 \InsetSpace ~
31358 \InsetSpace ~
31359 \InsetSpace ~
31360 \InsetSpace ~
31361 \InsetSpace ~
31362 \InsetSpace ~
31363 \InsetSpace ~
31364 \InsetSpace ~
31365 \InsetSpace ~
31366 \InsetSpace ~
31367 sdcdb-step-from-src\InsetSpace ~
31368 \InsetSpace ~
31369 \InsetSpace ~
31370 \InsetSpace ~
31371 \InsetSpace ~
31372 \InsetSpace ~
31373 \InsetSpace ~
31374 \InsetSpace ~
31375 \InsetSpace ~
31376 \InsetSpace ~
31377 SDCDB step command 
31378 \newline
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 sdcdb-w
31396 hatis-c-sexp\InsetSpace ~
31397 \InsetSpace ~
31398 \InsetSpace ~
31399 \InsetSpace ~
31400 \InsetSpace ~
31401 \InsetSpace ~
31402 \InsetSpace ~
31403 \InsetSpace ~
31404 \InsetSpace ~
31405 \InsetSpace ~
31406 SDCDB ptypecommand for data at 
31407 \newline
31408 ;;\InsetSpace ~
31409 \InsetSpace ~
31410 \InsetSpace ~
31411 \InsetSpace ~
31412 \InsetSpace ~
31413 \InsetSpace ~
31414 \InsetSpace ~
31415 \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 \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 \InsetSpace ~
31445 \InsetSpace ~
31446 \InsetSpace ~
31447 \InsetSpace ~
31448 \InsetSpace ~
31449 \InsetSpace ~
31450 \InsetSpace ~
31451 \InsetSpace ~
31452 \InsetSpace ~
31453 \InsetSpace ~
31454 \InsetSpace ~
31455 buffer point 
31456 \newline
31457 ;;\InsetSpace ~
31458 x\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 sdcdbsrc-delete\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 SDCD
31488 B Delete all breakpoints if no arg 
31489 \newline
31490 ;;\InsetSpace ~
31491 \InsetSpace ~
31492 \InsetSpace ~
31493 \InsetSpace ~
31494 \InsetSpace ~
31495 \InsetSpace ~
31496 \InsetSpace ~
31497 \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 \InsetSpace ~
31513 \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 \InsetSpace ~
31529 \InsetSpace ~
31530 \InsetSpace ~
31531 \InsetSpace ~
31532 \InsetSpace ~
31533 \InsetSpace ~
31534 \InsetSpace ~
31535 \InsetSpace ~
31536 \InsetSpace ~
31537 given or delete arg (C-u arg x) 
31538 \newline
31539 ;;\InsetSpace ~
31540 m\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 sdcdbsrc
31556 -frame\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 SDCDB Display current frame if no arg, 
31572 \newline
31573 ;;\InsetSpace ~
31574 \InsetSpace ~
31575 \InsetSpace ~
31576 \InsetSpace ~
31577 \InsetSpace ~
31578 \InsetSpace ~
31579 \InsetSpace ~
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 given or display frame arg
31621  
31622 \newline
31623 ;;\InsetSpace ~
31624 \InsetSpace ~
31625 \InsetSpace ~
31626 \InsetSpace ~
31627 \InsetSpace ~
31628 \InsetSpace ~
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 \InsetSpace ~
31646 \InsetSpace ~
31647 \InsetSpace ~
31648 \InsetSpace ~
31649 \InsetSpace ~
31650 \InsetSpace ~
31651 \InsetSpace ~
31652 \InsetSpace ~
31653 \InsetSpace ~
31654 \InsetSpace ~
31655 \InsetSpace ~
31656 \InsetSpace ~
31657 \InsetSpace ~
31658 \InsetSpace ~
31659 \InsetSpace ~
31660 \InsetSpace ~
31661 \InsetSpace ~
31662 \InsetSpace ~
31663 \InsetSpace ~
31664 \InsetSpace ~
31665 \InsetSpace ~
31666 \InsetSpace ~
31667 \InsetSpace ~
31668 \InsetSpace ~
31669 \InsetSpace ~
31670 buffer point 
31671 \newline
31672 ;;\InsetSpace ~
31673 !\InsetSpace ~
31674 \InsetSpace ~
31675 \InsetSpace ~
31676 \InsetSpace ~
31677 \InsetSpace ~
31678 \InsetSpace ~
31679 \InsetSpace ~
31680 \InsetSpace ~
31681 \InsetSpace ~
31682 \InsetSpace ~
31683 \InsetSpace ~
31684 \InsetSpace ~
31685 \InsetSpace ~
31686 \InsetSpace ~
31687 \InsetSpace ~
31688 sdcdbsrc-goto-sdcdb\InsetSpace ~
31689 \InsetSpace ~
31690 \InsetSpace ~
31691 \InsetSpace ~
31692 \InsetSpace ~
31693 \InsetSpace ~
31694 \InsetSpace ~
31695 \InsetSpace ~
31696 \InsetSpace ~
31697 \InsetSpace ~
31698 Goto the SDCDB output buffer 
31699 \newline
31700 ;;\InsetSpace ~
31701 p\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 sdcdb-prin
31717 t-c-sexp\InsetSpace ~
31718 \InsetSpace ~
31719 \InsetSpace ~
31720 \InsetSpace ~
31721 \InsetSpace ~
31722 \InsetSpace ~
31723 \InsetSpace ~
31724 \InsetSpace ~
31725 \InsetSpace ~
31726 \InsetSpace ~
31727 \InsetSpace ~
31728 SDCDB print command for data at 
31729 \newline
31730 ;;\InsetSpace ~
31731 \InsetSpace ~
31732 \InsetSpace ~
31733 \InsetSpace ~
31734 \InsetSpace ~
31735 \InsetSpace ~
31736 \InsetSpace ~
31737 \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 \InsetSpace ~
31753 \InsetSpace ~
31754 \InsetSpace ~
31755 \InsetSpace ~
31756 \InsetSpace ~
31757 \InsetSpace ~
31758 \InsetSpace ~
31759 \InsetSpace ~
31760 \InsetSpace ~
31761 \InsetSpace ~
31762 \InsetSpace ~
31763 \InsetSpace ~
31764 \InsetSpace ~
31765 \InsetSpace ~
31766 \InsetSpace ~
31767 \InsetSpace ~
31768 \InsetSpace ~
31769 \InsetSpace ~
31770 \InsetSpace ~
31771 \InsetSpace ~
31772 \InsetSpace ~
31773 \InsetSpace ~
31774 \InsetSpace ~
31775 \InsetSpace ~
31776 \InsetSpace ~
31777 buffer point 
31778 \newline
31779 ;;\InsetSpace ~
31780 g\InsetSpace ~
31781 \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 sdcdbsrc-goto-sdcdb\InsetSpace ~
31796 \InsetSpace ~
31797 \InsetSpace ~
31798 \InsetSpace ~
31799 \InsetSpace ~
31800 \InsetSpace ~
31801 \InsetSpace ~
31802 \InsetSpace ~
31803 \InsetSpace ~
31804 \InsetSpace ~
31805 Got
31806 o the SDCDB output buffer 
31807 \newline
31808 ;;\InsetSpace ~
31809 t\InsetSpace ~
31810 \InsetSpace ~
31811 \InsetSpace ~
31812 \InsetSpace ~
31813 \InsetSpace ~
31814 \InsetSpace ~
31815 \InsetSpace ~
31816 \InsetSpace ~
31817 \InsetSpace ~
31818 \InsetSpace ~
31819 \InsetSpace ~
31820 \InsetSpace ~
31821 \InsetSpace ~
31822 \InsetSpace ~
31823 \InsetSpace ~
31824 sdcdbsrc-mode\InsetSpace ~
31825 \InsetSpace ~
31826 \InsetSpace ~
31827 \InsetSpace ~
31828 \InsetSpace ~
31829 \InsetSpace ~
31830 \InsetSpace ~
31831 \InsetSpace ~
31832 \InsetSpace ~
31833 \InsetSpace ~
31834 \InsetSpace ~
31835 \InsetSpace ~
31836 \InsetSpace ~
31837 \InsetSpace ~
31838 \InsetSpace ~
31839 \InsetSpace ~
31840 Toggles Sdcdbsrc mode (turns it
31841  off) 
31842 \newline
31843 ;; 
31844 \newline
31845 ;;\InsetSpace ~
31846 C-c\InsetSpace ~
31847 C-f\InsetSpace ~
31848 \InsetSpace ~
31849 \InsetSpace ~
31850 \InsetSpace ~
31851 \InsetSpace ~
31852 \InsetSpace ~
31853 \InsetSpace ~
31854 \InsetSpace ~
31855 \InsetSpace ~
31856 sdcdb-finish-from-src\InsetSpace ~
31857 \InsetSpace ~
31858 \InsetSpace ~
31859 \InsetSpace ~
31860 \InsetSpace ~
31861 \InsetSpace ~
31862 \InsetSpace ~
31863 \InsetSpace ~
31864 SDCDB finish command 
31865 \newline
31866 ;; 
31867 \newline
31868 ;;\InsetSpace ~
31869 C-x\InsetSpace ~
31870 SPC\InsetSpace ~
31871 \InsetSpace ~
31872 \InsetSpace ~
31873 \InsetSpace ~
31874 \InsetSpace ~
31875 \InsetSpace ~
31876 \InsetSpace ~
31877 \InsetSpace ~
31878 \InsetSpace ~
31879 sdcdb-brea
31880 k\InsetSpace ~
31881 \InsetSpace ~
31882 \InsetSpace ~
31883 \InsetSpace ~
31884 \InsetSpace ~
31885 \InsetSpace ~
31886 \InsetSpace ~
31887 \InsetSpace ~
31888 \InsetSpace ~
31889 \InsetSpace ~
31890 \InsetSpace ~
31891 \InsetSpace ~
31892 \InsetSpace ~
31893 \InsetSpace ~
31894 \InsetSpace ~
31895 \InsetSpace ~
31896 \InsetSpace ~
31897 \InsetSpace ~
31898 Set break for line with point 
31899 \newline
31900 ;;\InsetSpace ~
31901 ESC\InsetSpace ~
31902 t\InsetSpace ~
31903 \InsetSpace ~
31904 \InsetSpace ~
31905 \InsetSpace ~
31906 \InsetSpace ~
31907 \InsetSpace ~
31908 \InsetSpace ~
31909 \InsetSpace ~
31910 \InsetSpace ~
31911 \InsetSpace ~
31912 \InsetSpace ~
31913 sdcdbsrc-mode\InsetSpace ~
31914 \InsetSpace ~
31915 \InsetSpace ~
31916 \InsetSpace ~
31917 \InsetSpace ~
31918 \InsetSpace ~
31919 \InsetSpace ~
31920 \InsetSpace ~
31921 \InsetSpace ~
31922 \InsetSpace ~
31923 \InsetSpace ~
31924 \InsetSpace ~
31925 \InsetSpace ~
31926 \InsetSpace ~
31927 \InsetSpace ~
31928 \InsetSpace ~
31929 Toggle Sdcdbsrc mode 
31930 \newline
31931 ;;\InsetSpace ~
31932 ESC\InsetSpace ~
31933 m\InsetSpace ~
31934 \InsetSpace ~
31935 \InsetSpace ~
31936 \InsetSpace ~
31937 \InsetSpace ~
31938 \InsetSpace ~
31939 \InsetSpace ~
31940 \InsetSpace ~
31941 \InsetSpace ~
31942 \InsetSpace ~
31943 \InsetSpace ~
31944 sdc
31945 dbsrc-srcmode\InsetSpace ~
31946 \InsetSpace ~
31947 \InsetSpace ~
31948 \InsetSpace ~
31949 \InsetSpace ~
31950 \InsetSpace ~
31951 \InsetSpace ~
31952 \InsetSpace ~
31953 \InsetSpace ~
31954 \InsetSpace ~
31955 \InsetSpace ~
31956 \InsetSpace ~
31957 \InsetSpace ~
31958 Toggle list mode 
31959 \newline
31960 ;; 
31961 \newline
31962
31963 \family default
31964
31965 \newpage
31966
31967 \end_layout
31968
31969 \begin_layout Chapter
31970 TIPS
31971 \end_layout
31972
31973 \begin_layout Standard
31974 Here are a few guidelines that will help the compiler generate more efficient
31975  code, some of the tips are specific to this compiler others are generally
31976  good programming practice.
31977 \end_layout
31978
31979 \begin_layout Itemize
31980 Use the smallest data type to represent your data-value.
31981  If it is known in advance that the value is going to be less than 256 then
31982  use an 'unsigned char' instead of a 'short' or 'int'.
31983  Please note, that ANSI C requires both signed and unsigned chars to be
31984  promoted to 'signed int'
31985 \begin_inset LatexCommand index
31986 name "promotion to signed int"
31987
31988 \end_inset
31989
31990
31991 \begin_inset Marginal
31992 status collapsed
31993
31994 \begin_layout Standard
31995
31996 \series bold
31997 \InsetSpace ~
31998 !
31999 \end_layout
32000
32001 \end_inset
32002
32003  before doing any operation.
32004  This promotion
32005 \begin_inset LatexCommand index
32006 name "type promotion"
32007
32008 \end_inset
32009
32010
32011 \begin_inset LatexCommand label
32012 name "type promotion"
32013
32014 \end_inset
32015
32016  can be omitted, if the result is the same.
32017  The effect of the promotion rules together with the sign-extension is often
32018  surprising:
32019 \end_layout
32020
32021 \begin_deeper
32022 \begin_layout Verse
32023
32024 \family typewriter
32025 unsigned char uc = 0xfe;
32026 \newline
32027 if (uc * uc < 0) /* this is true! */
32028 \newline
32029 {
32030 \newline
32031 \InsetSpace ~
32032 \InsetSpace ~
32033 \InsetSpace ~
32034 \InsetSpace ~
32035 ....
32036 \newline
32037 }
32038 \end_layout
32039
32040 \begin_layout Standard
32041
32042 \family typewriter
32043 uc * uc
32044 \family default
32045  is evaluated as 
32046 \family typewriter
32047 (int) uc * (int) uc = (int) 0xfe * (int) 0xfe = (int) 0xfc04 = -1024
32048 \family default
32049 .
32050  
32051 \newline
32052 Another one:
32053 \end_layout
32054
32055 \begin_layout Verse
32056
32057 \family typewriter
32058 (unsigned char) -12 / (signed char) -3 = ...
32059 \end_layout
32060
32061 \begin_layout Standard
32062 No, the result is not 4:
32063 \end_layout
32064
32065 \begin_layout Verse
32066
32067 \family typewriter
32068 (int) (unsigned char) -12 / (int) (signed char) -3 =
32069 \newline
32070 (int) (unsigned char)
32071  0xf4 / (int) (signed char) 0xfd =
32072 \newline
32073 (int) 0x00f4 / (int) 0xfffd =
32074 \newline
32075 (int) 0x00f4
32076  / (int) 0xfffd =
32077 \newline
32078 (int) 244 / (int) -3 =
32079 \newline
32080 (int) -81 = (int) 0xffaf;
32081 \end_layout
32082
32083 \begin_layout Standard
32084 Don't complain, that gcc gives you a different result.
32085  gcc uses 32 bit ints, while SDCC uses 16 bit ints.
32086  Therefore the results are different.
32087 \newline
32088 From 
32089 \begin_inset Quotes sld
32090 \end_inset
32091
32092 comp.lang.c FAQ
32093 \begin_inset Quotes srd
32094 \end_inset
32095
32096 :
32097 \end_layout
32098
32099 \begin_layout Quote
32100
32101 \emph on
32102 If well-defined overflow characteristics are important and negative values
32103  are not, or if you want to steer clear of sign-extension problems when
32104  manipulating bits or bytes, use one of the corresponding unsigned types.
32105  (Beware when mixing signed and unsigned values in expressions, though.)
32106 \newline
32107 Although
32108  character types (especially unsigned char) can be used as "tiny" integers,
32109  doing so is sometimes more trouble than it's worth, due to unpredictable
32110  sign extension and increased code size.
32111 \end_layout
32112
32113 \end_deeper
32114 \begin_layout Itemize
32115 Use unsigned when it is known in advance that the value is not going to
32116  be negative.
32117  This helps especially if you are doing division or multiplication, bit-shifting
32118  or are using an array index.
32119 \end_layout
32120
32121 \begin_layout Itemize
32122 NEVER jump into a LOOP.
32123 \end_layout
32124
32125 \begin_layout Itemize
32126 Declare the variables to be local
32127 \begin_inset LatexCommand index
32128 name "local variables"
32129
32130 \end_inset
32131
32132  whenever possible, especially loop control variables (induction).
32133 \end_layout
32134
32135 \begin_layout Itemize
32136 Have a look at the assembly listing to get a 
32137 \begin_inset Quotes sld
32138 \end_inset
32139
32140 feeling
32141 \begin_inset Quotes srd
32142 \end_inset
32143
32144  for the code generation.
32145 \end_layout
32146
32147 \begin_layout Section
32148 Porting code from or to other compilers
32149 \begin_inset LatexCommand label
32150 name "sec:Porting-code-to-other-compilers"
32151
32152 \end_inset
32153
32154
32155 \end_layout
32156
32157 \begin_layout Itemize
32158 check whether endianness of the compilers differs and adapt where needed.
32159 \end_layout
32160
32161 \begin_layout Itemize
32162 check the device specific header files
32163 \begin_inset LatexCommand index
32164 name "Header files"
32165
32166 \end_inset
32167
32168
32169 \begin_inset LatexCommand index
32170 name "Include files"
32171
32172 \end_inset
32173
32174  for compiler specific syntax.
32175  Eventually include the file <compiler.h
32176 \begin_inset LatexCommand index
32177 name "compiler.h (include file)"
32178
32179 \end_inset
32180
32181
32182 \begin_inset LatexCommand url
32183 target "http://sdcc.svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/device/include/mcs51/compiler.h?view=markup"
32184
32185 \end_inset
32186
32187  to allow using common header files.
32188  (see f.e.
32189  cc2510fx.h 
32190 \begin_inset LatexCommand url
32191 target "http://sdcc.svn.sourceforge.net/viewvc/sdcc/trunk/sdcc/device/include/mcs51/cc2510fx.h?view=markup"
32192
32193 \end_inset
32194
32195 ).
32196 \end_layout
32197
32198 \begin_layout Itemize
32199 check whether the startup code contains the correct initialization (watchdog,
32200  peripherals).
32201 \end_layout
32202
32203 \begin_layout Itemize
32204 check whether the sizes of short, int, long match.
32205 \end_layout
32206
32207 \begin_layout Itemize
32208 check if some 16 or 32 bit hardware registers require a specific addressing
32209  order (least significant or most significant byte first) and adapt if needed
32210  (
32211 \emph on
32212 first
32213 \emph default
32214  and 
32215 \emph on
32216 last
32217 \emph default
32218  relate to time and not to lower/upper memory location here, so this is
32219  
32220 \emph on
32221 not
32222 \emph default
32223  the same as endianness).
32224 \end_layout
32225
32226 \begin_layout Itemize
32227 check whether the keyword 
32228 \emph on
32229 volatile
32230 \emph default
32231  is used where needed.
32232  The compilers might differ in their optimization characteristics (as different
32233  versions of the same compiler might also use more clever optimizations
32234  this is good idea anyway).
32235  See section 
32236 \begin_inset LatexCommand ref
32237 reference "sub:Common-interrupt-pitfall-volatile"
32238
32239 \end_inset
32240
32241 .
32242 \end_layout
32243
32244 \begin_layout Itemize
32245 check that the compilers are not told to suppress warnings.
32246 \end_layout
32247
32248 \begin_layout Itemize
32249 check and convert compiler specific extensions (interrupts, memory areas,
32250  pragmas etc.).
32251 \end_layout
32252
32253 \begin_layout Itemize
32254 check for differences in type promotion.
32255  Especially check for math operations on 
32256 \family typewriter
32257 char
32258 \family default
32259  or 
32260 \family typewriter
32261 unsigned char
32262 \family default
32263  variables.
32264  For the sake of C99 compatibility SDCC will probably promote these to 
32265 \family typewriter
32266 int
32267 \family default
32268  more often than other compilers.
32269  Eventually insert explicit casts to 
32270 \family typewriter
32271 (char)
32272 \family default
32273  or 
32274 \family typewriter
32275 (unsigned char)
32276 \family default
32277 .
32278  Also check that the ~\InsetSpace ~
32279 operator
32280 \begin_inset LatexCommand index
32281 name "\\~\\/ Operator"
32282
32283 \end_inset
32284
32285  is not used on 
32286 \family typewriter
32287 bit
32288 \begin_inset LatexCommand index
32289 name "bit"
32290
32291 \end_inset
32292
32293
32294 \family default
32295  variables, use the !\InsetSpace ~
32296 operator instead.
32297  See sections 
32298 \begin_inset LatexCommand ref
32299 reference "type promotion"
32300
32301 \end_inset
32302
32303  and 
32304 \begin_inset LatexCommand ref
32305 reference "sec:Compatibility-with-previous"
32306
32307 \end_inset
32308
32309 .
32310 \end_layout
32311
32312 \begin_layout Itemize
32313 check the assembly code generated for interrupt routines (f.e.
32314  for calls to possibly non-reentrant library functions).
32315 \end_layout
32316
32317 \begin_layout Itemize
32318 check whether timing loops result in proper timing (or preferably consider
32319  a rewrite of the code with timer based delays instead).
32320 \end_layout
32321
32322 \begin_layout Itemize
32323 check for differences in printf parameters (some compilers push (va_arg
32324 \begin_inset LatexCommand index
32325 name "vararg, va\\_arg"
32326
32327 \end_inset
32328
32329 ) char variables as 
32330 \family typewriter
32331 int
32332 \family default
32333  others push them as 
32334 \family typewriter
32335 char
32336 \family default
32337 .
32338  See section 
32339 \begin_inset LatexCommand ref
32340 reference "sec:Compatibility-with-previous"
32341
32342 \end_inset
32343
32344 ).
32345 \end_layout
32346
32347 \begin_layout Itemize
32348 check the resulting memory map
32349 \begin_inset LatexCommand index
32350 name "Memory map"
32351
32352 \end_inset
32353
32354 .
32355  Usage of different memory spaces: code, stack, data (for mcs51/ds390 additional
32356 ly idata, pdata, xdata).
32357  Eventually check if unexpected library functions are included.
32358 \end_layout
32359
32360 \begin_layout Section
32361 Tools
32362 \begin_inset LatexCommand index
32363 name "Tools"
32364
32365 \end_inset
32366
32367  included in the distribution
32368 \end_layout
32369
32370 \begin_layout Standard
32371 \align left
32372 \begin_inset Tabular
32373 <lyxtabular version="3" rows="12" columns="3">
32374 <features>
32375 <column alignment="left" valignment="top" leftline="true" width="0pt">
32376 <column alignment="left" valignment="top" leftline="true" width="0pt">
32377 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0pt">
32378 <row topline="true" bottomline="true">
32379 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32380 \begin_inset Text
32381
32382 \begin_layout Standard
32383
32384 \series bold
32385 Name
32386 \end_layout
32387
32388 \end_inset
32389 </cell>
32390 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32391 \begin_inset Text
32392
32393 \begin_layout Standard
32394
32395 \series bold
32396 Purpose
32397 \end_layout
32398
32399 \end_inset
32400 </cell>
32401 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32402 \begin_inset Text
32403
32404 \begin_layout Standard
32405
32406 \series bold
32407 Directory
32408 \end_layout
32409
32410 \end_inset
32411 </cell>
32412 </row>
32413 <row topline="true">
32414 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32415 \begin_inset Text
32416
32417 \begin_layout Standard
32418 uCsim
32419 \begin_inset LatexCommand index
32420 name "uCsim"
32421
32422 \end_inset
32423
32424
32425 \end_layout
32426
32427 \end_inset
32428 </cell>
32429 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32430 \begin_inset Text
32431
32432 \begin_layout Standard
32433 Simulator for various architectures
32434 \end_layout
32435
32436 \end_inset
32437 </cell>
32438 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32439 \begin_inset Text
32440
32441 \begin_layout Standard
32442 sdcc/sim/ucsim
32443 \end_layout
32444
32445 \end_inset
32446 </cell>
32447 </row>
32448 <row topline="true">
32449 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32450 \begin_inset Text
32451
32452 \begin_layout Standard
32453 keil2sdcc.pl
32454 \end_layout
32455
32456 \end_inset
32457 </cell>
32458 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32459 \begin_inset Text
32460
32461 \begin_layout Standard
32462 header file
32463 \begin_inset LatexCommand index
32464 name "Header files"
32465
32466 \end_inset
32467
32468
32469 \begin_inset LatexCommand index
32470 name "Include files"
32471
32472 \end_inset
32473
32474  conversion
32475 \end_layout
32476
32477 \end_inset
32478 </cell>
32479 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32480 \begin_inset Text
32481
32482 \begin_layout Standard
32483 sdcc/support/scripts
32484 \end_layout
32485
32486 \end_inset
32487 </cell>
32488 </row>
32489 <row topline="true">
32490 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32491 \begin_inset Text
32492
32493 \begin_layout Standard
32494 mh2h.c
32495 \end_layout
32496
32497 \end_inset
32498 </cell>
32499 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32500 \begin_inset Text
32501
32502 \begin_layout Standard
32503 header file conversion
32504 \end_layout
32505
32506 \end_inset
32507 </cell>
32508 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32509 \begin_inset Text
32510
32511 \begin_layout Standard
32512 sdcc/support/scripts
32513 \end_layout
32514
32515 \end_inset
32516 </cell>
32517 </row>
32518 <row topline="true">
32519 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32520 \begin_inset Text
32521
32522 \begin_layout Standard
32523 as-gbz80
32524 \end_layout
32525
32526 \end_inset
32527 </cell>
32528 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32529 \begin_inset Text
32530
32531 \begin_layout Standard
32532 Assembler
32533 \end_layout
32534
32535 \end_inset
32536 </cell>
32537 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32538 \begin_inset Text
32539
32540 \begin_layout Standard
32541
32542 \family roman
32543 \series medium
32544 \shape up
32545 \size normal
32546 \emph off
32547 \bar no
32548 \noun off
32549 \color none
32550 sdcc/bin
32551 \end_layout
32552
32553 \end_inset
32554 </cell>
32555 </row>
32556 <row topline="true">
32557 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32558 \begin_inset Text
32559
32560 \begin_layout Standard
32561 as-z80
32562 \end_layout
32563
32564 \end_inset
32565 </cell>
32566 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32567 \begin_inset Text
32568
32569 \begin_layout Standard
32570 Assembler
32571 \end_layout
32572
32573 \end_inset
32574 </cell>
32575 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32576 \begin_inset Text
32577
32578 \begin_layout Standard
32579
32580 \family roman
32581 \series medium
32582 \shape up
32583 \size normal
32584 \emph off
32585 \bar no
32586 \noun off
32587 \color none
32588 sdcc/bin
32589 \end_layout
32590
32591 \end_inset
32592 </cell>
32593 </row>
32594 <row topline="true">
32595 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32596 \begin_inset Text
32597
32598 \begin_layout Standard
32599 asx8051
32600 \end_layout
32601
32602 \end_inset
32603 </cell>
32604 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32605 \begin_inset Text
32606
32607 \begin_layout Standard
32608 Assembler
32609 \end_layout
32610
32611 \end_inset
32612 </cell>
32613 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32614 \begin_inset Text
32615
32616 \begin_layout Standard
32617
32618 \family roman
32619 \series medium
32620 \shape up
32621 \size normal
32622 \emph off
32623 \bar no
32624 \noun off
32625 \color none
32626 sdcc/bin
32627 \end_layout
32628
32629 \end_inset
32630 </cell>
32631 </row>
32632 <row topline="true">
32633 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32634 \begin_inset Text
32635
32636 \begin_layout Standard
32637 SDCDB
32638 \end_layout
32639
32640 \end_inset
32641 </cell>
32642 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32643 \begin_inset Text
32644
32645 \begin_layout Standard
32646 Simulator
32647 \end_layout
32648
32649 \end_inset
32650 </cell>
32651 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32652 \begin_inset Text
32653
32654 \begin_layout Standard
32655
32656 \family roman
32657 \series medium
32658 \shape up
32659 \size normal
32660 \emph off
32661 \bar no
32662 \noun off
32663 \color none
32664 sdcc/bin
32665 \end_layout
32666
32667 \end_inset
32668 </cell>
32669 </row>
32670 <row topline="true">
32671 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32672 \begin_inset Text
32673
32674 \begin_layout Standard
32675 aslink
32676 \end_layout
32677
32678 \end_inset
32679 </cell>
32680 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32681 \begin_inset Text
32682
32683 \begin_layout Standard
32684 Linker
32685 \end_layout
32686
32687 \end_inset
32688 </cell>
32689 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32690 \begin_inset Text
32691
32692 \begin_layout Standard
32693
32694 \family roman
32695 \series medium
32696 \shape up
32697 \size normal
32698 \emph off
32699 \bar no
32700 \noun off
32701 \color none
32702 sdcc/bin
32703 \end_layout
32704
32705 \end_inset
32706 </cell>
32707 </row>
32708 <row topline="true">
32709 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32710 \begin_inset Text
32711
32712 \begin_layout Standard
32713 link-z80
32714 \end_layout
32715
32716 \end_inset
32717 </cell>
32718 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32719 \begin_inset Text
32720
32721 \begin_layout Standard
32722 Linker
32723 \end_layout
32724
32725 \end_inset
32726 </cell>
32727 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32728 \begin_inset Text
32729
32730 \begin_layout Standard
32731
32732 \family roman
32733 \series medium
32734 \shape up
32735 \size normal
32736 \emph off
32737 \bar no
32738 \noun off
32739 \color none
32740 sdcc/bin
32741 \end_layout
32742
32743 \end_inset
32744 </cell>
32745 </row>
32746 <row topline="true">
32747 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32748 \begin_inset Text
32749
32750 \begin_layout Standard
32751 link-gbz80
32752 \end_layout
32753
32754 \end_inset
32755 </cell>
32756 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32757 \begin_inset Text
32758
32759 \begin_layout Standard
32760 Linker
32761 \end_layout
32762
32763 \end_inset
32764 </cell>
32765 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32766 \begin_inset Text
32767
32768 \begin_layout Standard
32769
32770 \family roman
32771 \series medium
32772 \shape up
32773 \size normal
32774 \emph off
32775 \bar no
32776 \noun off
32777 \color none
32778 sdcc/bin
32779 \end_layout
32780
32781 \end_inset
32782 </cell>
32783 </row>
32784 <row topline="true" bottomline="true">
32785 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32786 \begin_inset Text
32787
32788 \begin_layout Standard
32789 packihx
32790 \end_layout
32791
32792 \end_inset
32793 </cell>
32794 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32795 \begin_inset Text
32796
32797 \begin_layout Standard
32798 Intel Hex packer 
32799 \begin_inset LatexCommand index
32800 name "packihx (tool)"
32801
32802 \end_inset
32803
32804
32805 \end_layout
32806
32807 \end_inset
32808 </cell>
32809 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32810 \begin_inset Text
32811
32812 \begin_layout Standard
32813
32814 \family roman
32815 \series medium
32816 \shape up
32817 \size normal
32818 \emph off
32819 \bar no
32820 \noun off
32821 \color none
32822 sdcc/bin
32823 \end_layout
32824
32825 \end_inset
32826 </cell>
32827 </row>
32828 </lyxtabular>
32829
32830 \end_inset
32831
32832
32833 \newline
32834
32835 \end_layout
32836
32837 \begin_layout Section
32838 Documentation
32839 \begin_inset LatexCommand index
32840 name "Documentation"
32841
32842 \end_inset
32843
32844  included in the distribution
32845 \end_layout
32846
32847 \begin_layout Standard
32848 \align left
32849 \begin_inset Tabular
32850 <lyxtabular version="3" rows="10" columns="2">
32851 <features>
32852 <column alignment="block" valignment="top" leftline="true" width="40col%">
32853 <column alignment="block" valignment="top" leftline="true" rightline="true" width="60col%">
32854 <row topline="true" bottomline="true" endhead="true">
32855 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32856 \begin_inset Text
32857
32858 \begin_layout Standard
32859
32860 \series bold
32861 Subject / Title
32862 \end_layout
32863
32864 \end_inset
32865 </cell>
32866 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32867 \begin_inset Text
32868
32869 \begin_layout Standard
32870
32871 \series bold
32872 Filename / Where to get
32873 \end_layout
32874
32875 \end_inset
32876 </cell>
32877 </row>
32878 <row topline="true">
32879 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32880 \begin_inset Text
32881
32882 \begin_layout Standard
32883 SDCC Compiler User Guide
32884 \end_layout
32885
32886 \end_inset
32887 </cell>
32888 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32889 \begin_inset Text
32890
32891 \begin_layout Standard
32892 You're reading it right now 
32893 \emph on
32894 \InsetSpace ~
32895 \InsetSpace ~
32896 \InsetSpace ~
32897
32898 \hfill
32899 online at:
32900 \emph default
32901
32902 \newline
32903
32904 \begin_inset LatexCommand url
32905 target "http://sdcc.sourceforge.net/doc/sdccman.pdf"
32906
32907 \end_inset
32908
32909
32910 \end_layout
32911
32912 \end_inset
32913 </cell>
32914 </row>
32915 <row topline="true">
32916 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32917 \begin_inset Text
32918
32919 \begin_layout Standard
32920 Changelog of SDCC
32921 \end_layout
32922
32923 \end_inset
32924 </cell>
32925 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
32926 \begin_inset Text
32927
32928 \begin_layout Standard
32929 sdcc/Changelog 
32930 \emph on
32931 \InsetSpace ~
32932 \InsetSpace ~
32933 \InsetSpace ~
32934
32935 \hfill
32936 online at:
32937 \emph default
32938
32939 \newline
32940
32941 \begin_inset LatexCommand url
32942 target "http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/ChangeLog"
32943
32944 \end_inset
32945
32946
32947 \end_layout
32948
32949 \end_inset
32950 </cell>
32951 </row>
32952 <row topline="true">
32953 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
32954 \begin_inset Text
32955
32956 \begin_layout Standard
32957 ASXXXX
32958 \begin_inset LatexCommand index
32959 name "asXXXX (as-gbz80, as-hc08, asx8051, as-z80)"
32960
32961 \end_inset
32962
32963
32964 \begin_inset LatexCommand index
32965 name "Assembler documentation"
32966
32967 \end_inset
32968
32969  Assemblers and
32970 \newline
32971 ASLINK
32972 \begin_inset LatexCommand index
32973 name "aslink"
32974
32975 \end_inset
32976
32977
32978 \begin_inset LatexCommand index
32979 name "Linker documentation"
32980
32981 \end_inset
32982
32983  Relocating Linker
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/as/doc/asxhtm.html 
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.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/as/doc/asxhtm.html"
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 SDCC regression test
33021 \begin_inset LatexCommand index
33022 name "Regression test"
33023
33024 \end_inset
33025
33026
33027 \end_layout
33028
33029 \end_inset
33030 </cell>
33031 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33032 \begin_inset Text
33033
33034 \begin_layout Standard
33035 sdcc/doc/test_suite_spec.pdf 
33036 \emph on
33037 \InsetSpace ~
33038 \InsetSpace ~
33039 \InsetSpace ~
33040
33041 \hfill
33042 online at:
33043 \emph default
33044
33045 \newline
33046
33047 \begin_inset LatexCommand url
33048 target "http://sdcc.sourceforge.net/doc/test_suite_spec.pdf"
33049
33050 \end_inset
33051
33052
33053 \end_layout
33054
33055 \end_inset
33056 </cell>
33057 </row>
33058 <row topline="true">
33059 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33060 \begin_inset Text
33061
33062 \begin_layout Standard
33063 Various notes
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/doc/* 
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/sdcc/trunk/sdcc/doc/"
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 Notes on debugging with SDCDB
33101 \begin_inset LatexCommand index
33102 name "SDCDB (debugger)"
33103
33104 \end_inset
33105
33106
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 sdcc/debugger/README 
33116 \emph on
33117 \InsetSpace ~
33118 \InsetSpace ~
33119 \InsetSpace ~
33120
33121 \hfill
33122 online at
33123 \emph default
33124 :
33125 \newline
33126
33127 \begin_inset LatexCommand url
33128 target "http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/debugger/README"
33129
33130 \end_inset
33131
33132
33133 \end_layout
33134
33135 \end_inset
33136 </cell>
33137 </row>
33138 <row topline="true">
33139 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33140 \begin_inset Text
33141
33142 \begin_layout Standard
33143 uCsim
33144 \begin_inset LatexCommand index
33145 name "uCsim"
33146
33147 \end_inset
33148
33149  Software simulator for microcontrollers
33150 \end_layout
33151
33152 \end_inset
33153 </cell>
33154 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33155 \begin_inset Text
33156
33157 \begin_layout Standard
33158
33159 \family roman
33160 \series medium
33161 \shape up
33162 \size normal
33163 \emph off
33164 \bar no
33165 \noun off
33166 \color none
33167 sdcc/sim/ucsim/doc
33168 \family default
33169 \series default
33170 \shape default
33171 \size default
33172 \emph default
33173 \bar default
33174 \noun default
33175 /index.html 
33176 \emph on
33177 \InsetSpace ~
33178 \InsetSpace ~
33179 \InsetSpace ~
33180
33181 \hfill
33182 online at:
33183 \emph default
33184
33185 \newline
33186
33187 \begin_inset LatexCommand url
33188 target "http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/sim/ucsim/doc/index.html"
33189
33190 \end_inset
33191
33192
33193 \end_layout
33194
33195 \end_inset
33196 </cell>
33197 </row>
33198 <row topline="true">
33199 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33200 \begin_inset Text
33201
33202 \begin_layout Standard
33203 Temporary notes on the pic16
33204 \begin_inset LatexCommand index
33205 name "PIC16"
33206
33207 \end_inset
33208
33209  port
33210 \end_layout
33211
33212 \end_inset
33213 </cell>
33214 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33215 \begin_inset Text
33216
33217 \begin_layout Standard
33218 sdcc/src/pic16/NOTES 
33219 \emph on
33220 \InsetSpace ~
33221 \InsetSpace ~
33222 \InsetSpace ~
33223
33224 \hfill
33225 online at:
33226 \newline
33227
33228 \emph default
33229
33230 \begin_inset LatexCommand url
33231 target "http://sdcc.svn.sourceforge.net/viewvc/*checkout*/sdcc/trunk/sdcc/src/pic16/NOTES"
33232
33233 \end_inset
33234
33235
33236 \end_layout
33237
33238 \end_inset
33239 </cell>
33240 </row>
33241 <row topline="true" bottomline="true">
33242 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33243 \begin_inset Text
33244
33245 \begin_layout Standard
33246 SDCC internal documentation (debugging file format)
33247 \end_layout
33248
33249 \end_inset
33250 </cell>
33251 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33252 \begin_inset Text
33253
33254 \begin_layout Standard
33255 sdcc/doc/
33256 \family roman
33257 \series medium
33258 \shape up
33259 \size normal
33260 \emph off
33261 \bar no
33262 \noun off
33263 \color none
33264 cdbfileformat.pd
33265 \family default
33266 \series default
33267 \shape default
33268 \size default
33269 \emph default
33270 \bar default
33271 \noun default
33272
33273 \emph on
33274 \InsetSpace ~
33275 \InsetSpace ~
33276 \InsetSpace ~
33277
33278 \hfill
33279 online at:
33280 \emph default
33281
33282 \newline
33283
33284 \begin_inset LatexCommand url
33285 target "http://sdcc.sourceforge.net/doc/cdbfileformat.pdf"
33286
33287 \end_inset
33288
33289
33290 \end_layout
33291
33292 \end_inset
33293 </cell>
33294 </row>
33295 </lyxtabular>
33296
33297 \end_inset
33298
33299
33300 \newline
33301
33302 \end_layout
33303
33304 \begin_layout Section
33305 Related open source tools
33306 \begin_inset LatexCommand label
33307 name "sec:Related-open-source-tools"
33308
33309 \end_inset
33310
33311
33312 \begin_inset LatexCommand index
33313 name "Related tools"
33314
33315 \end_inset
33316
33317
33318 \end_layout
33319
33320 \begin_layout Standard
33321 \align left
33322 \begin_inset Tabular
33323 <lyxtabular version="3" rows="16" columns="3">
33324 <features>
33325 <column alignment="left" valignment="top" leftline="true" width="0pt">
33326 <column alignment="block" valignment="top" leftline="true" width="30line%">
33327 <column alignment="left" valignment="top" leftline="true" rightline="true" width="40col%">
33328 <row topline="true" bottomline="true">
33329 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33330 \begin_inset Text
33331
33332 \begin_layout Standard
33333
33334 \series bold
33335 Name
33336 \end_layout
33337
33338 \end_inset
33339 </cell>
33340 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33341 \begin_inset Text
33342
33343 \begin_layout Standard
33344
33345 \series bold
33346 Purpose
33347 \end_layout
33348
33349 \end_inset
33350 </cell>
33351 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33352 \begin_inset Text
33353
33354 \begin_layout Standard
33355
33356 \series bold
33357 Where to get
33358 \end_layout
33359
33360 \end_inset
33361 </cell>
33362 </row>
33363 <row topline="true">
33364 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33365 \begin_inset Text
33366
33367 \begin_layout Standard
33368 gpsim
33369 \begin_inset LatexCommand index
33370 name "gpsim (pic simulator)"
33371
33372 \end_inset
33373
33374
33375 \end_layout
33376
33377 \end_inset
33378 </cell>
33379 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33380 \begin_inset Text
33381
33382 \begin_layout Standard
33383 PIC simulator
33384 \end_layout
33385
33386 \end_inset
33387 </cell>
33388 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33389 \begin_inset Text
33390
33391 \begin_layout Standard
33392 \begin_inset LatexCommand url
33393 target "http://www.dattalo.com/gnupic/gpsim.html"
33394
33395 \end_inset
33396
33397
33398 \end_layout
33399
33400 \end_inset
33401 </cell>
33402 </row>
33403 <row topline="true">
33404 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33405 \begin_inset Text
33406
33407 \begin_layout Standard
33408 gputils
33409 \begin_inset LatexCommand index
33410 name "gputils (pic tools)"
33411
33412 \end_inset
33413
33414
33415 \end_layout
33416
33417 \end_inset
33418 </cell>
33419 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33420 \begin_inset Text
33421
33422 \begin_layout Standard
33423 GNU PIC utilities
33424 \end_layout
33425
33426 \end_inset
33427 </cell>
33428 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33429 \begin_inset Text
33430
33431 \begin_layout Standard
33432 \begin_inset LatexCommand url
33433 target "http://sourceforge.net/projects/gputils"
33434
33435 \end_inset
33436
33437
33438 \end_layout
33439
33440 \end_inset
33441 </cell>
33442 </row>
33443 <row topline="true">
33444 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33445 \begin_inset Text
33446
33447 \begin_layout Standard
33448 flP5
33449 \end_layout
33450
33451 \end_inset
33452 </cell>
33453 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33454 \begin_inset Text
33455
33456 \begin_layout Standard
33457 PIC programmer
33458 \end_layout
33459
33460 \end_inset
33461 </cell>
33462 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33463 \begin_inset Text
33464
33465 \begin_layout Standard
33466 \begin_inset LatexCommand url
33467 target "http://freshmeat.net/projects/flp5/"
33468
33469 \end_inset
33470
33471
33472 \end_layout
33473
33474 \end_inset
33475 </cell>
33476 </row>
33477 <row topline="true">
33478 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33479 \begin_inset Text
33480
33481 \begin_layout Standard
33482 ec2drv/newcdb
33483 \end_layout
33484
33485 \end_inset
33486 </cell>
33487 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33488 \begin_inset Text
33489
33490 \begin_layout Standard
33491 Tools for Silicon Laboratories JTAG debug adapter, partly based on SDCDB
33492  (Unix only)
33493 \end_layout
33494
33495 \end_inset
33496 </cell>
33497 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33498 \begin_inset Text
33499
33500 \begin_layout Standard
33501 \begin_inset LatexCommand url
33502 target "http://sourceforge.net/projects/ec2drv"
33503
33504 \end_inset
33505
33506
33507 \end_layout
33508
33509 \end_inset
33510 </cell>
33511 </row>
33512 <row topline="true">
33513 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33514 \begin_inset Text
33515
33516 \begin_layout Standard
33517 indent
33518 \begin_inset LatexCommand index
33519 name "indent (source formatting tool)"
33520
33521 \end_inset
33522
33523
33524 \end_layout
33525
33526 \end_inset
33527 </cell>
33528 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33529 \begin_inset Text
33530
33531 \begin_layout Standard
33532 Formats C source - Master of the white spaces
33533 \end_layout
33534
33535 \end_inset
33536 </cell>
33537 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33538 \begin_inset Text
33539
33540 \begin_layout Standard
33541 \begin_inset LatexCommand url
33542 target "http://directory.fsf.org/GNU/indent.html"
33543
33544 \end_inset
33545
33546
33547 \end_layout
33548
33549 \end_inset
33550 </cell>
33551 </row>
33552 <row topline="true">
33553 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33554 \begin_inset Text
33555
33556 \begin_layout Standard
33557 srecord
33558 \begin_inset LatexCommand index
33559 name "srecord (bin, hex, ... tool)"
33560
33561 \end_inset
33562
33563
33564 \end_layout
33565
33566 \end_inset
33567 </cell>
33568 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33569 \begin_inset Text
33570
33571 \begin_layout Standard
33572 Object file conversion, checksumming, ...
33573 \end_layout
33574
33575 \end_inset
33576 </cell>
33577 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33578 \begin_inset Text
33579
33580 \begin_layout Standard
33581 \begin_inset LatexCommand url
33582 target "http://sourceforge.net/projects/srecord"
33583
33584 \end_inset
33585
33586
33587 \end_layout
33588
33589 \end_inset
33590 </cell>
33591 </row>
33592 <row topline="true">
33593 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33594 \begin_inset Text
33595
33596 \begin_layout Standard
33597 objdump
33598 \begin_inset LatexCommand index
33599 name "objdump (tool)"
33600
33601 \end_inset
33602
33603
33604 \end_layout
33605
33606 \end_inset
33607 </cell>
33608 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33609 \begin_inset Text
33610
33611 \begin_layout Standard
33612 Object file conversion, ...
33613 \end_layout
33614
33615 \end_inset
33616 </cell>
33617 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33618 \begin_inset Text
33619
33620 \begin_layout Standard
33621 Part of binutils (should be there anyway)
33622 \end_layout
33623
33624 \end_inset
33625 </cell>
33626 </row>
33627 <row topline="true">
33628 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33629 \begin_inset Text
33630
33631 \begin_layout Standard
33632 cmon51
33633 \end_layout
33634
33635 \end_inset
33636 </cell>
33637 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33638 \begin_inset Text
33639
33640 \begin_layout Standard
33641 8051 monitor (hex up-/download, single step, disassemble)
33642 \end_layout
33643
33644 \end_inset
33645 </cell>
33646 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33647 \begin_inset Text
33648
33649 \begin_layout Standard
33650 \begin_inset LatexCommand url
33651 target "http://sourceforge.net/projects/cmon51"
33652
33653 \end_inset
33654
33655
33656 \end_layout
33657
33658 \end_inset
33659 </cell>
33660 </row>
33661 <row topline="true">
33662 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33663 \begin_inset Text
33664
33665 \begin_layout Standard
33666 doxygen
33667 \begin_inset LatexCommand index
33668 name "doxygen (source documentation tool)"
33669
33670 \end_inset
33671
33672
33673 \end_layout
33674
33675 \end_inset
33676 </cell>
33677 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33678 \begin_inset Text
33679
33680 \begin_layout Standard
33681 Source code documentation system
33682 \end_layout
33683
33684 \end_inset
33685 </cell>
33686 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33687 \begin_inset Text
33688
33689 \begin_layout Standard
33690 \begin_inset LatexCommand url
33691 target "http://www.doxygen.org"
33692
33693 \end_inset
33694
33695
33696 \end_layout
33697
33698 \end_inset
33699 </cell>
33700 </row>
33701 <row topline="true">
33702 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33703 \begin_inset Text
33704
33705 \begin_layout Standard
33706 kdevelop
33707 \end_layout
33708
33709 \end_inset
33710 </cell>
33711 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33712 \begin_inset Text
33713
33714 \begin_layout Standard
33715 IDE (has anyone tried integrating SDCC & SDCDB? Unix only)
33716 \end_layout
33717
33718 \end_inset
33719 </cell>
33720 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33721 \begin_inset Text
33722
33723 \begin_layout Standard
33724 \begin_inset LatexCommand url
33725 target "http://www.kdevelop.org"
33726
33727 \end_inset
33728
33729
33730 \end_layout
33731
33732 \end_inset
33733 </cell>
33734 </row>
33735 <row topline="true">
33736 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33737 \begin_inset Text
33738
33739 \begin_layout Standard
33740 paulmon
33741 \end_layout
33742
33743 \end_inset
33744 </cell>
33745 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33746 \begin_inset Text
33747
33748 \begin_layout Standard
33749 8051 monitor (hex up-/download, single step, disassemble)
33750 \end_layout
33751
33752 \end_inset
33753 </cell>
33754 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33755 \begin_inset Text
33756
33757 \begin_layout Standard
33758 \begin_inset LatexCommand url
33759 target "http://www.pjrc.com/tech/8051/paulmon2.html"
33760
33761 \end_inset
33762
33763
33764 \end_layout
33765
33766 \end_inset
33767 </cell>
33768 </row>
33769 <row topline="true">
33770 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33771 \begin_inset Text
33772
33773 \begin_layout Standard
33774 splint
33775 \begin_inset LatexCommand index
33776 name "splint (syntax checking tool)"
33777
33778 \end_inset
33779
33780
33781 \end_layout
33782
33783 \end_inset
33784 </cell>
33785 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33786 \begin_inset Text
33787
33788 \begin_layout Standard
33789 Statically checks c sources (see 
33790 \begin_inset LatexCommand ref
33791 reference "lyx:more-pedantic-SPLINT"
33792
33793 \end_inset
33794
33795 )
33796 \end_layout
33797
33798 \end_inset
33799 </cell>
33800 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33801 \begin_inset Text
33802
33803 \begin_layout Standard
33804 \begin_inset LatexCommand url
33805 target "http://www.splint.org"
33806
33807 \end_inset
33808
33809
33810 \end_layout
33811
33812 \end_inset
33813 </cell>
33814 </row>
33815 <row topline="true" bottomline="true">
33816 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33817 \begin_inset Text
33818
33819 \begin_layout Standard
33820 ddd
33821 \begin_inset LatexCommand index
33822 name "DDD (debugger)"
33823
33824 \end_inset
33825
33826
33827 \end_layout
33828
33829 \end_inset
33830 </cell>
33831 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33832 \begin_inset Text
33833
33834 \begin_layout Standard
33835 Debugger, serves nicely as GUI to SDCDB
33836 \begin_inset LatexCommand index
33837 name "SDCDB (debugger)"
33838
33839 \end_inset
33840
33841  (Unix only)
33842 \end_layout
33843
33844 \end_inset
33845 </cell>
33846 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
33847 \begin_inset Text
33848
33849 \begin_layout Standard
33850 \begin_inset LatexCommand url
33851 target "http://www.gnu.org/software/ddd/"
33852
33853 \end_inset
33854
33855
33856 \end_layout
33857
33858 \end_inset
33859 </cell>
33860 </row>
33861 <row bottomline="true">
33862 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33863 \begin_inset Text
33864
33865 \begin_layout Standard
33866 d52
33867 \begin_inset LatexCommand index
33868 name "d52"
33869
33870 \end_inset
33871
33872
33873 \begin_inset LatexCommand index
33874 name "d52 (disassembler)"
33875
33876 \end_inset
33877
33878
33879 \end_layout
33880
33881 \end_inset
33882 </cell>
33883 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33884 \begin_inset Text
33885
33886 \begin_layout Standard
33887 Disassembler, can count instruction cycles
33888 \begin_inset LatexCommand index
33889 name "instruction cycles (count)"
33890
33891 \end_inset
33892
33893 , use with options -pnd
33894 \end_layout
33895
33896 \end_inset
33897 </cell>
33898 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33899 \begin_inset Text
33900
33901 \begin_layout Standard
33902 \begin_inset LatexCommand url
33903 target "http://www.8052.com/users/disasm/"
33904
33905 \end_inset
33906
33907
33908 \end_layout
33909
33910 \end_inset
33911 </cell>
33912 </row>
33913 <row bottomline="true">
33914 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33915 \begin_inset Text
33916
33917 \begin_layout Standard
33918 cmake
33919 \begin_inset LatexCommand index
33920 name "cmake"
33921
33922 \end_inset
33923
33924
33925 \end_layout
33926
33927 \end_inset
33928 </cell>
33929 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33930 \begin_inset Text
33931
33932 \begin_layout Standard
33933 Cross platform build system, generates Makefiles
33934 \begin_inset LatexCommand index
33935 name "Makefile"
33936
33937 \end_inset
33938
33939  and project workspaces
33940 \begin_inset LatexCommand index
33941 name "project workspace"
33942
33943 \end_inset
33944
33945
33946 \end_layout
33947
33948 \end_inset
33949 </cell>
33950 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33951 \begin_inset Text
33952
33953 \begin_layout Standard
33954 \begin_inset LatexCommand url
33955 target "http://www.cmake.org"
33956
33957 \end_inset
33958
33959  \InsetSpace ~
33960 \InsetSpace ~
33961 \InsetSpace ~
33962 \InsetSpace ~
33963 and a dedicated wiki entry: 
33964 \begin_inset LatexCommand url
33965 target "http://www.cmake.org/Wiki/CmakeSdcc"
33966
33967 \end_inset
33968
33969
33970 \end_layout
33971
33972 \end_inset
33973 </cell>
33974 </row>
33975 </lyxtabular>
33976
33977 \end_inset
33978
33979
33980 \newline
33981
33982 \end_layout
33983
33984 \begin_layout Section
33985 Related documentation / recommended reading
33986 \end_layout
33987
33988 \begin_layout Standard
33989 \align left
33990 \begin_inset Tabular
33991 <lyxtabular version="3" rows="7" columns="3">
33992 <features>
33993 <column alignment="left" valignment="top" leftline="true" width="0pt">
33994 <column alignment="left" valignment="top" leftline="true" width="0">
33995 <column alignment="left" valignment="top" leftline="true" rightline="true" width="0pt">
33996 <row topline="true" bottomline="true">
33997 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
33998 \begin_inset Text
33999
34000 \begin_layout Standard
34001
34002 \series bold
34003 Name
34004 \end_layout
34005
34006 \end_inset
34007 </cell>
34008 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34009 \begin_inset Text
34010
34011 \begin_layout Standard
34012
34013 \series bold
34014 Subject / Title
34015 \end_layout
34016
34017 \end_inset
34018 </cell>
34019 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34020 \begin_inset Text
34021
34022 \begin_layout Standard
34023
34024 \series bold
34025 Where to get
34026 \end_layout
34027
34028 \end_inset
34029 </cell>
34030 </row>
34031 <row topline="true">
34032 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34033 \begin_inset Text
34034
34035 \begin_layout Standard
34036
34037 \family roman
34038 \series medium
34039 \shape up
34040 \size normal
34041 \emph off
34042 \bar no
34043 \noun off
34044 \color none
34045 c-refcard.pdf
34046 \end_layout
34047
34048 \end_inset
34049 </cell>
34050 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34051 \begin_inset Text
34052
34053 \begin_layout Standard
34054 C Reference Card
34055 \begin_inset LatexCommand index
34056 name "C Reference card"
34057
34058 \end_inset
34059
34060 , 2 pages
34061 \end_layout
34062
34063 \end_inset
34064 </cell>
34065 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34066 \begin_inset Text
34067
34068 \begin_layout Standard
34069 \begin_inset LatexCommand url
34070 target "http://refcards.com/refcards/c/index.html"
34071
34072 \end_inset
34073
34074
34075 \end_layout
34076
34077 \end_inset
34078 </cell>
34079 </row>
34080 <row topline="true">
34081 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34082 \begin_inset Text
34083
34084 \begin_layout Standard
34085 c-faq
34086 \end_layout
34087
34088 \end_inset
34089 </cell>
34090 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34091 \begin_inset Text
34092
34093 \begin_layout Standard
34094 C-FAQ
34095 \begin_inset LatexCommand index
34096 name "C FAQ"
34097
34098 \end_inset
34099
34100
34101 \end_layout
34102
34103 \end_inset
34104 </cell>
34105 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34106 \begin_inset Text
34107
34108 \begin_layout Standard
34109 \begin_inset LatexCommand url
34110 target "http://www.c-faq.com"
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 9899:TC2
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 C-Standard
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/standards.html#9899"
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 ISO/IEC DTR 18037
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 \begin_inset Quotes sld
34178 \end_inset
34179
34180 Extensions for Embedded C
34181 \begin_inset Quotes srd
34182 \end_inset
34183
34184
34185 \end_layout
34186
34187 \end_inset
34188 </cell>
34189 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34190 \begin_inset Text
34191
34192 \begin_layout Standard
34193
34194 \size footnotesize
34195 \begin_inset LatexCommand url
34196 target "http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1021.pdf"
34197
34198 \end_inset
34199
34200
34201 \end_layout
34202
34203 \end_inset
34204 </cell>
34205 </row>
34206 <row topline="true">
34207 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34208 \begin_inset Text
34209
34210 \begin_layout Standard
34211
34212 \end_layout
34213
34214 \end_inset
34215 </cell>
34216 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34217 \begin_inset Text
34218
34219 \begin_layout Standard
34220 Latest datasheet of target CPU
34221 \end_layout
34222
34223 \end_inset
34224 </cell>
34225 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34226 \begin_inset Text
34227
34228 \begin_layout Standard
34229 vendor
34230 \end_layout
34231
34232 \end_inset
34233 </cell>
34234 </row>
34235 <row topline="true" bottomline="true">
34236 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34237 \begin_inset Text
34238
34239 \begin_layout Standard
34240
34241 \end_layout
34242
34243 \end_inset
34244 </cell>
34245 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34246 \begin_inset Text
34247
34248 \begin_layout Standard
34249 Revision history of datasheet
34250 \end_layout
34251
34252 \end_inset
34253 </cell>
34254 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34255 \begin_inset Text
34256
34257 \begin_layout Standard
34258 vendor
34259 \end_layout
34260
34261 \end_inset
34262 </cell>
34263 </row>
34264 </lyxtabular>
34265
34266 \end_inset
34267
34268
34269 \newline
34270
34271 \end_layout
34272
34273 \begin_layout Section
34274 Application notes specifically for SDCC
34275 \end_layout
34276
34277 \begin_layout Standard
34278 SDCC makes no claims about the completeness of this list and about up-to-datenes
34279 s or correctness of the application notes
34280 \begin_inset LatexCommand index
34281 name "Application notes"
34282
34283 \end_inset
34284
34285 .
34286 \end_layout
34287
34288 \begin_layout Standard
34289 \align left
34290
34291 \size footnotesize
34292 \begin_inset Tabular
34293 <lyxtabular version="3" rows="7" columns="3">
34294 <features>
34295 <column alignment="block" valignment="top" leftline="true" width="17col%">
34296 <column alignment="block" valignment="top" leftline="true" width="27col%">
34297 <column alignment="block" valignment="top" leftline="true" rightline="true" width="57col%">
34298 <row topline="true" bottomline="true">
34299 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34300 \begin_inset Text
34301
34302 \begin_layout Standard
34303
34304 \series bold
34305 \size footnotesize
34306 Vendor
34307 \end_layout
34308
34309 \end_inset
34310 </cell>
34311 <cell alignment="left" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
34312 \begin_inset Text
34313
34314 \begin_layout Standard
34315
34316 \series bold
34317 \size footnotesize
34318 Subject / Title
34319 \end_layout
34320
34321 \end_inset
34322 </cell>
34323 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34324 \begin_inset Text
34325
34326 \begin_layout Standard
34327
34328 \series bold
34329 \size footnotesize
34330 Where to get
34331 \end_layout
34332
34333 \end_inset
34334 </cell>
34335 </row>
34336 <row topline="true">
34337 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34338 \begin_inset Text
34339
34340 \begin_layout Standard
34341
34342 \size footnotesize
34343 Maxim / Dallas
34344 \end_layout
34345
34346 \end_inset
34347 </cell>
34348 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34349 \begin_inset Text
34350
34351 \begin_layout Standard
34352
34353 \size footnotesize
34354 Using the SDCC Compiler for the DS80C400
34355 \begin_inset LatexCommand index
34356 name "DS80C400"
34357
34358 \end_inset
34359
34360
34361 \end_layout
34362
34363 \end_inset
34364 </cell>
34365 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34366 \begin_inset Text
34367
34368 \begin_layout Standard
34369
34370 \size footnotesize
34371 \begin_inset LatexCommand url
34372 target "http://pdfserv.maxim-ic.com/en/an/AN3346.pdf"
34373
34374 \end_inset
34375
34376
34377 \end_layout
34378
34379 \end_inset
34380 </cell>
34381 </row>
34382 <row topline="true">
34383 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34384 \begin_inset Text
34385
34386 \begin_layout Standard
34387
34388 \size footnotesize
34389 Maxim / Dallas
34390 \end_layout
34391
34392 \end_inset
34393 </cell>
34394 <cell multicolumn="1" alignment="left" valignment="top" topline="true" leftline="true" usebox="none" width="30line%">
34395 \begin_inset Text
34396
34397 \begin_layout Standard
34398
34399 \size footnotesize
34400 Using the Free SDCC C Compiler to Develop Firmware for the DS89C420/430/440/450
34401 \begin_inset LatexCommand index
34402 name "DS89C4x0"
34403
34404 \end_inset
34405
34406  Family of Microcontrollers
34407 \end_layout
34408
34409 \end_inset
34410 </cell>
34411 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34412 \begin_inset Text
34413
34414 \begin_layout Standard
34415
34416 \size footnotesize
34417 \begin_inset LatexCommand url
34418 target "http://pdfserv.maxim-ic.com/en/an/AN3477.pdf"
34419
34420 \end_inset
34421
34422
34423 \end_layout
34424
34425 \end_inset
34426 </cell>
34427 </row>
34428 <row topline="true">
34429 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34430 \begin_inset Text
34431
34432 \begin_layout Standard
34433
34434 \size footnotesize
34435 Silicon Laboratories / Cygnal
34436 \end_layout
34437
34438 \end_inset
34439 </cell>
34440 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34441 \begin_inset Text
34442
34443 \begin_layout Standard
34444
34445 \size footnotesize
34446 Integrating SDCC 8051 Tools Into The Silicon Labs IDE
34447 \begin_inset LatexCommand index
34448 name "IDE"
34449
34450 \end_inset
34451
34452
34453 \end_layout
34454
34455 \end_inset
34456 </cell>
34457 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34458 \begin_inset Text
34459
34460 \begin_layout Standard
34461
34462 \size footnotesize
34463 \begin_inset LatexCommand url
34464 target "http://www.silabs.com/public/documents/tpub_doc/anote/Microcontrollers/en/an198.pdf"
34465
34466 \end_inset
34467
34468
34469 \end_layout
34470
34471 \end_inset
34472 </cell>
34473 </row>
34474 <row topline="true">
34475 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34476 \begin_inset Text
34477
34478 \begin_layout Standard
34479
34480 \size footnotesize
34481 Ramtron / Goal Semiconductor
34482 \end_layout
34483
34484 \end_inset
34485 </cell>
34486 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34487 \begin_inset Text
34488
34489 \begin_layout Standard
34490
34491 \size footnotesize
34492 Interfacing SDCC to Syn and Textpad
34493 \end_layout
34494
34495 \end_inset
34496 </cell>
34497 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34498 \begin_inset Text
34499
34500 \begin_layout Standard
34501
34502 \size footnotesize
34503 \begin_inset LatexCommand url
34504 target "http://www.ramtron.com/doc/Products/Microcontroller/Support_Tools.asp"
34505
34506 \end_inset
34507
34508
34509 \end_layout
34510
34511 \end_inset
34512 </cell>
34513 </row>
34514 <row topline="true">
34515 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34516 \begin_inset Text
34517
34518 \begin_layout Standard
34519
34520 \size footnotesize
34521 Ramtron / Goal Semiconductor
34522 \end_layout
34523
34524 \end_inset
34525 </cell>
34526 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34527 \begin_inset Text
34528
34529 \begin_layout Standard
34530
34531 \size footnotesize
34532 Installing and Configuring SDCC and Crimson Editor 
34533 \end_layout
34534
34535 \end_inset
34536 </cell>
34537 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34538 \begin_inset Text
34539
34540 \begin_layout Standard
34541
34542 \size footnotesize
34543 \begin_inset LatexCommand url
34544 target "http://www.ramtron.com/doc/Products/Microcontroller/Support_Tools.asp"
34545
34546 \end_inset
34547
34548
34549 \end_layout
34550
34551 \end_inset
34552 </cell>
34553 </row>
34554 <row topline="true" bottomline="true">
34555 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34556 \begin_inset Text
34557
34558 \begin_layout Standard
34559
34560 \size footnotesize
34561 Texas Instruments
34562 \end_layout
34563
34564 \end_inset
34565 </cell>
34566 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
34567 \begin_inset Text
34568
34569 \begin_layout Standard
34570
34571 \size footnotesize
34572 MSC12xx Programming with SDCC
34573 \end_layout
34574
34575 \end_inset
34576 </cell>
34577 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
34578 \begin_inset Text
34579
34580 \begin_layout Standard
34581
34582 \size footnotesize
34583 \begin_inset LatexCommand url
34584 target "http://focus.ti.com/general/docs/lit/getliterature.tsp?literatureNumber=sbaa109&fileType=pdf"
34585
34586 \end_inset
34587
34588
34589 \end_layout
34590
34591 \end_inset
34592 </cell>
34593 </row>
34594 </lyxtabular>
34595
34596 \end_inset
34597
34598
34599 \end_layout
34600
34601 \begin_layout Section
34602 Some Questions
34603 \end_layout
34604
34605 \begin_layout Standard
34606 Some questions answered, some pointers given - it might be time to in turn
34607  ask 
34608 \emph on
34609 you
34610 \emph default
34611  some questions: 
34612 \end_layout
34613
34614 \begin_layout Itemize
34615 can you solve your project with the selected microcontroller? Would you
34616  find out early or rather late that your target is too small/slow/whatever?
34617  Can you switch to a slightly better device if it doesn't fit?
34618 \end_layout
34619
34620 \begin_layout Itemize
34621 should you solve the problem with an 8 bit CPU? Or would a 16/32 bit CPU
34622  and/or another programming language be more adequate? Would an operating
34623  system on the target device help?
34624 \end_layout
34625
34626 \begin_layout Itemize
34627 if you solved the problem, will the marketing department be happy?
34628 \end_layout
34629
34630 \begin_layout Itemize
34631 if the marketing department is happy, will customers be happy?
34632 \end_layout
34633
34634 \begin_layout Itemize
34635 if you're the project manager, marketing department and maybe even the customer
34636  in one person, have you tried to see the project from the outside?
34637 \end_layout
34638
34639 \begin_layout Itemize
34640 is the project done if you think it is done? Or is just that other interface/pro
34641 tocol/feature/configuration/option missing? How about website, manual(s),
34642  internationali(z|s)ation, packaging, labels, 2nd source for components,
34643  electromagnetic compatability/interference, documentation for production,
34644  production test software, update mechanism, patent issues?
34645 \end_layout
34646
34647 \begin_layout Itemize
34648 is your project adequately positioned in that magic triangle: fame, fortune,
34649  fun?
34650 \end_layout
34651
34652 \begin_layout Standard
34653 Maybe not all answers to these questions are known and some answers may
34654  even be 
34655 \emph on
34656 no
34657 \emph default
34658 , nevertheless knowing these questions may help you to avoid burnout
34659 \begin_inset Foot
34660 status open
34661
34662 \begin_layout Standard
34663 burnout is bad for electronic devices, programmers and motorcycle tyres
34664 \end_layout
34665
34666 \end_inset
34667
34668 .
34669  Chances are you didn't want to hear some of them...
34670 \end_layout
34671
34672 \begin_layout Chapter
34673 Support
34674 \begin_inset LatexCommand index
34675 name "Support"
34676
34677 \end_inset
34678
34679
34680 \end_layout
34681
34682 \begin_layout Standard
34683 SDCC has grown to be a large project.
34684  The compiler alone (without the preprocessor, assembler and linker) is
34685  well over 150,000 lines of code (blank stripped).
34686  The open source nature of this project is a key to its continued growth
34687  and support.
34688  You gain the benefit and support of many active software developers and
34689  end users.
34690  Is SDCC perfect? No, that's why we need your help.
34691  The developers take pride in fixing reported bugs.
34692  You can help by reporting the bugs and helping other SDCC users.
34693  There are lots of ways to contribute, and we encourage you to take part
34694  in making SDCC a great software package.
34695  
34696 \end_layout
34697
34698 \begin_layout Standard
34699 The SDCC project is hosted on the SDCC sourceforge site at 
34700 \begin_inset LatexCommand htmlurl
34701 target "http://sourceforge.net/projects/sdcc"
34702
34703 \end_inset
34704
34705 .
34706  You'll find the complete set of mailing lists
34707 \begin_inset LatexCommand index
34708 name "Mailing list(s)"
34709
34710 \end_inset
34711
34712 , forums, bug reporting system, patch submission
34713 \begin_inset LatexCommand index
34714 name "Patch submission"
34715
34716 \end_inset
34717
34718  system, download
34719 \begin_inset LatexCommand index
34720 name "download"
34721
34722 \end_inset
34723
34724  area and Subversion code repository
34725 \begin_inset LatexCommand index
34726 name "Subversion code repository"
34727
34728 \end_inset
34729
34730  there.
34731 \end_layout
34732
34733 \begin_layout Section
34734 Reporting Bugs
34735 \begin_inset LatexCommand index
34736 name "Bug reporting"
34737
34738 \end_inset
34739
34740
34741 \begin_inset LatexCommand index
34742 name "Reporting bugs"
34743
34744 \end_inset
34745
34746
34747 \end_layout
34748
34749 \begin_layout Standard
34750 The recommended way of reporting bugs is using the infrastructure of the
34751  sourceforge site.
34752  You can follow the status of bug reports there and have an overview about
34753  the known bugs.
34754 \end_layout
34755
34756 \begin_layout Standard
34757 Bug reports are automatically forwarded to the developer mailing list and
34758  will be fixed ASAP.
34759  When reporting a bug, it is very useful to include a small test program
34760  (the smaller the better) which reproduces the problem.
34761  If you can isolate the problem by looking at the generated assembly code,
34762  this can be very helpful.
34763  Compiling your program with the -
34764 \begin_inset ERT
34765 status collapsed
34766
34767 \begin_layout Standard
34768
34769
34770 \backslash
34771 /
34772 \end_layout
34773
34774 \end_inset
34775
34776 -dumpall
34777 \begin_inset LatexCommand index
34778 name "-\\/-dumpall"
34779
34780 \end_inset
34781
34782  option can sometimes be useful in locating optimization problems.
34783  When reporting a bug please make sure you:
34784 \end_layout
34785
34786 \begin_layout Enumerate
34787 Attach the code you are compiling with SDCC.
34788  
34789 \end_layout
34790
34791 \begin_layout Enumerate
34792 Specify the exact command you use to run SDCC, or attach your Makefile.
34793  
34794 \end_layout
34795
34796 \begin_layout Enumerate
34797 Specify the SDCC version (type "
34798 \family sans
34799 \series bold
34800 sdcc -v
34801 \family default
34802 \series default
34803 "), your platform, and operating system.
34804  
34805 \end_layout
34806
34807 \begin_layout Enumerate
34808 Provide an exact copy of any error message or incorrect output.
34809  
34810 \end_layout
34811
34812 \begin_layout Enumerate
34813 Put something meaningful in the subject of your message.
34814 \end_layout
34815
34816 \begin_layout Standard
34817 Please attempt to include these 5 important parts, as applicable, in all
34818  requests for support or when reporting any problems or bugs with SDCC.
34819  Though this will make your message lengthy, it will greatly improve your
34820  chance that SDCC users and developers will be able to help you.
34821  Some SDCC developers are frustrated by bug reports without code provided
34822  that they can use to reproduce and ultimately fix the problem, so please
34823  be sure to provide sample code if you are reporting a bug! 
34824 \end_layout
34825
34826 \begin_layout Standard
34827 Please have a short check that you are using a recent version of SDCC and
34828  the bug is not yet known.
34829  This is the link for reporting bugs: 
34830 \begin_inset LatexCommand htmlurl
34831 target "http://sourceforge.net/tracker/?group_id=599&atid=100599"
34832
34833 \end_inset
34834
34835 .
34836  With SDCC on average having more than 200 downloads
34837 \begin_inset LatexCommand index
34838 name "download"
34839
34840 \end_inset
34841
34842  on sourceforge per day
34843 \begin_inset Foot
34844 status open
34845
34846 \begin_layout Standard
34847 220 daily downloads on average Jan-Sept 2006 and about 150 daily downloads
34848  between 2002 and 2005.
34849  This does not include other methods of distribution.
34850 \end_layout
34851
34852 \end_inset
34853
34854  there must be some users.
34855  So it's not exactly easy to find a new bug.
34856  If you find one we need it: 
34857 \emph on
34858 reporting bugs is good
34859 \emph default
34860 .
34861 \end_layout
34862
34863 \begin_layout Section
34864 Requesting Features
34865 \begin_inset LatexCommand label
34866 name "sub:Requesting-Features"
34867
34868 \end_inset
34869
34870
34871 \begin_inset LatexCommand index
34872 name "Feature request"
34873
34874 \end_inset
34875
34876
34877 \begin_inset LatexCommand index
34878 name "Requesting features"
34879
34880 \end_inset
34881
34882
34883 \end_layout
34884
34885 \begin_layout Standard
34886 Like bug reports feature requests are forwarded to the developer mailing
34887  list.
34888  This is the link for requesting features: 
34889 \begin_inset LatexCommand htmlurl
34890 target "http://sourceforge.net/tracker/?group_id=599&atid=350599"
34891
34892 \end_inset
34893
34894 .
34895 \end_layout
34896
34897 \begin_layout Section
34898 Submitting patches
34899 \end_layout
34900
34901 \begin_layout Standard
34902 Like bug reports contributed patches are forwarded to the developer mailing
34903  list.
34904  This is the link for submitting patches
34905 \begin_inset LatexCommand index
34906 name "Patch submission"
34907
34908 \end_inset
34909
34910
34911 \begin_inset LatexCommand url
34912 target "http://sourceforge.net/tracker/?group_id=599&atid=300599"
34913
34914 \end_inset
34915
34916 .
34917 \end_layout
34918
34919 \begin_layout Standard
34920 You need to specify some parameters to the 
34921 \family typewriter
34922 diff
34923 \family default
34924  command for the patches to be useful.
34925  If you modified more than one file a patch created f.e.
34926  with 
34927 \family sans
34928 \series bold
34929
34930 \begin_inset Quotes sld
34931 \end_inset
34932
34933 diff -Naur unmodified_directory modified_directory >my_changes.patch
34934 \begin_inset Quotes srd
34935 \end_inset
34936
34937
34938 \family default
34939 \series default
34940  will be fine, otherwise 
34941 \family sans
34942 \series bold
34943
34944 \begin_inset Quotes sld
34945 \end_inset
34946
34947 diff -u sourcefile.c.orig sourcefile.c >my_changes.patch
34948 \begin_inset Quotes srd
34949 \end_inset
34950
34951
34952 \family default
34953 \series default
34954  will do.
34955 \end_layout
34956
34957 \begin_layout Section
34958 Getting Help
34959 \end_layout
34960
34961 \begin_layout Standard
34962 These links should take you directly to the 
34963 \begin_inset LatexCommand url
34964 name "Mailing lists"
34965 target "http://sourceforge.net/mail/?group_id=599"
34966
34967 \end_inset
34968
34969
34970 \begin_inset Foot
34971 status open
34972
34973 \begin_layout Standard
34974 Traffic on sdcc-devel and sdcc-user is about 100 mails/month each not counting
34975  automated messages (mid 2003)
34976 \end_layout
34977
34978 \end_inset
34979
34980  and the 
34981 \begin_inset LatexCommand url
34982 name "Forums"
34983 target "http://sourceforge.net/forum/?group_id=599"
34984
34985 \end_inset
34986
34987 , lists
34988 \begin_inset LatexCommand index
34989 name "Mailing list(s)"
34990
34991 \end_inset
34992
34993  and forums are archived and searchable so if you are lucky someone already
34994  had a similar problem.
34995  While mails to the lists themselves are delivered promptly their web front
34996  end on sourceforge sometimes shows a severe time lag (up to several weeks),
34997  if you're seriously using SDCC please consider subscribing to the lists.
34998 \end_layout
34999
35000 \begin_layout Section
35001 ChangeLog
35002 \end_layout
35003
35004 \begin_layout Standard
35005 You can follow the status of the Subversion version
35006 \begin_inset LatexCommand index
35007 name "version"
35008
35009 \end_inset
35010
35011  of SDCC by watching the Changelog
35012 \begin_inset LatexCommand index
35013 name "Changelog"
35014
35015 \end_inset
35016
35017  in the Subversion repository
35018 \size footnotesize
35019  
35020 \begin_inset LatexCommand htmlurl
35021 target "http://sdcc.svn.sourceforge.net/viewcvs.cgi/*checkout*/sdcc/trunk/sdcc/ChangeLog"
35022
35023 \end_inset
35024
35025 .
35026 \end_layout
35027
35028 \begin_layout Section
35029 Subversion Source Code Repository
35030 \end_layout
35031
35032 \begin_layout Standard
35033 The output of 
35034 \family sans
35035 \series bold
35036 sdcc -
35037 \family default
35038
35039 \begin_inset ERT
35040 status open
35041
35042 \begin_layout Standard
35043
35044
35045 \backslash
35046 /
35047 \end_layout
35048
35049 \end_inset
35050
35051
35052 \family sans
35053 -version
35054 \family default
35055 \series default
35056  or the filenames of the snapshot versions of SDCC include date and its
35057  Subversion
35058 \begin_inset LatexCommand index
35059 name "Subversion code repository"
35060
35061 \end_inset
35062
35063  number.
35064  Subversion allows to download the source of recent or previous versions
35065  
35066 \begin_inset LatexCommand url
35067 target "http://sourceforge.net/svn/?group_id=599"
35068
35069 \end_inset
35070
35071  (by number or by date).
35072  An on-line source code browser and detailled instructions are also available
35073  there.
35074  SDCC versions starting from 1999 up to now are available (currently the
35075  versions prior to the conversion from cvs
35076 \begin_inset LatexCommand index
35077 name "cvs|see{Subversion}"
35078
35079 \end_inset
35080
35081  to Subversion (April 2006) are either by accessible by Subversion or by
35082  cvs).
35083 \end_layout
35084
35085 \begin_layout Section
35086 Release policy
35087 \begin_inset LatexCommand index
35088 name "Release policy"
35089
35090 \end_inset
35091
35092
35093 \end_layout
35094
35095 \begin_layout Standard
35096 Historically there often were long delays between official releases and
35097  the sourceforge download area tends to get not updated at all.
35098  Excuses in the past might have referred to problems with live range analysis,
35099  but as this was fixed a while ago, the current problem is that another
35100  excuse has to be found.
35101  Kidding aside, we have to get better there! On the other hand there are
35102  daily snapshots available at 
35103 \begin_inset LatexCommand htmlurl
35104 name "snap"
35105 target "http://sdcc.sourceforge.net/snap.php"
35106
35107 \end_inset
35108
35109 , and you can always build the very last version (hopefully with many bugs
35110  fixed, and features added) from the source code available at 
35111 \begin_inset LatexCommand htmlurl
35112 name "Source"
35113 target "http://sdcc.sourceforge.net/snap.php#Source"
35114
35115 \end_inset
35116
35117 .
35118  The SDCC Wiki
35119 \begin_inset LatexCommand index
35120 name "wiki"
35121
35122 \end_inset
35123
35124
35125 \begin_inset LatexCommand index
35126 name "SDCC Wiki"
35127
35128 \end_inset
35129
35130  at 
35131 \begin_inset LatexCommand url
35132 target "http://sdcc.wiki.sourceforge.net/"
35133
35134 \end_inset
35135
35136  also holds some information about past and future releases.
35137 \end_layout
35138
35139 \begin_layout Section
35140 Examples
35141 \begin_inset LatexCommand index
35142 name "Examples"
35143
35144 \end_inset
35145
35146
35147 \end_layout
35148
35149 \begin_layout Standard
35150 You'll find some small examples in the directory 
35151 \emph on
35152 sdcc/device/examples/.
35153
35154 \emph default
35155  More examples and libraries are available at 
35156 \emph on
35157 The SDCC Open Knowledge Resource 
35158 \begin_inset LatexCommand url
35159 target "http://sdccokr.dl9sec.de/"
35160
35161 \end_inset
35162
35163
35164 \emph default
35165  web site or at 
35166 \begin_inset LatexCommand url
35167 target "http://www.pjrc.com/tech/8051/"
35168
35169 \end_inset
35170
35171 .
35172 \end_layout
35173
35174 \begin_layout Standard
35175 \begin_inset Note Note
35176 status collapsed
35177
35178 \begin_layout Standard
35179 I did insert a reference to Paul's web site here although it seems rather
35180  dedicated to a specific 8032 board (I think it's okay because it f.e.
35181  shows LCD/Harddisc interface and has a free 8051 monitor.
35182  Independent 8032 board vendors face hard competition of heavily subsidized
35183  development boards anyway).
35184 \end_layout
35185
35186 \begin_layout Standard
35187 Maybe we should include some links to real world applications.
35188  Preferably pointer to pointers (one for each architecture) so this stays
35189  manageable here?
35190 \end_layout
35191
35192 \end_inset
35193
35194
35195 \end_layout
35196
35197 \begin_layout Section
35198 Quality control
35199 \begin_inset LatexCommand label
35200 name "sec:Quality-control"
35201
35202 \end_inset
35203
35204
35205 \begin_inset LatexCommand index
35206 name "Quality control"
35207
35208 \end_inset
35209
35210
35211 \end_layout
35212
35213 \begin_layout Standard
35214 The compiler is passed through snaphot build compile and build checks.
35215  The so called 
35216 \shape italic
35217 regression tests
35218 \shape default
35219
35220 \begin_inset LatexCommand index
35221 name "Regression test"
35222
35223 \end_inset
35224
35225  check that SDCC itself compiles flawlessly on several host platforms (i386,
35226  Opteron, 64 bit Alpha, ppc64, Mac OS X on ppc and i386, Solaris on Sparc)
35227  and checks the quality of the code generated by SDCC by running the code
35228  for several target platforms through simulators.
35229  The regression test suite comprises more than 100 files which expand to
35230  more than 500 test cases which include more than 4500 tests.
35231  The results of these tests are published daily on SDCC's snapshot page
35232  (click on the red or green symbols on the right side of 
35233 \begin_inset LatexCommand url
35234 target "http://sdcc.sourceforge.net/snap.php"
35235
35236 \end_inset
35237
35238 ).
35239 \end_layout
35240
35241 \begin_layout Standard
35242 There is a separate document 
35243 \shape italic
35244 test_suite.pdf 
35245 \begin_inset LatexCommand index
35246 name "Test suite"
35247
35248 \end_inset
35249
35250
35251 \shape default
35252  
35253 \begin_inset LatexCommand url
35254 target "http://sdcc.sourceforge.net/doc/test_suite_spec.pdf"
35255
35256 \end_inset
35257
35258  about the regression test suite.
35259 \end_layout
35260
35261 \begin_layout Standard
35262 You'll find the test code in the directory 
35263 \shape italic
35264 sdcc/support/regression
35265 \shape default
35266 .
35267  You can run these tests manually by running 
35268 \family sans
35269 make
35270 \family default
35271  in this directory (or f.e.
35272  
35273 \family sans
35274 \series bold
35275
35276 \begin_inset Quotes sld
35277 \end_inset
35278
35279 make test-mcs51
35280 \begin_inset Quotes srd
35281 \end_inset
35282
35283
35284 \family default
35285 \series default
35286  if you don't want to run the complete tests).
35287  The test code might also be interesting if you want to look for examples
35288 \begin_inset LatexCommand index
35289 name "Examples"
35290
35291 \end_inset
35292
35293  checking corner cases of SDCC or if you plan to submit patches
35294 \begin_inset LatexCommand index
35295 name "Patch submission"
35296
35297 \end_inset
35298
35299 .
35300 \end_layout
35301
35302 \begin_layout Standard
35303 The PIC14 port uses a different set of regression tests 
35304 \begin_inset LatexCommand index
35305 name "Regression test (PIC14)"
35306
35307 \end_inset
35308
35309 , you'll find them in the directory 
35310 \shape italic
35311 sdcc/src/regression
35312 \shape default
35313 .
35314 \end_layout
35315
35316 \begin_layout Section
35317 Use of SDCC in Education
35318 \end_layout
35319
35320 \begin_layout Standard
35321 In short: 
35322 \emph on
35323 highly
35324 \emph default
35325  encouraged
35326 \begin_inset Foot
35327 status open
35328
35329 \begin_layout Standard
35330 the phrase "use in education" might evoke the association "
35331 \emph on
35332 only
35333 \emph default
35334  fit for use in education".
35335  This connotation is not intended but nevertheless risked as the licensing
35336  of SDCC makes it difficult to offer educational discounts
35337 \end_layout
35338
35339 \end_inset
35340
35341 .
35342  If your rationales are to:
35343 \end_layout
35344
35345 \begin_layout Enumerate
35346 give students a chance to understand the 
35347 \emph on
35348 complete
35349 \emph default
35350  steps of code generation
35351 \end_layout
35352
35353 \begin_layout Enumerate
35354 have a curriculum that can be extended for years.
35355  Then you could use an fpga board as target and your curriculum will seamlessly
35356  extend from logic synthesis (
35357 \begin_inset LatexCommand url
35358 name "http://www.opencores.org"
35359 target "opencores.org"
35360
35361 \end_inset
35362
35363
35364 \begin_inset LatexCommand url
35365 name "Oregano"
35366 target "http://www.oregano.at/ip/ip01.htm"
35367
35368 \end_inset
35369
35370 ), over assembly programming, to C to FPGA compilers (
35371 \begin_inset LatexCommand url
35372 name "FPGAC"
35373 target "http://sf.net/projects/fpgac"
35374
35375 \end_inset
35376
35377 ) and to C.
35378 \end_layout
35379
35380 \begin_layout Enumerate
35381 be able to insert excursions about skills like using a revision control
35382  system, submitting/applying patches, using a type-setting (as opposed to
35383  word-processing) engine LyX/LaTeX, using 
35384 \begin_inset LatexCommand url
35385 name "SourceForge"
35386 target "http://www.sf.net"
35387
35388 \end_inset
35389
35390 , following some 
35391 \begin_inset LatexCommand url
35392 name "netiquette"
35393 target "http://en.wikipedia.org/wiki/Netiquette"
35394
35395 \end_inset
35396
35397 , understanding BSD/LGPL/GPL/Proprietary licensing, growth models of Open
35398  Source Software, CPU simulation, compiler regression tests
35399 \begin_inset LatexCommand index
35400 name "Regression test"
35401
35402 \end_inset
35403
35404 .
35405  
35406 \newline
35407 And if there should be a shortage of ideas then you can always point students
35408  to the ever-growing feature request list 
35409 \begin_inset LatexCommand htmlurl
35410 target "http://sourceforge.net/tracker/?group_id=599&atid=350599"
35411
35412 \end_inset
35413
35414 .
35415 \end_layout
35416
35417 \begin_layout Enumerate
35418 not tie students to a specific host platform and instead allow them to use
35419  a host platform of 
35420 \emph on
35421 their
35422 \emph default
35423  choice (among them Alpha, i386, i386_64, Mac OS X, Mips, Sparc, Windows
35424  and eventually 
35425 \begin_inset LatexCommand url
35426 name "OLPC"
35427 target "http://www.laptop.org"
35428
35429 \end_inset
35430
35431 )
35432 \end_layout
35433
35434 \begin_layout Enumerate
35435 not encourage students to use illegal copies of educational software
35436 \end_layout
35437
35438 \begin_layout Enumerate
35439 be immune to licensing/availability/price changes of the chosen tool chain
35440 \end_layout
35441
35442 \begin_layout Enumerate
35443 be able to change to a new target platform without having to adopt a new
35444  tool chain
35445 \end_layout
35446
35447 \begin_layout Enumerate
35448 have complete control over and insight into the tool chain
35449 \end_layout
35450
35451 \begin_layout Enumerate
35452 make your students aware about the pros and cons of open source software
35453  development
35454 \end_layout
35455
35456 \begin_layout Enumerate
35457 give back to the public as you are probably at least partially publicly
35458  funded
35459 \end_layout
35460
35461 \begin_layout Enumerate
35462 give students a chance to publicly prove their skills and to possibly see
35463  a world wide impact
35464 \end_layout
35465
35466 \begin_layout Standard
35467 then SDCC is probably among the first choices.
35468  Well, probably SDCC might be the only choice.
35469 \newpage
35470
35471 \end_layout
35472
35473 \begin_layout Chapter
35474 SDCC Technical Data
35475 \end_layout
35476
35477 \begin_layout Section
35478 Optimizations
35479 \begin_inset LatexCommand index
35480 name "Optimizations"
35481
35482 \end_inset
35483
35484
35485 \end_layout
35486
35487 \begin_layout Standard
35488 SDCC performs a host of standard optimizations in addition to some MCU specific
35489  optimizations.
35490  
35491 \end_layout
35492
35493 \begin_layout Subsection
35494 Sub-expression Elimination
35495 \begin_inset LatexCommand index
35496 name "Subexpression elimination"
35497
35498 \end_inset
35499
35500
35501 \end_layout
35502
35503 \begin_layout Standard
35504 The compiler does local and 
35505 \emph on
35506 g
35507 \emph default
35508 lobal 
35509 \emph on
35510 c
35511 \emph default
35512 ommon 
35513 \emph on
35514 s
35515 \emph default
35516 ubexpression 
35517 \emph on
35518 e
35519 \emph default
35520 limination, e.g.: 
35521 \end_layout
35522
35523 \begin_layout Verse
35524
35525 \family typewriter
35526 i = x + y + 1; 
35527 \newline
35528 j = x + y;
35529 \end_layout
35530
35531 \begin_layout Standard
35532 will be translated to
35533 \end_layout
35534
35535 \begin_layout Verse
35536
35537 \family typewriter
35538 iTemp = x + y; 
35539 \newline
35540 i = iTemp + 1; 
35541 \newline
35542 j = iTemp;
35543 \end_layout
35544
35545 \begin_layout Standard
35546 Some subexpressions are not as obvious as the above example, e.g.:
35547 \end_layout
35548
35549 \begin_layout Verse
35550
35551 \family typewriter
35552 a->b[i].c = 10; 
35553 \newline
35554 a->b[i].d = 11;
35555 \end_layout
35556
35557 \begin_layout Standard
35558 In this case the address arithmetic a->b[i] will be computed only once;
35559  the equivalent code in C would be.
35560 \end_layout
35561
35562 \begin_layout Verse
35563
35564 \family typewriter
35565 iTemp = a->b[i]; 
35566 \newline
35567 iTemp.c = 10; 
35568 \newline
35569 iTemp.d = 11;
35570 \end_layout
35571
35572 \begin_layout Standard
35573 The compiler will try to keep these temporary variables in registers.
35574 \end_layout
35575
35576 \begin_layout Subsection
35577 Dead-Code Elimination
35578 \begin_inset LatexCommand index
35579 name "Dead-code elimination"
35580
35581 \end_inset
35582
35583
35584 \end_layout
35585
35586 \begin_layout Verse
35587
35588 \family typewriter
35589 int global;
35590 \newline
35591
35592 \newline
35593 void f () { 
35594 \newline
35595 \InsetSpace ~
35596 \InsetSpace ~
35597 int i; 
35598 \newline
35599 \InsetSpace ~
35600 \InsetSpace ~
35601 i = 1; \InsetSpace ~
35602 \InsetSpace ~
35603 \InsetSpace ~
35604 \InsetSpace ~
35605 \InsetSpace ~
35606 /* dead store */ 
35607 \newline
35608 \InsetSpace ~
35609 \InsetSpace ~
35610 global = 1;\InsetSpace ~
35611 /* dead
35612  store */ 
35613 \newline
35614 \InsetSpace ~
35615 \InsetSpace ~
35616 global = 2; 
35617 \newline
35618 \InsetSpace ~
35619 \InsetSpace ~
35620 return; 
35621 \newline
35622 \InsetSpace ~
35623 \InsetSpace ~
35624 global = 3;\InsetSpace ~
35625 /* unreachable */ 
35626 \newline
35627 }
35628 \end_layout
35629
35630 \begin_layout Standard
35631 will be changed to
35632 \end_layout
35633
35634 \begin_layout Verse
35635
35636 \family typewriter
35637 int global;
35638 \newline
35639
35640 \newline
35641 void f () {
35642 \newline
35643 \InsetSpace ~
35644 \InsetSpace ~
35645 global = 2; 
35646 \newline
35647 }
35648 \end_layout
35649
35650 \begin_layout Subsection
35651 Copy-Propagation
35652 \begin_inset LatexCommand index
35653 name "Copy propagation"
35654
35655 \end_inset
35656
35657
35658 \end_layout
35659
35660 \begin_layout Verse
35661
35662 \family typewriter
35663 int f() { 
35664 \newline
35665 \InsetSpace ~
35666 \InsetSpace ~
35667 int i, j; 
35668 \newline
35669 \InsetSpace ~
35670 \InsetSpace ~
35671 i = 10; 
35672 \newline
35673 \InsetSpace ~
35674 \InsetSpace ~
35675 j = i; 
35676 \newline
35677 \InsetSpace ~
35678 \InsetSpace ~
35679 return j; 
35680 \newline
35681 }
35682 \end_layout
35683
35684 \begin_layout Standard
35685 will be changed to 
35686 \end_layout
35687
35688 \begin_layout Verse
35689
35690 \family typewriter
35691 int f() { 
35692 \newline
35693 \InsetSpace ~
35694 \InsetSpace ~
35695 int i, j; 
35696 \newline
35697 \InsetSpace ~
35698 \InsetSpace ~
35699 i = 10; 
35700 \newline
35701 \InsetSpace ~
35702 \InsetSpace ~
35703 j = 10; 
35704 \newline
35705 \InsetSpace ~
35706 \InsetSpace ~
35707 return 10; 
35708 \newline
35709 }
35710 \end_layout
35711
35712 \begin_layout Standard
35713 Note: the dead stores created by this copy propagation will be eliminated
35714  by dead-code elimination.
35715 \end_layout
35716
35717 \begin_layout Subsection
35718 Loop Optimizations
35719 \begin_inset LatexCommand index
35720 name "Loop optimization"
35721
35722 \end_inset
35723
35724
35725 \begin_inset LatexCommand label
35726 name "sub:Loop-Optimizations"
35727
35728 \end_inset
35729
35730
35731 \end_layout
35732
35733 \begin_layout Standard
35734 Two types of loop optimizations are done by SDCC 
35735 \emph on
35736 loop invariant
35737 \emph default
35738  lifting and 
35739 \emph on
35740 strength reduction
35741 \emph default
35742  of loop induction variables.
35743  In addition to the strength reduction the optimizer marks the induction
35744  variables and the register allocator tries to keep the induction variables
35745  in registers for the duration of the loop.
35746  Because of this preference of the register allocator
35747 \begin_inset LatexCommand index
35748 name "Register allocation"
35749
35750 \end_inset
35751
35752 , loop induction optimization causes an increase in register pressure, which
35753  may cause unwanted spilling of other temporary variables into the stack
35754 \begin_inset LatexCommand index
35755 name "stack"
35756
35757 \end_inset
35758
35759  / data space.
35760  The compiler will generate a warning message when it is forced to allocate
35761  extra space either on the stack or data space.
35762  If this extra space allocation is undesirable then induction optimization
35763  can be eliminated either for the entire source file (with -
35764 \begin_inset ERT
35765 status collapsed
35766
35767 \begin_layout Standard
35768
35769
35770 \backslash
35771 /
35772 \end_layout
35773
35774 \end_inset
35775
35776 -noinduction option) or for a given function only using #pragma\InsetSpace ~
35777 noinduction
35778 \begin_inset LatexCommand index
35779 name "\\#pragma noinduction"
35780
35781 \end_inset
35782
35783 .
35784 \newline
35785
35786 \newline
35787 Loop Invariant:
35788 \end_layout
35789
35790 \begin_layout Verse
35791
35792 \family typewriter
35793 for (i = 0 ; i < 100 ; i ++) 
35794 \newline
35795 \InsetSpace ~
35796 \InsetSpace ~
35797 \InsetSpace ~
35798 \InsetSpace ~
35799 f += k + l;
35800 \end_layout
35801
35802 \begin_layout Standard
35803 changed to
35804 \end_layout
35805
35806 \begin_layout Verse
35807
35808 \family typewriter
35809 itemp = k + l; 
35810 \newline
35811 for (i = 0; i < 100; i++) 
35812 \newline
35813 \InsetSpace ~
35814 \InsetSpace ~
35815 \InsetSpace ~
35816 \InsetSpace ~
35817 f += itemp;
35818 \end_layout
35819
35820 \begin_layout Standard
35821 As mentioned previously some loop invariants are not as apparent, all static
35822  address computations are also moved out of the loop.
35823 \newline
35824
35825 \newline
35826 Strength Reduction
35827 \begin_inset LatexCommand index
35828 name "Strength reduction"
35829
35830 \end_inset
35831
35832 , this optimization substitutes an expression by a cheaper expression:
35833 \end_layout
35834
35835 \begin_layout Verse
35836
35837 \family typewriter
35838 for (i=0;i < 100; i++)
35839 \newline
35840 \InsetSpace ~
35841 \InsetSpace ~
35842 \InsetSpace ~
35843 \InsetSpace ~
35844 ar[i*5] = i*3;
35845 \end_layout
35846
35847 \begin_layout Standard
35848 changed to
35849 \end_layout
35850
35851 \begin_layout Verse
35852
35853 \family typewriter
35854 itemp1 = 0; 
35855 \newline
35856 itemp2 = 0; 
35857 \newline
35858 for (i=0;i< 100;i++) { 
35859 \newline
35860 \InsetSpace ~
35861 \InsetSpace ~
35862 \InsetSpace ~
35863 \InsetSpace ~
35864 ar[itemp1] = itemp2; 
35865 \newline
35866 \InsetSpace ~
35867 \InsetSpace ~
35868 \InsetSpace ~
35869 \InsetSpace ~
35870 itemp1
35871  += 5; 
35872 \newline
35873 \InsetSpace ~
35874 \InsetSpace ~
35875 \InsetSpace ~
35876 \InsetSpace ~
35877 itemp2 += 3; 
35878 \newline
35879 }
35880 \end_layout
35881
35882 \begin_layout Standard
35883 The more expensive multiplication
35884 \begin_inset LatexCommand index
35885 name "Multiplication"
35886
35887 \end_inset
35888
35889  is changed to a less expensive addition.
35890 \end_layout
35891
35892 \begin_layout Subsection
35893 Loop Reversing
35894 \begin_inset LatexCommand index
35895 name "Loop reversing"
35896
35897 \end_inset
35898
35899
35900 \end_layout
35901
35902 \begin_layout Standard
35903 This optimization is done to reduce the overhead of checking loop boundaries
35904  for every iteration.
35905  Some simple loops can be reversed and implemented using a 
35906 \begin_inset Quotes eld
35907 \end_inset
35908
35909 decrement and jump if not zero
35910 \begin_inset Quotes erd
35911 \end_inset
35912
35913  instruction.
35914  SDCC checks for the following criterion to determine if a loop is reversible
35915  (note: more sophisticated compilers use data-dependency analysis to make
35916  this determination, SDCC uses a more simple minded analysis).
35917 \end_layout
35918
35919 \begin_layout Itemize
35920 The 'for' loop is of the form 
35921 \newline
35922
35923 \newline
35924
35925 \family typewriter
35926 for(<symbol> = <expression>; <sym> [< | <=] <expression>; [<sym>++ | <sym>
35927  += 1])
35928 \newline
35929 \InsetSpace ~
35930 \InsetSpace ~
35931 \InsetSpace ~
35932 \InsetSpace ~
35933 <for body>
35934 \end_layout
35935
35936 \begin_layout Itemize
35937 The <for body> does not contain 
35938 \begin_inset Quotes eld
35939 \end_inset
35940
35941 continue
35942 \begin_inset Quotes erd
35943 \end_inset
35944
35945  or 'break
35946 \begin_inset Quotes erd
35947 \end_inset
35948
35949 .
35950 \end_layout
35951
35952 \begin_layout Itemize
35953 All goto's are contained within the loop.
35954 \end_layout
35955
35956 \begin_layout Itemize
35957 No function calls within the loop.
35958 \end_layout
35959
35960 \begin_layout Itemize
35961 The loop control variable <sym> is not assigned any value within the loop
35962 \end_layout
35963
35964 \begin_layout Itemize
35965 The loop control variable does NOT participate in any arithmetic operation
35966  within the loop.
35967 \end_layout
35968
35969 \begin_layout Itemize
35970 There are NO switch statements in the loop.
35971 \end_layout
35972
35973 \begin_layout Subsection
35974 Algebraic Simplifications
35975 \end_layout
35976
35977 \begin_layout Standard
35978 SDCC does numerous algebraic simplifications, the following is a small sub-set
35979  of these optimizations.
35980 \end_layout
35981
35982 \begin_layout Verse
35983
35984 \family typewriter
35985 i = j + 0;\InsetSpace ~
35986 \InsetSpace ~
35987 \InsetSpace ~
35988 \InsetSpace ~
35989  /* changed to: */\InsetSpace ~
35990 \InsetSpace ~
35991 \InsetSpace ~
35992 \InsetSpace ~
35993  i = j; 
35994 \newline
35995 i /= 2;\InsetSpace ~
35996 \InsetSpace ~
35997 \InsetSpace ~
35998 \InsetSpace ~
35999 \InsetSpace ~
36000 \InsetSpace ~
36001 \InsetSpace ~
36002  /* changed to: */\InsetSpace ~
36003 \InsetSpace ~
36004 \InsetSpace ~
36005 \InsetSpace ~
36006  i >>= 1; 
36007 \newline
36008 i
36009  = j - j;\InsetSpace ~
36010 \InsetSpace ~
36011 \InsetSpace ~
36012 \InsetSpace ~
36013  /* changed to: */\InsetSpace ~
36014 \InsetSpace ~
36015 \InsetSpace ~
36016 \InsetSpace ~
36017  i = 0; 
36018 \newline
36019 i = j / 1;\InsetSpace ~
36020 \InsetSpace ~
36021 \InsetSpace ~
36022 \InsetSpace ~
36023  /* changed to: */\InsetSpace ~
36024 \InsetSpace ~
36025 \InsetSpace ~
36026 \InsetSpace ~
36027  i = j;
36028 \end_layout
36029
36030 \begin_layout Standard
36031 Note the subexpressions
36032 \begin_inset LatexCommand index
36033 name "Subexpression"
36034
36035 \end_inset
36036
36037  given above are generally introduced by macro expansions or as a result
36038  of copy/constant propagation.
36039 \end_layout
36040
36041 \begin_layout Subsection
36042 'switch' Statements
36043 \begin_inset LatexCommand label
36044 name "sub:'switch'-Statements"
36045
36046 \end_inset
36047
36048
36049 \begin_inset LatexCommand index
36050 name "switch statement"
36051
36052 \end_inset
36053
36054
36055 \end_layout
36056
36057 \begin_layout Standard
36058 SDCC can optimize switch statements to jump tables
36059 \begin_inset LatexCommand index
36060 name "jump tables"
36061
36062 \end_inset
36063
36064 .
36065  It makes the decision based on an estimate of the generated code size.
36066  SDCC is quite liberal in the requirements for jump table generation: 
36067 \end_layout
36068
36069 \begin_layout Itemize
36070 The labels need not be in order, and the starting number need not be one
36071  or zero, the case labels are in numerical sequence or not too many case
36072  labels are missing.
36073 \end_layout
36074
36075 \begin_deeper
36076 \begin_layout Verse
36077
36078 \family typewriter
36079 switch(i) {\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 \InsetSpace ~
36094 \InsetSpace ~
36095 \InsetSpace ~
36096 \InsetSpace ~
36097 \InsetSpace ~
36098 \InsetSpace ~
36099 \InsetSpace ~
36100 \InsetSpace ~
36101 \InsetSpace ~
36102 \InsetSpace ~
36103 \InsetSpace ~
36104 \InsetSpace ~
36105 switch (i) { 
36106 \newline
36107 \InsetSpace ~
36108 \InsetSpace ~
36109 \InsetSpace ~
36110 case 4: ...\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 \InsetSpace ~
36126 \InsetSpace ~
36127 \InsetSpace ~
36128 \InsetSpace ~
36129 \InsetSpace ~
36130 \InsetSpace ~
36131 \InsetSpace ~
36132 \InsetSpace ~
36133 \InsetSpace ~
36134 \InsetSpace ~
36135 \InsetSpace ~
36136 case 0: ...
36137  
36138 \newline
36139 \InsetSpace ~
36140 \InsetSpace ~
36141 \InsetSpace ~
36142 case 5: ...\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 \InsetSpace ~
36158 \InsetSpace ~
36159 \InsetSpace ~
36160 \InsetSpace ~
36161 \InsetSpace ~
36162 \InsetSpace ~
36163 \InsetSpace ~
36164 \InsetSpace ~
36165 \InsetSpace ~
36166 \InsetSpace ~
36167 \InsetSpace ~
36168 case 1: ...
36169  
36170 \newline
36171 \InsetSpace ~
36172 \InsetSpace ~
36173 \InsetSpace ~
36174 case 3: ...\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 \InsetSpace ~
36189 \InsetSpace ~
36190 \InsetSpace ~
36191 \InsetSpace ~
36192 \InsetSpace ~
36193 \InsetSpace ~
36194 \InsetSpace ~
36195 \InsetSpace ~
36196 \InsetSpace ~
36197 \InsetSpace ~
36198 \InsetSpace ~
36199 \InsetSpace ~
36200
36201 \newline
36202 \InsetSpace ~
36203 \InsetSpace ~
36204 \InsetSpace ~
36205 case 6: ...\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 \InsetSpace ~
36221 \InsetSpace ~
36222 \InsetSpace ~
36223 \InsetSpace ~
36224 \InsetSpace ~
36225 \InsetSpace ~
36226 \InsetSpace ~
36227 \InsetSpace ~
36228 \InsetSpace ~
36229 \InsetSpace ~
36230 \InsetSpace ~
36231 case 3: ...
36232  
36233 \newline
36234 \InsetSpace ~
36235 \InsetSpace ~
36236 \InsetSpace ~
36237 case 7: ...\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 \InsetSpace ~
36253 \InsetSpace ~
36254 \InsetSpace ~
36255 \InsetSpace ~
36256 \InsetSpace ~
36257 \InsetSpace ~
36258 \InsetSpace ~
36259 \InsetSpace ~
36260 \InsetSpace ~
36261 \InsetSpace ~
36262 \InsetSpace ~
36263 case 4: ...
36264  
36265 \newline
36266 \InsetSpace ~
36267 \InsetSpace ~
36268 \InsetSpace ~
36269 case 8: ...\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 \InsetSpace ~
36285 \InsetSpace ~
36286 \InsetSpace ~
36287 \InsetSpace ~
36288 \InsetSpace ~
36289 \InsetSpace ~
36290 \InsetSpace ~
36291 \InsetSpace ~
36292 \InsetSpace ~
36293 \InsetSpace ~
36294 \InsetSpace ~
36295 case 5: ...
36296  
36297 \newline
36298 \InsetSpace ~
36299 \InsetSpace ~
36300 \InsetSpace ~
36301 case 9: ...\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 \InsetSpace ~
36316 \InsetSpace ~
36317 \InsetSpace ~
36318 \InsetSpace ~
36319 \InsetSpace ~
36320 \InsetSpace ~
36321 \InsetSpace ~
36322 \InsetSpace ~
36323 \InsetSpace ~
36324 \InsetSpace ~
36325 \InsetSpace ~
36326 \InsetSpace ~
36327 case 6: ...
36328  
36329 \newline
36330 \InsetSpace ~
36331 \InsetSpace ~
36332 \InsetSpace ~
36333 case 10: ...\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 \InsetSpace ~
36347 \InsetSpace ~
36348 \InsetSpace ~
36349 \InsetSpace ~
36350 \InsetSpace ~
36351 \InsetSpace ~
36352 \InsetSpace ~
36353 \InsetSpace ~
36354 \InsetSpace ~
36355 \InsetSpace ~
36356 \InsetSpace ~
36357 \InsetSpace ~
36358 case 7: ...
36359  
36360 \newline
36361 \InsetSpace ~
36362 \InsetSpace ~
36363 \InsetSpace ~
36364 case 11: ...\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 \InsetSpace ~
36386 \InsetSpace ~
36387 \InsetSpace ~
36388 \InsetSpace ~
36389 case 8: ...
36390  
36391 \newline
36392 }\InsetSpace ~
36393 \InsetSpace ~
36394 \InsetSpace ~
36395 \InsetSpace ~
36396 \InsetSpace ~
36397 \InsetSpace ~
36398 \InsetSpace ~
36399 \InsetSpace ~
36400 \InsetSpace ~
36401 \InsetSpace ~
36402 \InsetSpace ~
36403 \InsetSpace ~
36404 \InsetSpace ~
36405 \InsetSpace ~
36406 \InsetSpace ~
36407 \InsetSpace ~
36408 \InsetSpace ~
36409 \InsetSpace ~
36410 \InsetSpace ~
36411 \InsetSpace ~
36412 \InsetSpace ~
36413 \InsetSpace ~
36414 \InsetSpace ~
36415 \InsetSpace ~
36416 \InsetSpace ~
36417 \InsetSpace ~
36418 \InsetSpace ~
36419 \InsetSpace ~
36420 \InsetSpace ~
36421 \InsetSpace ~
36422 \InsetSpace ~
36423 \InsetSpace ~
36424 \InsetSpace ~
36425 \InsetSpace ~
36426 \InsetSpace ~
36427 \InsetSpace ~
36428 }
36429 \end_layout
36430
36431 \begin_layout Standard
36432 Both the above switch statements will be implemented using a jump-table.
36433  The example to the right side is slightly more efficient as the check for
36434  the lower boundary of the jump-table is not needed.
36435 \end_layout
36436
36437 \end_deeper
36438 \begin_layout Itemize
36439 The number of case labels is not larger than supported by the target architectur
36440 e.
36441 \end_layout
36442
36443 \begin_layout Itemize
36444 If the case labels are not in numerical sequence ('gaps' between cases)
36445  SDCC checks whether a jump table with additionally inserted dummy cases
36446  is still attractive.
36447  
36448 \end_layout
36449
36450 \begin_layout Itemize
36451 If the starting number is not zero and a check for the lower boundary of
36452  the jump-table can thus be eliminated SDCC might insert dummy cases 0,
36453  ...
36454  .
36455 \end_layout
36456
36457 \begin_layout Standard
36458 Switch statements which have large gaps in the numeric sequence or those
36459  that have too many case labels can be split into more than one switch statement
36460  for efficient code generation, e.g.:
36461 \end_layout
36462
36463 \begin_layout Verse
36464
36465 \family typewriter
36466 switch (i) { 
36467 \newline
36468 \InsetSpace ~
36469 \InsetSpace ~
36470 case 1: ...
36471  
36472 \newline
36473 \InsetSpace ~
36474 \InsetSpace ~
36475 case 2: ...
36476  
36477 \newline
36478 \InsetSpace ~
36479 \InsetSpace ~
36480 case 3: ...
36481  
36482 \newline
36483 \InsetSpace ~
36484 \InsetSpace ~
36485 case 4: ...
36486  
36487 \newline
36488 \InsetSpace ~
36489 \InsetSpace ~
36490 case 5: ...
36491  
36492 \newline
36493 \InsetSpace ~
36494 \InsetSpace ~
36495 case 6: ...
36496  
36497 \newline
36498 \InsetSpace ~
36499 \InsetSpace ~
36500 case 7: ...
36501  
36502 \newline
36503 \InsetSpace ~
36504 \InsetSpace ~
36505 case 101: ...
36506  
36507 \newline
36508 \InsetSpace ~
36509 \InsetSpace ~
36510 case 102: ...
36511  
36512 \newline
36513 \InsetSpace ~
36514 \InsetSpace ~
36515 case 103: ...
36516  
36517 \newline
36518 \InsetSpace ~
36519 \InsetSpace ~
36520 case 104: ...
36521  
36522 \newline
36523 \InsetSpace ~
36524 \InsetSpace ~
36525 case 105: ...
36526  
36527 \newline
36528 \InsetSpace ~
36529 \InsetSpace ~
36530 case 106: ...
36531  
36532 \newline
36533 \InsetSpace ~
36534 \InsetSpace ~
36535 case 107: ...
36536  
36537 \newline
36538 }
36539 \end_layout
36540
36541 \begin_layout Standard
36542 If the above switch statement is broken down into two switch statements
36543 \end_layout
36544
36545 \begin_layout Verse
36546
36547 \family typewriter
36548 switch (i) { 
36549 \newline
36550 \InsetSpace ~
36551 \InsetSpace ~
36552 case 1: ...
36553  
36554 \newline
36555 \InsetSpace ~
36556 \InsetSpace ~
36557 case 2: ...
36558  
36559 \newline
36560 \InsetSpace ~
36561 \InsetSpace ~
36562 case 3: ...
36563  
36564 \newline
36565 \InsetSpace ~
36566 \InsetSpace ~
36567 case 4: ...
36568  
36569 \newline
36570 \InsetSpace ~
36571 \InsetSpace ~
36572 case 5: ...
36573  
36574 \newline
36575 \InsetSpace ~
36576 \InsetSpace ~
36577 case 6: ...
36578  
36579 \newline
36580 \InsetSpace ~
36581 \InsetSpace ~
36582 case 7: ...
36583  
36584 \newline
36585 }
36586 \end_layout
36587
36588 \begin_layout Standard
36589 and
36590 \end_layout
36591
36592 \begin_layout Verse
36593
36594 \family typewriter
36595 switch (i) { 
36596 \newline
36597 \InsetSpace ~
36598 \InsetSpace ~
36599 case 101: ...
36600  
36601 \newline
36602 \InsetSpace ~
36603 \InsetSpace ~
36604 case 102: ...
36605  
36606 \newline
36607 \InsetSpace ~
36608 \InsetSpace ~
36609 case 103: ...
36610  
36611 \newline
36612 \InsetSpace ~
36613 \InsetSpace ~
36614 case 104: ...
36615  
36616 \newline
36617 \InsetSpace ~
36618 \InsetSpace ~
36619 case 105: ...
36620  
36621 \newline
36622 \InsetSpace ~
36623 \InsetSpace ~
36624 case 106: ...
36625  
36626 \newline
36627 \InsetSpace ~
36628 \InsetSpace ~
36629 case 107: ...
36630  
36631 \newline
36632 }
36633 \end_layout
36634
36635 \begin_layout Standard
36636 then both the switch statements will be implemented using jump-tables whereas
36637  the unmodified switch statement will not be.
36638 \end_layout
36639
36640 \begin_layout Standard
36641 \begin_inset Note Note
36642 status collapsed
36643
36644 \begin_layout Standard
36645 There might be reasons which SDCC cannot know about to either favour or
36646  not favour jump tables.
36647  If the target system has to be as quick for the last switch case as for
36648  the first (pro jump table), or if the switch argument is known to be zero
36649  in the majority of the cases (contra jump table).
36650 \end_layout
36651
36652 \end_inset
36653
36654
36655 \end_layout
36656
36657 \begin_layout Standard
36658 The pragma nojtbound
36659 \begin_inset LatexCommand index
36660 name "\\#pragma nojtbound"
36661
36662 \end_inset
36663
36664  can be used to turn off checking the 
36665 \emph on
36666 j
36667 \emph default
36668 ump 
36669 \emph on
36670 t
36671 \emph default
36672 able 
36673 \emph on
36674 bound
36675 \emph default
36676 aries.
36677  It has no effect if a default label is supplied.
36678  Use of this pragma is dangerous: if the switch
36679 \begin_inset LatexCommand index
36680 name "switch statement"
36681
36682 \end_inset
36683
36684  argument is not matched by a case statement the processor will happily
36685  jump into Nirvana.
36686 \end_layout
36687
36688 \begin_layout Subsection
36689 Bit-shifting Operations
36690 \begin_inset LatexCommand index
36691 name "Bit shifting"
36692
36693 \end_inset
36694
36695 .
36696 \end_layout
36697
36698 \begin_layout Standard
36699 Bit shifting is one of the most frequently used operation in embedded programmin
36700 g.
36701  SDCC tries to implement bit-shift operations in the most efficient way
36702  possible, e.g.:
36703 \end_layout
36704
36705 \begin_layout Verse
36706
36707 \family typewriter
36708 unsigned char i;
36709 \newline
36710 ...
36711  
36712 \newline
36713 i >>= 4; 
36714 \newline
36715 ...
36716 \end_layout
36717
36718 \begin_layout Standard
36719 generates the following code:
36720 \end_layout
36721
36722 \begin_layout Verse
36723
36724 \family typewriter
36725 mov\InsetSpace ~
36726  a,_i 
36727 \newline
36728 swap a 
36729 \newline
36730 anl\InsetSpace ~
36731  a,#0x0f 
36732 \newline
36733 mov\InsetSpace ~
36734  _i,a
36735 \end_layout
36736
36737 \begin_layout Standard
36738 In general SDCC will never setup a loop if the shift count is known.
36739  Another example:
36740 \end_layout
36741
36742 \begin_layout Verse
36743
36744 \family typewriter
36745 unsigned int i; 
36746 \newline
36747 ...
36748  
36749 \newline
36750 i >>= 9; 
36751 \newline
36752 ...
36753 \end_layout
36754
36755 \begin_layout Standard
36756 will generate:
36757 \end_layout
36758
36759 \begin_layout Verse
36760
36761 \family typewriter
36762 mov\InsetSpace ~
36763 \InsetSpace ~
36764 a,(_i + 1) 
36765 \newline
36766 mov\InsetSpace ~
36767 \InsetSpace ~
36768 (_i + 1),#0x00 
36769 \newline
36770 clr\InsetSpace ~
36771 \InsetSpace ~
36772
36773 \newline
36774 rrc\InsetSpace ~
36775 \InsetSpace ~
36776
36777 \newline
36778 mov\InsetSpace ~
36779 \InsetSpace ~
36780 _i,a
36781 \end_layout
36782
36783 \begin_layout Subsection
36784 Bit-rotation
36785 \begin_inset LatexCommand index
36786 name "Bit rotation"
36787
36788 \end_inset
36789
36790
36791 \end_layout
36792
36793 \begin_layout Standard
36794 A special case of the bit-shift operation is bit rotation
36795 \begin_inset LatexCommand index
36796 name "rotating bits"
36797
36798 \end_inset
36799
36800 , SDCC recognizes the following expression to be a left bit-rotation:
36801 \end_layout
36802
36803 \begin_layout Verse
36804
36805 \family typewriter
36806 \series bold
36807 unsigned
36808 \series default
36809 \InsetSpace ~
36810 \InsetSpace ~
36811 char i;\InsetSpace ~
36812 \InsetSpace ~
36813 \InsetSpace ~
36814 \InsetSpace ~
36815 \InsetSpace ~
36816 \InsetSpace ~
36817 \InsetSpace ~
36818 \InsetSpace ~
36819 \InsetSpace ~
36820 \InsetSpace ~
36821 \InsetSpace ~
36822 /* unsigned is needed for rotation */ 
36823 \newline
36824 ...
36825  
36826 \newline
36827 i = ((i << 1) | (i >> 7));
36828 \family default
36829  
36830 \newline
36831
36832 \family typewriter
36833 ...
36834 \end_layout
36835
36836 \begin_layout Standard
36837 will generate the following code:
36838 \end_layout
36839
36840 \begin_layout Verse
36841
36842 \family typewriter
36843 mov\InsetSpace ~
36844 \InsetSpace ~
36845 a,_i 
36846 \newline
36847 rl\InsetSpace ~
36848 \InsetSpace ~
36849 \InsetSpace ~
36850
36851 \newline
36852 mov\InsetSpace ~
36853 \InsetSpace ~
36854 _i,a
36855 \end_layout
36856
36857 \begin_layout Standard
36858 SDCC uses pattern matching on the parse tree to determine this operation.Variatio
36859 ns of this case will also be recognized as bit-rotation, i.e.: 
36860 \end_layout
36861
36862 \begin_layout Verse
36863
36864 \family typewriter
36865 i = ((i >> 7) | (i << 1)); /* left-bit rotation */
36866 \end_layout
36867
36868 \begin_layout Subsection
36869 Nibble and Byte Swapping
36870 \end_layout
36871
36872 \begin_layout Standard
36873 Other special cases of the bit-shift operations are nibble or byte swapping
36874 \begin_inset LatexCommand index
36875 name "swapping nibbles/bytes"
36876
36877 \end_inset
36878
36879 , SDCC recognizes the following expressions:
36880 \end_layout
36881
36882 \begin_layout Verse
36883
36884 \family typewriter
36885 \series bold
36886 unsigned
36887 \series default
36888 \InsetSpace ~
36889 \InsetSpace ~
36890 char i; 
36891 \newline
36892
36893 \series bold
36894 unsigned
36895 \series default
36896 \InsetSpace ~
36897 \InsetSpace ~
36898 int j; 
36899 \newline
36900 ...
36901  
36902 \newline
36903 i = ((i << 4) | (i >> 4));
36904 \family default
36905  
36906 \newline
36907
36908 \family typewriter
36909 j = ((j << 8) | (j >> 8)); 
36910 \end_layout
36911
36912 \begin_layout Standard
36913 and generates a swap instruction for the nibble swapping
36914 \begin_inset LatexCommand index
36915 name "Nibble swapping"
36916
36917 \end_inset
36918
36919  or move instructions for the byte swapping
36920 \begin_inset LatexCommand index
36921 name "Byte swapping"
36922
36923 \end_inset
36924
36925 .
36926  The 
36927 \begin_inset Quotes sld
36928 \end_inset
36929
36930 j
36931 \begin_inset Quotes srd
36932 \end_inset
36933
36934  example can be used to convert from little to big-endian or vice versa.
36935  If you want to change the endianness of a 
36936 \emph on
36937 signed
36938 \emph default
36939  integer you have to cast to 
36940 \family typewriter
36941 (unsigned int)
36942 \family default
36943  first.
36944 \end_layout
36945
36946 \begin_layout Standard
36947 Note that SDCC stores numbers in little-endian
36948 \begin_inset Foot
36949 status open
36950
36951 \begin_layout Standard
36952 Usually 8-bit processors don't care much about endianness.
36953  This is not the case for the standard 8051 which only has an instruction
36954  to increment its 
36955 \emph on
36956 dptr
36957 \emph default
36958
36959 \begin_inset LatexCommand index
36960 name "DPTR"
36961
36962 \end_inset
36963
36964 -datapointer so little-endian is the more efficient byte order.
36965 \end_layout
36966
36967 \end_inset
36968
36969
36970 \begin_inset LatexCommand index
36971 name "little-endian"
36972
36973 \end_inset
36974
36975
36976 \begin_inset LatexCommand index
36977 name "Endianness"
36978
36979 \end_inset
36980
36981  format (i.e.
36982  lowest order first).
36983 \end_layout
36984
36985 \begin_layout Subsection
36986 Highest Order Bit
36987 \begin_inset LatexCommand index
36988 name "Highest Order Bit"
36989
36990 \end_inset
36991
36992  / Any Order Bit
36993 \begin_inset LatexCommand index
36994 name "Any Order Bit"
36995
36996 \end_inset
36997
36998
36999 \end_layout
37000
37001 \begin_layout Standard
37002 It is frequently required to obtain the highest order bit of an integral
37003  type (long, int, short or char types).
37004  Also obtaining any other order bit is not uncommon.
37005  SDCC recognizes the following expressions to yield the highest order bit
37006  and generates optimized code for it, e.g.:
37007 \end_layout
37008
37009 \begin_layout Verse
37010
37011 \family typewriter
37012 unsigned int gint; 
37013 \newline
37014
37015 \newline
37016 foo () { 
37017 \newline
37018 \InsetSpace ~
37019 \InsetSpace ~
37020 unsigned char hob1, aob1; 
37021 \newline
37022 \InsetSpace ~
37023 \InsetSpace ~
37024 bit hob2, hob3, aob2,
37025  aob3; 
37026 \newline
37027 \InsetSpace ~
37028 \InsetSpace ~
37029 ...
37030  
37031 \newline
37032 \InsetSpace ~
37033 \InsetSpace ~
37034 hob1 = (gint >> 15) & 1; 
37035 \newline
37036 \InsetSpace ~
37037 \InsetSpace ~
37038 hob2 = (gint >> 15) & 1; 
37039 \newline
37040 \InsetSpace ~
37041 \InsetSpace ~
37042 hob3 = gint & 0x8000;
37043  
37044 \newline
37045 \InsetSpace ~
37046 \InsetSpace ~
37047 aob1 = (gint >> 9) & 1; 
37048 \newline
37049 \InsetSpace ~
37050 \InsetSpace ~
37051 aob2 = (gint >> 8) & 1; 
37052 \newline
37053 \InsetSpace ~
37054 \InsetSpace ~
37055 aob3 = gint & 0x0800; 
37056 \newline
37057 \InsetSpace ~
37058 \InsetSpace ~
37059 ..
37060  
37061 \newline
37062 }
37063 \end_layout
37064
37065 \begin_layout Standard
37066 will generate the following code:
37067 \end_layout
37068
37069 \begin_layout Verse
37070
37071 \family typewriter
37072 \InsetSpace ~
37073 \InsetSpace ~
37074 \InsetSpace ~
37075 \InsetSpace ~
37076 \InsetSpace ~
37077 \InsetSpace ~
37078 \InsetSpace ~
37079 \InsetSpace ~
37080 \InsetSpace ~
37081 \InsetSpace ~
37082 \InsetSpace ~
37083 \InsetSpace ~
37084 \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  61 ;\InsetSpace ~
37098  hob.c 7 
37099 \newline
37100 000A E5*01\InsetSpace ~
37101 \InsetSpace ~
37102 \InsetSpace ~
37103 \InsetSpace ~
37104 \InsetSpace ~
37105 \InsetSpace ~
37106 \InsetSpace ~
37107 \InsetSpace ~
37108 \InsetSpace ~
37109 \InsetSpace ~
37110 \InsetSpace ~
37111 \InsetSpace ~
37112 \InsetSpace ~
37113 \InsetSpace ~
37114 \InsetSpace ~
37115  62\InsetSpace ~
37116 \InsetSpace ~
37117 \InsetSpace ~
37118 \InsetSpace ~
37119 \InsetSpace ~
37120 \InsetSpace ~
37121 \InsetSpace ~
37122 \InsetSpace ~
37123  mov\InsetSpace ~
37124 \InsetSpace ~
37125  a,(_gint + 1) 
37126 \newline
37127 000C 23\InsetSpace ~
37128 \InsetSpace ~
37129 \InsetSpace ~
37130 \InsetSpace ~
37131 \InsetSpace ~
37132 \InsetSpace ~
37133 \InsetSpace ~
37134 \InsetSpace ~
37135 \InsetSpace ~
37136 \InsetSpace ~
37137 \InsetSpace ~
37138 \InsetSpace ~
37139 \InsetSpace ~
37140 \InsetSpace ~
37141 \InsetSpace ~
37142 \InsetSpace ~
37143 \InsetSpace ~
37144 \InsetSpace ~
37145  63\InsetSpace ~
37146 \InsetSpace ~
37147 \InsetSpace ~
37148 \InsetSpace ~
37149 \InsetSpace ~
37150 \InsetSpace ~
37151 \InsetSpace ~
37152 \InsetSpace ~
37153  rl\InsetSpace ~
37154 \InsetSpace ~
37155 \InsetSpace ~
37156  a 
37157 \newline
37158 000D 54 01\InsetSpace ~
37159 \InsetSpace ~
37160 \InsetSpace ~
37161 \InsetSpace ~
37162 \InsetSpace ~
37163 \InsetSpace ~
37164 \InsetSpace ~
37165 \InsetSpace ~
37166 \InsetSpace ~
37167 \InsetSpace ~
37168 \InsetSpace ~
37169 \InsetSpace ~
37170 \InsetSpace ~
37171 \InsetSpace ~
37172 \InsetSpace ~
37173
37174  64\InsetSpace ~
37175 \InsetSpace ~
37176 \InsetSpace ~
37177 \InsetSpace ~
37178 \InsetSpace ~
37179 \InsetSpace ~
37180 \InsetSpace ~
37181 \InsetSpace ~
37182  anl\InsetSpace ~
37183 \InsetSpace ~
37184  a,#0x01 
37185 \newline
37186 000F F5*02\InsetSpace ~
37187 \InsetSpace ~
37188 \InsetSpace ~
37189 \InsetSpace ~
37190 \InsetSpace ~
37191 \InsetSpace ~
37192 \InsetSpace ~
37193 \InsetSpace ~
37194 \InsetSpace ~
37195 \InsetSpace ~
37196 \InsetSpace ~
37197 \InsetSpace ~
37198 \InsetSpace ~
37199 \InsetSpace ~
37200 \InsetSpace ~
37201  65\InsetSpace ~
37202 \InsetSpace ~
37203 \InsetSpace ~
37204 \InsetSpace ~
37205 \InsetSpace ~
37206 \InsetSpace ~
37207 \InsetSpace ~
37208 \InsetSpace ~
37209  mov\InsetSpace ~
37210 \InsetSpace ~
37211  _foo_hob1_1_1,a 
37212 \newline
37213 \InsetSpace ~
37214 \InsetSpace ~
37215 \InsetSpace ~
37216 \InsetSpace ~
37217 \InsetSpace ~
37218 \InsetSpace ~
37219 \InsetSpace ~
37220 \InsetSpace ~
37221 \InsetSpace ~
37222 \InsetSpace ~
37223 \InsetSpace ~
37224 \InsetSpace ~
37225 \InsetSpace ~
37226 \InsetSpace ~
37227 \InsetSpace ~
37228 \InsetSpace ~
37229 \InsetSpace ~
37230 \InsetSpace ~
37231 \InsetSpace ~
37232 \InsetSpace ~
37233 \InsetSpace ~
37234 \InsetSpace ~
37235 \InsetSpace ~
37236 \InsetSpace ~
37237 \InsetSpace ~
37238  66 ;\InsetSpace ~
37239  hob.c 8 
37240 \newline
37241 0011 E5*01\InsetSpace ~
37242 \InsetSpace ~
37243 \InsetSpace ~
37244 \InsetSpace ~
37245 \InsetSpace ~
37246 \InsetSpace ~
37247 \InsetSpace ~
37248 \InsetSpace ~
37249 \InsetSpace ~
37250 \InsetSpace ~
37251 \InsetSpace ~
37252 \InsetSpace ~
37253 \InsetSpace ~
37254 \InsetSpace ~
37255 \InsetSpace ~
37256
37257  67\InsetSpace ~
37258 \InsetSpace ~
37259 \InsetSpace ~
37260 \InsetSpace ~
37261 \InsetSpace ~
37262 \InsetSpace ~
37263 \InsetSpace ~
37264 \InsetSpace ~
37265  mov\InsetSpace ~
37266 \InsetSpace ~
37267  a,(_gint + 1) 
37268 \newline
37269 0013 33\InsetSpace ~
37270 \InsetSpace ~
37271 \InsetSpace ~
37272 \InsetSpace ~
37273 \InsetSpace ~
37274 \InsetSpace ~
37275 \InsetSpace ~
37276 \InsetSpace ~
37277 \InsetSpace ~
37278 \InsetSpace ~
37279 \InsetSpace ~
37280 \InsetSpace ~
37281 \InsetSpace ~
37282 \InsetSpace ~
37283 \InsetSpace ~
37284 \InsetSpace ~
37285 \InsetSpace ~
37286 \InsetSpace ~
37287  68\InsetSpace ~
37288 \InsetSpace ~
37289 \InsetSpace ~
37290 \InsetSpace ~
37291 \InsetSpace ~
37292 \InsetSpace ~
37293 \InsetSpace ~
37294 \InsetSpace ~
37295  rlc\InsetSpace ~
37296 \InsetSpace ~
37297  a 
37298 \newline
37299 0014 92*00\InsetSpace ~
37300 \InsetSpace ~
37301 \InsetSpace ~
37302 \InsetSpace ~
37303 \InsetSpace ~
37304 \InsetSpace ~
37305 \InsetSpace ~
37306 \InsetSpace ~
37307 \InsetSpace ~
37308 \InsetSpace ~
37309 \InsetSpace ~
37310 \InsetSpace ~
37311 \InsetSpace ~
37312 \InsetSpace ~
37313 \InsetSpace ~
37314  69\InsetSpace ~
37315 \InsetSpace ~
37316 \InsetSpace ~
37317 \InsetSpace ~
37318 \InsetSpace ~
37319 \InsetSpace ~
37320 \InsetSpace ~
37321 \InsetSpace ~
37322  mov\InsetSpace ~
37323 \InsetSpace ~
37324  _foo_hob2_1_1,c
37325  
37326 \newline
37327 \InsetSpace ~
37328 \InsetSpace ~
37329 \InsetSpace ~
37330 \InsetSpace ~
37331 \InsetSpace ~
37332 \InsetSpace ~
37333 \InsetSpace ~
37334 \InsetSpace ~
37335 \InsetSpace ~
37336 \InsetSpace ~
37337 \InsetSpace ~
37338 \InsetSpace ~
37339 \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  66 ;\InsetSpace ~
37353  hob.c 9 
37354 \newline
37355 0016 E5*01\InsetSpace ~
37356 \InsetSpace ~
37357 \InsetSpace ~
37358 \InsetSpace ~
37359 \InsetSpace ~
37360 \InsetSpace ~
37361 \InsetSpace ~
37362 \InsetSpace ~
37363 \InsetSpace ~
37364 \InsetSpace ~
37365 \InsetSpace ~
37366 \InsetSpace ~
37367 \InsetSpace ~
37368 \InsetSpace ~
37369 \InsetSpace ~
37370  67\InsetSpace ~
37371 \InsetSpace ~
37372 \InsetSpace ~
37373 \InsetSpace ~
37374 \InsetSpace ~
37375 \InsetSpace ~
37376 \InsetSpace ~
37377 \InsetSpace ~
37378  mov\InsetSpace ~
37379 \InsetSpace ~
37380  a,(_gint + 1) 
37381 \newline
37382 0018 33\InsetSpace ~
37383 \InsetSpace ~
37384 \InsetSpace ~
37385 \InsetSpace ~
37386 \InsetSpace ~
37387 \InsetSpace ~
37388 \InsetSpace ~
37389 \InsetSpace ~
37390 \InsetSpace ~
37391 \InsetSpace ~
37392 \InsetSpace ~
37393 \InsetSpace ~
37394 \InsetSpace ~
37395 \InsetSpace ~
37396 \InsetSpace ~
37397 \InsetSpace ~
37398 \InsetSpace ~
37399 \InsetSpace ~
37400  68\InsetSpace ~
37401 \InsetSpace ~
37402 \InsetSpace ~
37403 \InsetSpace ~
37404 \InsetSpace ~
37405 \InsetSpace ~
37406 \InsetSpace ~
37407 \InsetSpace ~
37408  rlc\InsetSpace ~
37409 \InsetSpace ~
37410  a 
37411 \newline
37412 0019 92*01\InsetSpace ~
37413 \InsetSpace ~
37414 \InsetSpace ~
37415 \InsetSpace ~
37416 \InsetSpace ~
37417 \InsetSpace ~
37418 \InsetSpace ~
37419 \InsetSpace ~
37420 \InsetSpace ~
37421 \InsetSpace ~
37422 \InsetSpace ~
37423 \InsetSpace ~
37424 \InsetSpace ~
37425 \InsetSpace ~
37426 \InsetSpace ~
37427
37428  69\InsetSpace ~
37429 \InsetSpace ~
37430 \InsetSpace ~
37431 \InsetSpace ~
37432 \InsetSpace ~
37433 \InsetSpace ~
37434 \InsetSpace ~
37435 \InsetSpace ~
37436  mov\InsetSpace ~
37437 \InsetSpace ~
37438  _foo_hob3_1_1,c 
37439 \newline
37440 \InsetSpace ~
37441 \InsetSpace ~
37442 \InsetSpace ~
37443 \InsetSpace ~
37444 \InsetSpace ~
37445 \InsetSpace ~
37446 \InsetSpace ~
37447 \InsetSpace ~
37448 \InsetSpace ~
37449 \InsetSpace ~
37450 \InsetSpace ~
37451 \InsetSpace ~
37452 \InsetSpace ~
37453 \InsetSpace ~
37454 \InsetSpace ~
37455 \InsetSpace ~
37456 \InsetSpace ~
37457 \InsetSpace ~
37458 \InsetSpace ~
37459 \InsetSpace ~
37460 \InsetSpace ~
37461 \InsetSpace ~
37462 \InsetSpace ~
37463 \InsetSpace ~
37464 \InsetSpace ~
37465  70 ;\InsetSpace ~
37466  hob.c 10 
37467 \newline
37468 001B E5*01\InsetSpace ~
37469 \InsetSpace ~
37470 \InsetSpace ~
37471 \InsetSpace ~
37472 \InsetSpace ~
37473 \InsetSpace ~
37474 \InsetSpace ~
37475 \InsetSpace ~
37476 \InsetSpace ~
37477 \InsetSpace ~
37478 \InsetSpace ~
37479 \InsetSpace ~
37480 \InsetSpace ~
37481 \InsetSpace ~
37482 \InsetSpace ~
37483  71\InsetSpace ~
37484 \InsetSpace ~
37485 \InsetSpace ~
37486 \InsetSpace ~
37487 \InsetSpace ~
37488 \InsetSpace ~
37489 \InsetSpace ~
37490 \InsetSpace ~
37491  mov\InsetSpace ~
37492 \InsetSpace ~
37493  a,(_gint + 1) 
37494 \newline
37495 001D
37496  03\InsetSpace ~
37497 \InsetSpace ~
37498 \InsetSpace ~
37499 \InsetSpace ~
37500 \InsetSpace ~
37501 \InsetSpace ~
37502 \InsetSpace ~
37503 \InsetSpace ~
37504 \InsetSpace ~
37505 \InsetSpace ~
37506 \InsetSpace ~
37507 \InsetSpace ~
37508 \InsetSpace ~
37509 \InsetSpace ~
37510 \InsetSpace ~
37511 \InsetSpace ~
37512 \InsetSpace ~
37513 \InsetSpace ~
37514  72\InsetSpace ~
37515 \InsetSpace ~
37516 \InsetSpace ~
37517 \InsetSpace ~
37518 \InsetSpace ~
37519 \InsetSpace ~
37520 \InsetSpace ~
37521 \InsetSpace ~
37522  rr\InsetSpace ~
37523 \InsetSpace ~
37524 \InsetSpace ~
37525  a 
37526 \newline
37527 001E 54 01\InsetSpace ~
37528 \InsetSpace ~
37529 \InsetSpace ~
37530 \InsetSpace ~
37531 \InsetSpace ~
37532 \InsetSpace ~
37533 \InsetSpace ~
37534 \InsetSpace ~
37535 \InsetSpace ~
37536 \InsetSpace ~
37537 \InsetSpace ~
37538 \InsetSpace ~
37539 \InsetSpace ~
37540 \InsetSpace ~
37541 \InsetSpace ~
37542  73\InsetSpace ~
37543 \InsetSpace ~
37544 \InsetSpace ~
37545 \InsetSpace ~
37546 \InsetSpace ~
37547 \InsetSpace ~
37548 \InsetSpace ~
37549 \InsetSpace ~
37550  anl\InsetSpace ~
37551 \InsetSpace ~
37552  a,#0x01 
37553 \newline
37554 0020 F5*03\InsetSpace ~
37555 \InsetSpace ~
37556 \InsetSpace ~
37557 \InsetSpace ~
37558 \InsetSpace ~
37559 \InsetSpace ~
37560 \InsetSpace ~
37561 \InsetSpace ~
37562 \InsetSpace ~
37563 \InsetSpace ~
37564 \InsetSpace ~
37565 \InsetSpace ~
37566 \InsetSpace ~
37567 \InsetSpace ~
37568 \InsetSpace ~
37569  74\InsetSpace ~
37570 \InsetSpace ~
37571 \InsetSpace ~
37572 \InsetSpace ~
37573 \InsetSpace ~
37574 \InsetSpace ~
37575 \InsetSpace ~
37576 \InsetSpace ~
37577  mov\InsetSpace ~
37578 \InsetSpace ~
37579  _foo_aob1_1_1,a
37580  
37581 \newline
37582 \InsetSpace ~
37583 \InsetSpace ~
37584 \InsetSpace ~
37585 \InsetSpace ~
37586 \InsetSpace ~
37587 \InsetSpace ~
37588 \InsetSpace ~
37589 \InsetSpace ~
37590 \InsetSpace ~
37591 \InsetSpace ~
37592 \InsetSpace ~
37593 \InsetSpace ~
37594 \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  75 ;\InsetSpace ~
37608  hob.c 11 
37609 \newline
37610 0022 E5*01\InsetSpace ~
37611 \InsetSpace ~
37612 \InsetSpace ~
37613 \InsetSpace ~
37614 \InsetSpace ~
37615 \InsetSpace ~
37616 \InsetSpace ~
37617 \InsetSpace ~
37618 \InsetSpace ~
37619 \InsetSpace ~
37620 \InsetSpace ~
37621 \InsetSpace ~
37622 \InsetSpace ~
37623 \InsetSpace ~
37624 \InsetSpace ~
37625  76\InsetSpace ~
37626 \InsetSpace ~
37627 \InsetSpace ~
37628 \InsetSpace ~
37629 \InsetSpace ~
37630 \InsetSpace ~
37631 \InsetSpace ~
37632 \InsetSpace ~
37633  mov\InsetSpace ~
37634 \InsetSpace ~
37635  a,(_gint + 1) 
37636 \newline
37637 0024 13\InsetSpace ~
37638 \InsetSpace ~
37639 \InsetSpace ~
37640 \InsetSpace ~
37641 \InsetSpace ~
37642 \InsetSpace ~
37643 \InsetSpace ~
37644 \InsetSpace ~
37645 \InsetSpace ~
37646 \InsetSpace ~
37647 \InsetSpace ~
37648 \InsetSpace ~
37649 \InsetSpace ~
37650 \InsetSpace ~
37651 \InsetSpace ~
37652 \InsetSpace ~
37653 \InsetSpace ~
37654 \InsetSpace ~
37655  77\InsetSpace ~
37656 \InsetSpace ~
37657 \InsetSpace ~
37658 \InsetSpace ~
37659 \InsetSpace ~
37660 \InsetSpace ~
37661 \InsetSpace ~
37662 \InsetSpace ~
37663  rrc\InsetSpace ~
37664 \InsetSpace ~
37665  a 
37666 \newline
37667 0025 92*02\InsetSpace ~
37668 \InsetSpace ~
37669 \InsetSpace ~
37670 \InsetSpace ~
37671 \InsetSpace ~
37672 \InsetSpace ~
37673 \InsetSpace ~
37674 \InsetSpace ~
37675 \InsetSpace ~
37676 \InsetSpace ~
37677 \InsetSpace ~
37678 \InsetSpace ~
37679 \InsetSpace ~
37680 \InsetSpace ~
37681 \InsetSpace ~
37682
37683  78\InsetSpace ~
37684 \InsetSpace ~
37685 \InsetSpace ~
37686 \InsetSpace ~
37687 \InsetSpace ~
37688 \InsetSpace ~
37689 \InsetSpace ~
37690 \InsetSpace ~
37691  mov\InsetSpace ~
37692 \InsetSpace ~
37693  _foo_aob2_1_1,c 
37694 \newline
37695 \InsetSpace ~
37696 \InsetSpace ~
37697 \InsetSpace ~
37698 \InsetSpace ~
37699 \InsetSpace ~
37700 \InsetSpace ~
37701 \InsetSpace ~
37702 \InsetSpace ~
37703 \InsetSpace ~
37704 \InsetSpace ~
37705 \InsetSpace ~
37706 \InsetSpace ~
37707 \InsetSpace ~
37708 \InsetSpace ~
37709 \InsetSpace ~
37710 \InsetSpace ~
37711 \InsetSpace ~
37712 \InsetSpace ~
37713 \InsetSpace ~
37714 \InsetSpace ~
37715 \InsetSpace ~
37716 \InsetSpace ~
37717 \InsetSpace ~
37718 \InsetSpace ~
37719 \InsetSpace ~
37720  79 ;\InsetSpace ~
37721  hob.c 12 
37722 \newline
37723 0027 E5*01\InsetSpace ~
37724 \InsetSpace ~
37725 \InsetSpace ~
37726 \InsetSpace ~
37727 \InsetSpace ~
37728 \InsetSpace ~
37729 \InsetSpace ~
37730 \InsetSpace ~
37731 \InsetSpace ~
37732 \InsetSpace ~
37733 \InsetSpace ~
37734 \InsetSpace ~
37735 \InsetSpace ~
37736 \InsetSpace ~
37737 \InsetSpace ~
37738  80\InsetSpace ~
37739 \InsetSpace ~
37740 \InsetSpace ~
37741 \InsetSpace ~
37742 \InsetSpace ~
37743 \InsetSpace ~
37744 \InsetSpace ~
37745 \InsetSpace ~
37746  mov\InsetSpace ~
37747 \InsetSpace ~
37748  a,(_gint + 1) 
37749 \newline
37750 0029
37751  A2 E3\InsetSpace ~
37752 \InsetSpace ~
37753 \InsetSpace ~
37754 \InsetSpace ~
37755 \InsetSpace ~
37756 \InsetSpace ~
37757 \InsetSpace ~
37758 \InsetSpace ~
37759 \InsetSpace ~
37760 \InsetSpace ~
37761 \InsetSpace ~
37762 \InsetSpace ~
37763 \InsetSpace ~
37764 \InsetSpace ~
37765 \InsetSpace ~
37766  81\InsetSpace ~
37767 \InsetSpace ~
37768 \InsetSpace ~
37769 \InsetSpace ~
37770 \InsetSpace ~
37771 \InsetSpace ~
37772 \InsetSpace ~
37773 \InsetSpace ~
37774  mov\InsetSpace ~
37775 \InsetSpace ~
37776  c,acc[3] 
37777 \newline
37778 002B 92*03\InsetSpace ~
37779 \InsetSpace ~
37780 \InsetSpace ~
37781 \InsetSpace ~
37782 \InsetSpace ~
37783 \InsetSpace ~
37784 \InsetSpace ~
37785 \InsetSpace ~
37786 \InsetSpace ~
37787 \InsetSpace ~
37788 \InsetSpace ~
37789 \InsetSpace ~
37790 \InsetSpace ~
37791 \InsetSpace ~
37792 \InsetSpace ~
37793  82\InsetSpace ~
37794 \InsetSpace ~
37795 \InsetSpace ~
37796 \InsetSpace ~
37797 \InsetSpace ~
37798 \InsetSpace ~
37799 \InsetSpace ~
37800 \InsetSpace ~
37801  mov\InsetSpace ~
37802 \InsetSpace ~
37803  _foo_aob3_1_1,c 
37804 \end_layout
37805
37806 \begin_layout Standard
37807 Other variations of these cases however will 
37808 \emph on
37809 not
37810 \emph default
37811  be recognized.
37812  They are standard C expressions, so I heartily recommend these be the only
37813  way to get the highest order bit, (it is portable).
37814  Of course it will be recognized even if it is embedded in other expressions,
37815  e.g.:
37816 \end_layout
37817
37818 \begin_layout Verse
37819
37820 \family typewriter
37821 xyz = gint + ((gint >> 15) & 1);
37822 \end_layout
37823
37824 \begin_layout Standard
37825 will still be recognized.
37826 \end_layout
37827
37828 \begin_layout Subsection
37829 Higher Order Byte
37830 \begin_inset LatexCommand index
37831 name "Higher Order Byte"
37832
37833 \end_inset
37834
37835  / Higher Order Word
37836 \begin_inset LatexCommand index
37837 name "Higher Order Word"
37838
37839 \end_inset
37840
37841
37842 \end_layout
37843
37844 \begin_layout Standard
37845 It is also frequently required to obtain a higher order byte or word of
37846  a larger integral type (long, int or short types).
37847  SDCC recognizes the following expressions to yield the higher order byte
37848  or word and generates optimized code for it, e.g.:
37849 \end_layout
37850
37851 \begin_layout Verse
37852
37853 \family typewriter
37854 unsigned int gint; 
37855 \newline
37856 unsigned long int glong; 
37857 \newline
37858
37859 \newline
37860 foo () { 
37861 \newline
37862 \InsetSpace ~
37863 \InsetSpace ~
37864 unsigned char hob1,
37865  hob2; 
37866 \newline
37867 \InsetSpace ~
37868 \InsetSpace ~
37869 unsigned int how1, how2; 
37870 \newline
37871 \InsetSpace ~
37872 \InsetSpace ~
37873 ...
37874  
37875 \newline
37876 \InsetSpace ~
37877 \InsetSpace ~
37878 hob1 = (gint >> 8) & 0xFF; 
37879 \newline
37880 \InsetSpace ~
37881 \InsetSpace ~
37882 hob2 = glong >> 24; 
37883 \newline
37884 \InsetSpace ~
37885 \InsetSpace ~
37886 how1 = (glong >> 16) & 0xFFFF;
37887  
37888 \newline
37889 \InsetSpace ~
37890 \InsetSpace ~
37891 how2 = glong >> 8; 
37892 \newline
37893 \InsetSpace ~
37894 \InsetSpace ~
37895 ..
37896  
37897 \newline
37898 }
37899 \end_layout
37900
37901 \begin_layout Standard
37902 will generate the following code:
37903 \end_layout
37904
37905 \begin_layout Verse
37906
37907 \family typewriter
37908 \InsetSpace ~
37909 \InsetSpace ~
37910 \InsetSpace ~
37911 \InsetSpace ~
37912 \InsetSpace ~
37913 \InsetSpace ~
37914 \InsetSpace ~
37915 \InsetSpace ~
37916 \InsetSpace ~
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  91 ;\InsetSpace ~
37934  hob.c 15 
37935 \newline
37936 0037 85*01*06\InsetSpace ~
37937 \InsetSpace ~
37938 \InsetSpace ~
37939 \InsetSpace ~
37940 \InsetSpace ~
37941 \InsetSpace ~
37942 \InsetSpace ~
37943 \InsetSpace ~
37944 \InsetSpace ~
37945 \InsetSpace ~
37946 \InsetSpace ~
37947 \InsetSpace ~
37948  92\InsetSpace ~
37949 \InsetSpace ~
37950 \InsetSpace ~
37951 \InsetSpace ~
37952 \InsetSpace ~
37953 \InsetSpace ~
37954 \InsetSpace ~
37955 \InsetSpace ~
37956  mov\InsetSpace ~
37957 \InsetSpace ~
37958  _foo_hob1_1_1,(_gint + 1) 
37959 \newline
37960 \InsetSpace ~
37961 \InsetSpace ~
37962 \InsetSpace ~
37963 \InsetSpace ~
37964 \InsetSpace ~
37965 \InsetSpace ~
37966 \InsetSpace ~
37967 \InsetSpace ~
37968 \InsetSpace ~
37969 \InsetSpace ~
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  93 ;\InsetSpace ~
37986  hob.c
37987  16 
37988 \newline
37989 003A 85*05*07\InsetSpace ~
37990 \InsetSpace ~
37991 \InsetSpace ~
37992 \InsetSpace ~
37993 \InsetSpace ~
37994 \InsetSpace ~
37995 \InsetSpace ~
37996 \InsetSpace ~
37997 \InsetSpace ~
37998 \InsetSpace ~
37999 \InsetSpace ~
38000 \InsetSpace ~
38001  94\InsetSpace ~
38002 \InsetSpace ~
38003 \InsetSpace ~
38004 \InsetSpace ~
38005 \InsetSpace ~
38006 \InsetSpace ~
38007 \InsetSpace ~
38008 \InsetSpace ~
38009  mov\InsetSpace ~
38010 \InsetSpace ~
38011  _foo_hob2_1_1,(_glong + 3) 
38012 \newline
38013 \InsetSpace ~
38014 \InsetSpace ~
38015 \InsetSpace ~
38016 \InsetSpace ~
38017 \InsetSpace ~
38018 \InsetSpace ~
38019 \InsetSpace ~
38020 \InsetSpace ~
38021 \InsetSpace ~
38022 \InsetSpace ~
38023 \InsetSpace ~
38024 \InsetSpace ~
38025 \InsetSpace ~
38026 \InsetSpace ~
38027 \InsetSpace ~
38028 \InsetSpace ~
38029 \InsetSpace ~
38030 \InsetSpace ~
38031 \InsetSpace ~
38032 \InsetSpace ~
38033 \InsetSpace ~
38034 \InsetSpace ~
38035 \InsetSpace ~
38036 \InsetSpace ~
38037 \InsetSpace ~
38038  95 ;\InsetSpace ~
38039  hob.c 17 
38040 \newline
38041 003D 85*04*08\InsetSpace ~
38042 \InsetSpace ~
38043 \InsetSpace ~
38044 \InsetSpace ~
38045 \InsetSpace ~
38046 \InsetSpace ~
38047 \InsetSpace ~
38048 \InsetSpace ~
38049 \InsetSpace ~
38050 \InsetSpace ~
38051 \InsetSpace ~
38052 \InsetSpace ~
38053
38054  96\InsetSpace ~
38055 \InsetSpace ~
38056 \InsetSpace ~
38057 \InsetSpace ~
38058 \InsetSpace ~
38059 \InsetSpace ~
38060 \InsetSpace ~
38061 \InsetSpace ~
38062  mov\InsetSpace ~
38063 \InsetSpace ~
38064  _foo_how1_1_1,(_glong + 2) 
38065 \newline
38066 0040 85*05*09\InsetSpace ~
38067 \InsetSpace ~
38068 \InsetSpace ~
38069 \InsetSpace ~
38070 \InsetSpace ~
38071 \InsetSpace ~
38072 \InsetSpace ~
38073 \InsetSpace ~
38074 \InsetSpace ~
38075 \InsetSpace ~
38076 \InsetSpace ~
38077 \InsetSpace ~
38078  97\InsetSpace ~
38079 \InsetSpace ~
38080 \InsetSpace ~
38081 \InsetSpace ~
38082 \InsetSpace ~
38083 \InsetSpace ~
38084 \InsetSpace ~
38085 \InsetSpace ~
38086  mov\InsetSpace ~
38087 \InsetSpace ~
38088  (_foo_how1_1_1 +
38089  1),(_glong + 3) 
38090 \newline
38091 0043 85*03*0A\InsetSpace ~
38092 \InsetSpace ~
38093 \InsetSpace ~
38094 \InsetSpace ~
38095 \InsetSpace ~
38096 \InsetSpace ~
38097 \InsetSpace ~
38098 \InsetSpace ~
38099 \InsetSpace ~
38100 \InsetSpace ~
38101 \InsetSpace ~
38102 \InsetSpace ~
38103  98\InsetSpace ~
38104 \InsetSpace ~
38105 \InsetSpace ~
38106 \InsetSpace ~
38107 \InsetSpace ~
38108 \InsetSpace ~
38109 \InsetSpace ~
38110 \InsetSpace ~
38111  mov\InsetSpace ~
38112 \InsetSpace ~
38113  _foo_how2_1_1,(_glong + 1) 
38114 \newline
38115 0046 85*04*0B\InsetSpace ~
38116 \InsetSpace ~
38117 \InsetSpace ~
38118 \InsetSpace ~
38119 \InsetSpace ~
38120 \InsetSpace ~
38121 \InsetSpace ~
38122 \InsetSpace ~
38123 \InsetSpace ~
38124 \InsetSpace ~
38125 \InsetSpace ~
38126 \InsetSpace ~
38127
38128  99\InsetSpace ~
38129 \InsetSpace ~
38130 \InsetSpace ~
38131 \InsetSpace ~
38132 \InsetSpace ~
38133 \InsetSpace ~
38134 \InsetSpace ~
38135 \InsetSpace ~
38136  mov\InsetSpace ~
38137 \InsetSpace ~
38138  (_foo_how2_1_1 + 1),(_glong + 2) 
38139 \end_layout
38140
38141 \begin_layout Standard
38142 Again, variations of these cases may 
38143 \emph on
38144 not
38145 \emph default
38146  be recognized.
38147  They are standard C expressions, so I heartily recommend these be the only
38148  way to get the higher order byte/word, (it is portable).
38149  Of course it will be recognized even if it is embedded in other expressions,
38150  e.g.:
38151 \end_layout
38152
38153 \begin_layout Verse
38154
38155 \family typewriter
38156 xyz = gint + ((gint >> 8) & 0xFF);
38157 \end_layout
38158
38159 \begin_layout Standard
38160 will still be recognized.
38161 \end_layout
38162
38163 \begin_layout Subsection
38164 Peephole Optimizer
38165 \begin_inset LatexCommand label
38166 name "sub:Peephole-Optimizer"
38167
38168 \end_inset
38169
38170
38171 \begin_inset LatexCommand index
38172 name "Peephole optimizer"
38173
38174 \end_inset
38175
38176
38177 \end_layout
38178
38179 \begin_layout Standard
38180 The compiler uses a rule based, pattern matching and re-writing mechanism
38181  for peep-hole optimization.
38182  It is inspired by 
38183 \emph on
38184 copt
38185 \emph default
38186  a peep-hole optimizer by Christopher W.
38187  Fraser (cwfraser\InsetSpace ~
38188 @\InsetSpace ~
38189 microsoft.com).
38190  A default set of rules are compiled into the compiler, additional rules
38191  may be added with the 
38192 \emph on
38193 -
38194 \begin_inset ERT
38195 status collapsed
38196
38197 \begin_layout Standard
38198
38199
38200 \backslash
38201 /
38202 \end_layout
38203
38204 \end_inset
38205
38206 -peep-file
38207 \begin_inset LatexCommand index
38208 name "-\\/-peep-file"
38209
38210 \end_inset
38211
38212  <filename>
38213 \emph default
38214  option.
38215  The rule language is best illustrated with examples.
38216 \end_layout
38217
38218 \begin_layout Verse
38219
38220 \family typewriter
38221 replace { 
38222 \newline
38223 \InsetSpace ~
38224 \InsetSpace ~
38225 mov %1,a 
38226 \newline
38227 \InsetSpace ~
38228 \InsetSpace ~
38229 mov a,%1
38230 \newline
38231 } by {
38232 \newline
38233 \InsetSpace ~
38234 \InsetSpace ~
38235 mov %1,a
38236 \newline
38237 }
38238 \end_layout
38239
38240 \begin_layout Standard
38241 The above rule will change the following assembly
38242 \begin_inset LatexCommand index
38243 name "Assembler routines"
38244
38245 \end_inset
38246
38247  sequence:
38248 \end_layout
38249
38250 \begin_layout Verse
38251
38252 \family typewriter
38253 mov r1,a 
38254 \newline
38255 mov a,r1
38256 \end_layout
38257
38258 \begin_layout Standard
38259 to
38260 \end_layout
38261
38262 \begin_layout Verse
38263
38264 \family typewriter
38265 mov r1,a
38266 \end_layout
38267
38268 \begin_layout Standard
38269 Note: All occurrences of a 
38270 \emph on
38271 %n
38272 \emph default
38273  (pattern variable) must denote the same string.
38274  With the above rule, the assembly sequence:
38275 \end_layout
38276
38277 \begin_layout Verse
38278
38279 \family typewriter
38280 mov r1,a 
38281 \newline
38282 mov a,r2
38283 \end_layout
38284
38285 \begin_layout Standard
38286 will remain unmodified.
38287 \newline
38288
38289 \newline
38290 Other special case optimizations may be added by the
38291  user (via 
38292 \emph on
38293 -
38294 \begin_inset ERT
38295 status collapsed
38296
38297 \begin_layout Standard
38298
38299
38300 \backslash
38301 /
38302 \end_layout
38303
38304 \end_inset
38305
38306 -peep-file option
38307 \emph default
38308 ).
38309  E.g.
38310  some variants of the 8051 MCU
38311 \begin_inset LatexCommand index
38312 name "MCS51 variants"
38313
38314 \end_inset
38315
38316  allow only 
38317 \family typewriter
38318 ajmp
38319 \family default
38320  and 
38321 \family typewriter
38322 acall
38323 \family default
38324 .
38325  The following two rules will change all 
38326 \family typewriter
38327 ljmp
38328 \family default
38329  and 
38330 \family typewriter
38331 lcall
38332 \family default
38333  to 
38334 \family typewriter
38335 ajmp
38336 \family default
38337  and 
38338 \family typewriter
38339 acall
38340 \end_layout
38341
38342 \begin_layout Verse
38343
38344 \family typewriter
38345 replace { lcall %1 } by { acall %1 } 
38346 \newline
38347 replace { ljmp %1 } by { ajmp %1 }
38348 \end_layout
38349
38350 \begin_layout Standard
38351 (NOTE: from version 2.7.3 on, you can use option -
38352 \emph on
38353
38354 \begin_inset ERT
38355 status collapsed
38356
38357 \begin_layout Standard
38358
38359
38360 \backslash
38361 /
38362 \end_layout
38363
38364 \end_inset
38365
38366
38367 \emph default
38368 -acall-ajmp
38369 \begin_inset LatexCommand index
38370 name "-\\/-acall-ajmp"
38371
38372 \end_inset
38373
38374 , which also takes care of aligning the interrupt vectors properly.)
38375 \newline
38376
38377 \end_layout
38378
38379 \begin_layout Standard
38380 The 
38381 \emph on
38382 inline-assembler code
38383 \emph default
38384  is also passed through the peep hole optimizer, thus the peephole optimizer
38385  can also be used as an assembly level macro expander.
38386  The rules themselves are MCU dependent whereas the rule language infra-structur
38387 e is MCU independent.
38388  Peephole optimization rules for other MCU can be easily programmed using
38389  the rule language.
38390 \newline
38391
38392 \newline
38393 The syntax for a rule is as follows:
38394 \end_layout
38395
38396 \begin_layout Verse
38397
38398 \family typewriter
38399 rule := replace [ restart ] '{' <assembly sequence> '
38400 \backslash
38401 n' 
38402 \newline
38403 \InsetSpace ~
38404  \InsetSpace ~
38405  \InsetSpace ~
38406  \InsetSpace ~
38407  \InsetSpace ~
38408  \InsetSpace ~
38409  \InsetSpace ~
38410  \InsetSpace ~
38411  \InsetSpace ~
38412  \InsetSpace ~
38413  \InsetSpace ~
38414  \InsetSpace ~
38415  \InsetSpace ~
38416  \InsetSpace ~
38417  '}' by '{' '
38418 \backslash
38419 n' 
38420 \newline
38421 \InsetSpace ~
38422  \InsetSpace ~
38423  \InsetSpace ~
38424  \InsetSpace ~
38425  \InsetSpace ~
38426  \InsetSpace ~
38427  \InsetSpace ~
38428  \InsetSpace ~
38429  \InsetSpace ~
38430  \InsetSpace ~
38431  \InsetSpace ~
38432  \InsetSpace ~
38433  \InsetSpace ~
38434  \InsetSpace ~
38435  \InsetSpace ~
38436  \InsetSpace ~
38437  <assembly sequence> '
38438 \backslash
38439 n' 
38440 \newline
38441 \InsetSpace ~
38442  \InsetSpace ~
38443  \InsetSpace ~
38444  \InsetSpace ~
38445  \InsetSpace ~
38446  \InsetSpace ~
38447  \InsetSpace ~
38448  \InsetSpace ~
38449  \InsetSpace ~
38450  \InsetSpace ~
38451  \InsetSpace ~
38452  \InsetSpace ~
38453  \InsetSpace ~
38454  \InsetSpace ~
38455  '}' [if <functionName> ] '
38456 \backslash
38457 n' 
38458 \end_layout
38459
38460 \begin_layout Standard
38461 <assembly sequence> := assembly instruction (each instruction including
38462  labels must be on a separate line).
38463 \newline
38464
38465 \newline
38466 The optimizer will apply to the rules
38467  one by one from the top in the sequence of their appearance, it will terminate
38468  when all rules are exhausted.
38469  If the 'restart' option is specified, then the optimizer will start matching
38470  the rules again from the top, this option for a rule is expensive (performance)
38471 , it is intended to be used in situations where a transformation will trigger
38472  the same rule again.
38473  An example of this (not a good one, it has side effects) is the following
38474  rule:
38475 \end_layout
38476
38477 \begin_layout Verse
38478
38479 \family typewriter
38480 replace restart { 
38481 \newline
38482 \InsetSpace ~
38483 \InsetSpace ~
38484 pop %1 
38485 \newline
38486 \InsetSpace ~
38487 \InsetSpace ~
38488 push %1 } by { 
38489 \newline
38490 \InsetSpace ~
38491 \InsetSpace ~
38492 ; nop 
38493 \newline
38494 }
38495 \end_layout
38496
38497 \begin_layout Standard
38498 Note that the replace pattern cannot be a blank, but can be a comment line.
38499  Without the 'restart' option only the innermost 'pop' 'push' pair would
38500  be eliminated, i.e.:
38501 \end_layout
38502
38503 \begin_layout Verse
38504
38505 \family typewriter
38506 pop ar1 
38507 \newline
38508 pop ar2 
38509 \newline
38510 push ar2 
38511 \newline
38512 push ar1
38513 \end_layout
38514
38515 \begin_layout Standard
38516 would result in:
38517 \end_layout
38518
38519 \begin_layout Verse
38520
38521 \family typewriter
38522 pop ar1 
38523 \newline
38524 ; nop 
38525 \newline
38526 push ar1
38527 \end_layout
38528
38529 \begin_layout Standard
38530
38531 \emph on
38532 with
38533 \emph default
38534  the restart option the rule will be applied again to the resulting code
38535  and then all the pop-push pairs will be eliminated to yield:
38536 \end_layout
38537
38538 \begin_layout Verse
38539
38540 \family typewriter
38541 ; nop 
38542 \newline
38543 ; nop
38544 \end_layout
38545
38546 \begin_layout Standard
38547 A conditional function can be attached to a rule.
38548  Attaching rules are somewhat more involved, let me illustrate this with
38549  an example.
38550 \end_layout
38551
38552 \begin_layout Verse
38553
38554 \family typewriter
38555 replace { 
38556 \newline
38557 \InsetSpace ~
38558  \InsetSpace ~
38559  \InsetSpace ~
38560 ljmp %5 
38561 \newline
38562 %2:
38563 \newline
38564 } by { 
38565 \newline
38566 \InsetSpace ~
38567  \InsetSpace ~
38568  \InsetSpace ~
38569 sjmp %5 
38570 \newline
38571 %2:
38572 \newline
38573 } if labelInRange
38574 \end_layout
38575
38576 \begin_layout Standard
38577 The optimizer does a look-up of a function name table defined in function
38578  
38579 \emph on
38580 callFuncByName
38581 \emph default
38582  in the source file SDCCpeeph.c, with the name 
38583 \emph on
38584 labelInRange
38585 \emph default
38586 .
38587  If it finds a corresponding entry the function is called.
38588  Note there can be no parameters specified for these functions, in this
38589  case the use of 
38590 \emph on
38591 %5
38592 \emph default
38593  is crucial, since the function 
38594 \emph on
38595 labelInRange
38596 \emph default
38597  expects to find the label in that particular variable (the hash table containin
38598 g the variable bindings is passed as a parameter).
38599  If you want to code more such functions, take a close look at the function
38600  labelInRange and the calling mechanism in source file SDCCpeeph.c.
38601  Currently implemented are 
38602 \emph on
38603 labelInRange, labelRefCount, labelIsReturnOnly, operandsNotSame, xramMovcOption,
38604  24bitMode, portIsDS390, 24bitModeAndPortDS390
38605 \emph default
38606  and 
38607 \emph on
38608 notVolatile
38609 \emph default
38610 .
38611 \end_layout
38612
38613 \begin_layout Standard
38614 I know this whole thing is a little kludgey, but maybe some day we will
38615  have some better means.
38616  If you are looking at this file, you will see the default rules that are
38617  compiled into the compiler, you can add your own rules in the default set
38618  there if you get tired of specifying the -
38619 \begin_inset ERT
38620 status collapsed
38621
38622 \begin_layout Standard
38623
38624
38625 \backslash
38626 /
38627 \end_layout
38628
38629 \end_inset
38630
38631 -peep-file option.
38632 \end_layout
38633
38634 \begin_layout Section
38635 ANSI-Compliance
38636 \begin_inset LatexCommand index
38637 name "ANSI-compliance"
38638
38639 \end_inset
38640
38641
38642 \begin_inset LatexCommand label
38643 name "sub:ANSI-Compliance"
38644
38645 \end_inset
38646
38647
38648 \end_layout
38649
38650 \begin_layout Standard
38651 The latest publicly available version of the standard 
38652 \emph on
38653 ISO/IEC 9899 - Programming languages - C
38654 \emph default
38655  should be available at: 
38656 \begin_inset LatexCommand url
38657 target "http://www.open-std.org/jtc1/sc22/wg14/www/standards.html#9899"
38658
38659 \end_inset
38660
38661 .
38662 \newline
38663
38664 \end_layout
38665
38666 \begin_layout Standard
38667 Deviations from the compliance:
38668 \end_layout
38669
38670 \begin_layout Itemize
38671 functions are not reentrant
38672 \begin_inset LatexCommand index
38673 name "reentrant"
38674
38675 \end_inset
38676
38677  unless explicitly declared as such or the 
38678 \series bold
38679 -
38680 \begin_inset ERT
38681 status collapsed
38682
38683 \begin_layout Standard
38684
38685
38686 \backslash
38687 /
38688 \end_layout
38689
38690 \end_inset
38691
38692 -stack-auto
38693 \begin_inset LatexCommand index
38694 name "-\\/-stack-auto"
38695
38696 \end_inset
38697
38698
38699 \series default
38700  command line option is specified.
38701 \end_layout
38702
38703 \begin_layout Itemize
38704 structures
38705 \begin_inset LatexCommand index
38706 name "struct"
38707
38708 \end_inset
38709
38710  and unions
38711 \begin_inset LatexCommand index
38712 name "union"
38713
38714 \end_inset
38715
38716  cannot be assigned values directly, cannot be passed as function parameters
38717  or assigned to each other and cannot be a return value
38718 \begin_inset LatexCommand index
38719 name "return value"
38720
38721 \end_inset
38722
38723  from a function, e.g.:
38724 \end_layout
38725
38726 \begin_deeper
38727 \begin_layout Verse
38728
38729 \family typewriter
38730 struct s { ...
38731  }; 
38732 \newline
38733 struct s s1, s2; 
38734 \newline
38735 foo() 
38736 \newline
38737
38738 \newline
38739 \InsetSpace ~
38740 \InsetSpace ~
38741 \InsetSpace ~
38742 \InsetSpace ~
38743 ...
38744  
38745 \newline
38746 \InsetSpace ~
38747 \InsetSpace ~
38748 \InsetSpace ~
38749 \InsetSpace ~
38750 s1 = s2 ; /* is invalid in SDCC although allowed in ANSI */ 
38751 \newline
38752 \InsetSpace ~
38753 \InsetSpace ~
38754 \InsetSpace ~
38755 \InsetSpace ~
38756 ...
38757  
38758 \newline
38759 }
38760 \newline
38761
38762 \series bold
38763 struct
38764 \family default
38765 \series default
38766  
38767 \family typewriter
38768 s foo1 (
38769 \series bold
38770 struct
38771 \family default
38772 \series default
38773  
38774 \family typewriter
38775 s parms) /* invalid in SDCC although allowed in ANSI */
38776 \newline
38777
38778 \newline
38779 \InsetSpace ~
38780 \InsetSpace ~
38781 \InsetSpace ~
38782 \InsetSpace ~
38783 struct s rets;
38784  
38785 \newline
38786 \InsetSpace ~
38787 \InsetSpace ~
38788 \InsetSpace ~
38789 \InsetSpace ~
38790 ...
38791  
38792 \newline
38793 \InsetSpace ~
38794 \InsetSpace ~
38795 \InsetSpace ~
38796 \InsetSpace ~
38797 return rets; /* is invalid in SDCC although allowed in ANSI */ 
38798 \newline
38799 }
38800 \end_layout
38801
38802 \end_deeper
38803 \begin_layout Itemize
38804 initialization of structure arrays must be fully braced.
38805 \end_layout
38806
38807 \begin_deeper
38808 \begin_layout Verse
38809
38810 \family typewriter
38811 struct s { char x } a[] = {1, 2};\InsetSpace ~
38812 \InsetSpace ~
38813 \InsetSpace ~
38814 \InsetSpace ~
38815 \InsetSpace ~
38816 /* invalid in SDCC */
38817 \newline
38818 struct s { char x
38819  } a[] = {{1}, {2}}; /* OK */
38820 \end_layout
38821
38822 \end_deeper
38823 \begin_layout Itemize
38824 'long long
38825 \begin_inset LatexCommand index
38826 name "long long (not supported)"
38827
38828 \end_inset
38829
38830 ' (64 bit integers
38831 \begin_inset LatexCommand index
38832 name "int (64 bit) (not supported)"
38833
38834 \end_inset
38835
38836 ) not supported.
38837 \end_layout
38838
38839 \begin_layout Itemize
38840 'double
38841 \begin_inset LatexCommand index
38842 name "double (not supported)"
38843
38844 \end_inset
38845
38846 ' precision floating point 
38847 \begin_inset LatexCommand index
38848 name "Floating point support"
38849
38850 \end_inset
38851
38852 not supported.
38853 \end_layout
38854
38855 \begin_layout Itemize
38856 Old K&R style
38857 \begin_inset LatexCommand index
38858 name "K\\&R style"
38859
38860 \end_inset
38861
38862  function declarations are NOT allowed.
38863 \end_layout
38864
38865 \begin_deeper
38866 \begin_layout Verse
38867
38868 \family typewriter
38869 foo(i,j) /* this old style of function declarations */ 
38870 \newline
38871 int i,j; /* is valid
38872  in ANSI but not valid in SDCC */ 
38873 \newline
38874
38875 \newline
38876 \InsetSpace ~
38877 \InsetSpace ~
38878 \InsetSpace ~
38879 \InsetSpace ~
38880 ...
38881  
38882 \newline
38883 }
38884 \end_layout
38885
38886 \end_deeper
38887 \begin_layout Itemize
38888 Most enhancements in C99 are not supported, e.g.:
38889 \end_layout
38890
38891 \begin_deeper
38892 \begin_layout Verse
38893
38894 \family typewriter
38895 for (
38896 \series bold
38897 int
38898 \family default
38899 \series default
38900  
38901 \family typewriter
38902 i=0; i<10; i++) /* is invalid in SDCC although allowed in C99 */
38903 \end_layout
38904
38905 \end_deeper
38906 \begin_layout Itemize
38907 But some have been added recently in SDCC 2.7.0.
38908  They must be considered alpha quality however.
38909 \end_layout
38910
38911 \begin_deeper
38912 \begin_layout Verse
38913
38914 \family typewriter
38915 \series bold
38916 inline
38917 \begin_inset LatexCommand index
38918 name "inline (not supported)"
38919
38920 \end_inset
38921
38922
38923 \family default
38924 \series default
38925  
38926 \family typewriter
38927 int increment (int a) { return a+1; } /* inlines the increment without function
38928  call overhead */
38929 \newline
38930 int *
38931 \family default
38932  
38933 \family typewriter
38934 \series bold
38935 restrict
38936 \begin_inset LatexCommand index
38937 name "inline (not supported)"
38938
38939 \end_inset
38940
38941
38942 \family default
38943 \series default
38944  
38945 \family typewriter
38946 p; /* accepted but ignored */
38947 \end_layout
38948
38949 \end_deeper
38950 \begin_layout Itemize
38951 Certain words that are valid identifiers in the standard may be reserved
38952  words in SDCC unless the 
38953 \series bold
38954 -
38955 \begin_inset ERT
38956 status collapsed
38957
38958 \begin_layout Standard
38959
38960
38961 \backslash
38962 /
38963 \end_layout
38964
38965 \end_inset
38966
38967 -std-c89
38968 \begin_inset LatexCommand index
38969 name "-\\/-std-c89"
38970
38971 \end_inset
38972
38973
38974 \series default
38975  or 
38976 \series bold
38977 -
38978 \begin_inset ERT
38979 status collapsed
38980
38981 \begin_layout Standard
38982
38983
38984 \backslash
38985 /
38986 \end_layout
38987
38988 \end_inset
38989
38990 -std-c99
38991 \begin_inset LatexCommand index
38992 name "-\\/-std-c99"
38993
38994 \end_inset
38995
38996
38997 \series default
38998  command line options are used.
38999  These may include (depending on the selected processor): 'at', 'banked',
39000  'bit', 'code', 'critical', 'data', 'eeprom', 'far', 'flash', 'idata', 'interrup
39001 t', 'near', 'nonbanked', 'pdata', 'reentrant', 'sbit', 'sfr', 'shadowregs',
39002  'sram', 'using', 'wparam', 'xdata', '_overlay', '_asm', '_endasm', and
39003  '_naked'.
39004  Compliant equivalents of these keywords are always available in a form
39005  that begin with two underscores
39006 \begin_inset LatexCommand index
39007 name "\\_\\_ (prefix for extended keywords)"
39008
39009 \end_inset
39010
39011 , f.e.
39012  '__data' instead of 'data'.
39013 \end_layout
39014
39015 \begin_layout Itemize
39016 Integer promotion of variable arguments is not performed if the argument
39017  is explicitly taypecasted unless the 
39018 \series bold
39019 -
39020 \begin_inset ERT
39021 status collapsed
39022
39023 \begin_layout Standard
39024
39025
39026 \backslash
39027 /
39028 \end_layout
39029
39030 \end_inset
39031
39032 -std-c89
39033 \begin_inset LatexCommand index
39034 name "-\\/-std-c89"
39035
39036 \end_inset
39037
39038
39039 \series default
39040  or 
39041 \series bold
39042 -
39043 \begin_inset ERT
39044 status collapsed
39045
39046 \begin_layout Standard
39047
39048
39049 \backslash
39050 /
39051 \end_layout
39052
39053 \end_inset
39054
39055 -std-c99
39056 \begin_inset LatexCommand index
39057 name "-\\/-std-c99"
39058
39059 \end_inset
39060
39061
39062 \series default
39063  command line options are used.
39064 \end_layout
39065
39066 \begin_deeper
39067 \begin_layout Verse
39068
39069 \family typewriter
39070 void vararg_func (char *str, ...) { str; }
39071 \newline
39072
39073 \newline
39074 void main (void)
39075 \newline
39076 {
39077 \newline
39078 \InsetSpace ~
39079 \InsetSpace ~
39080 char c = 10;
39081 \newline
39082
39083 \newline
39084 \InsetSpace ~
39085 \InsetSpace ~
39086 /* argument
39087  u is promoted to int before
39088 \newline
39089 \InsetSpace ~
39090 \InsetSpace ~
39091 \InsetSpace ~
39092 * passing to function */
39093 \newline
39094 \InsetSpace ~
39095 \InsetSpace ~
39096 vararg_func ("%c", c);
39097 \newline
39098
39099 \newline
39100 \InsetSpace ~
39101 \InsetSpace ~
39102 /*
39103  argument u is not promoted to int,
39104 \newline
39105 \InsetSpace ~
39106 \InsetSpace ~
39107 \InsetSpace ~
39108 * it is passed as char to function
39109 \newline
39110 \InsetSpace ~
39111 \InsetSpace ~
39112 \InsetSpace ~
39113 * if
39114  --std-cXX is not defined;
39115 \newline
39116 \InsetSpace ~
39117 \InsetSpace ~
39118 \InsetSpace ~
39119 * is promoted to int before passing
39120 \newline
39121 \InsetSpace ~
39122 \InsetSpace ~
39123 \InsetSpace ~
39124 * to function
39125  if --std-cXX is defined */
39126 \newline
39127 \InsetSpace ~
39128 \InsetSpace ~
39129 vararg_func ("%bc", (char)u);
39130 \newline
39131 }
39132 \end_layout
39133
39134 \end_deeper
39135 \begin_layout Section
39136 Cyclomatic Complexity
39137 \begin_inset LatexCommand index
39138 name "Cyclomatic complexity"
39139
39140 \end_inset
39141
39142
39143 \end_layout
39144
39145 \begin_layout Standard
39146 Cyclomatic complexity of a function is defined as the number of independent
39147  paths the program can take during execution of the function.
39148  This is an important number since it defines the number test cases you
39149  have to generate to validate the function.
39150  The accepted industry standard for complexity number is 10, if the cyclomatic
39151  complexity reported by SDCC exceeds 10 you should think about simplification
39152  of the function logic.
39153  Note that the complexity level is not related to the number of lines of
39154  code in a function.
39155  Large functions can have low complexity, and small functions can have large
39156  complexity levels.
39157  
39158 \newline
39159
39160 \newline
39161 SDCC uses the following formula to compute the complexity:
39162 \newline
39163
39164 \end_layout
39165
39166 \begin_layout Standard
39167 complexity = (number of edges in control flow graph) - (number of nodes
39168  in control flow graph) + 2;
39169 \newline
39170
39171 \newline
39172 Having said that the industry standard is 10,
39173  you should be aware that in some cases it be may unavoidable to have a
39174  complexity level of less than 10.
39175  For example if you have switch statement with more than 10 case labels,
39176  each case label adds one to the complexity level.
39177  The complexity level is by no means an absolute measure of the algorithmic
39178  complexity of the function, it does however provide a good starting point
39179  for which functions you might look at for further optimization.
39180 \end_layout
39181
39182 \begin_layout Section
39183 Retargetting for other Processors
39184 \end_layout
39185
39186 \begin_layout Standard
39187 The issues for retargetting the compiler are far too numerous to be covered
39188  by this document.
39189  What follows is a brief description of each of the seven phases of the
39190  compiler and its MCU dependency.
39191 \end_layout
39192
39193 \begin_layout Itemize
39194 Parsing the source and building the annotated parse tree.
39195  This phase is largely MCU independent (except for the language extensions).
39196  Syntax & semantic checks are also done in this phase, along with some initial
39197  optimizations like back patching labels and the pattern matching optimizations
39198  like bit-rotation etc.
39199 \end_layout
39200
39201 \begin_layout Itemize
39202 The second phase involves generating an intermediate code which can be easy
39203  manipulated during the later phases.
39204  This phase is entirely MCU independent.
39205  The intermediate code generation assumes the target machine has unlimited
39206  number of registers, and designates them with the name iTemp.
39207  The compiler can be made to dump a human readable form of the code generated
39208  by using the -
39209 \begin_inset ERT
39210 status collapsed
39211
39212 \begin_layout Standard
39213
39214
39215 \backslash
39216 /
39217 \end_layout
39218
39219 \end_inset
39220
39221 -dumpraw option.
39222 \end_layout
39223
39224 \begin_layout Itemize
39225 This phase does the bulk of the standard optimizations and is also MCU independe
39226 nt.
39227  This phase can be broken down into several sub-phases:
39228 \newline
39229
39230 \newline
39231 Break down intermediate
39232  code (iCode) into basic blocks.
39233 \newline
39234 Do control flow & data flow analysis on the
39235  basic blocks.
39236 \newline
39237 Do local common subexpression elimination, then global subexpressio
39238 n elimination
39239 \newline
39240 Dead code elimination
39241 \newline
39242 Loop optimizations
39243 \newline
39244 If loop optimizations
39245  caused any changes then do 'global subexpression elimination' and 'dead
39246  code elimination' again.
39247 \end_layout
39248
39249 \begin_layout Itemize
39250 This phase determines the live-ranges; by live range I mean those iTemp
39251  variables defined by the compiler that still survive after all the optimization
39252 s.
39253  Live range analysis
39254 \begin_inset LatexCommand index
39255 name "Live range analysis"
39256
39257 \end_inset
39258
39259  is essential for register allocation, since these computation determines
39260  which of these iTemps will be assigned to registers, and for how long.
39261 \end_layout
39262
39263 \begin_layout Itemize
39264 Phase five is register allocation.
39265  There are two parts to this process.
39266 \newline
39267
39268 \newline
39269 The first part I call 'register packing'
39270  (for lack of a better term).
39271  In this case several MCU specific expression folding is done to reduce
39272  register pressure.
39273 \newline
39274
39275 \newline
39276 The second part is more MCU independent and deals with
39277  allocating registers to the remaining live ranges.
39278  A lot of MCU specific code does creep into this phase because of the limited
39279  number of index registers available in the 8051.
39280 \end_layout
39281
39282 \begin_layout Itemize
39283 The Code generation phase is (unhappily), entirely MCU dependent and very
39284  little (if any at all) of this code can be reused for other MCU.
39285  However the scheme for allocating a homogenized assembler operand for each
39286  iCode operand may be reused.
39287 \end_layout
39288
39289 \begin_layout Itemize
39290 As mentioned in the optimization section the peep-hole optimizer is rule
39291  based system, which can reprogrammed for other MCUs.
39292 \end_layout
39293
39294 \begin_layout Standard
39295 More information is available on SDCC Wiki
39296 \begin_inset LatexCommand index
39297 name "wiki"
39298
39299 \end_inset
39300
39301  (preliminary link 
39302 \begin_inset LatexCommand url
39303 target "http://sdcc.wiki.sourceforge.net/SDCC+internals+and+porting"
39304
39305 \end_inset
39306
39307 ) and in the thread 
39308 \begin_inset LatexCommand url
39309 target "http://sf.net/mailarchive/message.php?msg_id=13954144"
39310
39311 \end_inset
39312
39313  .
39314 \end_layout
39315
39316 \begin_layout Chapter
39317 Compiler internals
39318 \begin_inset LatexCommand index
39319 name "Compiler internals"
39320
39321 \end_inset
39322
39323
39324 \end_layout
39325
39326 \begin_layout Section
39327 The anatomy of the compiler
39328 \begin_inset LatexCommand label
39329 name "sub:The-anatomy-of"
39330
39331 \end_inset
39332
39333
39334 \end_layout
39335
39336 \begin_layout Standard
39337
39338 \shape italic
39339 This is an excerpt from an article published in Circuit Cellar Magazine
39340  in
39341 \shape default
39342  
39343 \series bold
39344 \shape italic
39345 August 2000
39346 \series default
39347 .
39348  It's a little outdated (the compiler is much more efficient now and user/develo
39349 per friendly), but pretty well exposes the guts of it all.
39350 \shape default
39351
39352 \newline
39353
39354 \newline
39355 The current version of SDCC can generate code for Intel 8051 and Z80 MCU.
39356  It is fairly easy to retarget for other 8-bit MCU.
39357  Here we take a look at some of the internals of the compiler.
39358  
39359 \end_layout
39360
39361 \begin_layout Paragraph*
39362 Parsing
39363 \begin_inset LatexCommand index
39364 name "Parsing"
39365
39366 \end_inset
39367
39368  
39369 \end_layout
39370
39371 \begin_layout Standard
39372 Parsing the input source file and creating an AST (Annotated Syntax Tree
39373 \begin_inset LatexCommand index
39374 name "Annotated syntax tree"
39375
39376 \end_inset
39377
39378 ).
39379  This phase also involves propagating types (annotating each node of the
39380  parse tree with type information) and semantic analysis.
39381  There are some MCU specific parsing rules.
39382  For example the storage classes, the extended storage classes are MCU specific
39383  while there may be a xdata storage class for 8051 there is no such storage
39384  class for z80 or Atmel AVR.
39385  SDCC allows MCU specific storage class extensions, i.e.
39386  xdata will be treated as a storage class specifier when parsing 8051 C
39387  code but will be treated as a C identifier when parsing z80 or ATMEL AVR
39388  C code.
39389 \end_layout
39390
39391 \begin_layout Paragraph*
39392 Generating iCode
39393 \begin_inset LatexCommand index
39394 name "iCode"
39395
39396 \end_inset
39397
39398
39399 \end_layout
39400
39401 \begin_layout Standard
39402 Intermediate code generation.
39403  In this phase the AST is broken down into three-operand form (iCode).
39404  These three operand forms are represented as doubly linked lists.
39405  ICode is the term given to the intermediate form generated by the compiler.
39406  ICode example section shows some examples of iCode generated for some simple
39407  C source functions.
39408 \end_layout
39409
39410 \begin_layout Paragraph*
39411 Optimizations
39412 \begin_inset LatexCommand index
39413 name "Optimizations"
39414
39415 \end_inset
39416
39417 .
39418 \end_layout
39419
39420 \begin_layout Standard
39421 Bulk of the target independent optimizations is performed in this phase.
39422  The optimizations include constant propagation, common sub-expression eliminati
39423 on, loop invariant code movement, strength reduction of loop induction variables
39424  and dead-code elimination.
39425 \end_layout
39426
39427 \begin_layout Paragraph*
39428 Live range analysis
39429 \begin_inset LatexCommand index
39430 name "Live range analysis"
39431
39432 \end_inset
39433
39434
39435 \end_layout
39436
39437 \begin_layout Standard
39438 During intermediate code generation phase, the compiler assumes the target
39439  machine has infinite number of registers and generates a lot of temporary
39440  variables.
39441  The live range computation determines the lifetime of each of these compiler-ge
39442 nerated temporaries.
39443  A picture speaks a thousand words.
39444  ICode example sections show the live range annotations for each of the
39445  operand.
39446  It is important to note here, each iCode is assigned a number in the order
39447  of its execution in the function.
39448  The live ranges are computed in terms of these numbers.
39449  The from number is the number of the iCode which first defines the operand
39450  and the to number signifies the iCode which uses this operand last.
39451 \end_layout
39452
39453 \begin_layout Paragraph*
39454 Register Allocation
39455 \begin_inset LatexCommand index
39456 name "Register allocation"
39457
39458 \end_inset
39459
39460
39461 \end_layout
39462
39463 \begin_layout Standard
39464 The register allocation determines the type and number of registers needed
39465  by each operand.
39466  In most MCUs only a few registers can be used for indirect addressing.
39467  In case of 8051 for example the registers R0 & R1 can be used to indirectly
39468  address the internal ram and DPTR to indirectly address the external ram.
39469  The compiler will try to allocate the appropriate register to pointer variables
39470  if it can.
39471  ICode example section shows the operands annotated with the registers assigned
39472  to them.
39473  The compiler will try to keep operands in registers as much as possible;
39474  there are several schemes the compiler uses to do achieve this.
39475  When the compiler runs out of registers the compiler will check to see
39476  if there are any live operands which is not used or defined in the current
39477  basic block being processed, if there are any found then it will push that
39478  operand and use the registers in this block, the operand will then be popped
39479  at the end of the basic block.
39480  
39481 \end_layout
39482
39483 \begin_layout Standard
39484 There are other MCU specific considerations in this phase.
39485  Some MCUs have an accumulator; very short-lived operands could be assigned
39486  to the accumulator instead of a general-purpose register.
39487 \end_layout
39488
39489 \begin_layout Paragraph*
39490 Code generation
39491 \end_layout
39492
39493 \begin_layout Standard
39494 Figure II gives a table of iCode
39495 \begin_inset LatexCommand index
39496 name "iCode"
39497
39498 \end_inset
39499
39500  operations supported by the compiler.
39501  The code generation involves translating these operations into corresponding
39502  assembly code for the processor.
39503  This sounds overly simple but that is the essence of code generation.
39504  Some of the iCode operations are generated on a MCU specific manner for
39505  example, the z80 port does not use registers to pass parameters so the
39506  SEND and RECV iCode operations will not be generated, and it also does
39507  not support JUMPTABLES.
39508  
39509 \newline
39510
39511 \end_layout
39512
39513 \begin_layout Standard
39514
39515 \size footnotesize
39516 Figure II 
39517 \begin_inset Tabular
39518 <lyxtabular version="3" rows="39" columns="4">
39519 <features islongtable="true" headBottomDL="true">
39520 <column alignment="block" valignment="top" leftline="true" width="13col%">
39521 <column alignment="left" valignment="top" leftline="true" width="13col%">
39522 <column alignment="block" valignment="top" leftline="true" width="22col%">
39523 <column alignment="block" valignment="top" leftline="true" rightline="true" width="40col%">
39524 <row topline="true" bottomline="true" endhead="true">
39525 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39526 \begin_inset Text
39527
39528 \begin_layout Standard
39529
39530 \series bold
39531 iCode
39532 \series default
39533
39534 \begin_inset LatexCommand index
39535 name "iCode"
39536
39537 \end_inset
39538
39539
39540 \end_layout
39541
39542 \end_inset
39543 </cell>
39544 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39545 \begin_inset Text
39546
39547 \begin_layout Standard
39548
39549 \series bold
39550 Operands
39551 \end_layout
39552
39553 \end_inset
39554 </cell>
39555 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39556 \begin_inset Text
39557
39558 \begin_layout Standard
39559
39560 \series bold
39561 Description
39562 \end_layout
39563
39564 \end_inset
39565 </cell>
39566 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39567 \begin_inset Text
39568
39569 \begin_layout Standard
39570
39571 \series bold
39572 C Equivalent
39573 \end_layout
39574
39575 \end_inset
39576 </cell>
39577 </row>
39578 <row topline="true">
39579 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39580 \begin_inset Text
39581
39582 \begin_layout Standard
39583
39584 \size footnotesize
39585 '!'
39586 \end_layout
39587
39588 \end_inset
39589 </cell>
39590 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39591 \begin_inset Text
39592
39593 \begin_layout Standard
39594
39595 \size footnotesize
39596 IC_LEFT() IC_RESULT()
39597 \end_layout
39598
39599 \end_inset
39600 </cell>
39601 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39602 \begin_inset Text
39603
39604 \begin_layout Standard
39605
39606 \size footnotesize
39607 NOT operation 
39608 \end_layout
39609
39610 \end_inset
39611 </cell>
39612 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39613 \begin_inset Text
39614
39615 \begin_layout Standard
39616
39617 \size footnotesize
39618 IC_RESULT = ! IC_LEFT;
39619 \end_layout
39620
39621 \end_inset
39622 </cell>
39623 </row>
39624 <row topline="true">
39625 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39626 \begin_inset Text
39627
39628 \begin_layout Standard
39629
39630 \size footnotesize
39631 '~'
39632 \end_layout
39633
39634 \end_inset
39635 </cell>
39636 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39637 \begin_inset Text
39638
39639 \begin_layout Standard
39640
39641 \size footnotesize
39642 IC_LEFT() IC_RESULT()
39643 \end_layout
39644
39645 \end_inset
39646 </cell>
39647 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39648 \begin_inset Text
39649
39650 \begin_layout Standard
39651
39652 \size footnotesize
39653 Bitwise complement of 
39654 \end_layout
39655
39656 \end_inset
39657 </cell>
39658 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39659 \begin_inset Text
39660
39661 \begin_layout Standard
39662
39663 \size footnotesize
39664 IC_RESULT = ~IC_LEFT;
39665 \end_layout
39666
39667 \end_inset
39668 </cell>
39669 </row>
39670 <row topline="true">
39671 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39672 \begin_inset Text
39673
39674 \begin_layout Standard
39675
39676 \size footnotesize
39677 RRC
39678 \end_layout
39679
39680 \end_inset
39681 </cell>
39682 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39683 \begin_inset Text
39684
39685 \begin_layout Standard
39686
39687 \size footnotesize
39688 IC_LEFT() IC_RESULT()
39689 \end_layout
39690
39691 \end_inset
39692 </cell>
39693 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39694 \begin_inset Text
39695
39696 \begin_layout Standard
39697
39698 \size footnotesize
39699 Rotate right with carry
39700 \end_layout
39701
39702 \end_inset
39703 </cell>
39704 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39705 \begin_inset Text
39706
39707 \begin_layout Standard
39708
39709 \size footnotesize
39710 IC_RESULT = (IC_LEFT << 1) | (IC_LEFT >> (sizeof(IC_LEFT)*8-1));
39711 \end_layout
39712
39713 \end_inset
39714 </cell>
39715 </row>
39716 <row topline="true">
39717 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39718 \begin_inset Text
39719
39720 \begin_layout Standard
39721
39722 \size footnotesize
39723 RLC
39724 \end_layout
39725
39726 \end_inset
39727 </cell>
39728 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39729 \begin_inset Text
39730
39731 \begin_layout Standard
39732
39733 \size footnotesize
39734 IC_LEFT() IC_RESULT()
39735 \end_layout
39736
39737 \end_inset
39738 </cell>
39739 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39740 \begin_inset Text
39741
39742 \begin_layout Standard
39743
39744 \size footnotesize
39745 Rotate left with carry
39746 \end_layout
39747
39748 \end_inset
39749 </cell>
39750 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39751 \begin_inset Text
39752
39753 \begin_layout Standard
39754
39755 \size footnotesize
39756 IC_RESULT = (IC_LEFT << (sizeof(LC_LEFT)*8-1) ) | (IC_LEFT >> 1);
39757 \end_layout
39758
39759 \end_inset
39760 </cell>
39761 </row>
39762 <row topline="true">
39763 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39764 \begin_inset Text
39765
39766 \begin_layout Standard
39767
39768 \size footnotesize
39769 GETHBIT
39770 \end_layout
39771
39772 \end_inset
39773 </cell>
39774 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39775 \begin_inset Text
39776
39777 \begin_layout Standard
39778
39779 \size footnotesize
39780 IC_LEFT() IC_RESULT()
39781 \end_layout
39782
39783 \end_inset
39784 </cell>
39785 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39786 \begin_inset Text
39787
39788 \begin_layout Standard
39789
39790 \size footnotesize
39791 Get the highest order bit of IC_LEFT
39792 \end_layout
39793
39794 \end_inset
39795 </cell>
39796 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39797 \begin_inset Text
39798
39799 \begin_layout Standard
39800
39801 \size footnotesize
39802 IC_RESULT = (IC_LEFT >> (sizeof(IC_LEFT)*8 -1));
39803 \end_layout
39804
39805 \end_inset
39806 </cell>
39807 </row>
39808 <row topline="true">
39809 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39810 \begin_inset Text
39811
39812 \begin_layout Standard
39813
39814 \size footnotesize
39815 UNARYMINUS
39816 \end_layout
39817
39818 \end_inset
39819 </cell>
39820 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39821 \begin_inset Text
39822
39823 \begin_layout Standard
39824
39825 \size footnotesize
39826 IC_LEFT() IC_RESULT()
39827 \end_layout
39828
39829 \end_inset
39830 </cell>
39831 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39832 \begin_inset Text
39833
39834 \begin_layout Standard
39835
39836 \size footnotesize
39837 Unary minus
39838 \end_layout
39839
39840 \end_inset
39841 </cell>
39842 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39843 \begin_inset Text
39844
39845 \begin_layout Standard
39846
39847 \size footnotesize
39848 IC_RESULT = - IC_LEFT;
39849 \end_layout
39850
39851 \end_inset
39852 </cell>
39853 </row>
39854 <row topline="true">
39855 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39856 \begin_inset Text
39857
39858 \begin_layout Standard
39859
39860 \size footnotesize
39861 IPUSH
39862 \end_layout
39863
39864 \end_inset
39865 </cell>
39866 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39867 \begin_inset Text
39868
39869 \begin_layout Standard
39870
39871 \size footnotesize
39872 IC_LEFT()
39873 \end_layout
39874
39875 \end_inset
39876 </cell>
39877 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39878 \begin_inset Text
39879
39880 \begin_layout Standard
39881
39882 \size footnotesize
39883 Push the operand into stack
39884 \end_layout
39885
39886 \end_inset
39887 </cell>
39888 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39889 \begin_inset Text
39890
39891 \begin_layout Standard
39892
39893 \size footnotesize
39894 NONE
39895 \end_layout
39896
39897 \end_inset
39898 </cell>
39899 </row>
39900 <row topline="true">
39901 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39902 \begin_inset Text
39903
39904 \begin_layout Standard
39905
39906 \size footnotesize
39907 IPOP
39908 \end_layout
39909
39910 \end_inset
39911 </cell>
39912 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39913 \begin_inset Text
39914
39915 \begin_layout Standard
39916
39917 \size footnotesize
39918 IC_LEFT()
39919 \end_layout
39920
39921 \end_inset
39922 </cell>
39923 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39924 \begin_inset Text
39925
39926 \begin_layout Standard
39927
39928 \size footnotesize
39929 Pop the operand from the stack 
39930 \end_layout
39931
39932 \end_inset
39933 </cell>
39934 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39935 \begin_inset Text
39936
39937 \begin_layout Standard
39938
39939 \size footnotesize
39940 NONE
39941 \end_layout
39942
39943 \end_inset
39944 </cell>
39945 </row>
39946 <row topline="true">
39947 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39948 \begin_inset Text
39949
39950 \begin_layout Standard
39951
39952 \size footnotesize
39953 CALL
39954 \end_layout
39955
39956 \end_inset
39957 </cell>
39958 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39959 \begin_inset Text
39960
39961 \begin_layout Standard
39962
39963 \size footnotesize
39964 IC_LEFT() IC_RESULT()
39965 \end_layout
39966
39967 \end_inset
39968 </cell>
39969 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39970 \begin_inset Text
39971
39972 \begin_layout Standard
39973
39974 \size footnotesize
39975 Call the function represented by IC_LEFT 
39976 \end_layout
39977
39978 \end_inset
39979 </cell>
39980 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
39981 \begin_inset Text
39982
39983 \begin_layout Standard
39984
39985 \size footnotesize
39986 IC_RESULT = IC_LEFT();
39987 \end_layout
39988
39989 \end_inset
39990 </cell>
39991 </row>
39992 <row topline="true">
39993 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
39994 \begin_inset Text
39995
39996 \begin_layout Standard
39997
39998 \size footnotesize
39999 PCALL
40000 \end_layout
40001
40002 \end_inset
40003 </cell>
40004 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40005 \begin_inset Text
40006
40007 \begin_layout Standard
40008
40009 \size footnotesize
40010 IC_LEFT() IC_RESULT()
40011 \end_layout
40012
40013 \end_inset
40014 </cell>
40015 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40016 \begin_inset Text
40017
40018 \begin_layout Standard
40019
40020 \size footnotesize
40021 Call via function pointer
40022 \end_layout
40023
40024 \end_inset
40025 </cell>
40026 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40027 \begin_inset Text
40028
40029 \begin_layout Standard
40030
40031 \size footnotesize
40032 IC_RESULT = (*IC_LEFT)();
40033 \end_layout
40034
40035 \end_inset
40036 </cell>
40037 </row>
40038 <row topline="true">
40039 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40040 \begin_inset Text
40041
40042 \begin_layout Standard
40043
40044 \size footnotesize
40045 RETURN
40046 \end_layout
40047
40048 \end_inset
40049 </cell>
40050 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40051 \begin_inset Text
40052
40053 \begin_layout Standard
40054
40055 \size footnotesize
40056 IC_LEFT()
40057 \end_layout
40058
40059 \end_inset
40060 </cell>
40061 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40062 \begin_inset Text
40063
40064 \begin_layout Standard
40065
40066 \size footnotesize
40067 Return the value in operand IC_LEFT 
40068 \end_layout
40069
40070 \end_inset
40071 </cell>
40072 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40073 \begin_inset Text
40074
40075 \begin_layout Standard
40076
40077 \size footnotesize
40078 return IC_LEFT;
40079 \end_layout
40080
40081 \end_inset
40082 </cell>
40083 </row>
40084 <row topline="true">
40085 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40086 \begin_inset Text
40087
40088 \begin_layout Standard
40089
40090 \size footnotesize
40091 LABEL
40092 \end_layout
40093
40094 \end_inset
40095 </cell>
40096 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40097 \begin_inset Text
40098
40099 \begin_layout Standard
40100
40101 \size footnotesize
40102 IC_LABEL() 
40103 \end_layout
40104
40105 \end_inset
40106 </cell>
40107 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40108 \begin_inset Text
40109
40110 \begin_layout Standard
40111
40112 \size footnotesize
40113 Label
40114 \end_layout
40115
40116 \end_inset
40117 </cell>
40118 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40119 \begin_inset Text
40120
40121 \begin_layout Standard
40122
40123 \size footnotesize
40124 IC_LABEL:
40125 \end_layout
40126
40127 \end_inset
40128 </cell>
40129 </row>
40130 <row topline="true">
40131 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40132 \begin_inset Text
40133
40134 \begin_layout Standard
40135
40136 \size footnotesize
40137 GOTO
40138 \end_layout
40139
40140 \end_inset
40141 </cell>
40142 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40143 \begin_inset Text
40144
40145 \begin_layout Standard
40146
40147 \size footnotesize
40148 IC_LABEL() 
40149 \end_layout
40150
40151 \end_inset
40152 </cell>
40153 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40154 \begin_inset Text
40155
40156 \begin_layout Standard
40157
40158 \size footnotesize
40159 Goto label
40160 \end_layout
40161
40162 \end_inset
40163 </cell>
40164 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40165 \begin_inset Text
40166
40167 \begin_layout Standard
40168
40169 \size footnotesize
40170 goto IC_LABEL();
40171 \end_layout
40172
40173 \end_inset
40174 </cell>
40175 </row>
40176 <row topline="true">
40177 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40178 \begin_inset Text
40179
40180 \begin_layout Standard
40181
40182 \size footnotesize
40183 '+'
40184 \end_layout
40185
40186 \end_inset
40187 </cell>
40188 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40189 \begin_inset Text
40190
40191 \begin_layout Standard
40192
40193 \size footnotesize
40194 IC_LEFT() IC_RIGHT() IC_RESULT()
40195 \end_layout
40196
40197 \end_inset
40198 </cell>
40199 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40200 \begin_inset Text
40201
40202 \begin_layout Standard
40203
40204 \size footnotesize
40205 Addition
40206 \end_layout
40207
40208 \end_inset
40209 </cell>
40210 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40211 \begin_inset Text
40212
40213 \begin_layout Standard
40214
40215 \size footnotesize
40216 IC_RESULT = IC_LEFT + IC_RIGHT
40217 \end_layout
40218
40219 \end_inset
40220 </cell>
40221 </row>
40222 <row topline="true">
40223 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40224 \begin_inset Text
40225
40226 \begin_layout Standard
40227
40228 \size footnotesize
40229 '-'
40230 \end_layout
40231
40232 \end_inset
40233 </cell>
40234 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40235 \begin_inset Text
40236
40237 \begin_layout Standard
40238
40239 \size footnotesize
40240 IC_LEFT() IC_RIGHT() IC_RESULT()
40241 \end_layout
40242
40243 \end_inset
40244 </cell>
40245 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40246 \begin_inset Text
40247
40248 \begin_layout Standard
40249
40250 \size footnotesize
40251 Subtraction
40252 \end_layout
40253
40254 \end_inset
40255 </cell>
40256 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40257 \begin_inset Text
40258
40259 \begin_layout Standard
40260
40261 \size footnotesize
40262 IC_RESULT = IC_LEFT - IC_RIGHT 
40263 \end_layout
40264
40265 \end_inset
40266 </cell>
40267 </row>
40268 <row topline="true">
40269 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40270 \begin_inset Text
40271
40272 \begin_layout Standard
40273
40274 \size footnotesize
40275 '*'
40276 \end_layout
40277
40278 \end_inset
40279 </cell>
40280 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40281 \begin_inset Text
40282
40283 \begin_layout Standard
40284
40285 \size footnotesize
40286 IC_LEFT() IC_RIGHT() IC_RESULT()
40287 \end_layout
40288
40289 \end_inset
40290 </cell>
40291 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40292 \begin_inset Text
40293
40294 \begin_layout Standard
40295
40296 \size footnotesize
40297 Multiplication 
40298 \end_layout
40299
40300 \end_inset
40301 </cell>
40302 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40303 \begin_inset Text
40304
40305 \begin_layout Standard
40306
40307 \size footnotesize
40308 IC_RESULT = IC_LEFT * IC_RIGHT;
40309 \end_layout
40310
40311 \end_inset
40312 </cell>
40313 </row>
40314 <row topline="true">
40315 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40316 \begin_inset Text
40317
40318 \begin_layout Standard
40319
40320 \size footnotesize
40321 '/'
40322 \end_layout
40323
40324 \end_inset
40325 </cell>
40326 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40327 \begin_inset Text
40328
40329 \begin_layout Standard
40330
40331 \size footnotesize
40332 IC_LEFT() IC_RIGHT() IC_RESULT()
40333 \end_layout
40334
40335 \end_inset
40336 </cell>
40337 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40338 \begin_inset Text
40339
40340 \begin_layout Standard
40341
40342 \size footnotesize
40343 Division
40344 \end_layout
40345
40346 \end_inset
40347 </cell>
40348 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40349 \begin_inset Text
40350
40351 \begin_layout Standard
40352
40353 \size footnotesize
40354 IC_RESULT = IC_LEFT / IC_RIGHT;
40355 \end_layout
40356
40357 \end_inset
40358 </cell>
40359 </row>
40360 <row topline="true">
40361 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40362 \begin_inset Text
40363
40364 \begin_layout Standard
40365
40366 \size footnotesize
40367 '%'
40368 \end_layout
40369
40370 \end_inset
40371 </cell>
40372 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40373 \begin_inset Text
40374
40375 \begin_layout Standard
40376
40377 \size footnotesize
40378 IC_LEFT() IC_RIGHT() IC_RESULT()
40379 \end_layout
40380
40381 \end_inset
40382 </cell>
40383 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40384 \begin_inset Text
40385
40386 \begin_layout Standard
40387
40388 \size footnotesize
40389 Modulus
40390 \end_layout
40391
40392 \end_inset
40393 </cell>
40394 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40395 \begin_inset Text
40396
40397 \begin_layout Standard
40398
40399 \size footnotesize
40400 IC_RESULT = IC_LEFT % IC_RIGHT;
40401 \end_layout
40402
40403 \end_inset
40404 </cell>
40405 </row>
40406 <row topline="true">
40407 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40408 \begin_inset Text
40409
40410 \begin_layout Standard
40411
40412 \size footnotesize
40413 '<'
40414 \end_layout
40415
40416 \end_inset
40417 </cell>
40418 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40419 \begin_inset Text
40420
40421 \begin_layout Standard
40422
40423 \size footnotesize
40424 IC_LEFT() IC_RIGHT() IC_RESULT()
40425 \end_layout
40426
40427 \end_inset
40428 </cell>
40429 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40430 \begin_inset Text
40431
40432 \begin_layout Standard
40433
40434 \size footnotesize
40435 Less than
40436 \end_layout
40437
40438 \end_inset
40439 </cell>
40440 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40441 \begin_inset Text
40442
40443 \begin_layout Standard
40444
40445 \size footnotesize
40446 IC_RESULT = IC_LEFT < IC_RIGHT;
40447 \end_layout
40448
40449 \end_inset
40450 </cell>
40451 </row>
40452 <row topline="true">
40453 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40454 \begin_inset Text
40455
40456 \begin_layout Standard
40457
40458 \size footnotesize
40459 '>'
40460 \end_layout
40461
40462 \end_inset
40463 </cell>
40464 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40465 \begin_inset Text
40466
40467 \begin_layout Standard
40468
40469 \size footnotesize
40470 IC_LEFT() IC_RIGHT() IC_RESULT()
40471 \end_layout
40472
40473 \end_inset
40474 </cell>
40475 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40476 \begin_inset Text
40477
40478 \begin_layout Standard
40479
40480 \size footnotesize
40481 Greater than 
40482 \end_layout
40483
40484 \end_inset
40485 </cell>
40486 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40487 \begin_inset Text
40488
40489 \begin_layout Standard
40490
40491 \size footnotesize
40492 IC_RESULT = IC_LEFT > IC_RIGHT;
40493 \end_layout
40494
40495 \end_inset
40496 </cell>
40497 </row>
40498 <row topline="true">
40499 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40500 \begin_inset Text
40501
40502 \begin_layout Standard
40503
40504 \size footnotesize
40505 EQ_OP
40506 \end_layout
40507
40508 \end_inset
40509 </cell>
40510 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40511 \begin_inset Text
40512
40513 \begin_layout Standard
40514
40515 \size footnotesize
40516 IC_LEFT() IC_RIGHT() IC_RESULT()
40517 \end_layout
40518
40519 \end_inset
40520 </cell>
40521 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40522 \begin_inset Text
40523
40524 \begin_layout Standard
40525
40526 \size footnotesize
40527 Equal to 
40528 \end_layout
40529
40530 \end_inset
40531 </cell>
40532 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40533 \begin_inset Text
40534
40535 \begin_layout Standard
40536
40537 \size footnotesize
40538 IC_RESULT = IC_LEFT == IC_RIGHT;
40539 \end_layout
40540
40541 \end_inset
40542 </cell>
40543 </row>
40544 <row topline="true">
40545 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40546 \begin_inset Text
40547
40548 \begin_layout Standard
40549
40550 \size footnotesize
40551 AND_OP
40552 \end_layout
40553
40554 \end_inset
40555 </cell>
40556 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40557 \begin_inset Text
40558
40559 \begin_layout Standard
40560
40561 \size footnotesize
40562 IC_LEFT() IC_RIGHT() IC_RESULT() 
40563 \end_layout
40564
40565 \end_inset
40566 </cell>
40567 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40568 \begin_inset Text
40569
40570 \begin_layout Standard
40571
40572 \size footnotesize
40573 Logical and operation
40574 \end_layout
40575
40576 \end_inset
40577 </cell>
40578 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40579 \begin_inset Text
40580
40581 \begin_layout Standard
40582
40583 \size footnotesize
40584 IC_RESULT = IC_LEFT && IC_RIGHT; 
40585 \end_layout
40586
40587 \end_inset
40588 </cell>
40589 </row>
40590 <row topline="true">
40591 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40592 \begin_inset Text
40593
40594 \begin_layout Standard
40595
40596 \size footnotesize
40597 OR_OP
40598 \end_layout
40599
40600 \end_inset
40601 </cell>
40602 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40603 \begin_inset Text
40604
40605 \begin_layout Standard
40606
40607 \size footnotesize
40608 IC_LEFT() IC_RIGHT() IC_RESULT() 
40609 \end_layout
40610
40611 \end_inset
40612 </cell>
40613 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40614 \begin_inset Text
40615
40616 \begin_layout Standard
40617
40618 \size footnotesize
40619 Logical or operation 
40620 \end_layout
40621
40622 \end_inset
40623 </cell>
40624 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40625 \begin_inset Text
40626
40627 \begin_layout Standard
40628
40629 \size footnotesize
40630 IC_RESULT = IC_LEFT || IC_RIGHT; 
40631 \end_layout
40632
40633 \end_inset
40634 </cell>
40635 </row>
40636 <row topline="true">
40637 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40638 \begin_inset Text
40639
40640 \begin_layout Standard
40641
40642 \size footnotesize
40643 '^'
40644 \end_layout
40645
40646 \end_inset
40647 </cell>
40648 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40649 \begin_inset Text
40650
40651 \begin_layout Standard
40652
40653 \size footnotesize
40654 IC_LEFT() IC_RIGHT() IC_RESULT() 
40655 \end_layout
40656
40657 \end_inset
40658 </cell>
40659 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40660 \begin_inset Text
40661
40662 \begin_layout Standard
40663
40664 \size footnotesize
40665 Exclusive OR
40666 \end_layout
40667
40668 \end_inset
40669 </cell>
40670 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40671 \begin_inset Text
40672
40673 \begin_layout Standard
40674
40675 \size footnotesize
40676 IC_RESULT = IC_LEFT ^ IC_RIGHT;
40677 \end_layout
40678
40679 \end_inset
40680 </cell>
40681 </row>
40682 <row topline="true">
40683 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40684 \begin_inset Text
40685
40686 \begin_layout Standard
40687
40688 \size footnotesize
40689 '|'
40690 \end_layout
40691
40692 \end_inset
40693 </cell>
40694 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40695 \begin_inset Text
40696
40697 \begin_layout Standard
40698
40699 \size footnotesize
40700 IC_LEFT() IC_RIGHT() IC_RESULT() 
40701 \end_layout
40702
40703 \end_inset
40704 </cell>
40705 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40706 \begin_inset Text
40707
40708 \begin_layout Standard
40709
40710 \size footnotesize
40711 Bitwise OR 
40712 \end_layout
40713
40714 \end_inset
40715 </cell>
40716 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40717 \begin_inset Text
40718
40719 \begin_layout Standard
40720
40721 \size footnotesize
40722 IC_RESULT = IC_LEFT | IC_RIGHT;
40723 \end_layout
40724
40725 \end_inset
40726 </cell>
40727 </row>
40728 <row topline="true">
40729 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40730 \begin_inset Text
40731
40732 \begin_layout Standard
40733
40734 \size footnotesize
40735 BITWISEAND
40736 \end_layout
40737
40738 \end_inset
40739 </cell>
40740 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40741 \begin_inset Text
40742
40743 \begin_layout Standard
40744
40745 \size footnotesize
40746 IC_LEFT() IC_RIGHT() IC_RESULT()
40747 \end_layout
40748
40749 \end_inset
40750 </cell>
40751 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40752 \begin_inset Text
40753
40754 \begin_layout Standard
40755
40756 \size footnotesize
40757 Bitwise AND 
40758 \end_layout
40759
40760 \end_inset
40761 </cell>
40762 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40763 \begin_inset Text
40764
40765 \begin_layout Standard
40766
40767 \size footnotesize
40768 IC_RESULT = IC_LEFT & IC_RIGHT;
40769 \end_layout
40770
40771 \end_inset
40772 </cell>
40773 </row>
40774 <row topline="true">
40775 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40776 \begin_inset Text
40777
40778 \begin_layout Standard
40779
40780 \size footnotesize
40781 LEFT_OP
40782 \end_layout
40783
40784 \end_inset
40785 </cell>
40786 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40787 \begin_inset Text
40788
40789 \begin_layout Standard
40790
40791 \size footnotesize
40792 IC_LEFT() IC_RIGHT() IC_RESULT()
40793 \end_layout
40794
40795 \end_inset
40796 </cell>
40797 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40798 \begin_inset Text
40799
40800 \begin_layout Standard
40801
40802 \size footnotesize
40803 Left shift 
40804 \end_layout
40805
40806 \end_inset
40807 </cell>
40808 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40809 \begin_inset Text
40810
40811 \begin_layout Standard
40812
40813 \size footnotesize
40814 IC_RESULT = IC_LEFT << IC_RIGHT 
40815 \end_layout
40816
40817 \end_inset
40818 </cell>
40819 </row>
40820 <row topline="true">
40821 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40822 \begin_inset Text
40823
40824 \begin_layout Standard
40825
40826 \size footnotesize
40827 RIGHT_OP
40828 \end_layout
40829
40830 \end_inset
40831 </cell>
40832 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40833 \begin_inset Text
40834
40835 \begin_layout Standard
40836
40837 \size footnotesize
40838 IC_LEFT() IC_RIGHT() IC_RESULT()
40839 \end_layout
40840
40841 \end_inset
40842 </cell>
40843 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40844 \begin_inset Text
40845
40846 \begin_layout Standard
40847
40848 \size footnotesize
40849 Right shift
40850 \end_layout
40851
40852 \end_inset
40853 </cell>
40854 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40855 \begin_inset Text
40856
40857 \begin_layout Standard
40858
40859 \size footnotesize
40860 IC_RESULT = IC_LEFT >> IC_RIGHT 
40861 \end_layout
40862
40863 \end_inset
40864 </cell>
40865 </row>
40866 <row topline="true">
40867 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40868 \begin_inset Text
40869
40870 \begin_layout Standard
40871
40872 \size footnotesize
40873 GET_VALUE_
40874 \newline
40875 AT_ ADDRESS
40876 \end_layout
40877
40878 \end_inset
40879 </cell>
40880 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40881 \begin_inset Text
40882
40883 \begin_layout Standard
40884
40885 \size footnotesize
40886 IC_LEFT() IC_RESULT()
40887 \end_layout
40888
40889 \end_inset
40890 </cell>
40891 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40892 \begin_inset Text
40893
40894 \begin_layout Standard
40895
40896 \size footnotesize
40897 Indirect fetch 
40898 \end_layout
40899
40900 \end_inset
40901 </cell>
40902 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40903 \begin_inset Text
40904
40905 \begin_layout Standard
40906
40907 \size footnotesize
40908 IC_RESULT = (*IC_LEFT);
40909 \end_layout
40910
40911 \end_inset
40912 </cell>
40913 </row>
40914 <row topline="true">
40915 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40916 \begin_inset Text
40917
40918 \begin_layout Standard
40919
40920 \size footnotesize
40921 POINTER_SET
40922 \end_layout
40923
40924 \end_inset
40925 </cell>
40926 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40927 \begin_inset Text
40928
40929 \begin_layout Standard
40930
40931 \size footnotesize
40932 IC_RIGHT() IC_RESULT() 
40933 \end_layout
40934
40935 \end_inset
40936 </cell>
40937 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40938 \begin_inset Text
40939
40940 \begin_layout Standard
40941
40942 \size footnotesize
40943 Indirect set
40944 \end_layout
40945
40946 \end_inset
40947 </cell>
40948 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40949 \begin_inset Text
40950
40951 \begin_layout Standard
40952
40953 \size footnotesize
40954 (*IC_RESULT) = IC_RIGHT;
40955 \end_layout
40956
40957 \end_inset
40958 </cell>
40959 </row>
40960 <row topline="true">
40961 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40962 \begin_inset Text
40963
40964 \begin_layout Standard
40965
40966 \size footnotesize
40967 '='
40968 \end_layout
40969
40970 \end_inset
40971 </cell>
40972 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40973 \begin_inset Text
40974
40975 \begin_layout Standard
40976
40977 \size footnotesize
40978 IC_RIGHT() IC_RESULT()
40979 \end_layout
40980
40981 \end_inset
40982 </cell>
40983 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
40984 \begin_inset Text
40985
40986 \begin_layout Standard
40987
40988 \size footnotesize
40989 Assignment
40990 \end_layout
40991
40992 \end_inset
40993 </cell>
40994 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
40995 \begin_inset Text
40996
40997 \begin_layout Standard
40998
40999 \size footnotesize
41000 IC_RESULT = IC_RIGHT;
41001 \end_layout
41002
41003 \end_inset
41004 </cell>
41005 </row>
41006 <row topline="true">
41007 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41008 \begin_inset Text
41009
41010 \begin_layout Standard
41011
41012 \size footnotesize
41013 IFX
41014 \end_layout
41015
41016 \end_inset
41017 </cell>
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 IC_COND IC_TRUE IC_LABEL
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 Conditional jump.
41036  If true label is present then jump to true label if condition is true else
41037  jump to false label if condition is false 
41038 \end_layout
41039
41040 \end_inset
41041 </cell>
41042 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
41043 \begin_inset Text
41044
41045 \begin_layout Standard
41046
41047 \size footnotesize
41048 if (IC_COND) goto IC_TRUE; 
41049 \newline
41050 \InsetSpace ~
41051 \InsetSpace ~
41052 Or 
41053 \newline
41054 If (!IC_COND) goto IC_FALSE;
41055 \end_layout
41056
41057 \end_inset
41058 </cell>
41059 </row>
41060 <row topline="true">
41061 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41062 \begin_inset Text
41063
41064 \begin_layout Standard
41065
41066 \size footnotesize
41067 ADDRESS_OF
41068 \end_layout
41069
41070 \end_inset
41071 </cell>
41072 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41073 \begin_inset Text
41074
41075 \begin_layout Standard
41076
41077 \size footnotesize
41078 IC_LEFT() IC_RESULT()
41079 \end_layout
41080
41081 \end_inset
41082 </cell>
41083 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41084 \begin_inset Text
41085
41086 \begin_layout Standard
41087
41088 \size footnotesize
41089 Address of 
41090 \end_layout
41091
41092 \end_inset
41093 </cell>
41094 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
41095 \begin_inset Text
41096
41097 \begin_layout Standard
41098
41099 \size footnotesize
41100 IC_RESULT = &IC_LEFT();
41101 \end_layout
41102
41103 \end_inset
41104 </cell>
41105 </row>
41106 <row topline="true">
41107 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41108 \begin_inset Text
41109
41110 \begin_layout Standard
41111
41112 \size footnotesize
41113 JUMPTABLE
41114 \end_layout
41115
41116 \end_inset
41117 </cell>
41118 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41119 \begin_inset Text
41120
41121 \begin_layout Standard
41122
41123 \size footnotesize
41124 IC_JTCOND IC_JTLABELS
41125 \end_layout
41126
41127 \end_inset
41128 </cell>
41129 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41130 \begin_inset Text
41131
41132 \begin_layout Standard
41133
41134 \size footnotesize
41135 Jump to list of labels depending on the value of JTCOND
41136 \end_layout
41137
41138 \end_inset
41139 </cell>
41140 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
41141 \begin_inset Text
41142
41143 \begin_layout Standard
41144
41145 \size footnotesize
41146 Switch statement
41147 \end_layout
41148
41149 \end_inset
41150 </cell>
41151 </row>
41152 <row topline="true">
41153 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41154 \begin_inset Text
41155
41156 \begin_layout Standard
41157
41158 \size footnotesize
41159 CAST
41160 \end_layout
41161
41162 \end_inset
41163 </cell>
41164 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41165 \begin_inset Text
41166
41167 \begin_layout Standard
41168
41169 \size footnotesize
41170 IC_RIGHT() IC_LEFT() IC_RESULT()
41171 \end_layout
41172
41173 \end_inset
41174 </cell>
41175 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41176 \begin_inset Text
41177
41178 \begin_layout Standard
41179
41180 \size footnotesize
41181 Cast types 
41182 \end_layout
41183
41184 \end_inset
41185 </cell>
41186 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
41187 \begin_inset Text
41188
41189 \begin_layout Standard
41190
41191 \size footnotesize
41192 IC_RESULT = (typeof IC_LEFT) IC_RIGHT;
41193 \end_layout
41194
41195 \end_inset
41196 </cell>
41197 </row>
41198 <row topline="true">
41199 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41200 \begin_inset Text
41201
41202 \begin_layout Standard
41203
41204 \size footnotesize
41205 SEND
41206 \end_layout
41207
41208 \end_inset
41209 </cell>
41210 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41211 \begin_inset Text
41212
41213 \begin_layout Standard
41214
41215 \size footnotesize
41216 IC_LEFT()
41217 \end_layout
41218
41219 \end_inset
41220 </cell>
41221 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41222 \begin_inset Text
41223
41224 \begin_layout Standard
41225
41226 \size footnotesize
41227 This is used for passing parameters in registers; 
41228 \newline
41229 move IC_LEFT to the next
41230  available parameter register.
41231 \end_layout
41232
41233 \end_inset
41234 </cell>
41235 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
41236 \begin_inset Text
41237
41238 \begin_layout Standard
41239
41240 \size footnotesize
41241 None
41242 \end_layout
41243
41244 \end_inset
41245 </cell>
41246 </row>
41247 <row topline="true">
41248 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41249 \begin_inset Text
41250
41251 \begin_layout Standard
41252
41253 \size footnotesize
41254 RECV
41255 \end_layout
41256
41257 \end_inset
41258 </cell>
41259 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41260 \begin_inset Text
41261
41262 \begin_layout Standard
41263
41264 \size footnotesize
41265 IC_RESULT()
41266 \end_layout
41267
41268 \end_inset
41269 </cell>
41270 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41271 \begin_inset Text
41272
41273 \begin_layout Standard
41274
41275 \size footnotesize
41276 This is used for receiving parameters passed in registers;
41277 \newline
41278 Move the values
41279  in the next parameter register to IC_RESULT 
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 \size footnotesize
41290 None
41291 \end_layout
41292
41293 \end_inset
41294 </cell>
41295 </row>
41296 <row topline="true" bottomline="true">
41297 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41298 \begin_inset Text
41299
41300 \begin_layout Standard
41301
41302 \shape slanted
41303 \size footnotesize
41304 (some more have been added)
41305 \end_layout
41306
41307 \end_inset
41308 </cell>
41309 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41310 \begin_inset Text
41311
41312 \begin_layout Standard
41313
41314 \end_layout
41315
41316 \end_inset
41317 </cell>
41318 <cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
41319 \begin_inset Text
41320
41321 \begin_layout Standard
41322
41323 \end_layout
41324
41325 \end_inset
41326 </cell>
41327 <cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
41328 \begin_inset Text
41329
41330 \begin_layout Standard
41331
41332 \shape slanted
41333 \size footnotesize
41334 see f.e.
41335
41336 \shape default
41337  
41338 \family typewriter
41339 \shape slanted
41340 gen51Code()
41341 \family default
41342 \shape default
41343  
41344 \shape slanted
41345 in
41346 \shape default
41347  
41348 \family typewriter
41349 \shape slanted
41350 src/mcs51/gen.c
41351 \end_layout
41352
41353 \end_inset
41354 </cell>
41355 </row>
41356 </lyxtabular>
41357
41358 \end_inset
41359
41360
41361 \end_layout
41362
41363 \begin_layout Standard
41364 \begin_inset Note Note
41365 status collapsed
41366
41367 \begin_layout Standard
41368 In the original article Figure II was announced to be downloadable on 
41369 \shape italic
41370 Circuit Cellar
41371 \shape default
41372 's web site.
41373  ftp://ftp.circuitcellar.com/pub/Circuit_Cellar/2000/121/dutta.ZIP
41374 \end_layout
41375
41376 \end_inset
41377
41378
41379 \end_layout
41380
41381 \begin_layout Paragraph*
41382 ICode Example
41383 \begin_inset LatexCommand index
41384 name "iCode"
41385
41386 \end_inset
41387
41388
41389 \end_layout
41390
41391 \begin_layout Standard
41392 This section shows some details of iCode.
41393  The example C code does not do anything useful; it is used as an example
41394  to illustrate the intermediate code generated by the compiler.
41395 \end_layout
41396
41397 \begin_layout Verse
41398
41399 \family typewriter
41400 1.\InsetSpace ~
41401 xdata int * p;
41402 \newline
41403 2.\InsetSpace ~
41404 int gint;
41405 \newline
41406 3.\InsetSpace ~
41407 /* This function does nothing useful.
41408  It is used
41409 \newline
41410 4.\InsetSpace ~
41411 \InsetSpace ~
41412 \InsetSpace ~
41413 \InsetSpace ~
41414 for the purpose of explaining iCode */
41415 \newline
41416 5.\InsetSpace ~
41417 short function (data
41418  int *x)
41419 \newline
41420 6.\InsetSpace ~
41421 {
41422 \newline
41423 7.\InsetSpace ~
41424 \InsetSpace ~
41425 \InsetSpace ~
41426 short i=10; \InsetSpace ~
41427 \InsetSpace ~
41428 /* dead initialization eliminated */
41429 \newline
41430 8.\InsetSpace ~
41431 \InsetSpace ~
41432 \InsetSpace ~
41433 short sum=10;
41434  /* dead initialization eliminated */
41435 \newline
41436 9.\InsetSpace ~
41437 \InsetSpace ~
41438 \InsetSpace ~
41439 short mul;
41440 \newline
41441 10.\InsetSpace ~
41442 \InsetSpace ~
41443 int j ;
41444 \newline
41445 11.\InsetSpace ~
41446 \InsetSpace ~
41447 while (*x) *x++
41448  = *p++; 
41449 \newline
41450 12.\InsetSpace ~
41451 \InsetSpace ~
41452 \InsetSpace ~
41453 \InsetSpace ~
41454 sum = 0 ; 
41455 \newline
41456 13.\InsetSpace ~
41457 \InsetSpace ~
41458 mul = 0;
41459 \newline
41460 14.\InsetSpace ~
41461 \InsetSpace ~
41462 /* compiler detects i,j to be induction
41463  variables */
41464 \newline
41465 15.\InsetSpace ~
41466 \InsetSpace ~
41467 for (i = 0, j = 10 ; i < 10 ; i++, j
41468 \family default
41469 -
41470 \begin_inset ERT
41471 status collapsed
41472
41473 \begin_layout Standard
41474
41475
41476 \backslash
41477 /
41478 \end_layout
41479
41480 \end_inset
41481
41482 -
41483 \family typewriter
41484 ) {
41485 \newline
41486 16.\InsetSpace ~
41487 \InsetSpace ~
41488 \InsetSpace ~
41489 \InsetSpace ~
41490 sum += i;
41491 \newline
41492 17.\InsetSpace ~
41493 \InsetSpace ~
41494 \InsetSpace ~
41495 \InsetSpace ~
41496 mul += i * 3; \InsetSpace ~
41497 \InsetSpace ~
41498 /* this multiplication remains */
41499 \newline
41500 18.\InsetSpace ~
41501 \InsetSpace ~
41502 \InsetSpace ~
41503 \InsetSpace ~
41504 gint +=
41505  j * 3;\InsetSpace ~
41506 \InsetSpace ~
41507 /* this multiplication changed to addition */
41508 \newline
41509 19.\InsetSpace ~
41510 \InsetSpace ~
41511 }
41512 \newline
41513 20.\InsetSpace ~
41514 \InsetSpace ~
41515 return sum+mul;
41516 \newline
41517 21.\InsetSpace ~
41518 }
41519 \end_layout
41520
41521 \begin_layout Standard
41522 In addition to the operands each iCode contains information about the filename
41523  and line it corresponds to in the source file.
41524  The first field in the listing should be interpreted as follows:
41525 \newline
41526
41527 \shape italic
41528 \size footnotesize
41529 Filename(linenumber: iCode Execution sequence number : ICode hash table
41530  key : loop depth of the iCode).
41531 \shape default
41532 \size default
41533
41534 \newline
41535 Then follows the human readable form of the ICode operation.
41536  Each operand of this triplet form can be of three basic types a) compiler
41537  generated temporary b) user defined variable c) a constant value.
41538  Note that local variables and parameters are replaced by compiler generated
41539  temporaries.
41540  Live ranges
41541 \begin_inset LatexCommand index
41542 name "Live range analysis"
41543
41544 \end_inset
41545
41546  are computed only for temporaries (i.e.
41547  live ranges are not computed for global variables).
41548  Registers
41549 \begin_inset LatexCommand index
41550 name "Register allocation"
41551
41552 \end_inset
41553
41554  are allocated for temporaries only.
41555  Operands are formatted in the following manner:
41556 \newline
41557
41558 \shape italic
41559 \size footnotesize
41560 Operand Name [lr live-from : live-to ] { type information } [ registers
41561  allocated ].
41562 \shape default
41563 \size default
41564
41565 \newline
41566 As mentioned earlier the live ranges are computed in terms of the execution
41567  sequence number of the iCodes, for example 
41568 \newline
41569 the iTemp0 is live from (i.e.
41570  first defined in iCode with execution sequence number 3, and is last used
41571  in the iCode with sequence number 5).
41572  For induction variables such as iTemp21 the live range computation extends
41573  the lifetime from the start to the end of the loop.
41574 \newline
41575 The register allocator
41576  used the live range information to allocate registers, the same registers
41577  may be used for different temporaries if their live ranges do not overlap,
41578  for example r0 is allocated to both iTemp6 and to iTemp17 since their live
41579  ranges do not overlap.
41580  In addition the allocator also takes into consideration the type and usage
41581  of a temporary, for example itemp6 is a pointer to near space and is used
41582  as to fetch data from (i.e.
41583  used in GET_VALUE_AT_ADDRESS) so it is allocated a pointer register (r0).
41584  Some short lived temporaries are allocated to special registers which have
41585  meaning to the code generator e.g.
41586  iTemp13 is allocated to a pseudo register CC which tells the back end that
41587  the temporary is used only for a conditional jump the code generation makes
41588  use of this information to optimize a compare and jump ICode.
41589 \newline
41590 There are several
41591  loop optimizations
41592 \begin_inset LatexCommand index
41593 name "Loop optimization"
41594
41595 \end_inset
41596
41597  performed by the compiler.
41598  It can detect induction variables iTemp21(i) and iTemp23(j).
41599  Also note the compiler does selective strength reduction
41600 \begin_inset LatexCommand index
41601 name "Strength reduction"
41602
41603 \end_inset
41604
41605 , i.e.
41606  the multiplication of an induction variable in line 18 (gint = j * 3) is
41607  changed to addition, a new temporary iTemp17 is allocated and assigned
41608  a initial value, a constant 3 is then added for each iteration of the loop.
41609  The compiler does not change the multiplication
41610 \begin_inset LatexCommand index
41611 name "Multiplication"
41612
41613 \end_inset
41614
41615  in line 17 however since the processor does support an 8 * 8 bit multiplication.
41616 \newline
41617
41618 Note the dead code elimination
41619 \begin_inset LatexCommand index
41620 name "Dead-code elimination"
41621
41622 \end_inset
41623
41624  optimization eliminated the dead assignments in line 7 & 8 to I and sum
41625  respectively.
41626 \newline
41627
41628 \end_layout
41629
41630 \begin_layout Standard
41631
41632 \size footnotesize
41633 Sample.c (5:1:0:0) _entry($9) :
41634 \end_layout
41635
41636 \begin_layout Standard
41637
41638 \size footnotesize
41639 Sample.c(5:2:1:0) proc _function [lr0:0]{function short}
41640 \end_layout
41641
41642 \begin_layout Standard
41643
41644 \size footnotesize
41645 Sample.c(11:3:2:0) iTemp0 [lr3:5]{_near * int}[r2] = recv 
41646 \end_layout
41647
41648 \begin_layout Standard
41649
41650 \size footnotesize
41651 Sample.c(11:4:53:0) preHeaderLbl0($11) :
41652 \end_layout
41653
41654 \begin_layout Standard
41655
41656 \size footnotesize
41657 Sample.c(11:5:55:0) iTemp6 [lr5:16]{_near * int}[r0] := iTemp0 [lr3:5]{_near
41658  * int}[r2]
41659 \end_layout
41660
41661 \begin_layout Standard
41662
41663 \size footnotesize
41664 Sample.c(11:6:5:1) _whilecontinue_0($1) :
41665 \end_layout
41666
41667 \begin_layout Standard
41668
41669 \size footnotesize
41670 Sample.c(11:7:7:1) iTemp4 [lr7:8]{int}[r2 r3] = @[iTemp6 [lr5:16]{_near *
41671  int}[r0]]
41672 \end_layout
41673
41674 \begin_layout Standard
41675
41676 \size footnotesize
41677 Sample.c(11:8:8:1) if iTemp4 [lr7:8]{int}[r2 r3] == 0 goto _whilebreak_0($3)
41678 \end_layout
41679
41680 \begin_layout Standard
41681
41682 \size footnotesize
41683 Sample.c(11:9:14:1) iTemp7 [lr9:13]{_far * int}[DPTR] := _p [lr0:0]{_far
41684  * int}
41685 \end_layout
41686
41687 \begin_layout Standard
41688
41689 \size footnotesize
41690 Sample.c(11:10:15:1) _p [lr0:0]{_far * int} = _p [lr0:0]{_far * int} + 0x2
41691  {short}
41692 \end_layout
41693
41694 \begin_layout Standard
41695
41696 \size footnotesize
41697 Sample.c(11:13:18:1) iTemp10 [lr13:14]{int}[r2 r3] = @[iTemp7 [lr9:13]{_far
41698  * int}[DPTR]]
41699 \end_layout
41700
41701 \begin_layout Standard
41702
41703 \size footnotesize
41704 Sample.c(11:14:19:1) *(iTemp6 [lr5:16]{_near * int}[r0]) := iTemp10 [lr13:14]{int
41705 }[r2 r3]
41706 \end_layout
41707
41708 \begin_layout Standard
41709
41710 \size footnotesize
41711 Sample.c(11:15:12:1) iTemp6 [lr5:16]{_near * int}[r0] = iTemp6 [lr5:16]{_near
41712  * int}[r0] + 0x2 {short}
41713 \end_layout
41714
41715 \begin_layout Standard
41716
41717 \size footnotesize
41718 Sample.c(11:16:20:1) goto _whilecontinue_0($1)
41719 \end_layout
41720
41721 \begin_layout Standard
41722
41723 \size footnotesize
41724 Sample.c(11:17:21:0)_whilebreak_0($3) :
41725 \end_layout
41726
41727 \begin_layout Standard
41728
41729 \size footnotesize
41730 Sample.c(12:18:22:0) iTemp2 [lr18:40]{short}[r2] := 0x0 {short}
41731 \end_layout
41732
41733 \begin_layout Standard
41734
41735 \size footnotesize
41736 Sample.c(13:19:23:0) iTemp11 [lr19:40]{short}[r3] := 0x0 {short}
41737 \end_layout
41738
41739 \begin_layout Standard
41740
41741 \size footnotesize
41742 Sample.c(15:20:54:0)preHeaderLbl1($13) :
41743 \end_layout
41744
41745 \begin_layout Standard
41746
41747 \size footnotesize
41748 Sample.c(15:21:56:0) iTemp21 [lr21:38]{short}[r4] := 0x0 {short}
41749 \end_layout
41750
41751 \begin_layout Standard
41752
41753 \size footnotesize
41754 Sample.c(15:22:57:0) iTemp23 [lr22:38]{int}[r5 r6] := 0xa {int}
41755 \end_layout
41756
41757 \begin_layout Standard
41758
41759 \size footnotesize
41760 Sample.c(15:23:58:0) iTemp17 [lr23:38]{int}[r7 r0] := 0x1e {int}
41761 \end_layout
41762
41763 \begin_layout Standard
41764
41765 \size footnotesize
41766 Sample.c(15:24:26:1)_forcond_0($4) :
41767 \end_layout
41768
41769 \begin_layout Standard
41770
41771 \size footnotesize
41772 Sample.c(15:25:27:1) iTemp13 [lr25:26]{char}[CC] = iTemp21 [lr21:38]{short}[r4]
41773  < 0xa {short}
41774 \end_layout
41775
41776 \begin_layout Standard
41777
41778 \size footnotesize
41779 Sample.c(15:26:28:1) if iTemp13 [lr25:26]{char}[CC] == 0 goto _forbreak_0($7)
41780 \end_layout
41781
41782 \begin_layout Standard
41783
41784 \size footnotesize
41785 Sample.c(16:27:31:1) iTemp2 [lr18:40]{short}[r2] = iTemp2 [lr18:40]{short}[r2]
41786  + ITemp21 [lr21:38]{short}[r4]
41787 \end_layout
41788
41789 \begin_layout Standard
41790
41791 \size footnotesize
41792 Sample.c(17:29:33:1) iTemp15 [lr29:30]{short}[r1] = iTemp21 [lr21:38]{short}[r4]
41793  * 0x3 {short}
41794 \end_layout
41795
41796 \begin_layout Standard
41797
41798 \size footnotesize
41799 Sample.c(17:30:34:1) iTemp11 [lr19:40]{short}[r3] = iTemp11 [lr19:40]{short}[r3]
41800  + iTemp15 [lr29:30]{short}[r1]
41801 \end_layout
41802
41803 \begin_layout Standard
41804
41805 \size footnotesize
41806 Sample.c(18:32:36:1:1) iTemp17 [lr23:38]{int}[r7 r0]= iTemp17 [lr23:38]{int}[r7
41807  r0]- 0x3 {short}
41808 \end_layout
41809
41810 \begin_layout Standard
41811
41812 \size footnotesize
41813 Sample.c(18:33:37:1) _gint [lr0:0]{int} = _gint [lr0:0]{int} + iTemp17 [lr23:38]{
41814 int}[r7 r0]
41815 \end_layout
41816
41817 \begin_layout Standard
41818
41819 \size footnotesize
41820 Sample.c(15:36:42:1) iTemp21 [lr21:38]{short}[r4] = iTemp21 [lr21:38]{short}[r4]
41821  + 0x1 {short}
41822 \end_layout
41823
41824 \begin_layout Standard
41825
41826 \size footnotesize
41827 Sample.c(15:37:45:1) iTemp23 [lr22:38]{int}[r5 r6]= iTemp23 [lr22:38]{int}[r5
41828  r6]- 0x1 {short}
41829 \end_layout
41830
41831 \begin_layout Standard
41832
41833 \size footnotesize
41834 Sample.c(19:38:47:1) goto _forcond_0($4)
41835 \end_layout
41836
41837 \begin_layout Standard
41838
41839 \size footnotesize
41840 Sample.c(19:39:48:0)_forbreak_0($7) :
41841 \end_layout
41842
41843 \begin_layout Standard
41844
41845 \size footnotesize
41846 Sample.c(20:40:49:0) iTemp24 [lr40:41]{short}[DPTR] = iTemp2 [lr18:40]{short}[r2]
41847  + ITemp11 [lr19:40]{short}[r3]
41848 \end_layout
41849
41850 \begin_layout Standard
41851
41852 \size footnotesize
41853 Sample.c(20:41:50:0) ret iTemp24 [lr40:41]{short}
41854 \end_layout
41855
41856 \begin_layout Standard
41857
41858 \size footnotesize
41859 Sample.c(20:42:51:0)_return($8) :
41860 \end_layout
41861
41862 \begin_layout Standard
41863
41864 \size footnotesize
41865 Sample.c(20:43:52:0) eproc _function [lr0:0]{ ia0 re0 rm0}{function short}
41866 \size default
41867
41868 \newline
41869
41870 \newline
41871 Finally the code generated for this function:
41872 \newline
41873
41874 \end_layout
41875
41876 \begin_layout Standard
41877
41878 \size footnotesize
41879 .area DSEG (DATA)
41880 \end_layout
41881
41882 \begin_layout Standard
41883
41884 \size footnotesize
41885 _p::
41886 \end_layout
41887
41888 \begin_layout Standard
41889
41890 \size footnotesize
41891 \InsetSpace ~
41892 \InsetSpace ~
41893 .ds 2
41894 \end_layout
41895
41896 \begin_layout Standard
41897
41898 \size footnotesize
41899 _gint::
41900 \end_layout
41901
41902 \begin_layout Standard
41903
41904 \size footnotesize
41905 \InsetSpace ~
41906 \InsetSpace ~
41907 .ds 2
41908 \end_layout
41909
41910 \begin_layout Standard
41911
41912 \size footnotesize
41913 ; sample.c 5
41914 \end_layout
41915
41916 \begin_layout Standard
41917
41918 \size footnotesize
41919 ; ----------------------------------------------
41920 \end_layout
41921
41922 \begin_layout Standard
41923
41924 \size footnotesize
41925 ; function function
41926 \end_layout
41927
41928 \begin_layout Standard
41929
41930 \size footnotesize
41931 ; ----------------------------------------------
41932 \end_layout
41933
41934 \begin_layout Standard
41935
41936 \size footnotesize
41937 _function:
41938 \end_layout
41939
41940 \begin_layout Standard
41941
41942 \size footnotesize
41943 ; iTemp0 [lr3:5]{_near * int}[r2] = recv 
41944 \end_layout
41945
41946 \begin_layout Standard
41947
41948 \size footnotesize
41949 \InsetSpace ~
41950 \InsetSpace ~
41951 mov r2,dpl
41952 \end_layout
41953
41954 \begin_layout Standard
41955
41956 \size footnotesize
41957 ; iTemp6 [lr5:16]{_near * int}[r0] := iTemp0 [lr3:5]{_near * int}[r2]
41958 \end_layout
41959
41960 \begin_layout Standard
41961
41962 \size footnotesize
41963 \InsetSpace ~
41964 \InsetSpace ~
41965 mov ar0,r2
41966 \end_layout
41967
41968 \begin_layout Standard
41969
41970 \size footnotesize
41971 ;_whilecontinue_0($1) :
41972 \end_layout
41973
41974 \begin_layout Standard
41975
41976 \size footnotesize
41977 00101$:
41978 \end_layout
41979
41980 \begin_layout Standard
41981
41982 \size footnotesize
41983 ; iTemp4 [lr7:8]{int}[r2 r3] = @[iTemp6 [lr5:16]{_near * int}[r0]]
41984 \end_layout
41985
41986 \begin_layout Standard
41987
41988 \size footnotesize
41989 ; if iTemp4 [lr7:8]{int}[r2 r3] == 0 goto _whilebreak_0($3)
41990 \end_layout
41991
41992 \begin_layout Standard
41993
41994 \size footnotesize
41995 \InsetSpace ~
41996 \InsetSpace ~
41997 mov ar2,@r0
41998 \end_layout
41999
42000 \begin_layout Standard
42001
42002 \size footnotesize
42003 \InsetSpace ~
42004 \InsetSpace ~
42005 inc r0
42006 \end_layout
42007
42008 \begin_layout Standard
42009
42010 \size footnotesize
42011 \InsetSpace ~
42012 \InsetSpace ~
42013 mov ar3,@r0
42014 \end_layout
42015
42016 \begin_layout Standard
42017
42018 \size footnotesize
42019 \InsetSpace ~
42020 \InsetSpace ~
42021 dec r0
42022 \end_layout
42023
42024 \begin_layout Standard
42025
42026 \size footnotesize
42027 \InsetSpace ~
42028 \InsetSpace ~
42029 mov a,r2
42030 \end_layout
42031
42032 \begin_layout Standard
42033
42034 \size footnotesize
42035 \InsetSpace ~
42036 \InsetSpace ~
42037 orl a,r3
42038 \end_layout
42039
42040 \begin_layout Standard
42041
42042 \size footnotesize
42043 \InsetSpace ~
42044 \InsetSpace ~
42045 jz 00103$
42046 \end_layout
42047
42048 \begin_layout Standard
42049
42050 \size footnotesize
42051 00114$:
42052 \end_layout
42053
42054 \begin_layout Standard
42055
42056 \size footnotesize
42057 ; iTemp7 [lr9:13]{_far * int}[DPTR] := _p [lr0:0]{_far * int}
42058 \end_layout
42059
42060 \begin_layout Standard
42061
42062 \size footnotesize
42063 \InsetSpace ~
42064 \InsetSpace ~
42065 mov dpl,_p
42066 \end_layout
42067
42068 \begin_layout Standard
42069
42070 \size footnotesize
42071 \InsetSpace ~
42072 \InsetSpace ~
42073 mov dph,(_p + 1)
42074 \end_layout
42075
42076 \begin_layout Standard
42077
42078 \size footnotesize
42079 ; _p [lr0:0]{_far * int} = _p [lr0:0]{_far * int} + 0x2 {short}
42080 \end_layout
42081
42082 \begin_layout Standard
42083
42084 \size footnotesize
42085 \InsetSpace ~
42086 \InsetSpace ~
42087 mov a,#0x02
42088 \end_layout
42089
42090 \begin_layout Standard
42091
42092 \size footnotesize
42093 \InsetSpace ~
42094 \InsetSpace ~
42095 add a,_p
42096 \end_layout
42097
42098 \begin_layout Standard
42099
42100 \size footnotesize
42101 \InsetSpace ~
42102 \InsetSpace ~
42103 mov _p,a
42104 \end_layout
42105
42106 \begin_layout Standard
42107
42108 \size footnotesize
42109 \InsetSpace ~
42110 \InsetSpace ~
42111 clr a
42112 \end_layout
42113
42114 \begin_layout Standard
42115
42116 \size footnotesize
42117 \InsetSpace ~
42118 \InsetSpace ~
42119 addc a,(_p + 1)
42120 \end_layout
42121
42122 \begin_layout Standard
42123
42124 \size footnotesize
42125 \InsetSpace ~
42126 \InsetSpace ~
42127 mov (_p + 1),a
42128 \end_layout
42129
42130 \begin_layout Standard
42131
42132 \size footnotesize
42133 ; iTemp10 [lr13:14]{int}[r2 r3] = @[iTemp7 [lr9:13]{_far * int}[DPTR]]
42134 \end_layout
42135
42136 \begin_layout Standard
42137
42138 \size footnotesize
42139 \InsetSpace ~
42140 \InsetSpace ~
42141 movx a,@dptr
42142 \end_layout
42143
42144 \begin_layout Standard
42145
42146 \size footnotesize
42147 \InsetSpace ~
42148 \InsetSpace ~
42149 mov r2,a
42150 \end_layout
42151
42152 \begin_layout Standard
42153
42154 \size footnotesize
42155 \InsetSpace ~
42156 \InsetSpace ~
42157 inc dptr
42158 \end_layout
42159
42160 \begin_layout Standard
42161
42162 \size footnotesize
42163 \InsetSpace ~
42164 \InsetSpace ~
42165 movx a,@dptr
42166 \end_layout
42167
42168 \begin_layout Standard
42169
42170 \size footnotesize
42171 \InsetSpace ~
42172 \InsetSpace ~
42173 mov r3,a
42174 \end_layout
42175
42176 \begin_layout Standard
42177
42178 \size footnotesize
42179 ; *(iTemp6 [lr5:16]{_near * int}[r0]) := iTemp10 [lr13:14]{int}[r2 r3]
42180 \end_layout
42181
42182 \begin_layout Standard
42183
42184 \size footnotesize
42185 \InsetSpace ~
42186 \InsetSpace ~
42187 mov @r0,ar2
42188 \end_layout
42189
42190 \begin_layout Standard
42191
42192 \size footnotesize
42193 \InsetSpace ~
42194 \InsetSpace ~
42195 inc r0
42196 \end_layout
42197
42198 \begin_layout Standard
42199
42200 \size footnotesize
42201 \InsetSpace ~
42202 \InsetSpace ~
42203 mov @r0,ar3
42204 \end_layout
42205
42206 \begin_layout Standard
42207
42208 \size footnotesize
42209 ; iTemp6 [lr5:16]{_near * int}[r0] = 
42210 \end_layout
42211
42212 \begin_layout Standard
42213
42214 \size footnotesize
42215 ; iTemp6 [lr5:16]{_near * int}[r0] + 
42216 \end_layout
42217
42218 \begin_layout Standard
42219
42220 \size footnotesize
42221 ; 0x2 {short}
42222 \end_layout
42223
42224 \begin_layout Standard
42225
42226 \size footnotesize
42227 \InsetSpace ~
42228 \InsetSpace ~
42229 inc r0
42230 \end_layout
42231
42232 \begin_layout Standard
42233
42234 \size footnotesize
42235 ; goto _whilecontinue_0($1)
42236 \end_layout
42237
42238 \begin_layout Standard
42239
42240 \size footnotesize
42241 \InsetSpace ~
42242 \InsetSpace ~
42243 sjmp 00101$
42244 \end_layout
42245
42246 \begin_layout Standard
42247
42248 \size footnotesize
42249 ; _whilebreak_0($3) :
42250 \end_layout
42251
42252 \begin_layout Standard
42253
42254 \size footnotesize
42255 00103$:
42256 \end_layout
42257
42258 \begin_layout Standard
42259
42260 \size footnotesize
42261 ; iTemp2 [lr18:40]{short}[r2] := 0x0 {short}
42262 \end_layout
42263
42264 \begin_layout Standard
42265
42266 \size footnotesize
42267 \InsetSpace ~
42268 \InsetSpace ~
42269 mov r2,#0x00
42270 \end_layout
42271
42272 \begin_layout Standard
42273
42274 \size footnotesize
42275 ; iTemp11 [lr19:40]{short}[r3] := 0x0 {short}
42276 \end_layout
42277
42278 \begin_layout Standard
42279
42280 \size footnotesize
42281 \InsetSpace ~
42282 \InsetSpace ~
42283 mov r3,#0x00
42284 \end_layout
42285
42286 \begin_layout Standard
42287
42288 \size footnotesize
42289 ; iTemp21 [lr21:38]{short}[r4] := 0x0 {short}
42290 \end_layout
42291
42292 \begin_layout Standard
42293
42294 \size footnotesize
42295 \InsetSpace ~
42296 \InsetSpace ~
42297 mov r4,#0x00
42298 \end_layout
42299
42300 \begin_layout Standard
42301
42302 \size footnotesize
42303 ; iTemp23 [lr22:38]{int}[r5 r6] := 0xa {int}
42304 \end_layout
42305
42306 \begin_layout Standard
42307
42308 \size footnotesize
42309 \InsetSpace ~
42310 \InsetSpace ~
42311 mov r5,#0x0A
42312 \end_layout
42313
42314 \begin_layout Standard
42315
42316 \size footnotesize
42317 \InsetSpace ~
42318 \InsetSpace ~
42319 mov r6,#0x00
42320 \end_layout
42321
42322 \begin_layout Standard
42323
42324 \size footnotesize
42325 ; iTemp17 [lr23:38]{int}[r7 r0] := 0x1e {int}
42326 \end_layout
42327
42328 \begin_layout Standard
42329
42330 \size footnotesize
42331 \InsetSpace ~
42332 \InsetSpace ~
42333 mov r7,#0x1E
42334 \end_layout
42335
42336 \begin_layout Standard
42337
42338 \size footnotesize
42339 \InsetSpace ~
42340 \InsetSpace ~
42341 mov r0,#0x00
42342 \end_layout
42343
42344 \begin_layout Standard
42345
42346 \size footnotesize
42347 ; _forcond_0($4) :
42348 \end_layout
42349
42350 \begin_layout Standard
42351
42352 \size footnotesize
42353 00104$:
42354 \end_layout
42355
42356 \begin_layout Standard
42357
42358 \size footnotesize
42359 ; iTemp13 [lr25:26]{char}[CC] = iTemp21 [lr21:38]{short}[r4] < 0xa {short}
42360 \end_layout
42361
42362 \begin_layout Standard
42363
42364 \size footnotesize
42365 ; if iTemp13 [lr25:26]{char}[CC] == 0 goto _forbreak_0($7)
42366 \end_layout
42367
42368 \begin_layout Standard
42369
42370 \size footnotesize
42371 \InsetSpace ~
42372 \InsetSpace ~
42373 clr c
42374 \end_layout
42375
42376 \begin_layout Standard
42377
42378 \size footnotesize
42379 \InsetSpace ~
42380 \InsetSpace ~
42381 mov a,r4
42382 \end_layout
42383
42384 \begin_layout Standard
42385
42386 \size footnotesize
42387 \InsetSpace ~
42388 \InsetSpace ~
42389 xrl a,#0x80
42390 \end_layout
42391
42392 \begin_layout Standard
42393
42394 \size footnotesize
42395 \InsetSpace ~
42396 \InsetSpace ~
42397 subb a,#0x8a
42398 \end_layout
42399
42400 \begin_layout Standard
42401
42402 \size footnotesize
42403 \InsetSpace ~
42404 \InsetSpace ~
42405 jnc 00107$
42406 \end_layout
42407
42408 \begin_layout Standard
42409
42410 \size footnotesize
42411 00115$:
42412 \end_layout
42413
42414 \begin_layout Standard
42415
42416 \size footnotesize
42417 ; iTemp2 [lr18:40]{short}[r2] = iTemp2 [lr18:40]{short}[r2] + 
42418 \end_layout
42419
42420 \begin_layout Standard
42421
42422 \size footnotesize
42423 ; iTemp21 [lr21:38]{short}[r4]
42424 \end_layout
42425
42426 \begin_layout Standard
42427
42428 \size footnotesize
42429 \InsetSpace ~
42430 \InsetSpace ~
42431 mov a,r4
42432 \end_layout
42433
42434 \begin_layout Standard
42435
42436 \size footnotesize
42437 \InsetSpace ~
42438 \InsetSpace ~
42439 add a,r2
42440 \end_layout
42441
42442 \begin_layout Standard
42443
42444 \size footnotesize
42445 \InsetSpace ~
42446 \InsetSpace ~
42447 mov r2,a
42448 \end_layout
42449
42450 \begin_layout Standard
42451
42452 \size footnotesize
42453 ; iTemp15 [lr29:30]{short}[r1] = iTemp21 [lr21:38]{short}[r4] * 0x3 {short}
42454 \end_layout
42455
42456 \begin_layout Standard
42457
42458 \size footnotesize
42459 \InsetSpace ~
42460 \InsetSpace ~
42461 mov b,#0x03
42462 \end_layout
42463
42464 \begin_layout Standard
42465
42466 \size footnotesize
42467 \InsetSpace ~
42468 \InsetSpace ~
42469 mov a,r4
42470 \end_layout
42471
42472 \begin_layout Standard
42473
42474 \size footnotesize
42475 \InsetSpace ~
42476 \InsetSpace ~
42477 mul ab
42478 \end_layout
42479
42480 \begin_layout Standard
42481
42482 \size footnotesize
42483 \InsetSpace ~
42484 \InsetSpace ~
42485 mov r1,a
42486 \end_layout
42487
42488 \begin_layout Standard
42489
42490 \size footnotesize
42491 ; iTemp11 [lr19:40]{short}[r3] = iTemp11 [lr19:40]{short}[r3] + 
42492 \end_layout
42493
42494 \begin_layout Standard
42495
42496 \size footnotesize
42497 ; iTemp15 [lr29:30]{short}[r1]
42498 \end_layout
42499
42500 \begin_layout Standard
42501
42502 \size footnotesize
42503 \InsetSpace ~
42504 \InsetSpace ~
42505 add a,r3
42506 \end_layout
42507
42508 \begin_layout Standard
42509
42510 \size footnotesize
42511 \InsetSpace ~
42512 \InsetSpace ~
42513 mov r3,a
42514 \end_layout
42515
42516 \begin_layout Standard
42517
42518 \size footnotesize
42519 ; iTemp17 [lr23:38]{int}[r7 r0]= iTemp17 [lr23:38]{int}[r7 r0]- 0x3 {short}
42520 \end_layout
42521
42522 \begin_layout Standard
42523
42524 \size footnotesize
42525 \InsetSpace ~
42526 \InsetSpace ~
42527 mov a,r7
42528 \end_layout
42529
42530 \begin_layout Standard
42531
42532 \size footnotesize
42533 \InsetSpace ~
42534 \InsetSpace ~
42535 add a,#0xfd
42536 \end_layout
42537
42538 \begin_layout Standard
42539
42540 \size footnotesize
42541 \InsetSpace ~
42542 \InsetSpace ~
42543 mov r7,a
42544 \end_layout
42545
42546 \begin_layout Standard
42547
42548 \size footnotesize
42549 \InsetSpace ~
42550 \InsetSpace ~
42551 mov a,r0
42552 \end_layout
42553
42554 \begin_layout Standard
42555
42556 \size footnotesize
42557 \InsetSpace ~
42558 \InsetSpace ~
42559 addc a,#0xff
42560 \end_layout
42561
42562 \begin_layout Standard
42563
42564 \size footnotesize
42565 \InsetSpace ~
42566 \InsetSpace ~
42567 mov r0,a
42568 \end_layout
42569
42570 \begin_layout Standard
42571
42572 \size footnotesize
42573 ; _gint [lr0:0]{int} = _gint [lr0:0]{int} + iTemp17 [lr23:38]{int}[r7 r0]
42574 \end_layout
42575
42576 \begin_layout Standard
42577
42578 \size footnotesize
42579 \InsetSpace ~
42580 \InsetSpace ~
42581 mov a,r7
42582 \end_layout
42583
42584 \begin_layout Standard
42585
42586 \size footnotesize
42587 \InsetSpace ~
42588 \InsetSpace ~
42589 add a,_gint
42590 \end_layout
42591
42592 \begin_layout Standard
42593
42594 \size footnotesize
42595 \InsetSpace ~
42596 \InsetSpace ~
42597 mov _gint,a
42598 \end_layout
42599
42600 \begin_layout Standard
42601
42602 \size footnotesize
42603 \InsetSpace ~
42604 \InsetSpace ~
42605 mov a,r0
42606 \end_layout
42607
42608 \begin_layout Standard
42609
42610 \size footnotesize
42611 \InsetSpace ~
42612 \InsetSpace ~
42613 addc a,(_gint + 1)
42614 \end_layout
42615
42616 \begin_layout Standard
42617
42618 \size footnotesize
42619 \InsetSpace ~
42620 \InsetSpace ~
42621 mov (_gint + 1),a
42622 \end_layout
42623
42624 \begin_layout Standard
42625
42626 \size footnotesize
42627 ; iTemp21 [lr21:38]{short}[r4] = iTemp21 [lr21:38]{short}[r4] + 0x1 {short}
42628 \end_layout
42629
42630 \begin_layout Standard
42631
42632 \size footnotesize
42633 \InsetSpace ~
42634 \InsetSpace ~
42635 inc r4
42636 \end_layout
42637
42638 \begin_layout Standard
42639
42640 \size footnotesize
42641 ; iTemp23 [lr22:38]{int}[r5 r6]= iTemp23 [lr22:38]{int}[r5 r6]- 0x1 {short}
42642 \end_layout
42643
42644 \begin_layout Standard
42645
42646 \size footnotesize
42647 \InsetSpace ~
42648 \InsetSpace ~
42649 dec r5
42650 \end_layout
42651
42652 \begin_layout Standard
42653
42654 \size footnotesize
42655 \InsetSpace ~
42656 \InsetSpace ~
42657 cjne r5,#0xff,00104$
42658 \end_layout
42659
42660 \begin_layout Standard
42661
42662 \size footnotesize
42663 \InsetSpace ~
42664 \InsetSpace ~
42665 dec r6
42666 \end_layout
42667
42668 \begin_layout Standard
42669
42670 \size footnotesize
42671 ; goto _forcond_0($4)
42672 \end_layout
42673
42674 \begin_layout Standard
42675
42676 \size footnotesize
42677 \InsetSpace ~
42678 \InsetSpace ~
42679 sjmp 00104$
42680 \end_layout
42681
42682 \begin_layout Standard
42683
42684 \size footnotesize
42685 ; _forbreak_0($7) :
42686 \end_layout
42687
42688 \begin_layout Standard
42689
42690 \size footnotesize
42691 00107$:
42692 \end_layout
42693
42694 \begin_layout Standard
42695
42696 \size footnotesize
42697 ; ret iTemp24 [lr40:41]{short}
42698 \end_layout
42699
42700 \begin_layout Standard
42701
42702 \size footnotesize
42703 \InsetSpace ~
42704 \InsetSpace ~
42705 mov a,r3
42706 \end_layout
42707
42708 \begin_layout Standard
42709
42710 \size footnotesize
42711 \InsetSpace ~
42712 \InsetSpace ~
42713 add a,r2
42714 \end_layout
42715
42716 \begin_layout Standard
42717
42718 \size footnotesize
42719 \InsetSpace ~
42720 \InsetSpace ~
42721 mov dpl,a
42722 \end_layout
42723
42724 \begin_layout Standard
42725
42726 \size footnotesize
42727 ; _return($8) :
42728 \end_layout
42729
42730 \begin_layout Standard
42731
42732 \size footnotesize
42733 00108$:
42734 \end_layout
42735
42736 \begin_layout Standard
42737
42738 \size footnotesize
42739 \InsetSpace ~
42740 \InsetSpace ~
42741 ret
42742 \newline
42743
42744 \end_layout
42745
42746 \begin_layout Section
42747 A few words about basic block successors, predecessors and dominators
42748 \end_layout
42749
42750 \begin_layout Standard
42751 Successors are basic blocks
42752 \begin_inset LatexCommand index
42753 name "Basic blocks"
42754
42755 \end_inset
42756
42757  that might execute after this basic block.
42758 \newline
42759 Predecessors are basic blocks
42760  that might execute before reaching this basic block.
42761 \newline
42762 Dominators are basic
42763  blocks that WILL execute before reaching this basic block.
42764 \newline
42765
42766 \end_layout
42767
42768 \begin_layout Standard
42769 [basic block 1]
42770 \end_layout
42771
42772 \begin_layout Standard
42773 if (something)
42774 \end_layout
42775
42776 \begin_layout Standard
42777 \InsetSpace ~
42778 \InsetSpace ~
42779 \InsetSpace ~
42780 \InsetSpace ~
42781 [basic block 2]
42782 \end_layout
42783
42784 \begin_layout Standard
42785 else
42786 \end_layout
42787
42788 \begin_layout Standard
42789 \InsetSpace ~
42790 \InsetSpace ~
42791 \InsetSpace ~
42792 \InsetSpace ~
42793 [basic block 3]
42794 \end_layout
42795
42796 \begin_layout Standard
42797 [basic block 4]
42798 \newline
42799
42800 \end_layout
42801
42802 \begin_layout Standard
42803 a) succList of [BB2] = [BB4], of [BB3] = [BB4], of [BB1] = [BB2,BB3]
42804 \end_layout
42805
42806 \begin_layout Standard
42807 b) predList of [BB2] = [BB1], of [BB3] = [BB1], of [BB4] = [BB2,BB3]
42808 \end_layout
42809
42810 \begin_layout Standard
42811 c) domVect of [BB4] = BB1 ...
42812  here we are not sure if BB2 or BB3 was executed but we are SURE that BB1
42813  was executed.
42814 \end_layout
42815
42816 \begin_layout Chapter
42817 Acknowledgments
42818 \end_layout
42819
42820 \begin_layout Standard
42821 \begin_inset LatexCommand url
42822 target "http://sdcc.sourceforge.net/#Who"
42823
42824 \end_inset
42825
42826
42827 \newline
42828
42829 \newline
42830
42831 \emph on
42832 Thanks to all the other volunteer developers who have helped with coding,
42833  testing, web-page creation, distribution sets, etc.
42834  You know who you are :-)
42835 \emph default
42836
42837 \newline
42838
42839 \newline
42840
42841 \emph on
42842 Thanks to Sourceforge 
42843 \begin_inset LatexCommand url
42844 target "http://www.sf.net"
42845
42846 \end_inset
42847
42848  which has hosted the project since 1999 and donates significant download
42849  bandwidth.
42850 \emph default
42851
42852 \newline
42853
42854 \newline
42855
42856 \emph on
42857 Also thanks to all SDCC Distributed Compile Farm members for donating CPU
42858  cycles and bandwidth for snapshot builds.
42859 \newline
42860
42861 \end_layout
42862
42863 \begin_layout Standard
42864 This document was initially written by Sandeep Dutta
42865 \end_layout
42866
42867 \begin_layout Standard
42868 All product names mentioned herein may be trademarks
42869 \begin_inset LatexCommand index
42870 name "Trademarks"
42871
42872 \end_inset
42873
42874  of their respective companies.
42875  
42876 \end_layout
42877
42878 \begin_layout Section*
42879 Alphabetical index
42880 \end_layout
42881
42882 \begin_layout Standard
42883 To avoid confusion, the installation and building options for SDCC itself
42884  (chapter 2) are not part of the index.
42885 \end_layout
42886
42887 \begin_layout Standard
42888 \begin_inset LatexCommand printindex
42889
42890 \end_inset
42891
42892
42893 \end_layout
42894
42895 \end_body
42896 \end_document